Pure MoonBit 32-bit Roaring Bitmap indexes
let left = @roaring.RoaringBitmap::from_array([1, 2, 3, 70_000]).unwrap()
let right = @roaring.RoaringBitmap::from_array([2, 3, 80_000]).unwrap()
assert_eq(left.intersection(right).to_array(), [2, 3])moon check --deny-warn
moon test --deny-warn
moon bench --release --deny-warn
moon run cmd/mainpub(all) struct BitmapBatchReport {
operand_count : Int
total_cardinality : Int
union_cardinality : Int
intersection_cardinality : Int
duplicate_occurrences : Int
empty_operands : Int
}fn BitmapCatalog::evaluate(self : BitmapCatalog, query : CatalogQuery, universe : RoaringBitmap) -> RoaringBitmapfn BitmapCatalog::evaluate_traced(self : BitmapCatalog, query : CatalogQuery, universe : RoaringBitmap) -> CatalogQueryResultfn BitmapCatalog::execute_with_trace(self : BitmapCatalog, query : CatalogQuery, universe : RoaringBitmap) -> QueryExecutionTracepub(all) struct BitmapComparison {
relation : SetRelation
left_cardinality : Int
right_cardinality : Int
common_cardinality : Int
left_only_cardinality : Int
right_only_cardinality : Int
union_cardinality : Int
}fn BitmapOperation::apply(self : BitmapOperation, bitmap : RoaringBitmap) -> Result[RoaringBitmap, RoaringError]pub(all) enum BitmapPlan {
Source(RoaringBitmap)
Union(BitmapPlan, BitmapPlan)
Intersection(BitmapPlan, BitmapPlan)
Difference(BitmapPlan, BitmapPlan)
Xor(BitmapPlan, BitmapPlan)
Take(BitmapPlan, Int)
Drop(BitmapPlan, Int)
}pub(all) struct BitmapPlanStats {
nodes : Int
depth : Int
sources : Int
}pub(all) struct BitmapProfile {
cardinality : Int
minimum : Int?
maximum : Int?
span : Int
block_count : Int
}pub(all) enum CatalogQuery {
Key(Int)
Any(Array[CatalogQuery])
All(Array[CatalogQuery])
Not(CatalogQuery)
AtLeast(Int, Array[CatalogQuery])
}fn CatalogQuery::result_upper_bound(self : CatalogQuery, catalog : BitmapCatalog, universe : RoaringBitmap) -> Intpub(all) struct CatalogQueryStats {
nodes : Int
depth : Int
key_references : Int
}pub(all) enum CodecError {
MissingHeader
UnsupportedVersion(Int)
InvalidCount(Int)
InvalidPayloadLength(Int, Int)
InvalidValue(Int)
InvalidRunLength(Int)
CardinalityMismatch(Int, Int)
PayloadTooLarge(Int)
NonCanonicalPayload
}pub(all) enum CodecFormat {
PlainWords
RunWords
}pub(all) enum ContainerKind {
Array
Bitmap
Run
}pub(all) struct IntRange {
start : Int
end : Int
}pub(all) enum JournalCodecError {
MissingHeader
UnsupportedVersion(Int)
InvalidOperationCount(Int)
InvalidTag(Int)
TruncatedPayload(Int)
InvalidBatchCount(Int)
}pub(all) enum JournalRangeError {
InvalidIndex(Int, Int)
}pub(all) struct QueryExecutionTrace {
result : RoaringBitmap
nodes : Int
depth : Int
requested_keys : Array[Int]
resolved_keys : Array[Int]
missing_keys : Array[Int]
result_cardinality : Int
}fn RoaringBitmap::add_all(self : RoaringBitmap, values : Array[Int]) -> Result[RoaringBitmap, RoaringError]fn RoaringBitmap::add_range(self : RoaringBitmap, start : Int, end : Int) -> Result[RoaringBitmap, RoaringError]fn RoaringBitmap::add_ranges(self : RoaringBitmap, ranges : Array[IntRange]) -> Result[RoaringBitmap, RoaringError]fn RoaringBitmap::contains_range(self : RoaringBitmap, start : Int, end : Int) -> Result[Bool, RoaringError]fn RoaringBitmap::count_in_range(self : RoaringBitmap, start : Int, end : Int) -> Result[Int, RoaringError]fn RoaringBitmap::encode(self : RoaringBitmap, format : CodecFormat) -> Result[Array[Int], CodecError]fn RoaringBitmap::frame(self : RoaringBitmap, format : CodecFormat) -> Result[BitmapFrame, CodecError]fn RoaringBitmap::map_values(self : RoaringBitmap, mapper : (Int) -> Int) -> Result[RoaringBitmap, RoaringError]fn RoaringBitmap::overlap_coefficient_parts(self : RoaringBitmap, other : RoaringBitmap) -> (Int, Int)fn RoaringBitmap::overlap_parts(self : RoaringBitmap, other : RoaringBitmap) -> (Int, Int, Int, Int)fn RoaringBitmap::partition(self : RoaringBitmap, predicate : (Int) -> Bool) -> (RoaringBitmap, RoaringBitmap)fn RoaringBitmap::quantile(self : RoaringBitmap, numerator : Int, denominator : Int) -> Result[Int?, RoaringError]fn RoaringBitmap::remove_all(self : RoaringBitmap, values : Array[Int]) -> Result[RoaringBitmap, RoaringError]fn RoaringBitmap::remove_range(self : RoaringBitmap, start : Int, end : Int) -> Result[RoaringBitmap, RoaringError]fn RoaringBitmap::remove_ranges(self : RoaringBitmap, ranges : Array[IntRange]) -> Result[RoaringBitmap, RoaringError]fn RoaringBitmap::slice_positions(self : RoaringBitmap, start : Int, end : Int) -> Result[RoaringBitmap, RoaringError]fn RoaringBitmap::symmetric_difference_cardinality(self : RoaringBitmap, other : RoaringBitmap) -> Intfn RoaringBuilder::push_all(self : RoaringBuilder, values : Array[Int]) -> Result[Unit, RoaringError]fn RoaringBuilder::push_range(self : RoaringBuilder, start : Int, end : Int) -> Result[Unit, RoaringError]pub struct RoaringCursor {
bitmap : RoaringBitmap
block_index : Int
lows : Array[Int]
low_index : Int
yielded : Int
}pub(all) enum RoaringError {
NegativeValue(Int)
InvalidRange(Int, Int)
RangeTooLarge(Int)
RangeEndpointOverflow(Int)
}fn RoaringOperationLog::append(self : RoaringOperationLog, operation : BitmapOperation) -> RoaringOperationLogfn RoaringOperationLog::append_all(self : RoaringOperationLog, additions : Array[BitmapOperation]) -> RoaringOperationLogfn RoaringOperationLog::checkpoint_frame(self : RoaringOperationLog, format : CodecFormat) -> Result[BitmapFrame, RoaringError]fn RoaringOperationLog::compact(self : RoaringOperationLog) -> Result[RoaringOperationLog, RoaringError]fn RoaringOperationLog::operation_at(self : RoaringOperationLog, index : Int) -> Result[BitmapOperation, JournalRangeError]fn RoaringOperationLog::pending_patch(self : RoaringOperationLog) -> Result[RoaringPatch, RoaringError]fn RoaringOperationLog::replay_prefix(self : RoaringOperationLog, count : Int) -> Result[RoaringBitmap, JournalRangeError]fn RoaringOperationLog::split_at(self : RoaringOperationLog, count : Int) -> Result[(RoaringOperationLog, RoaringOperationLog), JournalRangeError]fn RoaringSnapshot::advance(self : RoaringSnapshot, patch : RoaringPatch) -> Result[RoaringSnapshot, SnapshotError]fn RoaringSnapshot::apply_patch_envelope(self : RoaringSnapshot, envelope : SnapshotPatchEnvelope) -> Result[RoaringSnapshot, SnapshotError]fn RoaringSnapshot::at(generation : Int, bitmap : RoaringBitmap) -> Result[RoaringSnapshot, SnapshotError]fn RoaringSnapshot::envelope(self : RoaringSnapshot, format : CodecFormat) -> Result[SnapshotEnvelope, CodecError]fn RoaringSnapshot::patch_envelope(self : RoaringSnapshot, target : RoaringSnapshot, format : CodecFormat) -> Result[SnapshotPatchEnvelope, CodecError]pub(all) struct RoaringStats {
block_count : Int
array_blocks : Int
bitmap_blocks : Int
run_blocks : Int
cardinality : Int
}pub(all) enum SetRelation {
Equal
ProperSubset
ProperSuperset
Overlap
Disjoint
}pub(all) enum SnapshotError {
InvalidGeneration(Int)
GenerationOverflow(Int)
StaleGeneration(Int, Int)
Frame(FrameError)
}pub(all) struct SnapshotPatchEnvelope {
base_generation : Int
target_generation : Int
additions : BitmapFrame
removals : BitmapFrame
}pub(all) enum ValidationError {
UnsortedBlockKey(Int, Int)
EmptyBlock(Int)
InvalidLowValue(Int, Int)
UnsortedLowValue(Int, Int, Int)
BitmapCardinalityMismatch(Int, Int)
RunCardinalityMismatch(Int, Int)
InvalidRun(Int, Int, Int)
}fn decode_operation_log(checkpoint : RoaringBitmap, words : Array[Int]) -> Result[RoaringOperationLog, JournalCodecError]fn transcode(words : Array[Int], from : CodecFormat, to : CodecFormat) -> Result[Array[Int], CodecError]Install
Download zipPure MoonBit 32-bit Roaring Bitmap indexes