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

Commit

Permalink
facet number & strings
Browse files Browse the repository at this point in the history
  • Loading branch information
irevoire committed Aug 24, 2022
1 parent 52e8ac1 commit 9ce9a4b
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions milli/src/update/facets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ use grenad::{CompressionType, Reader, Writer};
use heed::types::{ByteSlice, DecodeIgnore};
use heed::{BytesDecode, BytesEncode, Error};
use log::debug;
use roaring::RoaringBitmap;
use roaring::{IterExt, RoaringBitmap};
use time::OffsetDateTime;

use crate::error::InternalError;
Expand Down Expand Up @@ -301,9 +301,7 @@ fn compute_facet_number_levels<'t>(
first_level_size,
level_group_size,
&mut |bitmaps, _, _| {
for bitmap in bitmaps {
number_document_ids |= bitmap;
}
number_document_ids |= bitmaps.or();
Ok(())
},
&|_i, (_field_id, _level, left, _right)| *left,
Expand All @@ -316,11 +314,11 @@ fn compute_facet_number_levels<'t>(

Ok((subwriters, number_document_ids))
} else {
let mut documents_ids = RoaringBitmap::new();
for result in db.range(rtxn, &(level_0_start..))?.take(first_level_size) {
let (_key, docids) = result?;
documents_ids |= docids;
}
let documents_ids = db
.range(rtxn, &(level_0_start..))?
.take(first_level_size)
.map(|result| result.map(|(_key, docids)| docids))
.or()?;

Ok((vec![], documents_ids))
}
Expand Down Expand Up @@ -389,11 +387,11 @@ fn compute_facet_strings_levels<'t>(

Ok((subwriters, strings_document_ids))
} else {
let mut documents_ids = RoaringBitmap::new();
for result in db.range(rtxn, &(level_0_start..))?.take(first_level_size) {
let (_key, (_original_value, docids)) = result?;
documents_ids |= docids;
}
let documents_ids = db
.range(rtxn, &(level_0_start..))?
.take(first_level_size)
.map(|result| result.map(|(_key, (_original_value, docids))| docids))
.or()?;

Ok((vec![], documents_ids))
}
Expand Down

0 comments on commit 9ce9a4b

Please sign in to comment.