Table of Contents

Public classSealed 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
RoaringBitmap

Constructors

Public constructor RoaringBitmap()

Initialises a new, empty RoaringBitmap.

Properties

Public propertyRead-only Cardinality

Gets the total number of set bits (document IDs) in this bitmap.

Public propertyRead-only IsEmpty

Gets a value indicating whether this bitmap contains no set bits.

Methods

Public method Add(int)

Adds the specified document ID to the bitmap. Has no effect if already present.

Public method AddRange(int, int)

Adds all document IDs in the range [start, end) to the bitmap.

Public methodStatic And(RoaringBitmap, RoaringBitmap)

Intersection: returns a new bitmap containing elements present in both a and b.

Public methodStatic AndNot(RoaringBitmap, RoaringBitmap)

Difference: returns elements in a but not in b.

Public method Contains(int)

Returns true if the specified document ID is set in this bitmap.

Public methodStatic Deserialise(BinaryReader)

Deserialises a RoaringBitmap from a System.IO.BinaryReader. See Serialise(BinaryWriter) for the binary format.

Public methodStatic Deserialise(string)

Deserialises a RoaringBitmap from the specified file path.

Public method GetEnumerator()

Returns an enumerator that iterates through the collection.

Public method OptimiseRuns()

Scans all containers and converts those with consecutive runs to RunContainers where this would use less memory.

Public methodStatic Or(RoaringBitmap, RoaringBitmap)

Union: returns a new bitmap containing elements present in either a or b.

Public method Remove(int)

Removes the specified document ID from the bitmap.

Public method Serialise(BinaryWriter)

Binary format: [int32:chunkCount][chunk0_key:ushort, chunk0_type:byte, chunk0_data...]... Container types: 0=Array, 1=Bitmap, 2=Run.

Public method Serialise(string)

Serialises this bitmap to the specified file path.

Public methodStatic Xor(RoaringBitmap, RoaringBitmap)

Symmetric difference: returns elements in either a or b but not both.

Explicit Interface Implementations

Public method IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.