Skip to main content

ExternalSort

Struct ExternalSort 

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

Removes its scratch directory if it is dropped without finish().

push can fail, and Store::bulk_load returns through ? when it does – before finish() has produced the SortedRuns whose own Drop would have cleaned up. Without this, every failed bulk load leaves a temp directory behind for the life of the machine.

Implementations§

Source§

impl ExternalSort

Source

pub fn new(dir: &Path, arena_bytes: usize) -> Result<Self>

Source

pub fn new_durable( dir: &Path, arena_bytes: usize, generation: u64, ) -> Result<Self>

Create a sorter whose runs survive process death. generation is the build generation, not the store page generation; reopen refuses a manifest from a different build so stale scratch cannot be attached to a later CREATE INDEX using the same directory.

Source

pub fn push_flagged( &mut self, key: Vec<u8>, val: Vec<u8>, marker: bool, ) -> Result<()>

Push with the overflow-marker flag carried explicitly through the run files. val is whatever the caller’s pipeline stores (recover tags it with a page number); the flag survives sort and merge untouched.

Source

pub fn push(&mut self, key: Vec<u8>, val: Vec<u8>) -> Result<()>

Source

pub fn flush_run(&mut self) -> Result<()>

Seal the current arena as one checksummed run without finishing the sorter. Chunked SQL builders call this at their scan watermark so peak live heap is bounded by the fixed chunk even when the configured arena is larger (the arena remains the hard upper ceiling).

Source

pub fn profile(&self) -> (u64, u64, usize)

Mechanism counters for load profiling. framed_bytes is the exact first-pass scratch payload (including each record header), excluding any extra merge-down pass. The pending arena counts as one future run.

Source

pub fn checkpoint(&mut self, watermark: u64) -> Result<Duration>

Flush one scan watermark and atomically publish the complete run list. The returned cost includes the run fsync, manifest fsync, rename and directory fsync: exactly the durability tax paid at this interval.

Source

pub fn reopen_durable( dir: &Path, arena_bytes: usize, expected_generation: u64, ) -> Result<(Self, u64)>

Reopen a durable sorter at its last completely published watermark. Torn .tmp manifests are ignored; every listed run is later checked by the ordinary framed CRC and exact record-count reader.

Source

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

Successful publication owns the cleanup decision. Until this is called, dropping the sorter deliberately leaves its checkpoint intact.

Source

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

Trait Implementations§

Source§

impl Drop for ExternalSort

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.