class documentation

class EWAHBitmap:

Constructor: EWAHBitmap(data)

View In Hierarchy

EWAH (Enhanced Word-Aligned Hybrid) compressed bitmap.

EWAH uses run-length encoding for efficient bitmap storage. Each bitmap consists of: - Uncompressed bit count (4 bytes) - Compressed word count (4 bytes) - Compressed words (8 bytes each) - Current RLW position (4 bytes)

Each Run Length Word (RLW) 64-bit layout (LSB to MSB): - Bit 0: running_bit (1 bit) - value of repeated words (0 or 1) - Bits 1-32: running_len (32 bits) - count of repeated words - Bits 33-63: literal_words (31 bits) - count of literal words following this RLW

Method __and__ Bitwise AND operation.
Method __contains__ Check if a bit is set.
Method __init__ Initialize EWAH bitmap.
Method __len__ Return the number of set bits.
Method __or__ Bitwise OR operation.
Method __sub__ Bitwise subtraction (set difference).
Method __xor__ Bitwise XOR operation.
Method add Set a bit.
Method encode Encode bitmap to EWAH compressed format.
Instance Variable bit_count Undocumented
Instance Variable bits Undocumented
Method _decode Decode EWAH compressed bitmap data.
def __and__(self, other: EWAHBitmap) -> EWAHBitmap:

Bitwise AND operation.

Parameters
other:EWAHBitmapOther bitmap to AND with
Returns
EWAHBitmapNew bitmap with AND result
def __contains__(self, bit: int) -> bool:

Check if a bit is set.

Parameters
bit:intBit position to check
Returns
boolTrue if bit is set, False otherwise
def __init__(self, data: bytes | None = None):

Initialize EWAH bitmap.

Parameters
data:bytes | NoneOptional compressed bitmap data to decode
def __len__(self) -> int:

Return the number of set bits.

Returns
intCount of set bits
def __or__(self, other: EWAHBitmap) -> EWAHBitmap:

Bitwise OR operation.

Parameters
other:EWAHBitmapOther bitmap to OR with
Returns
EWAHBitmapNew bitmap with OR result
def __sub__(self, other: EWAHBitmap) -> EWAHBitmap:

Bitwise subtraction (set difference).

Returns bits that are in self but not in other. Equivalent to: self & ~other

Parameters
other:EWAHBitmapBitmap to subtract
Returns
EWAHBitmapNew bitmap with bits in self but not in other
def __xor__(self, other: EWAHBitmap) -> EWAHBitmap:

Bitwise XOR operation.

Parameters
other:EWAHBitmapOther bitmap to XOR with
Returns
EWAHBitmapNew bitmap with XOR result
def add(self, bit: int):

Set a bit.

Parameters
bit:intBit position to set
def encode(self) -> bytes:

Encode bitmap to EWAH compressed format.

Returns
bytesCompressed bitmap data including header, words, and RLW position
bit_count =

Undocumented

bits: set[int] =

Undocumented

def _decode(self, data: bytes):

Decode EWAH compressed bitmap data.

Parameters
data:bytesCompressed bitmap data (EWAH format with header + words + RLW position)