Skip to content

Commit

Permalink
some bug fix when enable the EXEC_EnV_OLS (#377)
Browse files Browse the repository at this point in the history
* some bug fix when enable the EXEC_EnV_OLS

* avoid unit test failure

* unit test testing

* changed based on gopal's suggestion

* update load_impl(AlignedFileReader &reader)

* change the load_impl to be identical to objectstore

* remvoe blank
  • Loading branch information
jinwei14 authored Jun 28, 2023
1 parent 2b50d8e commit d6d2719
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions include/filter_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ inline tsl::robin_map<std::string, std::vector<uint32_t>> generate_label_specifi
path input_data_path, tsl::robin_map<std::string, uint32_t> labels_to_number_of_points,
std::vector<label_set> point_ids_to_labels, label_set all_labels)
{
#ifndef _WINDOWS
auto file_writing_timer = std::chrono::high_resolution_clock::now();
diskann::MemoryMapper input_data(input_data_path);
char *input_start = input_data.getBuf();
Expand Down Expand Up @@ -178,6 +179,7 @@ inline tsl::robin_map<std::string, std::vector<uint32_t>> generate_label_specifi
<< std::endl;

return label_id_to_orig_id;
#endif
}

inline std::vector<uint32_t> loadTags(const std::string &tags_file, const std::string &base_file)
Expand Down
1 change: 1 addition & 0 deletions include/in_mem_data_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "distance.h"
#include "natural_number_map.h"
#include "natural_number_set.h"
#include "aligned_file_reader.h"

namespace diskann
{
Expand Down
1 change: 1 addition & 0 deletions include/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ template <typename T, typename TagT = uint32_t, typename LabelT = uint32_t> clas
// Graph related data structures
std::vector<std::vector<uint32_t>> _final_graph;

T *_data = nullptr; // coordinates of all base points
// Dimensions
size_t _dim = 0;
size_t _nd = 0; // number of active points i.e. existing in the graph
Expand Down
11 changes: 6 additions & 5 deletions src/in_mem_data_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,27 @@ template <typename data_t> location_t InMemDataStore<data_t>::load(const std::st
}

#ifdef EXEC_ENV_OLS
template <typename data_t> location_t Index<data_t>::load_impl(AlignedFileReader &reader)
template <typename data_t> location_t InMemDataStore<data_t>::load_impl(AlignedFileReader &reader)
{
size_t file_dim, file_num_points;

diskann::get_bin_metadata(reader, file_num_points, file_dim);

if (file_dim != _dim)
if (file_dim != this->_dim)
{
std::stringstream stream;
stream << "ERROR: Driver requests loading " << _dim << " dimension,"
stream << "ERROR: Driver requests loading " << this->_dim << " dimension,"
<< "but file has " << file_dim << " dimension." << std::endl;
diskann::cerr << stream.str() << std::endl;
aligned_free(_data);
throw diskann::ANNException(stream.str(), -1, __FUNCSIG__, __FILE__, __LINE__);
}

if (file_num_points > _max_points + _num_frozen_pts)
if (file_num_points > this->capacity())
{
resize(file_num_points - _num_frozen_pts);
this->resize((location_t)file_num_points);
}
copy_aligned_data_from_file<data_t>(reader, _data, file_num_points, file_dim, _aligned_dim);

return file_num_points;
}
Expand Down
8 changes: 4 additions & 4 deletions src/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,12 @@ void Index<T, TagT, LabelT>::load(const char *filename, uint32_t num_threads, ui
_has_built = true;

size_t tags_file_num_pts = 0, graph_num_pts = 0, data_file_num_pts = 0, label_num_pts = 0;

#ifndef EXEC_ENV_OLS
std::string mem_index_file(filename);
std::string labels_file = mem_index_file + "_labels.txt";
std::string labels_to_medoids = mem_index_file + "_labels_to_medoids.txt";
std::string labels_map_file = mem_index_file + "_labels_map.txt";

#endif
if (!_save_as_one_file)
{
// For DLVS Store, we will not support saving the index in multiple
Expand Down Expand Up @@ -600,7 +600,7 @@ void Index<T, TagT, LabelT>::load(const char *filename, uint32_t num_threads, ui
diskann::cerr << stream.str() << std::endl;
throw diskann::ANNException(stream.str(), -1, __FUNCSIG__, __FILE__, __LINE__);
}

#ifndef EXEC_ENV_OLS
if (file_exists(labels_file))
{
_label_map = load_label_map(labels_map_file);
Expand Down Expand Up @@ -646,7 +646,7 @@ void Index<T, TagT, LabelT>::load(const char *filename, uint32_t num_threads, ui
universal_label_reader.close();
}
}

#endif
_nd = data_file_num_pts - _num_frozen_pts;
_empty_slots.clear();
_empty_slots.reserve(_max_points);
Expand Down

0 comments on commit d6d2719

Please sign in to comment.