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
impl StreamingQueueCompressor
Sourcepub fn with_splitters(
output_path: impl AsRef<Path>,
config: StreamingQueueConfig,
splitters: AHashSet<u64>,
) -> Result<Self>
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 archiveconfig- Compression configurationsplitters- Pre-computed splitter k-mers
Sourcepub fn with_full_splitter_data(
output_path: impl AsRef<Path>,
config: StreamingQueueConfig,
splitters: AHashSet<u64>,
singletons: Vec<u64>,
duplicates: AHashSet<u64>,
) -> Result<Self>
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 archiveconfig- Compression configurationsplitters- Pre-computed splitter k-merssingletons- Reference singleton k-mers (sorted Vec for binary search)duplicates- Reference duplicate k-mers
Sourcepub fn new(
output_path: impl AsRef<Path>,
config: StreamingQueueConfig,
) -> Result<Self>
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.
Sourcepub fn push(
&mut self,
sample_name: String,
contig_name: String,
data: Contig,
) -> Result<()>
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 samplecontig_name- Name of the contigdata- Contig sequence data (Vec)
§Example
compressor.push("sample1".to_string(), "chr1".to_string(), vec![b'A', b'T', b'G', b'C'])?;Sourcepub fn drain(&self) -> Result<()>
pub fn drain(&self) -> Result<()>
Finalize compression
This will:
- Close the queue (no more pushes allowed)
- Wait for all worker threads to finish processing
- Write metadata to the archive
- Close the archive file
§Example
// ... push sequences ...
compressor.finalize()?;Sourcepub fn sync_and_flush(&self, sample_name: &str) -> Result<()>
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().
pub fn finalize(self) -> Result<()>
Sourcepub fn queue_stats(&self) -> QueueStats
pub fn queue_stats(&self) -> QueueStats
Get current queue statistics
Auto Trait Implementations§
impl Freeze for StreamingQueueCompressor
impl !RefUnwindSafe for StreamingQueueCompressor
impl Send for StreamingQueueCompressor
impl Sync for StreamingQueueCompressor
impl Unpin for StreamingQueueCompressor
impl !UnwindSafe for StreamingQueueCompressor
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