mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 10:59:32 +08:00
Fix reader unites
Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
This commit is contained in:
parent
b817fa5aed
commit
a4988e8e83
@ -4,9 +4,11 @@ extern "C" {
|
||||
|
||||
typedef void* CCollection;
|
||||
|
||||
CCollection NewCollection(const char* collection_name, const char* schema_conf);
|
||||
CCollection
|
||||
NewCollection(const char* collection_name, const char* schema_conf);
|
||||
|
||||
void DeleteCollection(CCollection collection);
|
||||
void
|
||||
DeleteCollection(CCollection collection);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -6,9 +6,11 @@ extern "C" {
|
||||
|
||||
typedef void* CPartition;
|
||||
|
||||
CPartition NewPartition(CCollection collection, const char* partition_name);
|
||||
CPartition
|
||||
NewPartition(CCollection collection, const char* partition_name);
|
||||
|
||||
void DeletePartition(CPartition partition);
|
||||
void
|
||||
DeletePartition(CPartition partition);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -6,17 +6,33 @@ extern "C" {
|
||||
|
||||
typedef void* CSegmentBase;
|
||||
|
||||
CSegmentBase NewSegment(CPartition partition, unsigned long segment_id);
|
||||
CSegmentBase
|
||||
NewSegment(CPartition partition, unsigned long segment_id);
|
||||
|
||||
void DeleteSegment(CSegmentBase segment);
|
||||
void
|
||||
DeleteSegment(CSegmentBase segment);
|
||||
|
||||
int Insert(CSegmentBase c_segment,
|
||||
signed long int size,
|
||||
const unsigned long* primary_keys,
|
||||
const unsigned long int* timestamps,
|
||||
void* raw_data,
|
||||
int sizeof_per_row,
|
||||
signed long int count);
|
||||
int
|
||||
Insert(CSegmentBase c_segment,
|
||||
signed long int size,
|
||||
const unsigned long* primary_keys,
|
||||
const unsigned long* timestamps,
|
||||
void* raw_data,
|
||||
int sizeof_per_row,
|
||||
signed long int count);
|
||||
|
||||
int
|
||||
Delete(CSegmentBase c_segment,
|
||||
long size,
|
||||
const unsigned long* primary_keys,
|
||||
const unsigned long* timestamps);
|
||||
|
||||
int
|
||||
Search(CSegmentBase c_segment,
|
||||
void* fake_query,
|
||||
unsigned long timestamp,
|
||||
long int* result_ids,
|
||||
float* result_distances);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package reader
|
||||
import (
|
||||
"fmt"
|
||||
schema2 "github.com/czs007/suvlim/pulsar/client-go/schema"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type ResultEntityIds []int64
|
||||
@ -14,7 +15,7 @@ type SearchResult struct {
|
||||
|
||||
func getResultTopicByClientId(clientId int64) string {
|
||||
// TODO: Result topic?
|
||||
return "result-topic/partition-" + string(clientId)
|
||||
return "result-topic/partition-" + strconv.FormatInt(clientId, 10)
|
||||
}
|
||||
|
||||
func publishResult(ids *ResultEntityIds, clientId int64) schema2.Status {
|
||||
|
@ -15,6 +15,7 @@ import "C"
|
||||
import (
|
||||
"github.com/czs007/suvlim/errors"
|
||||
"github.com/czs007/suvlim/pulsar/client-go/schema"
|
||||
"strconv"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
@ -92,10 +93,10 @@ func SegmentInsert(segment *Segment, entityIds *[]uint64, timestamps *[]uint64,
|
||||
}
|
||||
const sizeofPerRow = 4 + DIM * 4
|
||||
|
||||
var status = C.Insert(segment.SegmentPtr, (*C.ulong)(entityIds), (*C.ulong)(timestamps), unsafe.Pointer(&rawData[0]), C.int(sizeofPerRow), C.long(N))
|
||||
var status = C.Insert(segment.SegmentPtr, C.long(N), (*C.ulong)(&(*entityIds)[0]), (*C.ulong)(&(*timestamps)[0]), unsafe.Pointer(&rawData[0]), C.int(sizeofPerRow), C.long(N))
|
||||
|
||||
if status != 0 {
|
||||
return nil, errors.New("Insert failed, error code = " + status)
|
||||
return nil, errors.New("Insert failed, error code = " + strconv.Itoa(int(status)))
|
||||
}
|
||||
|
||||
return ResultEntityIds{}, nil
|
||||
@ -111,10 +112,10 @@ func SegmentDelete(segment *Segment, entityIds *[]uint64, timestamps *[]uint64)
|
||||
*/
|
||||
size := len(*entityIds)
|
||||
|
||||
var status = C.Delete(segment.SegmentPtr, C.long(size), (*C.ulong)(entityIds), (*C.ulong)(timestamps))
|
||||
var status = C.Delete(segment.SegmentPtr, C.long(size), (*C.ulong)(&(*entityIds)[0]), (*C.ulong)(&(*timestamps)[0]))
|
||||
|
||||
if status != 0 {
|
||||
return nil, errors.New("Delete failed, error code = " + status)
|
||||
return nil, errors.New("Delete failed, error code = " + strconv.Itoa(int(status)))
|
||||
}
|
||||
|
||||
return ResultEntityIds{}, nil
|
||||
@ -140,7 +141,7 @@ func SegmentSearch(segment *Segment, queryString string, timestamps *[]uint64, v
|
||||
|
||||
var status = C.Search(segment.SegmentPtr, unsafe.Pointer(nil), C.ulong(timestamp), (*C.long)(&resultIds[0]), (*C.float)(&resultDistances[0]))
|
||||
if status != 0 {
|
||||
return nil, errors.New("Search failed, error code = " + status)
|
||||
return nil, errors.New("Search failed, error code = " + strconv.Itoa(int(status)))
|
||||
}
|
||||
|
||||
results = append(results, SearchResult{ResultIds: resultIds, ResultDistances: resultDistances})
|
||||
|
Loading…
Reference in New Issue
Block a user