Remove the roaring operation functions warnings

This commit is contained in:
Kerollmops 2021-06-30 14:12:56 +02:00
parent 66e6ea56b8
commit 32b7bd366f
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
14 changed files with 43 additions and 45 deletions

View File

@ -328,7 +328,7 @@ pub fn resolve_query_tree<'t>(
candidates = docids;
first_loop = false;
} else {
candidates.intersect_with(&docids);
candidates &= &docids;
}
}
Ok(candidates)
@ -358,7 +358,7 @@ pub fn resolve_query_tree<'t>(
let mut candidates = RoaringBitmap::new();
for op in ops {
let docids = resolve_operation(ctx, op, wdcache)?;
candidates.union_with(&docids);
candidates |= docids;
}
Ok(candidates)
}
@ -381,7 +381,7 @@ fn all_word_pair_proximity_docids<T: AsRef<str>, U: AsRef<str>>(
let current_docids = ctx
.word_pair_proximity_docids(left.as_ref(), right.as_ref(), proximity)?
.unwrap_or_default();
docids.union_with(&current_docids);
docids |= current_docids;
}
}
Ok(docids)
@ -401,7 +401,7 @@ fn query_docids(
let mut docids = RoaringBitmap::new();
for (word, _typo) in words {
let current_docids = ctx.word_docids(&word)?.unwrap_or_default();
docids.union_with(&current_docids);
docids |= current_docids;
}
Ok(docids)
} else {
@ -413,7 +413,7 @@ fn query_docids(
let mut docids = RoaringBitmap::new();
for (word, _typo) in words {
let current_docids = ctx.word_docids(&word)?.unwrap_or_default();
docids.union_with(&current_docids);
docids |= current_docids;
}
Ok(docids)
}
@ -430,7 +430,7 @@ fn query_pair_proximity_docids(
if proximity >= 8 {
let mut candidates = query_docids(ctx, left, wdcache)?;
let right_candidates = query_docids(ctx, right, wdcache)?;
candidates.intersect_with(&right_candidates);
candidates &= right_candidates;
return Ok(candidates);
}
@ -463,7 +463,7 @@ fn query_pair_proximity_docids(
proximity,
)?
.unwrap_or_default();
docids.union_with(&current_docids);
docids |= current_docids;
}
Ok(docids)
} else if prefix {

View File

@ -274,11 +274,11 @@ fn resolve_candidates<'t>(
let mut candidates =
query_pair_proximity_docids(ctx, lr, rl, pair_p + 1, wdcache)?;
if lcandidates.len() < rcandidates.len() {
candidates.intersect_with(lcandidates);
candidates.intersect_with(rcandidates);
candidates &= lcandidates;
candidates &= rcandidates;
} else {
candidates.intersect_with(rcandidates);
candidates.intersect_with(lcandidates);
candidates &= rcandidates;
candidates &= lcandidates;
}
if !candidates.is_empty() {
output.push((ll.clone(), rr.clone(), candidates));
@ -317,7 +317,7 @@ fn resolve_candidates<'t>(
for (_, rtail, mut candidates) in
mdfs(ctx, tail, proximity - p, cache, wdcache)?
{
candidates.intersect_with(&head_candidates);
candidates &= &head_candidates;
if !candidates.is_empty() {
output.push((lhead.clone(), rtail, candidates));
}
@ -334,7 +334,7 @@ fn resolve_candidates<'t>(
let mut candidates = RoaringBitmap::new();
for (_, _, cds) in resolve_operation(ctx, query_tree, proximity, cache, wdcache)? {
candidates.union_with(&cds);
candidates |= cds;
}
Ok(candidates)
}

View File

@ -281,7 +281,7 @@ fn resolve_candidates<'t>(
let mut candidates = RoaringBitmap::new();
for op in ops {
let docids = resolve_operation(ctx, op, number_typos, cache, wdcache)?;
candidates.union_with(&docids);
candidates |= docids;
}
Ok(candidates)
}
@ -329,8 +329,8 @@ fn resolve_candidates<'t>(
};
if !head_candidates.is_empty() {
let tail_candidates = mdfs(ctx, tail, mana - m, cache, wdcache)?;
head_candidates.intersect_with(&tail_candidates);
candidates.union_with(&head_candidates);
head_candidates &= tail_candidates;
candidates |= head_candidates;
}
}

View File

