Skip to content

Commit 88ceb7d

Browse files
committed
Improve the documentation of the function
1 parent 7b4df74 commit 88ceb7d

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/bitmap/ops_with_serialized.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,31 @@ use super::container::ARRAY_LIMIT;
1717
use super::store::{ArrayStore, BitmapStore, Store, BITMAP_LENGTH};
1818

1919
impl RoaringBitmap {
20-
/// Computes the len of the intersection with the specified other bitmap without creating a
21-
/// new bitmap.
20+
/// Computes the intersection between a materialized [`RoaringBitmap`] and a serialized one.
2221
///
23-
/// This is faster and more space efficient when you're only interested in the cardinality of
24-
/// the intersection.
22+
/// This is faster and more space efficient when you only need the intersection result.
23+
/// It reduces the number of deserialized internal container and therefore
24+
/// the number of allocations and copies of bytes.
2525
///
2626
/// # Examples
2727
///
2828
/// ```rust
2929
/// use roaring::RoaringBitmap;
30+
/// use std::io::Cursor;
3031
///
3132
/// let rb1: RoaringBitmap = (1..4).collect();
3233
/// let rb2: RoaringBitmap = (3..5).collect();
3334
///
35+
/// // Let's say the rb2 bitmap is serialized
36+
/// let mut bytes = Vec::new();
37+
/// rb2.serialize_into(&mut bytes).unwrap();
38+
/// let rb2_bytes = Cursor::new(bytes);
3439
///
35-
/// assert_eq!(rb1.intersection_len(&rb2), (rb1 & rb2).len());
40+
/// assert_eq!(
41+
/// rb1.intersection_with_serialized_unchecked(rb2_bytes).unwrap(),
42+
/// rb1 & rb2,
43+
/// );
3644
/// ```
37-
// TODO convert this into a trait
3845
pub fn intersection_with_serialized_unchecked<R>(&self, other: R) -> io::Result<RoaringBitmap>
3946
where
4047
R: io::Read + io::Seek,
@@ -92,7 +99,7 @@ impl RoaringBitmap {
9299
let mut description_bytes = &description_bytes[..];
93100

94101
if has_offsets {
95-
// We could use these offsets but we are lazy
102+
// I could use these offsets but I am a lazy developer (for now)
96103
reader.seek(SeekFrom::Current((size * OFFSET_BYTES) as i64))?;
97104
}
98105

0 commit comments

Comments
 (0)