Skip to main content

ParallelWriters

Struct ParallelWriters 

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

Parallel, pipelined writer pool.

The producer (parser thread) stages per-table bytes and ships ~256KB chunks over bounded channels to N writer threads, each owning a disjoint shard of tables (sharded by name hash). This overlaps parsing with writing (a pipeline / double-buffer) and keeps several writes in flight so a single synchronous thread doesn’t bottleneck a fast SSD (queue depth > 1). Batching into large chunks keeps per-statement channel overhead negligible.

Output is byte-identical to a single-threaded writer: each table’s file is written by exactly one thread, in input order. A table’s shard is assigned once (on first ship) and never changes, so growing the pool mid-run (grow_to) preserves per-table ordering by construction: already-seen tables keep their owner, only tables first seen after the growth hash across the new shard count.

Implementations§

Source§

impl ParallelWriters

Source

pub fn new( output_dir: PathBuf, num_writers: usize, capacity: usize, format: Compression, values: Arc<ProfileValues>, ) -> Result<Self>

Spawn num_writers writer threads targeting output_dir, compressing each per-table file with format. capacity is the per-shard channel depth (chunks in flight); values carries the active profile’s staging/buffer sizes and may be retuned mid-run by the controller.

Source

pub fn writer_count(&self) -> usize

Number of writer threads currently running.

Source

pub fn grow_to(&mut self, n: usize)

Grow the pool to n writer threads (never shrinks — a table’s owner thread must not change mid-run, see the type-level docs). Used by the adaptive controller’s deferred writer spawn: auto mode opens at W=1 and only pays for parallelism once the device has proven fast.

Source

pub fn stats(&self) -> WriterStats

Snapshot the pipeline’s instrumentation counters (monotonic since construction). Cheap enough to call at every epoch boundary.

Source

pub fn errored(&self) -> bool

True once any writer thread has hit an I/O error, so the producer can stop early; the actual error surfaces from finish.

Source

pub fn write(&mut self, table_name: &str, stmt: &[u8], suffix: &[u8])

Stage a statement for its table, appending suffix (e.g. b";") and a newline, shipping a chunk once the table’s buffer crosses the threshold.

Source

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

Flush all staged data, join the writer threads, and return the first I/O error encountered (if any).

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> Fake for T

Source§

fn fake<U>(&self) -> U
where Self: FakeBase<U>,

Source§

fn fake_with_rng<U, R>(&self, rng: &mut R) -> U
where R: RngExt + ?Sized, Self: FakeBase<U>,

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V