ReadableBitmap

sealed interface ReadableBitmap

A set of document ordinals that can be read, whether it is being built on the heap or read straight out of a mapped file.

An ordinal is the position of a document within one segment, counting from zero — which is what an index sidecar stores against a value, and the reason a bitmap here is per-segment rather than global. Ordinals run 0..BitmapFormat.MAX_ORDINAL.

Every operation on this interface is implemented once, here, over the two implementations' shared view of their blocks. That is not tidiness: Bitmap and BitmapView answer the same questions about the same values, and a rank that differed between them would mean a query returning different documents depending on whether the sidecar it read had been flushed yet. The interface is sealed so that stays true — an implementation from outside the module could not be given to the algebra.

Sizes and ranks are Int. See BitmapFormat.MAX_ORDINAL for the one ordinal that costs.

Inheritors

Properties

Link copied to clipboard
abstract 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 fun first(): Int

The smallest ordinal present.

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 fun xor(other: ReadableBitmap): Bitmap

The ordinals present in exactly one of the two.