Skip to main content

SortSession

Struct SortSession 

Source
pub struct SortSession<K, V> { /* private fields */ }
Expand description

An in-progress sort. Generic over the ordering key K and payload V.

Implementations§

Source§

impl<K, V> SortSession<K, V>
where K: Ord + Clone + Serialize + DeserializeOwned + Send + 'static, V: Serialize + DeserializeOwned + Send + 'static,

Source

pub fn new(plan: SortPlan, dir: PathBuf, dedup: bool) -> Self

Open a session for plan, spilling (if it spills at all) under the unique scratch directory dir. The directory is created lazily on the first spill, so a purely in-memory sort never touches disk.

Source

pub fn with_temp_dir(plan: SortPlan, temp_root: &Path, dedup: bool) -> Self

Open an ungoverned session under a freshly-minted unique directory beneath temp_root. For tests and callers that run without a governor; the engine stays bounded and async regardless.

Source

pub fn hold_resource(self, resource: Box<dyn Send>) -> Self

Attach an opaque resource (typically the admission lease) to be held alive for as long as this sort’s output stream — so the fd permits backing the sort are released only once its results are consumed.

Source

pub fn scratch_dir(&self) -> &Path

The unique scratch directory this sort spills into (created lazily on the first spill, removed when the output stream is dropped).

Source

pub async fn push_with_size( &mut self, key: K, value: V, estimated_bytes: usize, ) -> Result<(), SorterError>

Push one row, sized with a caller estimate. Spills the current run first when adding this row would overflow the plan’s run buffer.

§Errors

Returns SorterError if spilling the current run fails. A failed or cancelled spill invalidates the session; subsequent pushes and Self::finish fail instead of yielding incomplete results.

Source

pub async fn push(&mut self, key: K, value: V) -> Result<(), SorterError>

Push one row using a conservative fixed size estimate.

§Errors

Returns SorterError if spilling the current run fails.

Source

pub async fn finish( self, ) -> Result<Pin<Box<dyn Stream<Item = Result<V, SorterError>> + Send>>, SorterError>

Finish the sort, returning a stream of values in key order.

§Errors

Returns SorterError if a final spill or the merge setup fails.

Auto Trait Implementations§

§

impl<K, V> !RefUnwindSafe for SortSession<K, V>

§

impl<K, V> !Sync for SortSession<K, V>

§

impl<K, V> !UnwindSafe for SortSession<K, V>

§

impl<K, V> Freeze for SortSession<K, V>
where Vec<RunRow<K, V>>: Freeze,

§

impl<K, V> Send for SortSession<K, V>
where Vec<RunRow<K, V>>: Send,

§

impl<K, V> Unpin for SortSession<K, V>
where Vec<RunRow<K, V>>: Unpin,

§

impl<K, V> UnsafeUnpin for SortSession<K, V>
where Vec<RunRow<K, V>>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more