2020-11-09 16:27:11 +08:00
|
|
|
package reader
|
|
|
|
|
2020-11-17 10:07:42 +08:00
|
|
|
/*
|
|
|
|
#cgo CFLAGS: -I${SRCDIR}/../core/output/include
|
|
|
|
#cgo LDFLAGS: -L${SRCDIR}/../core/output/lib -lmilvus_segcore -Wl,-rpath=${SRCDIR}/../core/output/lib
|
|
|
|
#include "collection_c.h"
|
|
|
|
#include "segment_c.h"
|
|
|
|
#include "plan_c.h"
|
|
|
|
*/
|
2020-11-09 16:27:11 +08:00
|
|
|
import "C"
|
2020-11-17 10:07:42 +08:00
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
2020-11-09 16:27:11 +08:00
|
|
|
|
2020-11-17 10:07:42 +08:00
|
|
|
type Plan struct {
|
|
|
|
cPlan C.CPlan
|
2020-11-09 16:27:11 +08:00
|
|
|
}
|
|
|
|
|
2020-11-17 10:07:42 +08:00
|
|
|
func CreatePlan(col Collection, dsl string) *Plan {
|
|
|
|
cDsl := C.CString(dsl)
|
|
|
|
cPlan := C.CreatePlan(col.collectionPtr, cDsl)
|
|
|
|
var newPlan = &Plan{cPlan: cPlan}
|
|
|
|
return newPlan
|
2020-11-09 16:27:11 +08:00
|
|
|
}
|
|
|
|
|
2020-11-17 10:07:42 +08:00
|
|
|
func (plan *Plan) GetTopK() int64 {
|
|
|
|
topK := C.GetTopK(plan.cPlan)
|
|
|
|
return int64(topK)
|
|
|
|
}
|
|
|
|
|
2020-11-17 14:10:07 +08:00
|
|
|
func (plan *Plan) Delete() {
|
2020-11-17 10:07:42 +08:00
|
|
|
C.DeletePlan(plan.cPlan)
|
|
|
|
}
|
2020-11-09 16:27:11 +08:00
|
|
|
|
2020-11-17 10:07:42 +08:00
|
|
|
type PlaceholderGroup struct {
|
|
|
|
cPlaceholderGroup C.CPlaceholderGroup
|
|
|
|
}
|
2020-11-09 16:27:11 +08:00
|
|
|
|
2020-11-17 10:07:42 +08:00
|
|
|
func ParserPlaceholderGroup(plan *Plan, placeHolderBlob []byte) *PlaceholderGroup {
|
|
|
|
var blobPtr = unsafe.Pointer(&placeHolderBlob[0])
|
|
|
|
blobSize := C.long(len(placeHolderBlob))
|
|
|
|
cPlaceholderGroup := C.ParsePlaceholderGroup(plan.cPlan, blobPtr, blobSize)
|
|
|
|
var newPlaceholderGroup = &PlaceholderGroup{cPlaceholderGroup: cPlaceholderGroup}
|
|
|
|
return newPlaceholderGroup
|
|
|
|
}
|
2020-11-09 16:27:11 +08:00
|
|
|
|
2020-11-17 10:07:42 +08:00
|
|
|
func (pg *PlaceholderGroup) GetNumOfQuery() int64 {
|
|
|
|
numQueries := C.GetNumOfQueries(pg.cPlaceholderGroup)
|
|
|
|
return int64(numQueries)
|
|
|
|
}
|
2020-11-09 16:27:11 +08:00
|
|
|
|
2020-11-17 14:10:07 +08:00
|
|
|
func (pg *PlaceholderGroup) Delete() {
|
2020-11-17 10:07:42 +08:00
|
|
|
C.DeletePlaceholderGroup(pg.cPlaceholderGroup)
|
2020-11-09 16:27:11 +08:00
|
|
|
}
|