Skip to content

Commit

Permalink
modify
Browse files Browse the repository at this point in the history
Signed-off-by: jinjiabao.jjb <[email protected]>
  • Loading branch information
jinjiabao.jjb committed Jan 15, 2025
1 parent b510935 commit acf15c7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/index/pyramid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,17 @@ Pyramid::Deserialize(const BinarySet& binary_set) {

tl::expected<void, Error>
Pyramid::Deserialize(const ReaderSet& reader_set) {
auto keys = reader_set.GetKeys();
for (const auto& path : keys) {
const auto& reader = reader_set.Get(path);
auto path_slices = split(path, PART_OCTOTHORPE);
std::shared_ptr<IndexNode> node = try_get_node_with_init(indexes_, path_slices[0]);
for (int j = 1; j < path_slices.size(); ++j) {
node = try_get_node_with_init(node->children, path_slices[j]);
}
node->CreateIndex(pyramid_param_.index_builder);
node->index->Deserialize(reader_to_readerset(reader));
}
return {};
}

Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/test_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ class TestReader : public vsag::Reader {
vsag::Binary binary_;
};

<<<<<<< HEAD
} // namespace fixtures
2 changes: 2 additions & 0 deletions tests/test_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ TestIndex::TestSerializeBinarySet(const IndexPtr& index_from,
auto query = vsag::Dataset::Make();
query->NumElements(1)
->Dim(dim)
->Paths(queries->GetPaths() + i)
->Float32Vectors(queries->GetFloat32Vectors() + i * dim)
->Owner(false);
auto res_from = index_from->KnnSearch(query, topk, search_param);
Expand Down Expand Up @@ -453,6 +454,7 @@ TestIndex::TestSerializeReaderSet(const IndexPtr& index_from,
auto query = vsag::Dataset::Make();
query->NumElements(1)
->Dim(dim)
->Paths(queries->GetPaths() + i)
->Float32Vectors(queries->GetFloat32Vectors() + i * dim)
->Owner(false);
auto res_from = index_from->KnnSearch(query, topk, search_param);
Expand Down
27 changes: 27 additions & 0 deletions tests/test_pyramid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,30 @@ TEST_CASE_PERSISTENT_FIXTURE(fixtures::PyramidTestIndex,
TestRangeSearch(index, dataset, search_param, 0.49, 5, true);
}
}

TEST_CASE_PERSISTENT_FIXTURE(fixtures::PyramidTestIndex,
"Pyramid Serialize File",
"[ft][pyramid]") {
auto origin_size = vsag::Options::Instance().block_size_limit();
auto size = GENERATE(1024 * 1024 * 2);
auto metric_type = GENERATE("l2", "ip", "cosine");
const std::string name = "pyramid";
auto search_param = fmt::format(search_param_tmp, 200);

for (auto& dim : dims) {
vsag::Options::Instance().set_block_size_limit(size);
auto param = GeneratePyramidBuildParametersString(metric_type, dim);
auto index = TestFactory(name, param, true);
auto dataset = pool.GetDatasetAndCreate(dim, base_count, metric_type, /*with_path=*/true);
TestBuildIndex(index, dataset, true);
SECTION("serialize/deserialize by binary") {
auto index2 = TestFactory(name, param, true);
TestSerializeBinarySet(index, index2, dataset, search_param, true);
}
SECTION("serialize/deserialize by binary") {
auto index2 = TestFactory(name, param, true);
TestSerializeReaderSet(index, index2, dataset, search_param, name, true);
}
}
vsag::Options::Instance().set_block_size_limit(origin_size);
}

0 comments on commit acf15c7

Please sign in to comment.