(&self, index: usize)
| 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, |
nothing calls this directly
no outgoing calls
no test coverage detected