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
impl ExternalSort
pub fn new(dir: &Path, arena_bytes: usize) -> Result<Self>
Sourcepub fn new_durable(
dir: &Path,
arena_bytes: usize,
generation: u64,
) -> Result<Self>
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.
Sourcepub fn push_flagged(
&mut self,
key: Vec<u8>,
val: Vec<u8>,
marker: bool,
) -> Result<()>
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.
pub fn push(&mut self, key: Vec<u8>, val: Vec<u8>) -> Result<()>
Sourcepub fn flush_run(&mut self) -> Result<()>
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).
Sourcepub fn profile(&self) -> (u64, u64, usize)
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.
Sourcepub fn checkpoint(&mut self, watermark: u64) -> Result<Duration>
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.
Sourcepub fn reopen_durable(
dir: &Path,
arena_bytes: usize,
expected_generation: u64,
) -> Result<(Self, u64)>
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.
Sourcepub fn discard_durable(self) -> Result<()>
pub fn discard_durable(self) -> Result<()>
Successful publication owns the cleanup decision. Until this is called, dropping the sorter deliberately leaves its checkpoint intact.