Skip to main content

TempRun

Trait TempRun 

Source
pub trait TempRun: Send {
    // Required methods
    fn append(&mut self, bytes: &[u8]) -> Result<(), TempStoreError>;
    fn seal(&mut self) -> Result<(), TempStoreError>;
    fn read(&mut self, buf: &mut [u8]) -> Result<usize, TempStoreError>;
    fn bytes_written(&self) -> u64;
}
Expand description

One spill run: written once in sorted order, then read back once in that same order by a merge cursor.

The two phases are deliberate — a run is never appended to after it is sealed, and never seeks. That is all an external merge needs, and keeping the contract that narrow means a host implementation is a file handle and nothing else.

Dropping a run MUST remove its backing storage: a cancelled or panicking query has no other chance to clean up.

Required Methods§

Source

fn append(&mut self, bytes: &[u8]) -> Result<(), TempStoreError>

Append to the write phase.

Source

fn seal(&mut self) -> Result<(), TempStoreError>

End the write phase and rewind for reading.

Source

fn read(&mut self, buf: &mut [u8]) -> Result<usize, TempStoreError>

Fill buf from the current read position. Ok(0) is EOF.

Source

fn bytes_written(&self) -> u64

Bytes appended so far. Round 884 wired this to PG’s pg_stat_database.temp_bytes, read after seal so the figure is what the run really holds; the comment here used to say the column was hard-coded 0, and it was.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§