MCPcopy Create free account
hub / github.com/carsonpo/haystackdb / insert_append

Method insert_append

src/structures/inverted_index.rs:196–227  ·  view source on GitHub ↗
(&mut self, key: KVPair, mut value: InvertedIndexItem)

Source from the content-addressed store, hash-verified

194 }
195
196 pub fn insert_append(&mut self, key: KVPair, mut value: InvertedIndexItem) {
197 match self.get(key.clone()) {
198 Some(mut v) => {
199 // v.indices.extend(value.indices);
200 v.ids.extend(value.ids);
201
202 let mut decompressed = v.indices.clone();
203
204 // binary search to insert all of the ones to append
205 for index in value.indices {
206 let idx = decompressed.binary_search(&index).unwrap_or_else(|x| x);
207 decompressed.insert(idx, index);
208 }
209
210 decompressed.sort_unstable();
211 decompressed.dedup();
212
213 // println!("Before compression: {:?}", decompressed);
214
215 v.indices = compress_indices(decompressed);
216
217 // println!("After compression: {:?}", v.indices);
218
219 self.insert(key, v, true);
220 }
221 None => {
222 value.indices = compress_indices(value.indices);
223 // println!("Compressed: {:?}", value.indices);
224 self.insert(key, value, true);
225 }
226 }
227 }
228}

Callers 2

commitMethod · 0.80
recover_point_in_timeMethod · 0.80

Calls 4

compress_indicesFunction · 0.85
cloneMethod · 0.80
getMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected