pub struct RecordBuffer { /* private fields */ }Expand description
Contiguous buffer for inline record storage.
Records are stored sequentially in a single allocation:
[Header0][BAM0][Header1][BAM1][Header2][BAM2]...An index array of RecordRef is maintained for sorting.
Sorting only reorders the index; records stay in place.
Implementations§
Source§impl RecordBuffer
impl RecordBuffer
Sourcepub fn with_capacity(
estimated_records: usize,
estimated_bytes: usize,
nref: u32,
) -> Self
pub fn with_capacity( estimated_records: usize, estimated_bytes: usize, nref: u32, ) -> Self
Create a new buffer with estimated capacity.
§Arguments
estimated_records- Expected number of recordsestimated_bytes- Expected total bytes of BAM datanref- Number of reference sequences in header
Sourcepub fn push_coordinate(&mut self, record: &[u8])
pub fn push_coordinate(&mut self, record: &[u8])
Push a record for coordinate sorting.
Extracts the sort key inline from raw BAM bytes (zero-copy).
§Panics
Panics if the record length exceeds u32::MAX.
Sourcepub fn sort(&mut self)
pub fn sort(&mut self)
Sort the index by key (records stay in place).
Uses radix sort for O(n×k) performance instead of O(n log n) comparison sort. Falls back to insertion sort for small arrays.
Sourcepub fn par_sort(&mut self)
pub fn par_sort(&mut self)
Sort using parallel radix sort (for large arrays).
Divides data into chunks, sorts each with radix sort, then merges. For very large arrays this is faster than single-threaded radix sort.
Sourcepub fn get_record(&self, r: &RecordRef) -> &[u8] ⓘ
pub fn get_record(&self, r: &RecordRef) -> &[u8] ⓘ
Get record bytes by reference.
Sourcepub fn iter_sorted(&self) -> impl Iterator<Item = &[u8]>
pub fn iter_sorted(&self) -> impl Iterator<Item = &[u8]>
Iterate over sorted records.
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Memory usage in bytes (actual data stored, not capacity).
Auto Trait Implementations§
impl Freeze for RecordBuffer
impl RefUnwindSafe for RecordBuffer
impl Send for RecordBuffer
impl Sync for RecordBuffer
impl Unpin for RecordBuffer
impl UnsafeUnpin for RecordBuffer
impl UnwindSafe for RecordBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more