BufferedSegments

Struct BufferedSegments 

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

Buffered segments storage

Matches C++ AGC’s CBufferedSegPart (agc_compressor.h:27-536)

Architecture:

  • vl_seg_part: Vector of thread-safe lists, indexed by group_id (KNOWN segments)
  • s_seg_part: BTreeSet of NEW segments (not yet assigned group_id)

Workflow:

  1. During compression: Workers call add_known() or add_new()
  2. At registration barrier: Main thread calls sort_known(), process_new(), distribute_segments()
  3. During storage: Workers call get_vec_id() and get_part() to read segments
  4. After storage: Main thread calls clear()

Implementations§

Source§

impl BufferedSegments

Source

pub fn new(no_raw_groups: usize) -> Self

Create new buffered segments storage

Matches C++ AGC’s CBufferedSegPart::CBufferedSegPart (agc_compressor.h:308-311)

§Arguments
  • no_raw_groups - Initial number of group IDs
Source

pub fn add_known( &self, group_id: u32, kmer1: u64, kmer2: u64, sample_name: String, contig_name: String, seg_data: Vec<u8>, is_rev_comp: bool, seg_part_no: u32, )

Add segment to KNOWN group

Matches C++ AGC’s CBufferedSegPart::add_known (agc_compressor.h:320-324)

Thread-safe: SegmentPartList::emplace() has internal mutex

Source

pub fn add_new( &self, kmer1: u64, kmer2: u64, sample_name: String, contig_name: String, seg_data: Vec<u8>, is_rev_comp: bool, seg_part_no: u32, )

Add NEW segment (not yet assigned group_id)

Matches C++ AGC’s CBufferedSegPart::add_new (agc_compressor.h:326-331)

Thread-safe: Locks s_seg_part mutex

Source

pub fn sort_known(&self, _num_threads: usize)

Sort all KNOWN segments in parallel

Matches C++ AGC’s CBufferedSegPart::sort_known (agc_compressor.h:333-377)

Note: In C++ AGC, this uses std::async for parallelism. For now, we’ll use a simple sequential implementation. Parallelism can be added later with rayon.

§Arguments
  • _num_threads - Number of threads (unused in sequential version)
Source

pub fn process_new( &mut self, map_segments: &Mutex<AHashMap<(u64, u64), u32>>, ) -> u32

Process NEW segments: assign group IDs and move to KNOWN

Matches C++ AGC’s CBufferedSegPart::process_new (agc_compressor.h:384-415)

Returns: Number of NEW groups created

Source

pub fn get_num_new(&self) -> usize

Get the number of NEW segments (not yet assigned group_id)

For testing - count segments in s_seg_part

Source

pub fn distribute_segments( &self, src_id: u32, dest_id_from: u32, dest_id_to: u32, )

Distribute segments from src_id to range [dest_from, dest_to)

Matches C++ AGC’s CBufferedSegPart::distribute_segments (agc_compressor.h:417-435)

Pattern: Round-robin distribution

Example: distribute_segments(0, 0, num_workers)

  • Distributes group 0 segments among workers 0..num_workers
Source

pub fn clear(&mut self, _num_threads: usize)

Clear all buffered segments

Matches C++ AGC’s CBufferedSegPart::clear (agc_compressor.h:461-507)

§Arguments
  • _num_threads - Number of threads (unused in sequential version)
Source

pub fn restart_read_vec(&self)

Restart reading from highest group_id

Matches C++ AGC’s CBufferedSegPart::restart_read_vec (agc_compressor.h:509-514)

Source

pub fn get_vec_id(&self) -> i32

Atomically get next group_id to process (decrements from size-1 to 0)

Matches C++ AGC’s CBufferedSegPart::get_vec_id (agc_compressor.h:516-520)

Returns: group_id to process, or negative if done

Source

pub fn is_empty_part(&self, group_id: i32) -> bool

Check if group is empty

Matches C++ AGC’s CBufferedSegPart::is_empty_part (agc_compressor.h:527-530)

Source

pub fn get_part( &self, group_id: i32, ) -> Option<(u64, u64, String, String, Vec<u8>, bool, u32)>

Pop next segment from group

Matches C++ AGC’s CBufferedSegPart::get_part (agc_compressor.h:532-535)

Returns: (kmer1, kmer2, sample_name, contig_name, seg_data, is_rev_comp, seg_part_no)

Source

pub fn get_no_parts(&self) -> usize

Get current number of groups

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.