MCPcopy Create free account
hub / github.com/PerroEngine/Perro / hash_index

Method hash_index

perro_source/core/perro_csv/src/lib.rs:204–223  ·  view source on GitHub ↗
(&'static self, col: usize)

Source from the content-addressed store, hash-verified

202 self.get(row, col)
203 }
204
205 /// Returns the first primary row with `key_hash`.
206 ///
207 /// Hash-only lookups cannot distinguish collisions. Use [`Self::find_primary`] when the
208 /// original key text is available.
209 #[inline]
210 pub fn find_primary_hash(&self, key_hash: u64) -> Option<&'static CsvRow> {
211 self.rows.get(self.primary_lookup().get(&key_hash)?.first)
212 }
213
214 #[inline]
215 pub fn find_primary(&self, key: &str) -> Option<&'static CsvRow> {
216 let key_hash = perro_ids::string_to_u64(key);
217 self.primary_lookup()
218 .get(&key_hash)?
219 .rows()
220 .find_map(|row| {
221 self.rows.get(row).filter(|row| {
222 row.cells
223 .first()
224 .is_some_and(|cell| cell.hash == key_hash && cell.text == key)
225 })
226 })

Callers 1

candidate_rowsMethod · 0.80

Calls 6

cloneMethod · 0.80
getMethod · 0.45
expectMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected