MCPcopy Create free account
hub / github.com/cosdata/cosdata / insert

Method insert

src/models/inverted_index.rs:176–201  ·  view source on GitHub ↗

Inserts a value into the index at the specified dimension index. Finds the quantized value and pushes the vec_Id in array at index = quantized_value

(
        &self,
        value: f32,
        vector_id: u32,
        cache: &InvertedIndexCache,
        version: VersionNumber,
        values_upper_bound: f32,
    )

Source from the content-addressed store, hash-verified

174 /// Inserts a value into the index at the specified dimension index.
175 /// Finds the quantized value and pushes the vec_Id in array at index = quantized_value
176 pub fn insert(
177 &self,
178 value: f32,
179 vector_id: u32,
180 cache: &InvertedIndexCache,
181 version: VersionNumber,
182 values_upper_bound: f32,
183 ) -> Result<(), BufIoError> {
184 let quantized_value = self.quantize(value, values_upper_bound);
185 unsafe { &*self.data }
186 .try_get_data(cache)?
187 .map
188 .modify_or_insert(
189 quantized_value,
190 |list| {
191 list.push(version, vector_id);
192 },
193 || {
194 let mut pool = VersionedVec::new(version);
195 pool.push(version, vector_id);
196 pool
197 },
198 );
199 self.is_dirty.store(true, Ordering::Release);
200 Ok(())
201 }
202
203 /// Delete a value from the index at the specified dimension index.
204 /// Finds the quantized value and (soft) deletes the vec_id

Callers 1

add_sparse_vectorMethod · 0.45

Calls 6

calculate_pathFunction · 0.85
modify_or_insertMethod · 0.80
try_get_dataMethod · 0.80
quantizeMethod · 0.45
pushMethod · 0.45
find_or_create_nodeMethod · 0.45

Tested by

no test coverage detected