@ -61,7 +61,7 @@ impl<'a> FacetDistinctIter<'a> {
db_name: db_name::FACET_ID_STRING_DOCIDS,
key: None,
})?;
self.excluded.union_with(&facet_docids);
self.excluded |= facet_docids;
}
self.excluded.remove(id);
@ -79,7 +79,7 @@ impl<'a> FacetDistinctIter<'a> {
db_name: db_name::FACET_ID_F64_DOCIDS,
key: None,
})?;
self.excluded.union_with(&facet_docids);
self.excluded |= facet_docids;
}
self.excluded.remove(id);
@ -92,7 +92,7 @@ impl<'a> FacetDistinctIter<'a> {
/// handling easier.
fn next_inner(&mut self) -> Result<Option<DocumentId>> {
// The first step is to remove all the excluded documents from our candidates
self.candidates.difference_with(&self.excluded);
self.candidates -= &self.excluded;
let mut candidates_iter = self.candidates.iter().skip(self.iter_offset);
match candidates_iter.next() {

View File

@ -122,7 +122,7 @@ impl<'a> FacetDistribution<'a> {
for result in iter {
let (value, mut docids) = result?;
docids.intersect_with(candidates);
docids &= candidates;
if !docids.is_empty() {
distribution.insert(value.to_string(), docids.len());
}

View File

@ -289,7 +289,7 @@ impl FilterCondition {
for (i, result) in iter.enumerate() {
let ((_fid, level, l, r), docids) = result?;
debug!("{:?} to {:?} (level {}) found {} documents", l, r, level, docids.len());
output.union_with(&docids);
*output |= docids;
// We save the leftest and rightest bounds we actually found at this level.
if i == 0 {
left_found = Some(l);

View File

@ -213,10 +213,10 @@ impl<'t> Iterator for FacetIter<'t> {
match result {
Ok(((_fid, level, left, right), mut docids)) => {
docids.intersect_with(&documents_ids);
docids &= &*documents_ids;
if !docids.is_empty() {
if self.must_reduce {
documents_ids.difference_with(&docids);
*documents_ids -= &docids;
}
if level == 0 {

View File

@ -173,7 +173,7 @@ impl<'a> Search<'a> {
let mut candidates = distinct.distinct(candidates, excluded);
initial_candidates.union_with(&bucket_candidates);
initial_candidates |= bucket_candidates;
if offset != 0 {
let discarded = candidates.by_ref().take(offset).count();

View File

@ -12,7 +12,7 @@ impl AvailableDocumentsIds {
match docids.max() {
Some(last_id) => {
let mut available = RoaringBitmap::from_iter(0..last_id);
available.difference_with(&docids);
available -= docids;
let iter = match last_id.checked_add(1) {
Some(id) => id..=u32::max_value(),

View File

@ -43,7 +43,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
}
pub fn delete_documents(&mut self, docids: &RoaringBitmap) {
self.documents_ids.union_with(docids);
self.documents_ids |= docids;
}
pub fn delete_external_id(&mut self, external_id: &str) -> Option<u32> {
@ -65,7 +65,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
// We remove the documents ids that we want to delete
// from the documents in the database and write them back.
let current_documents_ids_len = documents_ids.len();
documents_ids.difference_with(&self.documents_ids);
documents_ids -= &self.documents_ids;
self.index.put_documents_ids(self.wtxn, &documents_ids)?;
// We can execute a ClearDocuments operation when the number of documents
@ -194,7 +194,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
if let Some((key, mut docids)) = iter.next().transpose()? {
if key == word.as_ref() {
let previous_len = docids.len();
docids.difference_with(&self.documents_ids);
docids -= &self.documents_ids;
if docids.is_empty() {
// safety: we don't keep references from inside the LMDB database.
unsafe { iter.del_current()? };
@ -245,7 +245,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
let (prefix, mut docids) = result?;
let prefix = prefix.to_owned();
let previous_len = docids.len();
docids.difference_with(&self.documents_ids);
docids -= &self.documents_ids;
if docids.is_empty() {
// safety: we don't keep references from inside the LMDB database.
unsafe { iter.del_current()? };
@ -285,7 +285,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
while let Some(result) = iter.next() {
let (key, mut docids) = result?;
let previous_len = docids.len();
docids.difference_with(&self.documents_ids);
docids -= &self.documents_ids;
if docids.is_empty() {
// safety: we don't keep references from inside the LMDB database.
unsafe { iter.del_current()? };
@ -306,7 +306,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
while let Some(result) = iter.next() {
let (bytes, mut docids) = result?;
let previous_len = docids.len();
docids.difference_with(&self.documents_ids);
docids -= &self.documents_ids;
if docids.is_empty() {
// safety: we don't keep references from inside the LMDB database.
unsafe { iter.del_current()? };
@ -325,7 +325,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
while let Some(result) = iter.next() {
let (bytes, mut docids) = result?;
let previous_len = docids.len();
docids.difference_with(&self.documents_ids);
docids -= &self.documents_ids;
if docids.is_empty() {
// safety: we don't keep references from inside the LMDB database.
unsafe { iter.del_current()? };
@ -344,7 +344,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
while let Some(result) = iter.next() {
let (bytes, mut docids) = result?;
let previous_len = docids.len();
docids.difference_with(&self.documents_ids);
docids -= &self.documents_ids;
if docids.is_empty() {
// safety: we don't keep references from inside the LMDB database.
unsafe { iter.del_current()? };
@ -361,7 +361,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
let mut iter = field_id_word_count_docids.iter_mut(self.wtxn)?;
while let Some((key, mut docids)) = iter.next().transpose()? {
let previous_len = docids.len();
docids.difference_with(&self.documents_ids);
docids -= &self.documents_ids;
if docids.is_empty() {
// safety: we don't keep references from inside the LMDB database.
unsafe { iter.del_current()? };
@ -390,7 +390,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
for field_id in self.index.faceted_fields_ids(self.wtxn)? {
// Remove docids from the number faceted documents ids
let mut docids = self.index.number_faceted_documents_ids(self.wtxn, field_id)?;
docids.difference_with(&self.documents_ids);
docids -= &self.documents_ids;
self.index.put_number_faceted_documents_ids(self.wtxn, field_id, &docids)?;
remove_docids_from_field_id_docid_facet_value(
@ -403,7 +403,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
// Remove docids from the string faceted documents ids
let mut docids = self.index.string_faceted_documents_ids(self.wtxn, field_id)?;
docids.difference_with(&self.documents_ids);
docids -= &self.documents_ids;
self.index.put_string_faceted_documents_ids(self.wtxn, field_id, &docids)?;
remove_docids_from_field_id_docid_facet_value(
@ -456,7 +456,7 @@ where
while let Some(result) = iter.next() {
let (bytes, mut docids) = result?;
let previous_len = docids.len();
docids.difference_with(to_remove);
docids -= to_remove;
if docids.is_empty() {
// safety: we don't keep references from inside the LMDB database.
unsafe { iter.del_current()? };

View File

@ -181,7 +181,7 @@ fn compute_facet_number_levels<'t>(
}
// The right bound is always the bound we run through.
group_docids.union_with(&docids);
group_docids |= docids;
right = value;
}

View File

@ -61,8 +61,7 @@ pub fn roaring_bitmap_merge(_key: &[u8], values: &[Cow<[u8]>]) -> Result<Vec<u8>
let mut head = RoaringBitmap::deserialize_from(&head[..])?;
for value in tail {
let bitmap = RoaringBitmap::deserialize_from(&value[..])?;
head.union_with(&bitmap);
head |= RoaringBitmap::deserialize_from(&value[..])?;
}
let mut vec = Vec::with_capacity(head.serialized_size());
@ -75,8 +74,7 @@ pub fn cbo_roaring_bitmap_merge(_key: &[u8], values: &[Cow<[u8]>]) -> Result<Vec
let mut head = CboRoaringBitmapCodec::deserialize_from(&head[..])?;
for value in tail {
let bitmap = CboRoaringBitmapCodec::deserialize_from(&value[..])?;
head.union_with(&bitmap);
head |= CboRoaringBitmapCodec::deserialize_from(&value[..])?;
}
let mut vec = Vec::new();

View File

@ -608,8 +608,8 @@ impl<'t, 'u, 'i, 'a> IndexDocuments<'t, 'u, 'i, 'a> {
self.index.put_external_documents_ids(self.wtxn, &external_documents_ids)?;
// We merge the new documents ids with the existing ones.
documents_ids.union_with(&new_documents_ids);
documents_ids.union_with(&replaced_documents_ids);
documents_ids |= new_documents_ids;
documents_ids |= replaced_documents_ids;
self.index.put_documents_ids(self.wtxn, &documents_ids)?;
let mut database_count = 0;

View File

@ -236,7 +236,7 @@ fn compute_positions_levels(
}
// The right bound is always the bound we run through.
group_docids.union_with(&docids);
group_docids |= docids;
}
if !group_docids.is_empty() {