mirror of https://github.com/milvus-io/milvus.git
Move HandleCProto into query node (#11763)
Signed-off-by: yudong.cai <yudong.cai@zilliz.com>pull/11782/head
parent
8c6c031e80
commit
34ae61d8e2
|
@ -24,10 +24,10 @@ import "C"
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"unsafe"
|
||||
|
||||
"github.com/milvus-io/milvus/internal/log"
|
||||
"github.com/milvus-io/milvus/internal/proto/commonpb"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// HandleCStatus deal with the error returned from CGO
|
||||
|
@ -48,13 +48,3 @@ func HandleCStatus(status *C.CStatus, extraInfo string) error {
|
|||
log.Warn(logMsg)
|
||||
return errors.New(finalMsg)
|
||||
}
|
||||
|
||||
// HandleCProto deal with the result proto returned from CGO
|
||||
func HandleCProto(cRes *C.CProto, msg proto.Message) error {
|
||||
// Standalone CProto is protobuf created by C side,
|
||||
// Passed from c side
|
||||
// memory is managed manually
|
||||
blob := C.GoBytes(unsafe.Pointer(cRes.proto_blob), C.int32_t(cRes.proto_size))
|
||||
defer C.free(cRes.proto_blob)
|
||||
return proto.Unmarshal(blob, msg)
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package querynode
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCGoHelper_Naive(t *testing.T) {
|
||||
}
|
|
@ -30,6 +30,7 @@ import (
|
|||
"unsafe"
|
||||
|
||||
"github.com/bits-and-blooms/bloom/v3"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/zap"
|
||||
|
||||
|
@ -310,6 +311,16 @@ func (s *Segment) search(plan *SearchPlan,
|
|||
return &searchResult, nil
|
||||
}
|
||||
|
||||
// HandleCProto deal with the result proto returned from CGO
|
||||
func HandleCProto(cRes *C.CProto, msg proto.Message) error {
|
||||
// Standalone CProto is protobuf created by C side,
|
||||
// Passed from c side
|
||||
// memory is managed manually
|
||||
blob := C.GoBytes(unsafe.Pointer(cRes.proto_blob), C.int32_t(cRes.proto_size))
|
||||
defer C.free(cRes.proto_blob)
|
||||
return proto.Unmarshal(blob, msg)
|
||||
}
|
||||
|
||||
func (s *Segment) retrieve(plan *RetrievePlan) (*segcorepb.RetrieveResults, error) {
|
||||
s.segPtrMu.RLock()
|
||||
defer s.segPtrMu.RUnlock()
|
||||
|
|
Loading…
Reference in New Issue