2020-08-28 17:29:26 +08:00
|
|
|
package reader
|
|
|
|
|
2020-09-02 10:38:08 +08:00
|
|
|
/*
|
|
|
|
|
2020-09-18 15:44:09 +08:00
|
|
|
#cgo CFLAGS: -I${SRCDIR}/../../core/include
|
2020-09-02 10:38:08 +08:00
|
|
|
|
2020-09-18 15:44:09 +08:00
|
|
|
#cgo LDFLAGS: -L${SRCDIR}/../../core/lib -lmilvus_dog_segment -Wl,-rpath=${SRCDIR}/../../core/lib
|
2020-09-02 10:38:08 +08:00
|
|
|
|
|
|
|
#include "collection_c.h"
|
|
|
|
#include "partition_c.h"
|
|
|
|
#include "segment_c.h"
|
|
|
|
|
|
|
|
*/
|
2020-08-28 17:29:26 +08:00
|
|
|
import "C"
|
|
|
|
|
|
|
|
type Partition struct {
|
2020-09-21 15:10:54 +08:00
|
|
|
PartitionPtr C.CPartition
|
|
|
|
PartitionName string
|
2020-09-23 14:26:13 +08:00
|
|
|
OpenedSegments []*Segment
|
|
|
|
ClosedSegments []*Segment
|
2020-08-28 17:29:26 +08:00
|
|
|
}
|
|
|
|
|
2020-09-08 10:39:09 +08:00
|
|
|
func (p *Partition) NewSegment(segmentId int64) *Segment {
|
2020-09-21 18:16:06 +08:00
|
|
|
/*
|
|
|
|
CSegmentBase
|
|
|
|
NewSegment(CPartition partition, unsigned long segment_id);
|
|
|
|
*/
|
2020-09-02 10:38:08 +08:00
|
|
|
segmentPtr := C.NewSegment(p.PartitionPtr, C.ulong(segmentId))
|
2020-08-28 17:29:26 +08:00
|
|
|
|
2020-08-31 15:54:44 +08:00
|
|
|
var newSegment = &Segment{SegmentPtr: segmentPtr, SegmentId: segmentId}
|
2020-09-23 14:26:13 +08:00
|
|
|
p.OpenedSegments = append(p.OpenedSegments, newSegment)
|
2020-09-01 16:23:39 +08:00
|
|
|
return newSegment
|
2020-08-28 17:29:26 +08:00
|
|
|
}
|
|
|
|
|
2020-09-01 16:23:39 +08:00
|
|
|
func (p *Partition) DeleteSegment(segment *Segment) {
|
2020-09-21 18:16:06 +08:00
|
|
|
/*
|
|
|
|
void
|
|
|
|
DeleteSegment(CSegmentBase segment);
|
|
|
|
*/
|
2020-09-01 16:23:39 +08:00
|
|
|
cPtr := segment.SegmentPtr
|
|
|
|
C.DeleteSegment(cPtr)
|
2020-08-28 17:29:26 +08:00
|
|
|
|
2020-08-31 15:54:44 +08:00
|
|
|
// TODO: remove from p.Segments
|
2020-08-28 17:29:26 +08:00
|
|
|
}
|