roaring · API

roaring.container

A single Roaring container, keyed externally by a 16-bit high key and holding up to 65536 low-16-bit values in one of three representations.

  • array: a sorted List[UInt16], used while cardinality <= 4096.
    • bitset: a fixed 1024-word (65536-bit) bitset, used above that.
    • run: sorted (start, length) runs, used only after run_optimize() finds it strictly smaller than the array/bitset encoding.

All three representations round-trip through the portable per-container byte layout described in portable.mojo.

Structs

Container

struct Container

Implements Copyable, Movable

Fields
kind: UInt8
arr: List[UInt16]
bits: List[UInt64]
run_start: List[UInt16]
run_len: List[UInt16]

__init__

def __init__(out self)

cardinality

def cardinality(self) -> Int

contains

def contains(self, v: UInt16) -> Bool

min_value

def min_value(self) -> UInt16

max_value

def max_value(self) -> UInt16

to_sorted_list

def to_sorted_list(self) -> List[UInt16]

to_bitset_words

def to_bitset_words(self) -> List[UInt64]

add

def add(mut self, v: UInt16)

remove

def remove(mut self, v: UInt16)

run_optimize

def run_optimize(mut self)

from_bitset_words

def from_bitset_words(var words: List[UInt64]) -> Self

or_

def or_(a, b: Self) -> Self

and_

def and_(a, b: Self) -> Self

and_not

def and_not(a, b: Self) -> Self

xor

def xor(a, b: Self) -> Self

serialized_body_size

def serialized_body_size(self) -> Int

serialize_body

def serialize_body(self, mut buf: List[UInt8])

deserialize_body

def deserialize_body[origin: Origin[mut=origin.mut], //](kind: UInt8, cardinality: Int, data: Span[UInt8, origin], pos: Int) -> Self

Aliases

comptime CONTAINER_ARRAY = UInt8(0)
comptime CONTAINER_BITSET = UInt8(1)
comptime CONTAINER_RUN = UInt8(2)