File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 135135 "xstring" : " cpp" ,
136136 "xtr1common" : " cpp" ,
137137 "xtree" : " cpp" ,
138- "xutility" : " cpp"
138+ "xutility" : " cpp" ,
139+ "*.rs" : " cpp"
139140 },
140141 "cSpell.words" : [
141142 " allclose" ,
Original file line number Diff line number Diff line change @@ -134,6 +134,9 @@ size_t NativeIndex::count(vector_key_t key) const { return index_->count(key); }
134134bool NativeIndex::contains (vector_key_t key) const { return index_->contains (key); }
135135
136136void NativeIndex::reserve (size_t capacity) const { index_->reserve (capacity); }
137+ void NativeIndex::reserve_capacity_and_threads (size_t capacity, size_t threads) const {
138+ index_->reserve ({capacity, threads});
139+ }
137140
138141size_t NativeIndex::dimensions () const { return index_->dimensions (); }
139142size_t NativeIndex::connectivity () const { return index_->connectivity (); }
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ class NativeIndex {
2525 NativeIndex (std::unique_ptr<index_dense_t > index);
2626
2727 void reserve (size_t ) const ;
28+ void reserve_capacity_and_threads (size_t , size_t ) const ;
2829
2930 void add_b1x8 (vector_key_t key, rust::Slice<uint8_t const > vector) const ;
3031 void add_i8 (vector_key_t key, rust::Slice<int8_t const > vector) const ;
Original file line number Diff line number Diff line change @@ -332,6 +332,7 @@ pub mod ffi {
332332
333333 pub fn new_native_index ( options : & IndexOptions ) -> Result < UniquePtr < NativeIndex > > ;
334334 pub fn reserve ( self : & NativeIndex , capacity : usize ) -> Result < ( ) > ;
335+ pub fn reserve_capacity_and_threads ( self : & NativeIndex , capacity : usize , threads : usize ) -> Result < ( ) > ;
335336 pub fn dimensions ( self : & NativeIndex ) -> usize ;
336337 pub fn connectivity ( self : & NativeIndex ) -> usize ;
337338 pub fn size ( self : & NativeIndex ) -> usize ;
@@ -1143,6 +1144,20 @@ impl Index {
11431144 self . inner . reserve ( capacity)
11441145 }
11451146
1147+ /// Reserves memory for a specified number of incoming vectors & active threads.
1148+ ///
1149+ /// # Arguments
1150+ ///
1151+ /// * `capacity` - The desired total capacity, including the current size.
1152+ /// * `threads` - The number of threads to use for the operation.
1153+ pub fn reserve_capacity_and_threads (
1154+ self : & Index ,
1155+ capacity : usize ,
1156+ threads : usize ,
1157+ ) -> Result < ( ) , cxx:: Exception > {
1158+ self . inner . reserve_capacity_and_threads ( capacity, threads)
1159+ }
1160+
11461161 /// Retrieves the number of dimensions in the vectors indexed.
11471162 pub fn dimensions ( self : & Index ) -> usize {
11481163 self . inner . dimensions ( )
You can’t perform that action at this time.
0 commit comments