Skip to content

Commit f134b41

Browse files
authored
fix: [2.5] inverted index null offset file not compacted (#46775) (#46868)
relate: #46774 pr: #46775 Signed-off-by: aoiasd <zhicheng.yue@zilliz.com>
1 parent 13d7f6f commit f134b41

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

internal/core/src/index/InvertedIndexTantivy.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,13 @@ InvertedIndexTantivy<T>::LoadIndexMetas(
215215
if (file_name.find(INDEX_NULL_OFFSET_FILE_NAME) != std::string::npos) {
216216
null_offset_files.push_back(file);
217217
}
218+
219+
// add slice meta file for null offset file compact
220+
if (file_name == INDEX_FILE_SLICE_META) {
221+
null_offset_files.push_back(file);
222+
}
218223
}
224+
219225
if (null_offset_files.size() > 0) {
220226
// null offset file is sliced
221227
auto index_datas =
@@ -243,6 +249,10 @@ InvertedIndexTantivy<T>::RetainTantivyIndexFiles(
243249
auto file_name =
244250
boost::filesystem::path(file).filename().string();
245251
return file_name == "index_type" ||
252+
// Slice meta is only used to compact null_offset files and non_exist_offset files.
253+
// It can be removed after compaction is complete.
254+
// Other index files are compacted by slice index instead of meta.
255+
file_name == INDEX_FILE_SLICE_META ||
246256
file_name.find(INDEX_NULL_OFFSET_FILE_NAME) !=
247257
std::string::npos;
248258
}),

internal/core/src/index/JsonInvertedIndex.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ JsonInvertedIndex<T>::LoadIndexMetas(
234234
std::string::npos) {
235235
non_exist_offset_files.push_back(file);
236236
}
237+
// add slice meta file for null offset file compact
238+
if (file_name == INDEX_FILE_SLICE_META) {
239+
non_exist_offset_files.push_back(file);
240+
}
237241
}
238242
if (non_exist_offset_files.size() > 0) {
239243
// null offset file is sliced

0 commit comments

Comments
 (0)