
RoaringBitmap
- Namespace
- Rowles.LeanLucene.Util
- Assembly
- Rowles.LeanLucene.dll
Compressed bitmap supporting efficient set operations on document IDs. Uses three container types that auto-convert based on cardinality:
- Array container (sorted ushort[], for ≤4096 values per 64K chunk)
- Bitmap container (1024-element ulong[], for >4096 values per 64K chunk)
- Run container (pairs of [start, length], for consecutive runs)
public sealed class RoaringBitmap : IEnumerable<int>, IEnumerable
Constructors
RoaringBitmap()
Initialises a new, empty RoaringBitmap.
Properties
Cardinality
Gets the total number of set bits (document IDs) in this bitmap.
IsEmpty
Gets a value indicating whether this bitmap contains no set bits.
Methods
Add(int)
Adds the specified document ID to the bitmap. Has no effect if already present.
AddRange(int, int)
Adds all document IDs in the range [
start,end) to the bitmap.
And(RoaringBitmap, RoaringBitmap)
Intersection: returns a new bitmap containing elements present in both a and b.
AndNot(RoaringBitmap, RoaringBitmap)
Difference: returns elements in a but not in b.
Contains(int)
Returns true if the specified document ID is set in this bitmap.
Deserialise(BinaryReader)
Deserialises a RoaringBitmap from a System.IO.BinaryReader. See Serialise(BinaryWriter) for the binary format.
Deserialise(string)
Deserialises a RoaringBitmap from the specified file path.
GetEnumerator()
Returns an enumerator that iterates through the collection.
OptimiseRuns()
Scans all containers and converts those with consecutive runs to RunContainers where this would use less memory.
Or(RoaringBitmap, RoaringBitmap)
Union: returns a new bitmap containing elements present in either a or b.
Remove(int)
Removes the specified document ID from the bitmap.
Serialise(BinaryWriter)
Binary format:
[int32:chunkCount][chunk0_key:ushort, chunk0_type:byte, chunk0_data...]...Container types: 0=Array, 1=Bitmap, 2=Run.
Serialise(string)
Serialises this bitmap to the specified file path.
Xor(RoaringBitmap, RoaringBitmap)
Symmetric difference: returns elements in either a or b but not both.
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.