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

Method push

src/structures/dense_vector_list.rs:52–66  ·  view source on GitHub ↗
(&mut self, vector: [u8; QUANTIZED_VECTOR_SIZE])

Source from the content-addressed store, hash-verified

50 }
51
52 pub fn push(&mut self, vector: [u8; QUANTIZED_VECTOR_SIZE]) -> io::Result<usize> {
53 let offset = self.used_space + HEADER_SIZE;
54 let required_space = offset + QUANTIZED_VECTOR_SIZE;
55
56 if required_space > self.mmap.len() {
57 self.resize_mmap(required_space * 2)?;
58 }
59
60 self.mmap[offset..required_space].copy_from_slice(&vector);
61 self.used_space += QUANTIZED_VECTOR_SIZE;
62 // Update the header in the mmap
63 self.mmap[0..HEADER_SIZE].copy_from_slice(&(self.used_space as u64).to_le_bytes());
64
65 Ok(self.used_space / QUANTIZED_VECTOR_SIZE - 1)
66 }
67
68 fn resize_mmap(&mut self, new_len: usize) -> io::Result<()> {
69 println!("Resizing mmap in DenseVectorList");

Callers 15

insertMethod · 0.80
get_range_nodeMethod · 0.80
batch_insertMethod · 0.80
deserializeMethod · 0.80
insertMethod · 0.80
deserializeMethod · 0.80
get_commits_beforeMethod · 0.80
get_uncommittedMethod · 0.80
add_to_walMethod · 0.80
batch_add_to_walMethod · 0.80
compress_indicesFunction · 0.80
serializeMethod · 0.80

Calls 2

lenMethod · 0.80
resize_mmapMethod · 0.45

Tested by 2

test_store_and_load_nodeFunction · 0.64