Skip to content

restartPointSortedBlock(entries, options?): SortedBlock

Defined in: packages/sorted-block/src/restart-point-sorted-block.ts:19

Build an immutable restart-point block from entries already in strictly ascending compareBytes key order.

Each key is stored as the bytes it does not share with the previous key, except at every restartInterval-th entry, a restart point, where it is stored whole. Lookups binary-search the restart keys in place and decode at most restartInterval entries forward. Every input byte is copied into one Uint8Array, so mutating the caller’s arrays afterwards cannot change the block. Builds in O(total key and value bytes).

Iterable<SortedBlockEntry>

RestartPointSortedBlockOptions

SortedBlock

With INVALID_RESTART_INTERVAL when restartInterval is not a positive safe integer, INVALID_ENTRY when entries is not iterable or an entry is not a [Uint8Array, Uint8Array] pair, UNSORTED_KEY or DUPLICATE_KEY when keys do not strictly ascend, and MAX_CAPACITY_EXCEEDED when the entries pass 2^32 - 1 bytes or entries, or the runtime refuses the allocation.