77namespace diskann
88{
99
10- InMemGraphStore::InMemGraphStore (const size_t max_pts , const size_t frozen_points )
11- : AbstractGraphStore(max_pts ), _num_frozen_pts(frozen_points )
10+ InMemGraphStore::InMemGraphStore (const size_t total_pts , const size_t num_frozen_pts )
11+ : AbstractGraphStore(total_pts ), _num_frozen_pts(num_frozen_pts )
1212{
1313}
1414
1515int InMemGraphStore::load (const std::string &index_path_prefix)
1616{
17- return load_impl (index_path_prefix, get_total_points () - _num_frozen_pts );
17+ return load_impl (index_path_prefix, get_total_points ());
1818}
19- int InMemGraphStore::store (const std::string &index_path_prefix, const size_t active_points )
19+ int InMemGraphStore::store (const std::string &index_path_prefix, const size_t num_points )
2020{
21- return save_graph (index_path_prefix, active_points );
21+ return save_graph (index_path_prefix, num_points );
2222}
2323std::vector<location_t > &InMemGraphStore::get_neighbours (const location_t i)
2424{
@@ -114,9 +114,9 @@ location_t InMemGraphStore::load_impl(const std::string &filename, size_t expect
114114 {
115115 diskann::cout << " ." << std::flush;
116116 }
117- if (k > _max_range_of_loaded_graph )
117+ if (k > _max_range_of_graph )
118118 {
119- _max_range_of_loaded_graph = k;
119+ _max_range_of_graph = k;
120120 }
121121 }
122122
@@ -130,8 +130,7 @@ location_t InMemGraphStore::load_impl(const std::string &filename, size_t expect
130130{
131131 size_t expected_file_size;
132132 size_t file_frozen_pts;
133- size_t file_offset = 0 ; // will need this for single file format support
134- auto max_points = get_total_points (); // from parent class holding max_pts
133+ size_t file_offset = 0 ; // will need this for single file format support
135134
136135 std::ifstream in;
137136 in.exceptions (std::ios::badbit | std::ios::failbit);
@@ -152,7 +151,7 @@ location_t InMemGraphStore::load_impl(const std::string &filename, size_t expect
152151 std::stringstream stream;
153152 if (file_frozen_pts == 1 )
154153 {
155- stream << " ERROR: When loading index , detected dynamic index, but "
154+ stream << " ERROR: When loading graph , detected dynamic index, but "
156155 " constructor asks for static index. Exitting."
157156 << std::endl;
158157 }
@@ -172,13 +171,13 @@ location_t InMemGraphStore::load_impl(const std::string &filename, size_t expect
172171
173172 // If user provides more points than max_points
174173 // resize the _graph to the larger size.
174+ auto max_points = get_total_points () - _num_frozen_pts; // from parent class holding max_pts
175175 if (max_points < expected_max_points)
176176 {
177177 diskann::cout << " Number of points in data: " << expected_max_points
178178 << " is greater than max_points: " << max_points
179179 << " Setting max points to: " << expected_max_points << std::endl;
180- _graph.resize (expected_max_points + _num_frozen_pts);
181- // _max_points = expected_max_points;
180+ _graph.resize (expected_max_points + file_frozen_pts);
182181 }
183182
184183 size_t bytes_read = vamana_metadata_size;
@@ -203,9 +202,9 @@ location_t InMemGraphStore::load_impl(const std::string &filename, size_t expect
203202 bytes_read += sizeof (uint32_t ) * ((size_t )k + 1 );
204203 if (nodes_read % 10000000 == 0 )
205204 diskann::cout << " ." << std::flush;
206- if (k > _max_range_of_loaded_graph )
205+ if (k > _max_range_of_graph )
207206 {
208- _max_range_of_loaded_graph = k;
207+ _max_range_of_graph = k;
209208 }
210209 }
211210
@@ -214,7 +213,7 @@ location_t InMemGraphStore::load_impl(const std::string &filename, size_t expect
214213 return nodes_read;
215214}
216215
217- int InMemGraphStore::save_graph (const std::string &index_path_prefix, const size_t active_points )
216+ int InMemGraphStore::save_graph (const std::string &index_path_prefix, const size_t num_points )
218217{
219218 std::ofstream out;
220219 open_file_to_write (out, index_path_prefix);
@@ -228,10 +227,9 @@ int InMemGraphStore::save_graph(const std::string &index_path_prefix, const size
228227 uint32_t ep_u32 = _start;
229228 out.write ((char *)&ep_u32, sizeof (uint32_t ));
230229 out.write ((char *)&_num_frozen_pts, sizeof (size_t ));
231- // Note: at this point, either active_points == _max_points or any frozen points have
232- // been temporarily moved to active_points, so active_points + _num_frozen_points is the valid
233- // location limit(active_points corresponds to _nd in index.h).
234- for (uint32_t i = 0 ; i < active_points + _num_frozen_pts; i++)
230+
231+ // Note: num_points = _nd + _num_frozen_points
232+ for (uint32_t i = 0 ; i < num_points; i++)
235233 {
236234 uint32_t GK = (uint32_t )_graph[i].size ();
237235 out.write ((char *)&GK, sizeof (uint32_t ));
@@ -246,13 +244,9 @@ int InMemGraphStore::save_graph(const std::string &index_path_prefix, const size
246244 return (int )index_size;
247245}
248246
249- size_t InMemGraphStore::get_num_frozen_points ()
250- {
251- return _num_frozen_pts;
252- }
253- size_t InMemGraphStore::get_max_range_of_loaded_graph ()
247+ size_t InMemGraphStore::get_max_range_of_graph ()
254248{
255- return _max_range_of_loaded_graph ;
249+ return _max_range_of_graph ;
256250}
257251uint32_t InMemGraphStore::get_max_observed_degree ()
258252{
0 commit comments