Skip to content

Commit

Permalink
Bug fix for dlvs (#509)
Browse files Browse the repository at this point in the history
* Fix small bugs for DLVS path.

* Easier for user to use.

---------

Co-authored-by: REDMOND\ninchen <[email protected]>
  • Loading branch information
NingyuanChen and REDMOND\ninchen authored Feb 7, 2024
1 parent 9500d5a commit 24581a4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion include/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const uint32_t NUM_FROZEN_POINTS_STATIC = 0;
const uint32_t NUM_FROZEN_POINTS_DYNAMIC = 1;

// In-mem index related limits
const float GRAPH_SLACK_FACTOR = 1.3;
const float GRAPH_SLACK_FACTOR = 1.3f;

// SSD Index related limits
const uint64_t MAX_GRAPH_DEGREE = 512;
Expand Down
1 change: 0 additions & 1 deletion include/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class IndexWriteParameters
const uint32_t num_threads;
const uint32_t filter_list_size; // Lf

private:
IndexWriteParameters(const uint32_t search_list_size, const uint32_t max_degree, const bool saturate_graph,
const uint32_t max_occlusion_size, const float alpha, const uint32_t num_threads,
const uint32_t filter_list_size)
Expand Down
4 changes: 4 additions & 0 deletions src/distance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,4 +726,8 @@ template DISKANN_DLLEXPORT class SlowDistanceL2<float>;
template DISKANN_DLLEXPORT class SlowDistanceL2<int8_t>;
template DISKANN_DLLEXPORT class SlowDistanceL2<uint8_t>;

template DISKANN_DLLEXPORT Distance<float> *get_distance_function(Metric m);
template DISKANN_DLLEXPORT Distance<int8_t> *get_distance_function(Metric m);
template DISKANN_DLLEXPORT Distance<uint8_t> *get_distance_function(Metric m);

} // namespace diskann
2 changes: 1 addition & 1 deletion src/pq_flash_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ int PQFlashIndex<T, LabelT>::load_from_separate_paths(uint32_t num_threads, cons
if (files.fileExists(medoids_file))
{
size_t tmp_dim;
diskann::load_bin<uint32_t>(files, medoids_file, _medoids, _num_medoids, tmp_dim);
diskann::load_bin<uint32_t>(files, norm_file, medoids_file, _medoids, _num_medoids, tmp_dim);
#else
if (file_exists(medoids_file))
{
Expand Down
45 changes: 23 additions & 22 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,29 +391,30 @@ template <typename T> void read_array(AlignedFileReader &reader, T *data, size_t
if (data == nullptr)
{
throw diskann::ANNException("read_array requires an allocated buffer.", -1);
if (size * sizeof(T) > MAX_REQUEST_SIZE)
{
std::stringstream ss;
ss << "Cannot read more than " << MAX_REQUEST_SIZE
<< " bytes. Current request size: " << std::to_string(size) << " sizeof(T): " << sizeof(T) << std::endl;
throw diskann::ANNException(ss.str(), -1, __FUNCSIG__, __FILE__, __LINE__);
}
std::vector<AlignedRead> read_requests;
AlignedRead read_req;
read_req.buf = data;
read_req.len = size * sizeof(T);
read_req.offset = offset;
read_requests.push_back(read_req);
IOContext &ctx = reader.get_ctx();
reader.read(read_requests, ctx);
}

if ((*(ctx.m_pRequestsStatus))[0] != IOContext::READ_SUCCESS)
{
std::stringstream ss;
ss << "Failed to read_array() of size: " << size * sizeof(T) << " at offset: " << offset << " from reader. "
<< std::endl;
throw diskann::ANNException(ss.str(), -1, __FUNCSIG__, __FILE__, __LINE__);
}
if (size * sizeof(T) > MAX_REQUEST_SIZE)
{
std::stringstream ss;
ss << "Cannot read more than " << MAX_REQUEST_SIZE << " bytes. Current request size: " << std::to_string(size)
<< " sizeof(T): " << sizeof(T) << std::endl;
throw diskann::ANNException(ss.str(), -1, __FUNCSIG__, __FILE__, __LINE__);
}
std::vector<AlignedRead> read_requests;
AlignedRead read_req;
read_req.buf = data;
read_req.len = size * sizeof(T);
read_req.offset = offset;
read_requests.push_back(read_req);
IOContext &ctx = reader.get_ctx();
reader.read(read_requests, ctx);

if ((*(ctx.m_pRequestsStatus))[0] != IOContext::READ_SUCCESS)
{
std::stringstream ss;
ss << "Failed to read_array() of size: " << size * sizeof(T) << " at offset: " << offset << " from reader. "
<< std::endl;
throw diskann::ANNException(ss.str(), -1, __FUNCSIG__, __FILE__, __LINE__);
}
}

Expand Down

0 comments on commit 24581a4

Please sign in to comment.