Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Merge #350
Browse files Browse the repository at this point in the history
350: Fix mdb val size error r=Kerollmops a=ManyTheFish

Related to [#1677](meilisearch/meilisearch#1677)

Co-authored-by: many <maxime@meilisearch.com>
  • Loading branch information
bors[bot] and ManyTheFish committed Sep 8, 2021
2 parents 63bc231 + e54280f commit 86c3b0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ pub fn extract_docid_word_positions<R: io::Read>(

for (index, token) in tokens {
let token = token.text().trim();
key_buffer.truncate(mem::size_of::<u32>());
key_buffer.extend_from_slice(token.as_bytes());
if !token.is_empty() {
key_buffer.truncate(mem::size_of::<u32>());
key_buffer.extend_from_slice(token.as_bytes());

let position: u32 = index
.try_into()
.map_err(|_| SerializationError::InvalidNumberSerialization)?;
let position = field_id as u32 * ONE_ATTRIBUTE + position;
docid_word_positions_sorter.insert(&key_buffer, &position.to_ne_bytes())?;
let position: u32 = index
.try_into()
.map_err(|_| SerializationError::InvalidNumberSerialization)?;
let position = field_id as u32 * ONE_ATTRIBUTE + position;
docid_word_positions_sorter
.insert(&key_buffer, &position.to_ne_bytes())?;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion milli/src/update/index_documents/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub use merge_functions::{
};

pub fn valid_lmdb_key(key: impl AsRef<[u8]>) -> bool {
key.as_ref().len() <= 511
key.as_ref().len() <= 511 && !key.as_ref().is_empty()
}

/// Divides one slice into two at an index, returns `None` if mid is out of bounds.
Expand Down

0 comments on commit 86c3b0c

Please sign in to comment.