enhance: mark sparse inverted index as mmap-able (#33281)

issue: #29419

Signed-off-by: Buqian Zheng <zhengbuqian@gmail.com>
pull/33138/head^2
Buqian Zheng 2024-05-23 14:11:42 +08:00 committed by GitHub
parent 229a6b942b
commit c5918ffbdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 3 deletions

View File

@ -81,7 +81,10 @@ class IndexBase {
index_type_ == knowhere::IndexEnum::INDEX_FAISS_IVFSQ8 ||
index_type_ == knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT ||
index_type_ == knowhere::IndexEnum::INDEX_FAISS_IDMAP ||
index_type_ == knowhere::IndexEnum::INDEX_FAISS_BIN_IDMAP;
index_type_ == knowhere::IndexEnum::INDEX_FAISS_BIN_IDMAP ||
index_type_ ==
knowhere::IndexEnum::INDEX_SPARSE_INVERTED_INDEX ||
index_type_ == knowhere::IndexEnum::INDEX_SPARSE_WAND;
}
const IndexType&

View File

@ -570,7 +570,7 @@ TEST_P(IndexTest, Mmap) {
load_conf["mmap_filepath"] = "mmap/test_index_mmap_" + index_type;
vec_index->Load(milvus::tracer::TraceContext{}, load_conf);
EXPECT_EQ(vec_index->Count(), NB);
EXPECT_EQ(vec_index->GetDim(), DIM);
EXPECT_EQ(vec_index->GetDim(), is_sparse ? kTestSparseDim : DIM);
milvus::SearchInfo search_info;
search_info.topk_ = K;

View File

@ -259,6 +259,18 @@ GenerateRandomSparseFloatVector(size_t rows,
std::vector<std::map<int32_t, float>> data(rows);
// ensure the actual dim of the entire generated dataset is cols.
data[0][cols - 1] = real_distrib(rng);
--num_elements;
// Ensure each row has at least one non-zero value
for (size_t i = 0; i < rows; ++i) {
auto col = col_distrib(rng);
float val = real_distrib(rng);
data[i][col] = val;
}
num_elements -= rows;
for (int32_t i = 0; i < num_elements; ++i) {
auto row = row_distrib(rng);
while (data[row].size() == (size_t)cols) {

View File

@ -57,7 +57,9 @@ func IsMmapSupported(indexType IndexType) bool {
indexType == IndexFaissBinIDMap ||
indexType == IndexFaissBinIvfFlat ||
indexType == IndexHNSW ||
indexType == IndexScaNN
indexType == IndexScaNN ||
indexType == IndexSparseInverted ||
indexType == IndexSparseWand
}
func IsDiskIndex(indexType IndexType) bool {