From b0054f1b48d19e4a32cecf912239f624f50015d1 Mon Sep 17 00:00:00 2001 From: Cai Yudong Date: Mon, 15 Nov 2021 16:57:09 +0800 Subject: [PATCH] Update C API NewSegment (#11809) Signed-off-by: yudong.cai --- internal/core/src/segcore/segment_c.cpp | 2 +- internal/core/src/segcore/segment_c.h | 2 +- internal/core/unittest/test_c_api.cpp | 54 ++++++++++++------------- internal/querynode/segment.go | 4 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/internal/core/src/segcore/segment_c.cpp b/internal/core/src/segcore/segment_c.cpp index d7410a1d00..6364891ccb 100644 --- a/internal/core/src/segcore/segment_c.cpp +++ b/internal/core/src/segcore/segment_c.cpp @@ -22,7 +22,7 @@ ////////////////////////////// common interfaces ////////////////////////////// CSegmentInterface -NewSegment(CCollection collection, uint64_t segment_id, SegmentType seg_type) { +NewSegment(CCollection collection, SegmentType seg_type) { auto col = (milvus::segcore::Collection*)collection; std::unique_ptr segment; diff --git a/internal/core/src/segcore/segment_c.h b/internal/core/src/segcore/segment_c.h index 024595fff0..62ab0bbbd6 100644 --- a/internal/core/src/segcore/segment_c.h +++ b/internal/core/src/segcore/segment_c.h @@ -29,7 +29,7 @@ typedef CProto CRetrieveResult; ////////////////////////////// common interfaces ////////////////////////////// CSegmentInterface -NewSegment(CCollection collection, uint64_t segment_id, SegmentType seg_type); +NewSegment(CCollection collection, SegmentType seg_type); void DeleteSegment(CSegmentInterface c_segment); diff --git a/internal/core/unittest/test_c_api.cpp b/internal/core/unittest/test_c_api.cpp index df7eb6ef2c..d2122dc9bc 100644 --- a/internal/core/unittest/test_c_api.cpp +++ b/internal/core/unittest/test_c_api.cpp @@ -193,14 +193,14 @@ TEST(CApiTest, GetCollectionNameTest) { TEST(CApiTest, SegmentTest) { auto collection = NewCollection(get_default_schema_config()); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); DeleteCollection(collection); DeleteSegment(segment); } TEST(CApiTest, InsertTest) { auto collection = NewCollection(get_default_schema_config()); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); int N = 10000; auto [raw_data, timestamps, uids] = generate_data(N); @@ -218,7 +218,7 @@ TEST(CApiTest, InsertTest) { TEST(CApiTest, DeleteTest) { auto collection = NewCollection(get_default_schema_config()); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); long delete_row_ids[] = {100000, 100001, 100002}; unsigned long delete_timestamps[] = {0, 0, 0}; @@ -234,7 +234,7 @@ TEST(CApiTest, DeleteTest) { TEST(CApiTest, SearchTest) { auto collection = NewCollection(get_default_schema_config()); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); int N = 10000; auto [raw_data, timestamps, uids] = generate_data(N); @@ -302,7 +302,7 @@ TEST(CApiTest, SearchTest) { TEST(CApiTest, SearchTestWithExpr) { auto collection = NewCollection(get_default_schema_config()); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); int N = 10000; auto [raw_data, timestamps, uids] = generate_data(N); @@ -354,7 +354,7 @@ TEST(CApiTest, SearchTestWithExpr) { TEST(CApiTest, RetrieveTestWithExpr) { auto collection = NewCollection(get_default_schema_config()); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); int N = 10000; auto [raw_data, timestamps, uids] = generate_data(N); @@ -392,7 +392,7 @@ TEST(CApiTest, RetrieveTestWithExpr) { TEST(CApiTest, GetMemoryUsageInBytesTest) { auto collection = NewCollection(get_default_schema_config()); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); auto old_memory_usage_size = GetMemoryUsageInBytes(segment); // std::cout << "old_memory_usage_size = " << old_memory_usage_size << std::endl; @@ -418,7 +418,7 @@ TEST(CApiTest, GetMemoryUsageInBytesTest) { TEST(CApiTest, GetDeletedCountTest) { auto collection = NewCollection(get_default_schema_config()); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); long delete_row_ids[] = {100000, 100001, 100002}; unsigned long delete_timestamps[] = {0, 0, 0}; @@ -438,7 +438,7 @@ TEST(CApiTest, GetDeletedCountTest) { TEST(CApiTest, GetRowCountTest) { auto collection = NewCollection(get_default_schema_config()); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); int N = 10000; auto [raw_data, timestamps, uids] = generate_data(N); @@ -464,7 +464,7 @@ TEST(CApiTest, GetRowCountTest) { // "\u003e\ncreate_time: 1600416765\nsegment_ids: 6873737669791618215\npartition_tags: \"default\"\n"; // // auto collection = NewCollection(schema_string.data()); -// auto segment = NewSegment(collection, 0, Growing); +// auto segment = NewSegment(collection, Growing); // DeleteCollection(collection); // DeleteSegment(segment); //} @@ -534,7 +534,7 @@ CheckSearchResultDuplicate(const std::vector& results) { TEST(CApiTest, ReduceRemoveDuplicates) { auto collection = NewCollection(get_default_schema_config()); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); int N = 10000; auto [raw_data, timestamps, uids] = generate_data(N); @@ -625,7 +625,7 @@ TEST(CApiTest, ReduceRemoveDuplicates) { TEST(CApiTest, Reduce) { auto collection = NewCollection(get_default_schema_config()); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); int N = 10000; auto [raw_data, timestamps, uids] = generate_data(N); @@ -708,7 +708,7 @@ TEST(CApiTest, Reduce) { TEST(CApiTest, ReduceSearchWithExpr) { auto collection = NewCollection(get_default_schema_config()); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); int N = 10000; auto [raw_data, timestamps, uids] = generate_data(N); @@ -881,7 +881,7 @@ TEST(CApiTest, Indexing_Without_Predicate) { std::string schema_string = generate_collection_schema("L2", DIM, false); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); auto N = ROW_COUNT; auto dataset = DataGen(schema, N); @@ -1005,7 +1005,7 @@ TEST(CApiTest, Indexing_Expr_Without_Predicate) { std::string schema_string = generate_collection_schema("L2", DIM, false); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); auto N = ROW_COUNT; auto dataset = DataGen(schema, N); @@ -1124,7 +1124,7 @@ TEST(CApiTest, Indexing_With_float_Predicate_Range) { std::string schema_string = generate_collection_schema("L2", DIM, false); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); auto N = ROW_COUNT; auto dataset = DataGen(schema, N); @@ -1262,7 +1262,7 @@ TEST(CApiTest, Indexing_Expr_With_float_Predicate_Range) { std::string schema_string = generate_collection_schema("L2", DIM, false); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); auto N = 1000 * 1000; auto dataset = DataGen(schema, N); @@ -1414,7 +1414,7 @@ TEST(CApiTest, Indexing_With_float_Predicate_Term) { std::string schema_string = generate_collection_schema("L2", DIM, false); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); auto N = ROW_COUNT; auto dataset = DataGen(schema, N); @@ -1550,7 +1550,7 @@ TEST(CApiTest, Indexing_Expr_With_float_Predicate_Term) { std::string schema_string = generate_collection_schema("L2", DIM, false); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); auto N = 1000 * 1000; auto dataset = DataGen(schema, N); @@ -1695,7 +1695,7 @@ TEST(CApiTest, Indexing_With_binary_Predicate_Range) { std::string schema_string = generate_collection_schema("JACCARD", DIM, true); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); auto N = 1000 * 1000; auto dataset = DataGen(schema, N); @@ -1833,7 +1833,7 @@ TEST(CApiTest, Indexing_Expr_With_binary_Predicate_Range) { std::string schema_string = generate_collection_schema("JACCARD", DIM, true); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); auto N = ROW_COUNT; auto dataset = DataGen(schema, N); @@ -1984,7 +1984,7 @@ TEST(CApiTest, Indexing_With_binary_Predicate_Term) { std::string schema_string = generate_collection_schema("JACCARD", DIM, true); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); auto N = ROW_COUNT; auto dataset = DataGen(schema, N); @@ -2126,7 +2126,7 @@ TEST(CApiTest, Indexing_Expr_With_binary_Predicate_Term) { std::string schema_string = generate_collection_schema("JACCARD", DIM, true); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Growing); + auto segment = NewSegment(collection, Growing); auto N = ROW_COUNT; auto dataset = DataGen(schema, N); @@ -2295,7 +2295,7 @@ TEST(CApiTest, SealedSegmentTest) { > >)"; auto collection = NewCollection(schema_tmp_conf); - auto segment = NewSegment(collection, 0, Sealed); + auto segment = NewSegment(collection, Sealed); int N = 10000; std::default_random_engine e(67); @@ -2322,7 +2322,7 @@ TEST(CApiTest, SealedSegment_search_float_Predicate_Range) { std::string schema_string = generate_collection_schema("L2", DIM, false); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Sealed); + auto segment = NewSegment(collection, Sealed); auto N = ROW_COUNT; auto dataset = DataGen(schema, N); @@ -2474,7 +2474,7 @@ TEST(CApiTest, SealedSegment_search_without_predicates) { std::string schema_string = generate_collection_schema("L2", DIM, false); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Sealed); + auto segment = NewSegment(collection, Sealed); auto N = ROW_COUNT; uint64_t ts_offset = 1000; @@ -2568,7 +2568,7 @@ TEST(CApiTest, SealedSegment_search_float_With_Expr_Predicate_Range) { std::string schema_string = generate_collection_schema("L2", DIM, false); auto collection = NewCollection(schema_string.c_str()); auto schema = ((segcore::Collection*)collection)->get_schema(); - auto segment = NewSegment(collection, 0, Sealed); + auto segment = NewSegment(collection, Sealed); auto N = ROW_COUNT; auto dataset = DataGen(schema, N); diff --git a/internal/querynode/segment.go b/internal/querynode/segment.go index 972fbf6800..c39fea2d3e 100644 --- a/internal/querynode/segment.go +++ b/internal/querynode/segment.go @@ -186,9 +186,9 @@ func newSegment(collection *Collection, segmentID UniqueID, partitionID UniqueID log.Warn("illegal segment type when create segment") return nil case segmentTypeSealed: - segmentPtr = C.NewSegment(collection.collectionPtr, C.ulong(segmentID), C.Sealed) + segmentPtr = C.NewSegment(collection.collectionPtr, C.Sealed) case segmentTypeGrowing: - segmentPtr = C.NewSegment(collection.collectionPtr, C.ulong(segmentID), C.Growing) + segmentPtr = C.NewSegment(collection.collectionPtr, C.Growing) default: log.Warn("illegal segment type when create segment") return nil