pub struct CompactionExecutor { /* private fields */ }Expand description
Compaction executor that performs merge-sort compaction.
Reads all input segments, merge-sorts by (series_key, timestamp),
deduplicates, optionally removes tombstoned data, and writes an
optimized output segment.
§Tombstone lookup complexity
Tombstones are passed as &TombstoneSet, which uses a HashMap keyed
by canonical series name for O(1) amortised per-row lookup in
execute. Each entry supports both full-series and
ranged (time-window) deletes. The overall cleanup pass is therefore
O(rows), not O(rows × tombstones).
Implementations§
Source§impl CompactionExecutor
impl CompactionExecutor
Sourcepub fn new(
compress: bool,
float_encoding: FloatEncoding,
row_group_size: usize,
compression_codec: CompressionCodec,
zstd_level: i32,
) -> Self
pub fn new( compress: bool, float_encoding: FloatEncoding, row_group_size: usize, compression_codec: CompressionCodec, zstd_level: i32, ) -> Self
Create an executor with custom settings.
Sourcepub fn with_field_encryption(
self,
writer: FieldEncryptionConfig,
reader: Arc<dyn FieldKeyProvider>,
) -> Self
pub fn with_field_encryption( self, writer: FieldEncryptionConfig, reader: Arc<dyn FieldKeyProvider>, ) -> Self
Give the executor this database’s per-column encryption.
Both halves, or neither. A compaction reads input segments and writes a new one, so a key provider without the writer config decrypts on the way in and writes the column back in plaintext — a compaction pass that silently undoes the encryption, hours after the write that asked for it, with no error anywhere. The writer config alone is the mirror image: the read fails closed, which is merely broken rather than dangerous.
Sourcepub fn with_task_timeout(self, timeout: Duration) -> Self
pub fn with_task_timeout(self, timeout: Duration) -> Self
Set the maximum wall-clock time for a single compaction task.
Sourcepub fn with_max_input_bytes(self, limit: u64) -> Self
pub fn with_max_input_bytes(self, limit: u64) -> Self
Set the maximum total bytes for input segments.
When the cumulative in-memory size of loaded RecordBatches
exceeds this threshold the compaction task is rejected early
with CompactionError::InputTooLarge. Pass 0 for unlimited.
Sourcepub fn execute(
&self,
task: &CompactionTask,
tombstones: &TombstoneSet,
) -> Result<SegmentMeta>
pub fn execute( &self, task: &CompactionTask, tombstones: &TombstoneSet, ) -> Result<SegmentMeta>
Execute a compaction task.
Reads all input segments, merges their data, deduplicates on
(series_key_hash, timestamp, canonical), removes tombstoned series,
and writes an optimized output segment.
§K-way Merge Architecture
Each segment’s row indices are sorted independently by
(series_hash, timestamp, canonical_id), then merged using a
K-element BinaryHeap (min-heap) in O(N log K) time — versus
the previous O(N log N) global sort. Deduplication is inline:
duplicate (hash, ts, canonical) keys are resolved by keeping
only the row from the newest segment (last-write-wins).
Output is assembled column-by-column via arrow::compute::interleave
in row-group-sized chunks, bounding peak memory to
O(chunk_size × columns) for the output stage.
§Errors
Returns an error if no eligible segments exist, reading/writing segments fails, or deduplication encounters an internal error.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CompactionExecutor
impl !UnwindSafe for CompactionExecutor
impl Freeze for CompactionExecutor
impl Send for CompactionExecutor
impl Sync for CompactionExecutor
impl Unpin for CompactionExecutor
impl UnsafeUnpin for CompactionExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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