Store the word positions under the documents

This commit is contained in:
Clément Renault 2020-09-05 18:03:06 +02:00
parent 580ed1119a
commit dc88a86259
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
7 changed files with 72 additions and 563 deletions

View file

@ -8,8 +8,7 @@ impl<'a> heed::BytesDecode<'a> for StrBEU32Codec {
type DItem = (&'a str, u32);
fn bytes_decode(bytes: &'a [u8]) -> Option<Self::DItem> {
let str_len = bytes.len().checked_sub(4)?;
let (str_bytes, n_bytes) = bytes.split_at(str_len);
let (str_bytes, n_bytes) = bytes.split_at(bytes.len() - 4);
let s = str::from_utf8(str_bytes).ok()?;
let n = n_bytes.try_into().map(u32::from_be_bytes).ok()?;
Some((s, n))