Skip to content

Commit d8f3dd1

Browse files
committed
Use much smaller scratch space for non filter case
1 parent 74ce806 commit d8f3dd1

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

include/pq_flash_index.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ template <typename T, typename LabelT = uint32_t> class PQFlashIndex
3636
DISKANN_DLLEXPORT int load(uint32_t num_threads, const char *index_prefix);
3737
#endif
3838

39+
#ifdef EXEC_ENV_OLS
40+
DISKANN_DLLEXPORT bool use_filter_support(MemoryMappedFiles &files);
41+
#else
42+
DISKANN_DLLEXPORT bool use_filter_support();
43+
#endif
44+
3945
#ifdef EXEC_ENV_OLS
4046
DISKANN_DLLEXPORT void load_labels(MemoryMappedFiles &files, const std::string &disk_index_file);
4147
#else

src/pq_flash_index.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,23 @@ void PQFlashIndex<T, LabelT>::load_dummy_map(const std::string &dummy_map_filepa
843843
throw FileException (dummy_map_filepath, e, __FUNCSIG__, __FILE__, __LINE__);
844844
}
845845
}
846+
847+
848+
template <typename T, typename LabelT>
849+
#ifdef EXEC_ENV_OLS
850+
bool PQFlashIndex<T, LabelT>::use_filter_support(MemoryMappedFiles &files)
851+
#else
852+
bool PQFlashIndex<T, LabelT>::use_filter_support()
853+
#endif
854+
{
855+
std::string labels_file = _disk_index_file + "_labels.txt";
856+
#ifdef EXEC_ENV_OLS
857+
return files.fileExists(labels_file);
858+
#else
859+
return file_exists(labels_file);
860+
#endif
861+
}
862+
846863
#ifdef EXEC_ENV_OLS
847864
template <typename T, typename LabelT>
848865
void PQFlashIndex<T, LabelT>::load_labels(MemoryMappedFiles &files, const std::string &disk_index_file)
@@ -1090,7 +1107,11 @@ int PQFlashIndex<T, LabelT>::load_from_separate_paths(uint32_t num_threads, cons
10901107
// bytes are needed to store the header and read in that many using our
10911108
// 'standard' aligned file reader approach.
10921109
reader->open(_disk_index_file);
1093-
this->setup_thread_data(num_threads);
1110+
this->setup_thread_data(
1111+
num_threads,
1112+
defaults::VISITED_RESERVE,
1113+
defaults::MAX_GRAPH_DEGREE,
1114+
(use_filter_support(files)? defaults::MAX_FILTERS_PER_QUERY, 0));
10941115
this->_max_nthreads = num_threads;
10951116

10961117
char *bytes = getHeaderBytes();
@@ -1180,7 +1201,11 @@ int PQFlashIndex<T, LabelT>::load_from_separate_paths(uint32_t num_threads, cons
11801201
// open AlignedFileReader handle to index_file
11811202
std::string index_fname(_disk_index_file);
11821203
reader->open(index_fname);
1183-
this->setup_thread_data(num_threads);
1204+
this->setup_thread_data(
1205+
num_threads,
1206+
defaults::VISITED_RESERVE,
1207+
defaults::MAX_GRAPH_DEGREE,
1208+
(use_filter_support()? defaults::MAX_FILTERS_PER_QUERY, 0));
11841209
this->_max_nthreads = num_threads;
11851210

11861211
#endif

0 commit comments

Comments
 (0)