StreamingQueueCompressor

Struct StreamingQueueCompressor 

Source
pub struct StreamingQueueCompressor { /* private fields */ }
Expand description

Streaming compressor with queue-based API

§Example

use ragc_core::{StreamingQueueCompressor, StreamingQueueConfig};
use ahash::AHashSet;

let config = StreamingQueueConfig::default();
let splitters = AHashSet::new(); // Normally from reference
let mut compressor = StreamingQueueCompressor::with_splitters(
    "output.agc",
    config,
    splitters
)?;

// Push sequences (blocks when queue is full - automatic backpressure!)
for (sample, contig_name, data) in sequences {
    compressor.push(sample, contig_name, data)?;
}

// Finalize - waits for all compression to complete
compressor.finalize()?;

Implementations§

Source§

impl StreamingQueueCompressor

Source

pub fn with_splitters( output_path: impl AsRef<Path>, config: StreamingQueueConfig, splitters: AHashSet<u64>, ) -> Result<Self>

Create a new streaming compressor with pre-computed splitters

Use this when you already have splitters (e.g., from a reference genome)

§Arguments
  • output_path - Path to output AGC archive
  • config - Compression configuration
  • splitters - Pre-computed splitter k-mers
Source

pub fn with_full_splitter_data( output_path: impl AsRef<Path>, config: StreamingQueueConfig, splitters: AHashSet<u64>, singletons: Vec<u64>, duplicates: AHashSet<u64>, ) -> Result<Self>

Create a new streaming compressor with full splitter data for dynamic discovery

This is the preferred constructor when using adaptive mode. It accepts:

  • splitters: Pre-computed splitter k-mers from reference (for initial segmentation)
  • singletons: All singleton k-mers from reference (for exclusion in find_new_splitters)
  • duplicates: All duplicate k-mers from reference (for exclusion in find_new_splitters)
§Arguments
  • output_path - Path to output AGC archive
  • config - Compression configuration
  • splitters - Pre-computed splitter k-mers
  • singletons - Reference singleton k-mers (sorted Vec for binary search)
  • duplicates - Reference duplicate k-mers
Source

pub fn new( output_path: impl AsRef<Path>, config: StreamingQueueConfig, ) -> Result<Self>

Create compressor and determine splitters from first contig

Note: This requires at least one contig to be pushed before workers start. Consider using with_splitters() instead if you have a reference genome.

Source

pub fn push( &mut self, sample_name: String, contig_name: String, data: Contig, ) -> Result<()>

Push a contig to the compression queue

BLOCKS if the queue is full (automatic backpressure!)

§Arguments
  • sample_name - Name of the sample
  • contig_name - Name of the contig
  • data - Contig sequence data (Vec)
§Example
compressor.push("sample1".to_string(), "chr1".to_string(), vec![b'A', b'T', b'G', b'C'])?;
Source

pub fn drain(&self) -> Result<()>

Finalize compression

This will:

  1. Close the queue (no more pushes allowed)
  2. Wait for all worker threads to finish processing
  3. Write metadata to the archive
  4. Close the archive file
§Example
// ... push sequences ...
compressor.finalize()?;
Source

pub fn sync_and_flush(&self, sample_name: &str) -> Result<()>

Insert sync tokens to trigger incremental compression of buffered segments. Call this after pushing a batch of samples to process them incrementally instead of waiting for finalize().

Source

pub fn finalize(self) -> Result<()>

Source

pub fn queue_stats(&self) -> QueueStats

Get current queue statistics

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.