BitmapView

A serialized bitmap, read where it lies.

Nothing is deserialized. open validates the structure in one pass and keeps only the mapping, the container count and the cardinality; a contains afterwards is a binary search of u16 reads against the file, and a rank is that plus one search inside one block. This is the reason the bitmap format is rabosh's own rather than a library's: an index sidecar is consulted far more often than it is written, and a bitmap that had to be parsed into heap objects first would pay for the whole file to answer a question about one value.

val view = BitmapView.open(segment, offset = handle.offset, length = handle.length, file = name)
view.contains(ordinal)
view.and(other) // materialises one 8 KB block at a time, never the whole bitmap

A view must not outlive the arena that mapped its segment. It holds no reference the runtime can see, so reading one after its arena has closed is a fault rather than a stale answer — the same rule Variant over a mapped segment follows, and the reason a Snapshot in the storage core is AutoCloseable.

What open checks and what it does not. It checks everything that decides where a byte is: the version, the container count, ascending keys, increasing prefix cardinalities, known container kinds, and that the blocks tile the slice exactly — offsets contiguous from the end of the directory to the last byte. What it does not do is walk the values. Confirming that a bitset's population count matches the cardinality the directory declares would mean reading 1024 words per block on a path whose whole point is to read one, and a bitmap always arrives inside a frame that has already been checksummed — phase 7's sidecar does for a bitmap what SegmentBytes.verifyBlock does for a segment's data block. verify is the deep pass, for tests and for anything that wants to audit a file it did not write.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The size of the slice this view was opened over.

Link copied to clipboard
open override val cardinality: Int

How many ordinals are present.

Link copied to clipboard
open val isEmpty: Boolean

Functions

Link copied to clipboard
open fun and(other: ReadableBitmap): Bitmap

The ordinals present in both.

Link copied to clipboard

How many ordinals the two share, without building the intersection.

Link copied to clipboard
open fun andNot(other: ReadableBitmap): Bitmap

The ordinals present here and not in other.

Link copied to clipboard
open fun contains(ordinal: Int): Boolean

Whether ordinal is present. Any Int is a fair question; a negative one is simply absent.

Link copied to clipboard
open fun cursor(): BitmapCursor

A walk over every present ordinal, ascending.

Link copied to clipboard
open fun encode(): ByteArray

This bitmap in the layout BitmapFormat describes, canonically encoded.

Link copied to clipboard
open fun encodedByteSize(): Int

The size encode will produce, without producing it.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open fun first(): Int

The smallest ordinal present.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Whether the two share an ordinal, without building the intersection.

Link copied to clipboard
open fun last(): Int

The largest ordinal present.

Link copied to clipboard
open fun or(other: ReadableBitmap): Bitmap

The ordinals present in either.

Link copied to clipboard
open fun rank(ordinal: Int): Int

How many present ordinals are less than or equal to ordinal.

Link copied to clipboard
open fun select(index: Int): Int

The index-th smallest ordinal present, counting from zero.

Link copied to clipboard
open fun toBitmap(): Bitmap

An independent, mutable bitmap holding the same ordinals.

Link copied to clipboard
open fun toIntArray(): IntArray

Every present ordinal, ascending. For tests and for small results; a cursor does not allocate.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun verify()

Walks every value, checking what open deliberately did not.

Link copied to clipboard
open fun xor(other: ReadableBitmap): Bitmap

The ordinals present in exactly one of the two.