@@ -70,8 +70,6 @@ inline void ParallelFor(size_t start, size_t end, size_t numThreads, Function fn
70
70
std::rethrow_exception (lastException);
71
71
}
72
72
}
73
-
74
-
75
73
}
76
74
77
75
@@ -108,7 +106,7 @@ class Index {
108
106
default_ef=10 ;
109
107
}
110
108
111
- static const int ser_version = 1 ; // serialization version
109
+ static const int ser_version = 2 ; // serialization version
112
110
113
111
std::string space_name;
114
112
int dim;
@@ -477,7 +475,6 @@ class Index {
477
475
assert_true (appr_alg->ef_construction_ == d[" ef_construction" ].cast <size_t >(), " Invalid value of ef_construction_ " );
478
476
479
477
appr_alg->ef_ = d[" ef" ].cast <size_t >();
480
- appr_alg->num_deleted_ =d[" num_deleted" ].cast <size_t >();
481
478
482
479
assert_true (appr_alg->size_links_per_element_ == d[" size_links_per_element" ].cast <size_t >(), " Invalid value of size_links_per_element_ " );
483
480
@@ -523,6 +520,26 @@ class Index {
523
520
524
521
}
525
522
}
523
+
524
+ // set num_deleted
525
+ if (d.contains (" has_deletions" ))
526
+ {
527
+ // create index from outdated pickle that doesn't contain num_deleted
528
+ appr_alg->num_deleted_ = 0 ;
529
+ std::cout << " Warning: creating index from outdated pickle" << std::endl;
530
+ bool has_deletions = d[" has_deletions" ].cast <bool >();
531
+ if (has_deletions)
532
+ {
533
+ for (size_t i = 0 ; i < appr_alg->cur_element_count ; i++) {
534
+ if (appr_alg->isMarkedDeleted (i))
535
+ appr_alg->num_deleted_ += 1 ;
536
+ }
537
+ }
538
+ }
539
+ else
540
+ {
541
+ appr_alg->num_deleted_ = d[" num_deleted" ].cast <size_t >();
542
+ }
526
543
}
527
544
528
545
py::object knnQuery_return_numpy (py::object input, size_t k = 1 , int num_threads = -1 ) {
0 commit comments