2020-08-28 09:29:26 +00:00
|
|
|
package reader
|
|
|
|
|
2020-09-02 02:38:08 +00:00
|
|
|
/*
|
|
|
|
|
2020-10-23 10:01:24 +00:00
|
|
|
#cgo CFLAGS: -I${SRCDIR}/../core/output/include
|
2020-09-02 02:38:08 +00:00
|
|
|
|
2020-10-31 07:11:47 +00:00
|
|
|
#cgo LDFLAGS: -L${SRCDIR}/../core/output/lib -lmilvus_segcore -Wl,-rpath=${SRCDIR}/../core/output/lib
|
2020-09-02 02:38:08 +00:00
|
|
|
|
|
|
|
#include "collection_c.h"
|
|
|
|
#include "partition_c.h"
|
|
|
|
#include "segment_c.h"
|
|
|
|
|
|
|
|
*/
|
2020-08-28 09:29:26 +00:00
|
|
|
import "C"
|
|
|
|
|
|
|
|
type Partition struct {
|
2020-10-23 10:01:24 +00:00
|
|
|
PartitionPtr C.CPartition
|
|
|
|
PartitionName string
|
|
|
|
Segments []*Segment
|
2020-08-28 09:29:26 +00:00
|
|
|
}
|
|
|
|
|
2020-11-05 02:52:50 +00:00
|
|
|
func (p *Partition) newSegment(segmentID int64) *Segment {
|
2020-09-21 10:16:06 +00:00
|
|
|
/*
|
2020-10-23 10:01:24 +00:00
|
|
|
CSegmentBase
|
2020-11-05 02:52:50 +00:00
|
|
|
newSegment(CPartition partition, unsigned long segment_id);
|
2020-10-23 10:01:24 +00:00
|
|
|
*/
|
2020-11-04 08:28:14 +00:00
|
|
|
segmentPtr := C.NewSegment(p.PartitionPtr, C.ulong(segmentID))
|
2020-08-28 09:29:26 +00:00
|
|
|
|
2020-11-04 08:28:14 +00:00
|
|
|
var newSegment = &Segment{SegmentPtr: segmentPtr, SegmentID: segmentID}
|
2020-09-23 11:51:14 +00:00
|
|
|
p.Segments = append(p.Segments, newSegment)
|
2020-09-01 08:23:39 +00:00
|
|
|
return newSegment
|
2020-08-28 09:29:26 +00:00
|
|
|
}
|
|
|
|
|
2020-11-05 02:52:50 +00:00
|
|
|
func (p *Partition) deleteSegment(node *QueryNode, segment *Segment) {
|
2020-09-21 10:16:06 +00:00
|
|
|
/*
|
2020-10-23 10:01:24 +00:00
|
|
|
void
|
2020-11-05 02:52:50 +00:00
|
|
|
deleteSegment(CSegmentBase segment);
|
2020-10-23 10:01:24 +00:00
|
|
|
*/
|
2020-09-01 08:23:39 +00:00
|
|
|
cPtr := segment.SegmentPtr
|
|
|
|
C.DeleteSegment(cPtr)
|
2020-08-28 09:29:26 +00:00
|
|
|
|
2020-10-24 02:45:57 +00:00
|
|
|
tmpSegments := make([]*Segment, 0)
|
|
|
|
|
|
|
|
for _, s := range p.Segments {
|
2020-11-04 08:28:14 +00:00
|
|
|
if s.SegmentID == segment.SegmentID {
|
|
|
|
delete(node.SegmentsMap, s.SegmentID)
|
2020-10-24 02:45:57 +00:00
|
|
|
} else {
|
|
|
|
tmpSegments = append(tmpSegments, s)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
p.Segments = tmpSegments
|
2020-08-28 09:29:26 +00:00
|
|
|
}
|