mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
762b1e1f1f
Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
67 lines
1.3 KiB
Go
67 lines
1.3 KiB
Go
package querynode
|
|
|
|
/*
|
|
|
|
#cgo CFLAGS: -I${SRCDIR}/../core/output/include
|
|
|
|
#cgo LDFLAGS: -L${SRCDIR}/../core/output/lib -lmilvus_segcore -Wl,-rpath=${SRCDIR}/../core/output/lib
|
|
|
|
#include "segcore/collection_c.h"
|
|
#include "segcore/segment_c.h"
|
|
|
|
*/
|
|
import "C"
|
|
import "unsafe"
|
|
|
|
type Collection struct {
|
|
collectionPtr C.CCollection
|
|
id UniqueID
|
|
name string
|
|
partitions []*Partition
|
|
}
|
|
|
|
func (c *Collection) Name() string {
|
|
return c.name
|
|
}
|
|
|
|
func (c *Collection) ID() UniqueID {
|
|
return c.id
|
|
}
|
|
|
|
func (c *Collection) Partitions() *[]*Partition {
|
|
return &c.partitions
|
|
}
|
|
|
|
func newCollection(collectionID UniqueID, schemaBlob string) *Collection {
|
|
/*
|
|
CCollection
|
|
NewCollection(const char* schema_proto_blob);
|
|
|
|
const char*
|
|
GetCollectionName(CCollection collection);
|
|
*/
|
|
cSchemaBlob := C.CString(schemaBlob)
|
|
collection := C.NewCollection(cSchemaBlob)
|
|
|
|
name := C.GetCollectionName(collection)
|
|
collectionName := C.GoString(name)
|
|
defer C.free(unsafe.Pointer(name))
|
|
|
|
var newCollection = &Collection{
|
|
collectionPtr: collection,
|
|
id: collectionID,
|
|
name: collectionName,
|
|
}
|
|
|
|
return newCollection
|
|
}
|
|
|
|
func deleteCollection(collection *Collection) {
|
|
/*
|
|
void
|
|
deleteCollection(CCollection collection);
|
|
*/
|
|
cPtr := collection.collectionPtr
|
|
C.DeleteCollection(cPtr)
|
|
}
|