Add log for segcore search (#15159)

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
pull/15168/head
bigsheeper 2022-01-11 18:07:34 +08:00 committed by GitHub
parent 21e1c8927a
commit ebed1a68ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 150 additions and 93 deletions

View File

@ -71,7 +71,7 @@ Search_SmallIndex(benchmark::State& state) {
auto chunk_rows = state.range(1) * 1024;
auto segconf = SegcoreConfig::default_config();
segconf.set_chunk_rows(chunk_rows);
auto segment = CreateGrowingSegment(schema, segconf);
auto segment = CreateGrowingSegment(schema, -1, segconf);
if (!is_small_index) {
segment->disable_small_index();
}

View File

@ -64,7 +64,11 @@ SearchOnSealed(const Schema& schema,
const void* query_data,
int64_t num_queries,
const faiss::BitsetView& bitset,
SearchResult& result) {
SearchResult& result,
int64_t segment_id) {
const std::string log_prefix = "[TODO: remove] debug #14077, segment_id = " + std::to_string(segment_id) + ", ";
std::cout << log_prefix << "SearchOnSealed searching..., query_data_ptr = " << query_data
<< ", nq = " << num_queries << std::endl;
auto topk = search_info.topk_;
auto round_decimal = search_info.round_decimal_;
@ -73,21 +77,27 @@ SearchOnSealed(const Schema& schema,
// Assert(field.get_data_type() == DataType::VECTOR_FLOAT);
auto dim = field.get_dim();
std::cout << log_prefix << "SearchOnSealed init topk, round_decimal, field_offset, field and dim done" << std::endl;
AssertInfo(record.is_ready(field_offset), "[SearchOnSealed]Record isn't ready");
auto field_indexing = record.get_field_indexing(field_offset);
std::cout << log_prefix << "SearchOnSealed get_field_indexing done" << std::endl;
AssertInfo(field_indexing->metric_type_ == search_info.metric_type_,
"Metric type of field index isn't the same with search info");
auto final = [&] {
auto ds = knowhere::GenDataset(num_queries, dim, query_data);
std::cout << log_prefix << "SearchOnSealed GenDataset done" << std::endl;
auto conf = search_info.search_params_;
conf[milvus::knowhere::meta::TOPK] = search_info.topk_;
conf[milvus::knowhere::Metric::TYPE] = MetricTypeToName(field_indexing->metric_type_);
auto index_type = field_indexing->indexing_->index_type();
std::cout << log_prefix << "SearchOnSealed get index_type done" << std::endl;
auto adapter = milvus::knowhere::AdapterMgr::GetInstance().GetAdapter(index_type);
std::cout << log_prefix << "SearchOnSealed GetAdapter done" << std::endl;
AssertInfo(adapter->CheckSearch(conf, index_type, field_indexing->indexing_->index_mode()),
"[SearchOnSealed]Search params check failed");
std::cout << log_prefix << "SearchOnSealed final done" << std::endl;
return field_indexing->indexing_->Query(ds, conf, bitset);
}();
@ -96,6 +106,8 @@ SearchOnSealed(const Schema& schema,
auto total_num = num_queries * topk;
std::cout << log_prefix << "SearchOnSealed ids = " << ids << ", distance = " << distances
<< ", total_num = " << total_num << std::endl;
const float multiplier = pow(10.0, round_decimal);
if (round_decimal != -1) {
const float multiplier = pow(10.0, round_decimal);
@ -108,7 +120,9 @@ SearchOnSealed(const Schema& schema,
result.num_queries_ = num_queries;
result.topk_ = topk;
std::cout << log_prefix << "SearchOnSealed result assignment done" << std::endl;
std::copy_n(ids, total_num, result.ids_.data());
std::copy_n(distances, total_num, result.distances_.data());
std::cout << log_prefix << "SearchOnSealed copy result done" << std::endl;
}
} // namespace milvus::query

View File

@ -33,6 +33,7 @@ SearchOnSealed(const Schema& schema,
const void* query_data,
int64_t num_queries,
const faiss::BitsetView& view,
SearchResult& result);
SearchResult& result,
int64_t segment_id);
} // namespace milvus::query

View File

@ -287,8 +287,8 @@ SegmentGrowingImpl::vector_search(int64_t vec_count,
SearchResult& output) const {
auto& sealed_indexing = this->get_sealed_indexing_record();
if (sealed_indexing.is_ready(search_info.field_offset_)) {
query::SearchOnSealed(this->get_schema(), sealed_indexing, search_info, query_data, query_count, bitset,
output);
query::SearchOnSealed(this->get_schema(), sealed_indexing, search_info, query_data, query_count, bitset, output,
id_);
} else {
SearchOnGrowing(*this, vec_count, search_info, query_data, query_count, bitset, output);
}

View File

@ -154,13 +154,14 @@ class SegmentGrowingImpl : public SegmentGrowing {
public:
friend std::unique_ptr<SegmentGrowing>
CreateGrowingSegment(SchemaPtr schema, const SegcoreConfig& segcore_config);
CreateGrowingSegment(SchemaPtr schema, const SegcoreConfig& segcore_config, int64_t segment_id);
explicit SegmentGrowingImpl(SchemaPtr schema, const SegcoreConfig& segcore_config)
explicit SegmentGrowingImpl(SchemaPtr schema, const SegcoreConfig& segcore_config, int64_t segment_id)
: segcore_config_(segcore_config),
schema_(std::move(schema)),
record_(*schema_, segcore_config.get_chunk_rows()),
indexing_record_(*schema_, segcore_config_) {
indexing_record_(*schema_, segcore_config_),
id_(segment_id) {
}
void
@ -224,14 +225,17 @@ class SegmentGrowingImpl : public SegmentGrowing {
SealedIndexingRecord sealed_indexing_record_;
tbb::concurrent_unordered_multimap<idx_t, int64_t> uid2offset_;
int64_t id_;
private:
bool enable_small_index_ = true;
};
inline SegmentGrowingPtr
CreateGrowingSegment(SchemaPtr schema, const SegcoreConfig& conf = SegcoreConfig::default_config()) {
return std::make_unique<SegmentGrowingImpl>(schema, conf);
CreateGrowingSegment(SchemaPtr schema,
int64_t segment_id = -1,
const SegcoreConfig& conf = SegcoreConfig::default_config()) {
return std::make_unique<SegmentGrowingImpl>(schema, conf, segment_id);
}
} // namespace milvus::segcore

View File

@ -313,19 +313,27 @@ SegmentSealedImpl::vector_search(int64_t vec_count,
Timestamp timestamp,
const BitsetView& bitset,
SearchResult& output) const {
// TODO: remove cout logs
const std::string log_prefix = "[TODO: remove] debug #14077, segment_id = " + std::to_string(id_) + ", ";
std::cout << log_prefix << "SegmentSealedImpl::vector_search begin to search..., vec_count = " << vec_count
<< ", query_count = " << query_count << ", timestamp = " << timestamp << std::endl;
AssertInfo(is_system_field_ready(), "System field is not ready");
auto field_offset = search_info.field_offset_;
auto& field_meta = schema_->operator[](field_offset);
std::cout << log_prefix << "SegmentSealedImpl get field meta done" << std::endl;
AssertInfo(field_meta.is_vector(), "The meta type of vector field is not vector type");
if (get_bit(vecindex_ready_bitset_, field_offset)) {
AssertInfo(vecindexs_.is_ready(field_offset),
"vector indexes isn't ready for field " + std::to_string(field_offset.get()));
query::SearchOnSealed(*schema_, vecindexs_, search_info, query_data, query_count, bitset, output);
std::cout << log_prefix << "SegmentSealedImpl vector indexes is ready for field" << std::endl;
query::SearchOnSealed(*schema_, vecindexs_, search_info, query_data, query_count, bitset, output, id_);
return;
} else if (!get_bit(field_data_ready_bitset_, field_offset)) {
std::cout << log_prefix << "SegmentSealedImpl field data is not loaded" << std::endl;
PanicInfo("Field Data is not loaded");
}
std::cout << log_prefix << "SegmentSealedImpl SearchOnSealed done" << std::endl;
query::dataset::SearchDataset dataset;
dataset.query_data = query_data;
@ -336,27 +344,38 @@ SegmentSealedImpl::vector_search(int64_t vec_count,
dataset.dim = field_meta.get_dim();
dataset.round_decimal = search_info.round_decimal_;
std::cout << log_prefix << "SegmentSealedImpl dataset assignment done" << std::endl;
AssertInfo(get_bit(field_data_ready_bitset_, field_offset),
"Can't get bitset element at " + std::to_string(field_offset.get()));
AssertInfo(row_count_opt_.has_value(), "Can't get row count value");
auto row_count = row_count_opt_.value();
auto chunk_data = fields_data_[field_offset.get()].data();
std::cout << log_prefix << "SegmentSealedImpl get row_count and chunk_data done" << std::endl;
auto sub_qr = [&] {
if (field_meta.get_data_type() == DataType::VECTOR_FLOAT) {
std::cout << log_prefix << "SegmentSealedImpl FloatSearchBruteForce ..." << std::endl;
return query::FloatSearchBruteForce(dataset, chunk_data, row_count, bitset);
} else {
std::cout << log_prefix << "SegmentSealedImpl BinarySearchBruteForce ..." << std::endl;
return query::BinarySearchBruteForce(dataset, chunk_data, row_count, bitset);
}
}();
SearchResult results;
results.distances_ = std::move(sub_qr.mutable_distances());
std::cout << log_prefix << "SegmentSealedImpl results.distances_ done" << std::endl;
results.ids_ = std::move(sub_qr.mutable_ids());
std::cout << log_prefix << "SegmentSealedImpl results.ids_ done" << std::endl;
results.topk_ = dataset.topk;
std::cout << log_prefix << "SegmentSealedImpl results.topk done, topk = " << results.topk_ << std::endl;
results.num_queries_ = dataset.num_queries;
std::cout << log_prefix << "SegmentSealedImpl results.num_queries done, nq = " << results.num_queries_ << std::endl;
output = std::move(results);
std::cout << log_prefix << "SegmentSealedImpl move results done" << std::endl;
}
void
@ -401,32 +420,40 @@ SegmentSealedImpl::DropIndex(const FieldId field_id) {
void
SegmentSealedImpl::check_search(const query::Plan* plan) const {
const std::string log_prefix = "[TODO: remove] debug #14077, segment_id = " + std::to_string(id_) + ", ";
std::cout << log_prefix << "SegmentSealedImpl::check_search check_search..., planPtr = " << plan << std::endl;
AssertInfo(plan, "Search plan is null");
AssertInfo(plan->extra_info_opt_.has_value(), "Extra info of search plan doesn't have value");
if (!is_system_field_ready()) {
std::cout << log_prefix << "SegmentSealedImpl::check_search is_system_field_ready done" << std::endl;
PanicInfo("System Field RowID or Timestamp is not loaded");
}
auto& request_fields = plan->extra_info_opt_.value().involved_fields_;
std::cout << log_prefix << "SegmentSealedImpl::check_search request_fields done" << std::endl;
auto field_ready_bitset = field_data_ready_bitset_ | vecindex_ready_bitset_;
AssertInfo(request_fields.size() == field_ready_bitset.size(),
"Request fields size not equal to field ready bitset size when check search");
auto absent_fields = request_fields - field_ready_bitset;
std::cout << log_prefix << "SegmentSealedImpl::check_search absent_fields done" << std::endl;
if (absent_fields.any()) {
auto field_offset = FieldOffset(absent_fields.find_first());
auto& field_meta = schema_->operator[](field_offset);
std::cout << log_prefix << "SegmentSealedImpl::check_search field_meta done" << std::endl;
PanicInfo("User Field(" + field_meta.get_name().get() + ") is not loaded");
}
std::cout << log_prefix << "SegmentSealedImpl::check_search all done" << std::endl;
}
SegmentSealedImpl::SegmentSealedImpl(SchemaPtr schema)
SegmentSealedImpl::SegmentSealedImpl(SchemaPtr schema, int64_t segment_id)
: schema_(schema),
fields_data_(schema->size()),
field_data_ready_bitset_(schema->size()),
vecindex_ready_bitset_(schema->size()),
scalar_indexings_(schema->size()) {
scalar_indexings_(schema->size()),
id_(segment_id) {
}
void
SegmentSealedImpl::bulk_subscript(SystemFieldType system_type,

View File

@ -32,7 +32,7 @@ namespace milvus::segcore {
class SegmentSealedImpl : public SegmentSealed {
public:
explicit SegmentSealedImpl(SchemaPtr schema);
explicit SegmentSealedImpl(SchemaPtr schema, int64_t segment_id);
void
LoadIndex(const LoadIndexInfo& info) override;
void
@ -188,11 +188,12 @@ class SegmentSealedImpl : public SegmentSealed {
aligned_vector<Timestamp> timestamps_;
TimestampIndex timestamp_index_;
SchemaPtr schema_;
int64_t id_;
};
inline SegmentSealedPtr
CreateSealedSegment(SchemaPtr schema) {
return std::make_unique<SegmentSealedImpl>(schema);
CreateSealedSegment(SchemaPtr schema, int64_t segment_id = -1) {
return std::make_unique<SegmentSealedImpl>(schema, segment_id);
}
} // namespace milvus::segcore

View File

@ -23,17 +23,17 @@
////////////////////////////// common interfaces //////////////////////////////
CSegmentInterface
NewSegment(CCollection collection, SegmentType seg_type) {
NewSegment(CCollection collection, SegmentType seg_type, int64_t segment_id) {
auto col = (milvus::segcore::Collection*)collection;
std::unique_ptr<milvus::segcore::SegmentInterface> segment;
switch (seg_type) {
case Growing:
segment = milvus::segcore::CreateGrowingSegment(col->get_schema());
segment = milvus::segcore::CreateGrowingSegment(col->get_schema(), segment_id);
break;
case Sealed:
case Indexing:
segment = milvus::segcore::CreateSealedSegment(col->get_schema());
segment = milvus::segcore::CreateSealedSegment(col->get_schema(), segment_id);
break;
default:
LOG_SEGCORE_ERROR_ << "invalid segment type " << (int32_t)seg_type;
@ -61,18 +61,28 @@ Search(CSegmentInterface c_segment,
CSearchPlan c_plan,
CPlaceholderGroup c_placeholder_group,
uint64_t timestamp,
CSearchResult* result) {
CSearchResult* result,
int64_t segment_id) {
const std::string log_prefix = "[TODO: remove] debug #14077, segment_id = " + std::to_string(segment_id) + ", ";
std::cout << log_prefix << "cgo::Search searching..., timestamp = " << timestamp << ", segmentPtr = " << c_segment
<< ", planPtr = " << c_plan << ", resultPtr = " << result << std::endl;
try {
auto segment = (milvus::segcore::SegmentInterface*)c_segment;
std::cout << log_prefix << "cgo::Search init segment done" << std::endl;
auto plan = (milvus::query::Plan*)c_plan;
std::cout << log_prefix << "cgo::Search init plan done" << std::endl;
auto phg_ptr = reinterpret_cast<const milvus::query::PlaceholderGroup*>(c_placeholder_group);
std::cout << log_prefix << "cgo::Search init placeHolderGroup done" << std::endl;
auto search_result = segment->Search(plan, *phg_ptr, timestamp);
std::cout << log_prefix << "cgo::Search done" << std::endl;
if (!milvus::segcore::PositivelyRelated(plan->plan_node_->search_info_.metric_type_)) {
for (auto& dis : search_result->distances_) {
dis *= -1;
}
}
std::cout << log_prefix << "cgo::Search PositivelyRelated done" << std::endl;
*result = search_result.release();
std::cout << log_prefix << "cgo::Search result release done" << std::endl;
return milvus::SuccessCStatus();
} catch (std::exception& e) {
return milvus::FailureCStatus(UnexpectedError, e.what());

View File

@ -29,7 +29,7 @@ typedef CProto CRetrieveResult;
////////////////////////////// common interfaces //////////////////////////////
CSegmentInterface
NewSegment(CCollection collection, SegmentType seg_type);
NewSegment(CCollection collection, SegmentType seg_type, int64_t segment_id);
void
DeleteSegment(CSegmentInterface c_segment);
@ -42,7 +42,8 @@ Search(CSegmentInterface c_segment,
CSearchPlan c_plan,
CPlaceholderGroup c_placeholder_group,
uint64_t timestamp,
CSearchResult* result);
CSearchResult* result,
int64_t segment_id);
void
DeleteRetrieveResult(CRetrieveResult* retrieve_result);

View File

@ -193,14 +193,14 @@ TEST(CApiTest, GetCollectionNameTest) {
TEST(CApiTest, SegmentTest) {
auto collection = NewCollection(get_default_schema_config());
auto segment = NewSegment(collection, Growing);
auto segment = NewSegment(collection, Growing, -1);
DeleteCollection(collection);
DeleteSegment(segment);
}
TEST(CApiTest, InsertTest) {
auto collection = NewCollection(get_default_schema_config());
auto segment = NewSegment(collection, Growing);
auto segment = NewSegment(collection, Growing, -1);
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, Growing);
auto segment = NewSegment(collection, Growing, -1);
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, Growing);
auto segment = NewSegment(collection, Growing, -1);
int N = 10000;
auto [raw_data, timestamps, uids] = generate_data(N);
@ -285,11 +285,11 @@ TEST(CApiTest, SearchTest) {
timestamps.push_back(1);
CSearchResult search_result;
auto res = Search(segment, plan, placeholderGroup, N + ts_offset, &search_result);
auto res = Search(segment, plan, placeholderGroup, N + ts_offset, &search_result, -1);
ASSERT_EQ(res.error_code, Success);
CSearchResult search_result2;
auto res2 = Search(segment, plan, placeholderGroup, ts_offset, &search_result2);
auto res2 = Search(segment, plan, placeholderGroup, ts_offset, &search_result2, -1);
ASSERT_EQ(res2.error_code, Success);
DeleteSearchPlan(plan);
@ -302,7 +302,7 @@ TEST(CApiTest, SearchTest) {
TEST(CApiTest, SearchTestWithExpr) {
auto collection = NewCollection(get_default_schema_config());
auto segment = NewSegment(collection, Growing);
auto segment = NewSegment(collection, Growing, -1);
int N = 10000;
auto [raw_data, timestamps, uids] = generate_data(N);
@ -342,7 +342,7 @@ TEST(CApiTest, SearchTestWithExpr) {
timestamps.push_back(1);
CSearchResult search_result;
auto res = Search(segment, plan, placeholderGroup, timestamps[0], &search_result);
auto res = Search(segment, plan, placeholderGroup, timestamps[0], &search_result, -1);
ASSERT_EQ(res.error_code, Success);
DeleteSearchPlan(plan);
@ -354,7 +354,7 @@ TEST(CApiTest, SearchTestWithExpr) {
TEST(CApiTest, RetrieveTestWithExpr) {
auto collection = NewCollection(get_default_schema_config());
auto segment = NewSegment(collection, Growing);
auto segment = NewSegment(collection, Growing, -1);
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, Growing);
auto segment = NewSegment(collection, Growing, -1);
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, Growing);
auto segment = NewSegment(collection, Growing, -1);
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, Growing);
auto segment = NewSegment(collection, Growing, -1);
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, Growing);
// auto segment = NewSegment(collection, Growing, -1);
// DeleteCollection(collection);
// DeleteSegment(segment);
//}
@ -534,7 +534,7 @@ CheckSearchResultDuplicate(const std::vector<CSearchResult>& results) {
TEST(CApiTest, ReduceRemoveDuplicates) {
auto collection = NewCollection(get_default_schema_config());
auto segment = NewSegment(collection, Growing);
auto segment = NewSegment(collection, Growing, -1);
int N = 10000;
auto [raw_data, timestamps, uids] = generate_data(N);
@ -581,9 +581,9 @@ TEST(CApiTest, ReduceRemoveDuplicates) {
{
std::vector<CSearchResult> results;
CSearchResult res1, res2;
status = Search(segment, plan, placeholderGroup, timestamps[0], &res1);
status = Search(segment, plan, placeholderGroup, timestamps[0], &res1, -1);
assert(status.error_code == Success);
status = Search(segment, plan, placeholderGroup, timestamps[0], &res2);
status = Search(segment, plan, placeholderGroup, timestamps[0], &res2, -1);
assert(status.error_code == Success);
results.push_back(res1);
results.push_back(res2);
@ -598,11 +598,11 @@ TEST(CApiTest, ReduceRemoveDuplicates) {
{
std::vector<CSearchResult> results;
CSearchResult res1, res2, res3;
status = Search(segment, plan, placeholderGroup, timestamps[0], &res1);
status = Search(segment, plan, placeholderGroup, timestamps[0], &res1, -1);
assert(status.error_code == Success);
status = Search(segment, plan, placeholderGroup, timestamps[0], &res2);
status = Search(segment, plan, placeholderGroup, timestamps[0], &res2, -1);
assert(status.error_code == Success);
status = Search(segment, plan, placeholderGroup, timestamps[0], &res3);
status = Search(segment, plan, placeholderGroup, timestamps[0], &res3, -1);
assert(status.error_code == Success);
results.push_back(res1);
results.push_back(res2);
@ -625,7 +625,7 @@ TEST(CApiTest, ReduceRemoveDuplicates) {
TEST(CApiTest, Reduce) {
auto collection = NewCollection(get_default_schema_config());
auto segment = NewSegment(collection, Growing);
auto segment = NewSegment(collection, Growing, -1);
int N = 10000;
auto [raw_data, timestamps, uids] = generate_data(N);
@ -672,9 +672,9 @@ TEST(CApiTest, Reduce) {
std::vector<CSearchResult> results;
CSearchResult res1;
CSearchResult res2;
auto res = Search(segment, plan, placeholderGroup, timestamps[0], &res1);
auto res = Search(segment, plan, placeholderGroup, timestamps[0], &res1, -1);
assert(res.error_code == Success);
res = Search(segment, plan, placeholderGroup, timestamps[0], &res2);
res = Search(segment, plan, placeholderGroup, timestamps[0], &res2, -1);
assert(res.error_code == Success);
results.push_back(res1);
results.push_back(res2);
@ -708,7 +708,7 @@ TEST(CApiTest, Reduce) {
TEST(CApiTest, ReduceSearchWithExpr) {
auto collection = NewCollection(get_default_schema_config());
auto segment = NewSegment(collection, Growing);
auto segment = NewSegment(collection, Growing, -1);
int N = 10000;
auto [raw_data, timestamps, uids] = generate_data(N);
@ -749,9 +749,9 @@ TEST(CApiTest, ReduceSearchWithExpr) {
std::vector<CSearchResult> results;
CSearchResult res1;
CSearchResult res2;
auto res = Search(segment, plan, placeholderGroup, timestamps[0], &res1);
auto res = Search(segment, plan, placeholderGroup, timestamps[0], &res1, -1);
assert(res.error_code == Success);
res = Search(segment, plan, placeholderGroup, timestamps[0], &res2);
res = Search(segment, plan, placeholderGroup, timestamps[0], &res2, -1);
assert(res.error_code == Success);
results.push_back(res1);
results.push_back(res2);
@ -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, Growing);
auto segment = NewSegment(collection, Growing, -1);
auto N = ROW_COUNT;
auto dataset = DataGen(schema, N);
@ -930,7 +930,7 @@ TEST(CApiTest, Indexing_Without_Predicate) {
Timestamp time = 10000000;
CSearchResult c_search_result_on_smallIndex;
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex, -1);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -979,7 +979,7 @@ TEST(CApiTest, Indexing_Without_Predicate) {
auto sealed_segment = SealedCreator(schema, dataset, *(LoadIndexInfo*)c_load_index_info);
CSearchResult c_search_result_on_bigIndex;
auto res_after_load_index =
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex);
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex, -1);
assert(res_after_load_index.error_code == Success);
auto search_result_on_raw_index_json = SearchResultToJson(*search_result_on_raw_index);
@ -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, Growing);
auto segment = NewSegment(collection, Growing, -1);
auto N = ROW_COUNT;
auto dataset = DataGen(schema, N);
@ -1049,7 +1049,7 @@ TEST(CApiTest, Indexing_Expr_Without_Predicate) {
Timestamp time = 10000000;
CSearchResult c_search_result_on_smallIndex;
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex, -1);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -1098,7 +1098,7 @@ TEST(CApiTest, Indexing_Expr_Without_Predicate) {
auto sealed_segment = SealedCreator(schema, dataset, *(LoadIndexInfo*)c_load_index_info);
CSearchResult c_search_result_on_bigIndex;
auto res_after_load_index =
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex);
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex, -1);
assert(res_after_load_index.error_code == Success);
auto search_result_on_raw_index_json = SearchResultToJson(*search_result_on_raw_index);
@ -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, Growing);
auto segment = NewSegment(collection, Growing, -1);
auto N = ROW_COUNT;
auto dataset = DataGen(schema, N);
@ -1185,7 +1185,7 @@ TEST(CApiTest, Indexing_With_float_Predicate_Range) {
Timestamp time = 10000000;
CSearchResult c_search_result_on_smallIndex;
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex, -1);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -1235,7 +1235,7 @@ TEST(CApiTest, Indexing_With_float_Predicate_Range) {
auto sealed_segment = SealedCreator(schema, dataset, *(LoadIndexInfo*)c_load_index_info);
CSearchResult c_search_result_on_bigIndex;
auto res_after_load_index =
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex);
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex, -1);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(SearchResult*)c_search_result_on_bigIndex);
@ -1261,7 +1261,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, Growing);
auto segment = NewSegment(collection, Growing, -1);
auto N = 1000 * 1000;
auto dataset = DataGen(schema, N);
@ -1336,7 +1336,7 @@ TEST(CApiTest, Indexing_Expr_With_float_Predicate_Range) {
Timestamp time = 10000000;
CSearchResult c_search_result_on_smallIndex;
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex, -1);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -1386,7 +1386,7 @@ TEST(CApiTest, Indexing_Expr_With_float_Predicate_Range) {
auto sealed_segment = SealedCreator(schema, dataset, *(LoadIndexInfo*)c_load_index_info);
CSearchResult c_search_result_on_bigIndex;
auto res_after_load_index =
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex);
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex, -1);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(SearchResult*)c_search_result_on_bigIndex);
@ -1412,7 +1412,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, Growing);
auto segment = NewSegment(collection, Growing, -1);
auto N = ROW_COUNT;
auto dataset = DataGen(schema, N);
@ -1471,7 +1471,7 @@ TEST(CApiTest, Indexing_With_float_Predicate_Term) {
Timestamp time = 10000000;
CSearchResult c_search_result_on_smallIndex;
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex, -1);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -1521,7 +1521,7 @@ TEST(CApiTest, Indexing_With_float_Predicate_Term) {
auto sealed_segment = SealedCreator(schema, dataset, *(LoadIndexInfo*)c_load_index_info);
CSearchResult c_search_result_on_bigIndex;
auto res_after_load_index =
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex);
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex, -1);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(SearchResult*)c_search_result_on_bigIndex);
@ -1547,7 +1547,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, Growing);
auto segment = NewSegment(collection, Growing, -1);
auto N = 1000 * 1000;
auto dataset = DataGen(schema, N);
@ -1615,7 +1615,7 @@ TEST(CApiTest, Indexing_Expr_With_float_Predicate_Term) {
Timestamp time = 10000000;
CSearchResult c_search_result_on_smallIndex;
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex, -1);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -1665,7 +1665,7 @@ TEST(CApiTest, Indexing_Expr_With_float_Predicate_Term) {
auto sealed_segment = SealedCreator(schema, dataset, *(LoadIndexInfo*)c_load_index_info);
CSearchResult c_search_result_on_bigIndex;
auto res_after_load_index =
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex);
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex, -1);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(SearchResult*)c_search_result_on_bigIndex);
@ -1691,7 +1691,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, Growing);
auto segment = NewSegment(collection, Growing, -1);
auto N = 1000 * 1000;
auto dataset = DataGen(schema, N);
@ -1751,7 +1751,7 @@ TEST(CApiTest, Indexing_With_binary_Predicate_Range) {
Timestamp time = 10000000;
CSearchResult c_search_result_on_smallIndex;
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex, -1);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -1802,7 +1802,7 @@ TEST(CApiTest, Indexing_With_binary_Predicate_Range) {
auto sealed_segment = SealedCreator(schema, dataset, *(LoadIndexInfo*)c_load_index_info);
CSearchResult c_search_result_on_bigIndex;
auto res_after_load_index =
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex);
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex, -1);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(SearchResult*)c_search_result_on_bigIndex);
@ -1828,7 +1828,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, Growing);
auto segment = NewSegment(collection, Growing, -1);
auto N = ROW_COUNT;
auto dataset = DataGen(schema, N);
@ -1901,7 +1901,7 @@ TEST(CApiTest, Indexing_Expr_With_binary_Predicate_Range) {
Timestamp time = 10000000;
CSearchResult c_search_result_on_smallIndex;
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex, -1);
ASSERT_TRUE(res_before_load_index.error_code == Success) << res_before_load_index.error_msg;
// load index to segment
@ -1952,7 +1952,7 @@ TEST(CApiTest, Indexing_Expr_With_binary_Predicate_Range) {
auto sealed_segment = SealedCreator(schema, dataset, *(LoadIndexInfo*)c_load_index_info);
CSearchResult c_search_result_on_bigIndex;
auto res_after_load_index =
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex);
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex, -1);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(SearchResult*)c_search_result_on_bigIndex);
@ -1978,7 +1978,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, Growing);
auto segment = NewSegment(collection, Growing, -1);
auto N = ROW_COUNT;
auto dataset = DataGen(schema, N);
@ -2037,7 +2037,7 @@ TEST(CApiTest, Indexing_With_binary_Predicate_Term) {
Timestamp time = 10000000;
CSearchResult c_search_result_on_smallIndex;
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex, -1);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -2088,7 +2088,7 @@ TEST(CApiTest, Indexing_With_binary_Predicate_Term) {
auto sealed_segment = SealedCreator(schema, dataset, *(LoadIndexInfo*)c_load_index_info);
CSearchResult c_search_result_on_bigIndex;
auto res_after_load_index =
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex);
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex, -1);
assert(res_after_load_index.error_code == Success);
std::vector<CSearchResult> results;
@ -2119,7 +2119,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, Growing);
auto segment = NewSegment(collection, Growing, -1);
auto N = ROW_COUNT;
auto dataset = DataGen(schema, N);
@ -2186,7 +2186,7 @@ TEST(CApiTest, Indexing_Expr_With_binary_Predicate_Term) {
Timestamp time = 10000000;
CSearchResult c_search_result_on_smallIndex;
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex);
auto res_before_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_smallIndex, -1);
assert(res_before_load_index.error_code == Success);
// load index to segment
@ -2237,7 +2237,7 @@ TEST(CApiTest, Indexing_Expr_With_binary_Predicate_Term) {
auto sealed_segment = SealedCreator(schema, dataset, *(LoadIndexInfo*)c_load_index_info);
CSearchResult c_search_result_on_bigIndex;
auto res_after_load_index =
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex);
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex, -1);
assert(res_after_load_index.error_code == Success);
std::vector<CSearchResult> results;
@ -2287,7 +2287,7 @@ TEST(CApiTest, SealedSegmentTest) {
>
>)";
auto collection = NewCollection(schema_tmp_conf);
auto segment = NewSegment(collection, Sealed);
auto segment = NewSegment(collection, Sealed, -1);
int N = 10000;
std::default_random_engine e(67);
@ -2314,7 +2314,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, Sealed);
auto segment = NewSegment(collection, Sealed, -1);
auto N = ROW_COUNT;
auto dataset = DataGen(schema, N);
@ -2444,7 +2444,7 @@ TEST(CApiTest, SealedSegment_search_float_Predicate_Range) {
auto sealed_segment = SealedCreator(schema, dataset, *(LoadIndexInfo*)c_load_index_info);
CSearchResult c_search_result_on_bigIndex;
auto res_after_load_index =
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex);
Search(sealed_segment.get(), plan, placeholderGroup, time, &c_search_result_on_bigIndex, -1);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(SearchResult*)c_search_result_on_bigIndex);
@ -2466,7 +2466,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, Sealed);
auto segment = NewSegment(collection, Sealed, -1);
auto N = ROW_COUNT;
uint64_t ts_offset = 1000;
@ -2538,12 +2538,12 @@ TEST(CApiTest, SealedSegment_search_without_predicates) {
std::vector<CPlaceholderGroup> placeholderGroups;
placeholderGroups.push_back(placeholderGroup);
CSearchResult search_result;
auto res = Search(segment, plan, placeholderGroup, N + ts_offset, &search_result);
auto res = Search(segment, plan, placeholderGroup, N + ts_offset, &search_result, -1);
std::cout << res.error_msg << std::endl;
ASSERT_EQ(res.error_code, Success);
CSearchResult search_result2;
auto res2 = Search(segment, plan, placeholderGroup, ts_offset, &search_result2);
auto res2 = Search(segment, plan, placeholderGroup, ts_offset, &search_result2, -1);
ASSERT_EQ(res2.error_code, Success);
DeleteSearchPlan(plan);
@ -2560,7 +2560,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, Sealed);
auto segment = NewSegment(collection, Sealed, -1);
auto N = ROW_COUNT;
auto dataset = DataGen(schema, N);
@ -2704,7 +2704,7 @@ TEST(CApiTest, SealedSegment_search_float_With_Expr_Predicate_Range) {
assert(status.error_code == Success);
CSearchResult c_search_result_on_bigIndex;
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex);
auto res_after_load_index = Search(segment, plan, placeholderGroup, time, &c_search_result_on_bigIndex, -1);
assert(res_after_load_index.error_code == Success);
auto search_result_on_bigIndex = (*(SearchResult*)c_search_result_on_bigIndex);

