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

Method get

src/structures/dense_vector_list.rs:118–138  ·  view source on GitHub ↗
(&self, index: usize)

Source from the content-addressed store, hash-verified

116 }
117
118 pub fn get(&self, index: usize) -> io::Result<&[u8; QUANTIZED_VECTOR_SIZE]> {
119 let offset = HEADER_SIZE + index * QUANTIZED_VECTOR_SIZE;
120 let end = offset + QUANTIZED_VECTOR_SIZE;
121
122 if end > self.used_space + HEADER_SIZE {
123 // print everything for debugging
124 println!("Offset: {}", offset);
125 println!("End: {}", end);
126 println!("Used space: {}", self.used_space);
127
128 return Err(io::Error::new(
129 io::ErrorKind::InvalidInput,
130 "Index out of bounds",
131 ));
132 }
133
134 //don't use unsafe
135 let bytes = &self.mmap[offset..end];
136 let val = bytes.try_into().unwrap();
137 Ok(val)
138 }
139
140 pub fn get_contiguous(
141 &self,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected