Skip to content

Run containers attempt 3 #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 69 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
9b67893
WIP: Run container
josephglanville Mar 23, 2020
3124aa4
Fix some bugs in the run container implementation
Kerollmops Sep 11, 2020
2068bb6
Fix the to_array/bitmap impl for runs, the end bound is inclusive
Kerollmops Sep 11, 2020
e605f64
Rework the array bitmap intersect_with using Vec::retain
Kerollmops Sep 11, 2020
9321618
Implement the array run intersect_with operation
Kerollmops Sep 11, 2020
a62fc7d
Implement the run array intersect_with operation
Kerollmops Sep 11, 2020
d658f28
Implement the run run union_with operation
Kerollmops Sep 11, 2020
0ded028
Implement the run array union_with operation
Kerollmops Sep 12, 2020
fe8a4ab
Implement the array run union_with operation
Kerollmops Sep 12, 2020
613163f
Implement the bitmap run union_with operation
Kerollmops Sep 12, 2020
0a66483
Implement the run run intersect_with operation
Kerollmops Sep 12, 2020
9af4366
Implement the bitmap run intersect_with operation
Kerollmops Sep 12, 2020
9612ae9
Implement the run bitmap intersect_with operation
Kerollmops Sep 12, 2020
4ae8986
Simplify the run run intersect_with operation
Kerollmops Sep 12, 2020
924d4db
Implement the remove_range operation for the run store type
Kerollmops Sep 12, 2020
d7bcad3
Implement the run array and array run is_disjoint operation
Kerollmops Sep 12, 2020
cb69d80
Implement the run run is_disjoint operation
Kerollmops Sep 13, 2020
c77c0f8
Simplify the array bitmap difference_with operation
Kerollmops Sep 13, 2020
3a9eefd
Implement the array run difference_with operation
Kerollmops Sep 13, 2020
183c1bb
Implement the bitmap run difference_with operation
Kerollmops Sep 13, 2020
07d0fcc
Clippy and fmt pass
Kerollmops Sep 13, 2020
3c99804
Implement the run array difference_with operation
Kerollmops Sep 13, 2020
c762f93
Mark array run symmetric_difference_with operation as unimplemented
Kerollmops Sep 13, 2020
9744f12
Implement the array run is_subset operation
Kerollmops Sep 13, 2020
67784ad
Implement the run run difference_with operation
Kerollmops Sep 13, 2020
ec86619
Merge remote-tracking branch 'origin/main' into run-containers
lucascool12 Apr 10, 2025
a57aff1
feat: insert and insert_range on runs
lucascool12 Apr 10, 2025
47b7cbf
fix: fixes ci failures introduced in a57aff16
lucascool12 Apr 11, 2025
71c6679
feat: run store push
lucascool12 Apr 11, 2025
7dfdd92
feat: run store remove index
lucascool12 Apr 11, 2025
f8df21c
feat: run store remove range
lucascool12 Apr 11, 2025
41580e4
feat: run store remove smallest
lucascool12 Apr 11, 2025
f4bb025
feat: run store remove biggest
lucascool12 Apr 11, 2025
38e203c
feat: store run contains
lucascool12 Apr 12, 2025
5f88543
feat: runs store contains range
lucascool12 Apr 12, 2025
2302e2c
feat: runs store is disjoint
lucascool12 Apr 12, 2025
12aad5f
feat: runs store is subset
lucascool12 Apr 12, 2025
1a3a465
feat: runs store intersection len
lucascool12 Apr 12, 2025
b0771c7
feat: runs store len
lucascool12 Apr 12, 2025
3a2654f
feat: runs store is_empty
lucascool12 Apr 12, 2025
37ee974
feat: runs store min max
lucascool12 Apr 12, 2025
561780f
feat: runs store rank
lucascool12 Apr 12, 2025
966ac14
feat: runs store select
lucascool12 Apr 12, 2025
5b01331
fix: failing ci
lucascool12 Apr 13, 2025
9939317
fix: run store wrong insert range with begin overlap and concescutive…
lucascool12 Apr 12, 2025
ada90cd
fix: llvm-cov uncovered bugs
lucascool12 Apr 13, 2025
04a8d03
feat: run store union and miscellaneous stuff
lucascool12 Apr 13, 2025
b901e41
feat: run store intersection
lucascool12 Apr 13, 2025
bd04ab7
feat: run store difference
lucascool12 Apr 13, 2025
892fe99
feat: run store symmetric difference
lucascool12 Apr 14, 2025
004e11e
feat: run store iterator
lucascool12 Apr 18, 2025
251d961
feat: add run store
lucascool12 Apr 18, 2025
340dff2
test: interval store
lucascool12 Apr 20, 2025
b2d2657
feat: run container statistics
lucascool12 Apr 20, 2025
6617d08
Merge remote-tracking branch 'origin/main' into run-containers
lucascool12 Apr 25, 2025
fd4c829
fix: remove unused method
lucascool12 Apr 25, 2025
0745eda
fix: improve debug_assertions, remove unused `#[allow(clippy::todo)]`…
lucascool12 Apr 25, 2025
41c7f08
fix: deobfuscate `IntervalStore::insert`
lucascool12 Apr 25, 2025
b074682
fix: deobfuscate `IntervalStore::insert_range`
lucascool12 Apr 25, 2025
53c9aa2
fix: deobfuscate `IntervalStore::insert_range`
lucascool12 Apr 25, 2025
6af1dad
fix ci
lucascool12 Apr 26, 2025
4496602
add more range-related testing to fuzzing
Dr-Emann Apr 27, 2025
e27487e
Merge pull request #1 from Dr-Emann/push-qmsznnqtlpkk
lucascool12 May 5, 2025
b88e258
fix: align container optimize with croaring implementation
lucascool12 May 5, 2025
a24ff69
fix: interval store iterator not stopping
lucascool12 May 5, 2025
869e780
test: align optimize in croaring to current optimize
lucascool12 May 5, 2025
08f3ed1
fix: interval select truncating much needed run_len bits
lucascool12 May 5, 2025
eff381a
feat: run optimized insert range
lucascool12 May 11, 2025
c3ebe86
feat: remove_run_compression
lucascool12 May 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 84 additions & 13 deletions fuzz/fuzz_targets/arbitrary_ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,19 @@ pub enum MutableBitmapOperation {
RemoveRange(RangeInclusive<Num>),
Clear,
Extend(Vec<Num>),
SwapSerialization,
Optimize,
RemoveRunCompression,
// Probably turn it into a bitmap
MakeBitmap { key: u16 },
// Probably turn it into a Range
MakeRange { key: u16 },
}

