-
Notifications
You must be signed in to change notification settings - Fork 20
[MOD-8244] fix TieredFactory::EstimateInitialSize #567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
b9073b5
60b3423
08add46
1964758
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,62 @@ TYPED_TEST(HNSWTieredIndexTest, CreateIndexInstance) { | |
ASSERT_EQ(tiered_index->labelToInsertJobs.at(vector_label).size(), 0); | ||
} | ||
|
||
TYPED_TEST(HNSWTieredIndexTest, testIndexesAttributes) { | ||
// Create TieredHNSW index instance with a mock queue. | ||
HNSWParams params = {.type = TypeParam::get_index_type(), | ||
.dim = 4, | ||
.metric = VecSimMetric_Cosine, | ||
.multi = TypeParam::isMulti()}; | ||
VecSimParams hnsw_params = CreateParams(params); | ||
auto mock_thread_pool = tieredIndexMock(); | ||
auto *tiered_index = this->CreateTieredHNSWIndex(hnsw_params, mock_thread_pool); | ||
|
||
HNSWIndex<TEST_DATA_T, TEST_DIST_T> *hnsw_index = this->CastToHNSW(tiered_index); | ||
BruteForceIndex<TEST_DATA_T, TEST_DIST_T> *bf_index = this->GetFlatIndex(tiered_index); | ||
|
||
VecSimIndexBasicInfo hnsw_info = VecSimIndex_Info(hnsw_index).commonInfo.basicInfo; | ||
VecSimIndexBasicInfo bf_info = VecSimIndex_Info(bf_index).commonInfo.basicInfo; | ||
|
||
// assert metric | ||
ASSERT_EQ(hnsw_info.metric, params.metric); | ||
ASSERT_EQ(bf_info.metric, params.metric); | ||
// assert type | ||
ASSERT_EQ(hnsw_info.type, params.type); | ||
ASSERT_EQ(bf_info.type, params.type); | ||
// assert dim | ||
ASSERT_EQ(hnsw_info.dim, params.dim); | ||
ASSERT_EQ(bf_info.dim, params.dim); | ||
// assert multi | ||
ASSERT_EQ(hnsw_info.isMulti, params.multi); | ||
ASSERT_EQ(bf_info.isMulti, params.multi); | ||
|
||
// assert containers | ||
|
||
// bf - multi with cosine | ||
IndexComponents<TEST_DATA_T, TEST_DIST_T> bf_components = bf_index->get_components(); | ||
PreprocessorsContainerAbstract *bf_preprocessors = bf_components.preprocessors; | ||
const std::type_info &bf_pp_container_expected_type = | ||
typeid(MultiPreprocessorsContainer<TEST_DATA_T, 1>); | ||
const std::type_info &bf_pp_container_actual_type = typeid(*bf_preprocessors); | ||
ASSERT_EQ(bf_pp_container_actual_type, bf_pp_container_expected_type); | ||
|
||
// CosinePreprocessor<TEST_DATA_T> cosine_pp = | ||
// dynamic_cast<MultiPreprocessorsContainer<TEST_DATA_T, 1> | ||
// *>(bf_preprocessors)->preprocessors[0]; | ||
std::array<PreprocessorInterface *, 1> pp_arr = | ||
dynamic_cast<MultiPreprocessorsContainer<TEST_DATA_T, 1> *>(bf_preprocessors) | ||
->getPreprocessors(); | ||
const std::type_info &bf_pp_expected_type = typeid(CosinePreprocessor<TEST_DATA_T>); | ||
const std::type_info &bf_pp_actual_type = typeid(*pp_arr[0]); | ||
ASSERT_EQ(bf_pp_actual_type, bf_pp_expected_type); | ||
|
||
// hnsw - simple | ||
IndexComponents<TEST_DATA_T, TEST_DIST_T> hnsw_components = hnsw_index->get_components(); | ||
const std::type_info &hnsw_pp_expected_type = typeid(PreprocessorsContainerAbstract); | ||
const std::type_info &hnsw_pp_actual_type = typeid(*hnsw_components.preprocessors); | ||
ASSERT_EQ(hnsw_pp_expected_type, hnsw_pp_actual_type); | ||
} | ||
|
||
TYPED_TEST(HNSWTieredIndexTest, testSizeEstimation) { | ||
size_t dim = 128; | ||
size_t n = DEFAULT_BLOCK_SIZE; | ||
|
@@ -129,7 +185,7 @@ TYPED_TEST(HNSWTieredIndexTest, testSizeEstimation) { | |
|
||
HNSWParams hnsw_params = {.type = TypeParam::get_index_type(), | ||
.dim = dim, | ||
.metric = VecSimMetric_L2, | ||
.metric = VecSimMetric_Cosine, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does changing the metric in this test enough to cover all the PR changes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It covers the second fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, it was not a problem in the actual indexes, only in the estimation function |
||
.multi = isMulti, | ||
.M = M}; | ||
VecSimParams vecsim_hnsw_params = CreateParams(hnsw_params); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?