Module seq_reader

Source
Expand description

A stateful reader for efficient, sequential access into an IntVec.

This module provides IntVecSeqReader, a reusable reader that is specifically optimized for access patterns that are sequential or have a high degree of locality (i.e., indices are strictly increasing or close to each other).

§Performance

IntVecSeqReader maintains an internal state of the current decoding position. When a new get request is made, it decides whether to:

  1. Decode Forward (Fast Path): If the requested index is at or after the current position and within the same sample block, the reader decodes forward from its last position. This avoids a costly seek operation and is the primary optimization.

  2. Seek and Decode (Fallback): If the requested index is far away or requires moving backward, the reader falls back to seeking to the nearest sample point and decoding from there, just like IntVecReader.

This makes it very efficient for iterating through indices that are sorted or clustered together.

Structs§

IntVecSeqReader
A stateful, sequential reader for an IntVec optimized for forward access.