pub struct ReferenceView<'a> { /* private fields */ }Expand description
A borrowed, zero-copy view over the persisted 2-bit forward reference
(Reference2bit). Decodes bases on demand from the mmap — no full-reference
allocation — so consumers (the aligner DP window in B4b, variants’ ref_base
in B4c) read the reference from the .idx alone. Uses global (concatenated)
coordinates; (contig, pos) mapping stays with ContigSet. The little-endian
host requirement is the same as FmIndexView (checked in new).
Implementations§
Source§impl<'a> ReferenceView<'a>
impl<'a> ReferenceView<'a>
Sourcepub fn base_at(&self, global: usize) -> u8
pub fn base_at(&self, global: usize) -> u8
The ASCII base at global position global. Mirrors CompressedDNA::base_at:
a set ambiguity bit decodes to N, otherwise the 2-bit code maps to A/C/G/T.
Sourcepub fn decode_window(&self, start: usize, end: usize, out: &mut Vec<u8>)
pub fn decode_window(&self, start: usize, end: usize, out: &mut Vec<u8>)
Decode [start, end.min(len)) into out (cleared first). end is clamped
to len, so an over-range request never panics; start <= end is the
caller’s contract. Bounded by the window size — never the whole genome.
Sourcepub fn decode_window_arc(&self, start: usize, end: usize) -> Arc<[u8]>
pub fn decode_window_arc(&self, start: usize, end: usize) -> Arc<[u8]>
Decode [start, end.min(len)) directly into an Arc<[u8]>, with no
separate owned Vec materialized first. Arc::from(Vec<u8>) REALLOCATES
— source and Arc buffers are both fully resident during the copy, so a
per-contig decode briefly holds two copies of the contig (the reference-
decode transient that broke the predicted-peak bound). Collecting a
TrustedLen range straight into the Arc writes into its allocation in
place, so peak resident reference memory is ONE copy. Byte-identical to
decode_window; bounded by the window size.