View File

@ -325,8 +325,8 @@ TEST(GetEntityByIds, delete_retrieve) {
}
int64_t new_count = 6;
std::vector<idx_t> new_pks{0,1,2,3,4,5};
std::vector<idx_t> new_timestamps{10, 10, 10,10,10, 10};
std::vector<idx_t> new_pks{0, 1, 2, 3, 4, 5};
std::vector<idx_t> new_timestamps{10, 10, 10, 10, 10, 10};
auto reserved_offset = segment->PreDelete(new_count);
ASSERT_EQ(reserved_offset, row_count);
segment->Delete(reserved_offset, new_count, reinterpret_cast<const int64_t*>(new_pks.data()),
@ -343,7 +343,7 @@ TEST(GetEntityByIds, delete_retrieve) {
for (int i = 0; i < size; ++i) {
auto index = choose(i);
auto data = field0_data.data(i);
ASSERT_EQ(data, i64_col[index+new_count]);
ASSERT_EQ(data, i64_col[index + new_count]);
}
auto field1 = retrieve_results->fields_data(1);
@ -351,5 +351,4 @@ TEST(GetEntityByIds, delete_retrieve) {
auto field1_data = field1.vectors().float_vector();
ASSERT_EQ(field1_data.data_size(), DIM * size);
}
}

View File

@ -30,7 +30,7 @@ TEST(Span, Naive) {
auto dataset = DataGen(schema, N);
auto seg_conf = SegcoreConfig::default_config();
auto segment = CreateGrowingSegment(schema, seg_conf);
auto segment = CreateGrowingSegment(schema, -1, seg_conf);
segment->PreInsert(N);
segment->Insert(0, N, dataset.row_ids_.data(), dataset.timestamps_.data(), dataset.raw_);
auto vec_ptr = dataset.get_col<uint8_t>(0);

View File

@ -192,9 +192,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.Sealed)
segmentPtr = C.NewSegment(collection.collectionPtr, C.Sealed, C.int64_t(segmentID))
case segmentTypeGrowing:
segmentPtr = C.NewSegment(collection.collectionPtr, C.Growing)
segmentPtr = C.NewSegment(collection.collectionPtr, C.Growing, C.int64_t(segmentID))
default:
log.Warn("illegal segment type when create segment")
return nil
@ -309,7 +309,7 @@ func (s *Segment) search(plan *SearchPlan,
cPlaceHolderGroup := cPlaceholderGroups[0]
log.Debug("do search on segment", zap.Int64("segmentID", s.segmentID), zap.Int32("segmentType", int32(s.segmentType)))
status := C.Search(s.segmentPtr, plan.cSearchPlan, cPlaceHolderGroup, ts, &searchResult.cSearchResult)
status := C.Search(s.segmentPtr, plan.cSearchPlan, cPlaceHolderGroup, ts, &searchResult.cSearchResult, C.int64_t(s.segmentID))
if err := HandleCStatus(&status, "Search failed"); err != nil {
return nil, err
}