Use another function to define the proximity

This commit is contained in:
Clément Renault
2020-09-06 17:33:26 +02:00
parent f928b91e9d
commit bb1ab428db
4 changed files with 36 additions and 7 deletions

View File

@ -199,13 +199,14 @@ impl Store {
let mut key = vec![WORD_DOCID_POSITIONS_BYTE];
let mut buffer = Vec::new();
// We serialize the document ids into a buffer
// We prefix the words by the document id.
key.extend_from_slice(&id.to_be_bytes());
let base_size = key.len();
for (word, positions) in iter {
key.truncate(1 + 4);
key.truncate(base_size);
key.extend_from_slice(word.as_bytes());
// We serialize the positions into a buffer.
buffer.clear();
buffer.reserve(positions.serialized_size());
positions.serialize_into(&mut buffer)?;