Skip to content

Commit

Permalink
fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanhaoji2 committed Mar 2, 2025
1 parent 50c2cf5 commit cd2bf73
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/pq_flash_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ template <typename T, typename LabelT = uint32_t> class PQFlashIndex
uint64_t _ndims_reorder_vecs = 0;
uint64_t _reorder_data_start_sector = 0;
uint64_t _nvecs_per_sector = 0;
uint64_t _reorder_node_size = 0;

diskann::Metric metric = diskann::Metric::L2;

Expand Down
6 changes: 4 additions & 2 deletions src/disk_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,10 +939,11 @@ void create_disk_layout(const std::string base_file, const std::string mem_index
: npts_64 * DIV_ROUND_UP(max_node_len, defaults::SECTOR_LEN);
uint64_t n_reorder_sectors = 0;
uint64_t n_data_nodes_per_sector = 0;

uint64_t n_reoder_node_size = 0;
if (append_reorder_data)
{
n_data_nodes_per_sector = defaults::SECTOR_LEN / (ndims_reorder_file * sizeof(T));
n_reoder_node_size = ndims_reorder_file * sizeof(T);
n_data_nodes_per_sector = defaults::SECTOR_LEN / n_reoder_node_size;
n_reorder_sectors = ROUND_UP(npts_64, n_data_nodes_per_sector) / n_data_nodes_per_sector;
}
uint64_t disk_index_file_size = (n_sectors + n_reorder_sectors + 1) * defaults::SECTOR_LEN;
Expand All @@ -961,6 +962,7 @@ void create_disk_layout(const std::string base_file, const std::string mem_index
output_file_meta.push_back(n_sectors + 1);
output_file_meta.push_back(ndims_reorder_file);
output_file_meta.push_back(n_data_nodes_per_sector);
output_file_meta.push_back(n_reoder_node_size);
}
output_file_meta.push_back(disk_index_file_size);

Expand Down
3 changes: 2 additions & 1 deletion src/pq_flash_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define VECTOR_SECTOR_NO(id) (((uint64_t)(id)) / _nvecs_per_sector + _reorder_data_start_sector)

// sector # beyond the end of graph where data for id is present for reordering
#define VECTOR_SECTOR_OFFSET(id) ((((uint64_t)(id)) % _nvecs_per_sector) * _data_dim * sizeof(float))
#define VECTOR_SECTOR_OFFSET(id) ((((uint64_t)(id)) % _nvecs_per_sector) * _reorder_node_size)

namespace diskann
{
Expand Down Expand Up @@ -1122,6 +1122,7 @@ int PQFlashIndex<T, LabelT>::load_from_separate_paths(uint32_t num_threads, cons
READ_U64(index_metadata, this->_reorder_data_start_sector);
READ_U64(index_metadata, this->_ndims_reorder_vecs);
READ_U64(index_metadata, this->_nvecs_per_sector);
READ_U64(index_metadata, this->_reorder_node_size);
}

diskann::cout << "Disk-Index File Meta-data: ";
Expand Down

0 comments on commit cd2bf73

Please sign in to comment.