Skip to main content

RecordBuffer

Struct RecordBuffer 

Source
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

Source

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 records
  • estimated_bytes - Expected total bytes of BAM data
  • nref - Number of reference sequences in header
Source

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.

Source

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.

Source

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.

Source

pub fn get_record(&self, r: &RecordRef) -> &[u8]

Get record bytes by reference.

Source

pub fn iter_sorted(&self) -> impl Iterator<Item = &[u8]>

Iterate over sorted records.

Source

pub fn refs(&self) -> &[RecordRef]

Get the sorted record references.

Source

pub fn memory_usage(&self) -> usize

Memory usage in bytes (actual data stored, not capacity).

Source

pub fn len(&self) -> usize

Number of records.

Source

pub fn is_empty(&self) -> bool

Check if buffer is empty.

Source

pub fn clear(&mut self)

Clear the buffer for reuse.

Source

pub fn nref(&self) -> u32

Get the number of reference sequences.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.