2020-08-25 15:45:19 +08:00
|
|
|
package reader
|
|
|
|
|
2020-09-01 16:23:39 +08:00
|
|
|
/*
|
|
|
|
|
2020-10-23 18:01:24 +08:00
|
|
|
#cgo CFLAGS: -I${SRCDIR}/../core/output/include
|
2020-09-01 16:23:39 +08:00
|
|
|
|
2020-10-31 15:11:47 +08:00
|
|
|
#cgo LDFLAGS: -L${SRCDIR}/../core/output/lib -lmilvus_segcore -Wl,-rpath=${SRCDIR}/../core/output/lib
|
2020-09-01 16:23:39 +08:00
|
|
|
|
2020-09-02 10:38:08 +08:00
|
|
|
#include "collection_c.h"
|
2020-09-01 16:23:39 +08:00
|
|
|
#include "partition_c.h"
|
2020-09-02 10:38:08 +08:00
|
|
|
#include "segment_c.h"
|
2020-09-01 16:23:39 +08:00
|
|
|
|
|
|
|
*/
|
2020-08-25 15:45:19 +08:00
|
|
|
import "C"
|
2020-11-04 17:58:43 +08:00
|
|
|
import "github.com/zilliztech/milvus-distributed/internal/util/typeutil"
|
|
|
|
|
|
|
|
type UniqueID = typeutil.UniqueID
|
2020-08-25 15:45:19 +08:00
|
|
|
|
|
|
|
type Collection struct {
|
2020-09-21 15:10:54 +08:00
|
|
|
CollectionPtr C.CCollection
|
2020-08-25 15:45:19 +08:00
|
|
|
CollectionName string
|
2020-11-04 17:58:43 +08:00
|
|
|
CollectionID UniqueID
|
2020-09-21 15:10:54 +08:00
|
|
|
Partitions []*Partition
|
2020-08-25 15:45:19 +08:00
|
|
|
}
|
|
|
|
|
2020-09-01 16:23:39 +08:00
|
|
|
func (c *Collection) NewPartition(partitionName string) *Partition {
|
2020-09-21 18:16:06 +08:00
|
|
|
/*
|
2020-10-24 10:45:57 +08:00
|
|
|
CPartition
|
|
|
|
NewPartition(CCollection collection, const char* partition_name);
|
|
|
|
*/
|
2020-08-31 15:54:44 +08:00
|
|
|
cName := C.CString(partitionName)
|
2020-09-01 16:23:39 +08:00
|
|
|
partitionPtr := C.NewPartition(c.CollectionPtr, cName)
|
2020-08-25 15:45:19 +08:00
|
|
|
|
2020-08-31 15:54:44 +08:00
|
|
|
var newPartition = &Partition{PartitionPtr: partitionPtr, PartitionName: partitionName}
|
|
|
|
c.Partitions = append(c.Partitions, newPartition)
|
2020-09-01 16:23:39 +08:00
|
|
|
return newPartition
|
2020-08-25 15:45:19 +08:00
|
|
|
}
|
|
|
|
|
2020-10-24 10:45:57 +08:00
|
|
|
func (c *Collection) DeletePartition(node *QueryNode, partition *Partition) {
|
2020-09-21 18:16:06 +08:00
|
|
|
/*
|
2020-10-24 10:45:57 +08:00
|
|
|
void
|
|
|
|
DeletePartition(CPartition partition);
|
|
|
|
*/
|
2020-09-01 16:23:39 +08:00
|
|
|
cPtr := partition.PartitionPtr
|
|
|
|
C.DeletePartition(cPtr)
|
2020-08-25 15:45:19 +08:00
|
|
|
|
2020-10-24 10:45:57 +08:00
|
|
|
tmpPartitions := make([]*Partition, 0)
|
|
|
|
|
|
|
|
for _, p := range c.Partitions {
|
|
|
|
if p.PartitionName == partition.PartitionName {
|
|
|
|
for _, s := range p.Segments {
|
2020-11-04 16:28:14 +08:00
|
|
|
delete(node.SegmentsMap, s.SegmentID)
|
2020-10-24 10:45:57 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tmpPartitions = append(tmpPartitions, p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
c.Partitions = tmpPartitions
|
2020-08-25 15:45:19 +08:00
|
|
|
}
|