Fix field distribution again

This commit is contained in:
Louis Dureuil 2023-10-30 16:57:08 +01:00
parent be395c7944
commit de10f20732
No known key found for this signature in database

View File

@ -674,10 +674,7 @@ impl<'a, 'i> Transform<'a, 'i> {
total_documents: self.documents_count, total_documents: self.documents_count,
}); });
// We increment all the field of the current document in the field distribution. for (key, value) in KvReader::new(val) {
let obkv = KvReader::new(val);
for (key, value) in obkv.iter() {
let reader = KvReaderDelAdd::new(value); let reader = KvReaderDelAdd::new(value);
match (reader.get(DelAdd::Deletion), reader.get(DelAdd::Addition)) { match (reader.get(DelAdd::Deletion), reader.get(DelAdd::Addition)) {
(None, None) => {} (None, None) => {}
@ -705,12 +702,14 @@ impl<'a, 'i> Transform<'a, 'i> {
BEntry::Occupied(mut entry) => { BEntry::Occupied(mut entry) => {
// attempt to remove one // attempt to remove one
match entry.get_mut().checked_sub(1) { match entry.get_mut().checked_sub(1) {
Some(0) => {
entry.remove();
}
Some(new_val) => { Some(new_val) => {
*entry.get_mut() = new_val; *entry.get_mut() = new_val;
} }
None => { None => {
// was 0, remove field from distribution unreachable!("Attempting to remove a field that wasn't in the field distribution")
entry.remove();
} }
} }
} }