#[derive(Arbitrary, Debug, Copy, Clone)]
pub enum RangeOperations {
Optimized,
Removed,
}

#[derive(Arbitrary, Debug)]
Expand All @@ -67,11 +78,11 @@ pub enum ReadBitmapOperation {
Maximum,
Rank(Num),
Select(Num),
Statistics,
Statistics(RangeOperations),
Clone,
Debug,
SerializedSize,
Serialize,
SerializedSize(RangeOperations),
Serialize(RangeOperations),
}

#[derive(Arbitrary, Debug)]
Expand All @@ -85,7 +96,7 @@ pub enum BitmapBinaryOperation {
}

impl ReadBitmapOperation {
pub fn apply(&self, x: &mut croaring::Bitmap, y: &roaring::RoaringBitmap) {
pub fn apply(&self, x: &mut croaring::Bitmap, y: &mut roaring::RoaringBitmap) {
match *self {
ReadBitmapOperation::ContainsRange(ref range) => {
let range = range.start().0..=range.end().0;
Expand Down Expand Up @@ -139,9 +150,19 @@ impl ReadBitmapOperation {
let actual = y.select(n);
assert_eq!(expected, actual);
}
ReadBitmapOperation::Statistics => {
// roaring-rs doesn't support range containers (yet)
x.remove_run_compression();
ReadBitmapOperation::Statistics(ranges) => {
match ranges {
RangeOperations::Optimized => {
x.remove_run_compression();
y.remove_run_compression();
assert_eq!(x.run_optimize(), y.optimize());
}
RangeOperations::Removed => {
x.run_optimize();
y.optimize();
assert_eq!(x.remove_run_compression(), y.remove_run_compression());
}
}
let expected = x.statistics();
let actual = y.statistics();
// Convert to the same statistics struct
Expand Down Expand Up @@ -174,16 +195,36 @@ impl ReadBitmapOperation {
use std::io::Write;
write!(std::io::sink(), "{:?}", y).unwrap();
}
ReadBitmapOperation::SerializedSize => {
// roaring-rs doesn't support range containers (yet)
x.remove_run_compression();
ReadBitmapOperation::SerializedSize(ranges) => {
match ranges {
RangeOperations::Optimized => {
x.remove_run_compression();
y.remove_run_compression();
assert_eq!(x.run_optimize(), y.optimize());
}
RangeOperations::Removed => {
x.run_optimize();
y.optimize();
assert_eq!(x.remove_run_compression(), y.remove_run_compression());
}
}
let expected = x.get_serialized_size_in_bytes::<croaring::Portable>();
let actual = y.serialized_size();
assert_eq!(expected, actual);
}
ReadBitmapOperation::Serialize => {
// roaring-rs doesn't support range containers (yet)
x.remove_run_compression();
ReadBitmapOperation::Serialize(ranges) => {
match ranges {
RangeOperations::Optimized => {
x.remove_run_compression();
y.remove_run_compression();
assert_eq!(x.run_optimize(), y.optimize());
}
RangeOperations::Removed => {
x.run_optimize();
y.optimize();
assert_eq!(x.remove_run_compression(), y.remove_run_compression());
}
}
let expected = x.serialize::<croaring::Portable>();
let mut actual = Vec::new();
y.serialize_into(&mut actual).unwrap();
Expand Down Expand Up @@ -230,12 +271,35 @@ impl MutableBitmapOperation {
x.clear();
y.clear();
}
MutableBitmapOperation::Optimize => {
x.remove_run_compression();
y.remove_run_compression();
assert_eq!(x.run_optimize(), y.optimize());
}
MutableBitmapOperation::RemoveRunCompression => {
x.run_optimize();
y.optimize();
assert_eq!(x.remove_run_compression(), y.remove_run_compression());
}
MutableBitmapOperation::Extend(ref items) => {
// Safety - Num is repr(transparent) over u32
let items: &[u32] = unsafe { mem::transmute(&items[..]) };
x.add_many(items);
y.extend(items);
}
MutableBitmapOperation::SwapSerialization => {
let x_serialized = x.serialize::<croaring::Portable>();
let mut y_serialized = Vec::new();
y.serialize_into(&mut y_serialized).unwrap();

let new_x =
croaring::Bitmap::try_deserialize::<croaring::Portable>(&y_serialized).unwrap();
let new_y = roaring::RoaringBitmap::deserialize_from(&x_serialized[..]).unwrap();
assert_eq!(new_x, *x);
assert_eq!(new_y, *y);
*x = new_x;
*y = new_y;
}
MutableBitmapOperation::MakeBitmap { key } => {
let key = u32::from(key);
let start = key * 0x1_0000;
Expand All @@ -245,6 +309,13 @@ impl MutableBitmapOperation {
y.insert(i);
}
}
MutableBitmapOperation::MakeRange { key } => {
let key = u32::from(key);
let start = key * 0x1_0000;
let end = start + 9 * 1024;
x.add_range(start..=end);
y.insert_range(start..=end);
}
}
}
}
Expand Down
48 changes: 46 additions & 2 deletions roaring/src/bitmap/arbitrary.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(test)]
mod test {
use crate::bitmap::container::Container;
use crate::bitmap::store::{ArrayStore, BitmapStore, Store};
use crate::bitmap::container::{Container, RUN_MAX_SIZE};
use crate::bitmap::store::{ArrayStore, BitmapStore, IntervalStore, Store};
use crate::RoaringBitmap;
use core::fmt::{Debug, Formatter};
use proptest::bits::{BitSetLike, SampledBitSetStrategy};
Expand Down Expand Up @@ -68,6 +68,47 @@ mod test {
}
}

impl BitSetLike for IntervalStore {
fn new_bitset(max: usize) -> Self {
assert!(max <= IntervalStore::MAX + 1);
IntervalStore::new()
}

fn len(&self) -> usize {
IntervalStore::MAX + 1
}

fn test(&self, bit: usize) -> bool {
assert!(bit <= IntervalStore::MAX);
self.contains(bit as u16)
}

fn set(&mut self, bit: usize) {
assert!(bit <= IntervalStore::MAX);
self.insert(bit as u16);
}

fn clear(&mut self, bit: usize) {
assert!(bit <= IntervalStore::MAX);
self.remove(bit as u16);
}

fn count(&self) -> usize {
self.len() as usize
}
}

impl IntervalStore {
const MAX: usize = u16::MAX as usize;

pub fn sampled(
size: impl Into<SizeRange>,
bits: impl Into<SizeRange>,
) -> SampledBitSetStrategy<Self> {
SampledBitSetStrategy::new(size.into(), bits.into())
}
}

impl Debug for ArrayStore {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
if self.len() < 16 {
Expand Down Expand Up @@ -130,6 +171,7 @@ mod test {
match self {
Store::Array(a) => write!(f, "Store({a:?})"),
Store::Bitmap(b) => write!(f, "Store({b:?})"),
Store::Run(c) => write!(f, "Store({c:?})"),
}
}
}
Expand All @@ -140,6 +182,8 @@ mod test {
ArrayStore::sampled(1..=4096, ..=u16::MAX as usize).prop_map(Store::Array),
BitmapStore::sampled(4097..u16::MAX as usize, ..=u16::MAX as usize)
.prop_map(Store::Bitmap),
IntervalStore::sampled(1..=RUN_MAX_SIZE as usize, ..=u16::MAX as usize)
.prop_map(Store::Run),
]
}
}
Expand Down
Loading
Loading