Move HandleCProto into query node (#11763)

Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
pull/11782/head
Cai Yudong 2021-11-15 11:05:09 +08:00 committed by GitHub
parent 8c6c031e80
commit 34ae61d8e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 20 deletions

View File

@ -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)
}

View File

@ -1,8 +0,0 @@
package querynode
import (
"testing"
)
func TestCGoHelper_Naive(t *testing.T) {
}

View File

@ -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()