pub struct ColumnChunk {
pub update_info: Option<UpdateInfo>,
pub stats: ColumnChunkStats,
/* private fields */
}Expand description
An in-memory buffer that accumulates values before flushing to a Column.
Fields§
§update_info: Option<UpdateInfo>Optional MVCC update version chain for this chunk. Tracks versioned updates to support snapshot isolation.
stats: ColumnChunkStatsMin/max stats for zone map predicate pushdown.
Implementations§
Source§impl ColumnChunk
impl ColumnChunk
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new empty chunk with a custom capacity.
Sourcepub fn enable_update_info(&mut self)
pub fn enable_update_info(&mut self)
Enable MVCC update tracking for this chunk.
Sourcepub fn append(&mut self, value: Value)
pub fn append(&mut self, value: Value)
Append a single value into the buffer.
Does not automatically flush when full — the caller should check
is_full() and call flush_to_column() at the appropriate time.
Sourcepub fn set_value(
&mut self,
idx: usize,
value: Value,
) -> Result<(), StorageError>
pub fn set_value( &mut self, idx: usize, value: Value, ) -> Result<(), StorageError>
Set a value at a specific index (for in-place writes like INSERT UPDATE and DELETE nulling).
This is the non-versioned write path: it overwrites the cell without
creating an MVCC version node, so snapshot readers see the new value
immediately. Versioned writes must use Self::set_value_with_version
so snapshot reads resolve the version chain correctly (P52.21).
Returns an error if the index is out of bounds.
Sourcepub fn set_value_with_version(
&mut self,
idx: usize,
value: Value,
version: u64,
) -> Result<(), StorageError>
pub fn set_value_with_version( &mut self, idx: usize, value: Value, version: u64, ) -> Result<(), StorageError>
Set a value with MVCC version tracking.
Records the replaced value in the update version chain at version (a
transaction commit timestamp) and overwrites the base cell. Snapshot
readers with snapshot_ts < version keep seeing the replaced value;
readers at or after version see the new value (P52.21).
Returns an error if the index is out of bounds.
Sourcepub fn get_value_with_snapshot(
&self,
idx: usize,
snapshot_ts: Option<u64>,
_commit_history: &HashMap<u64, u64>,
) -> Option<&Value>
pub fn get_value_with_snapshot( &self, idx: usize, snapshot_ts: Option<u64>, _commit_history: &HashMap<u64, u64>, ) -> Option<&Value>
Get a value considering MVCC visibility at a given snapshot timestamp.
If snapshot_ts is None, returns the latest value.
When a snapshot timestamp is provided and UpdateInfo has a version
node for this row whose update is NOT yet visible at snapshot_ts
(i.e. version > snapshot_ts), the snapshot predates the update and
must see the replaced (old) value. Since this variant returns &Value
it cannot deserialize the chain’s owned bytes, so callers that need a
versioned read must use Self::get_value_owned_with_snapshot.
Sourcepub fn get_value_owned_with_snapshot(
&self,
idx: usize,
snapshot_ts: Option<u64>,
_commit_history: &HashMap<u64, u64>,
) -> Option<Value>
pub fn get_value_owned_with_snapshot( &self, idx: usize, snapshot_ts: Option<u64>, _commit_history: &HashMap<u64, u64>, ) -> Option<Value>
Get a value with MVCC snapshot isolation, returning an owned Value.
This variant properly handles version chain traversal by deserializing
replaced values from the UpdateInfo chain. Returns the value visible at
snapshot_ts, or None if the index is out of bounds.
Sourcepub fn num_values(&self) -> usize
pub fn num_values(&self) -> usize
Number of buffered values.
Sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Whether the chunk has reached its capacity and should be flushed.
Sourcepub fn scan(&self, start: usize, count: usize) -> Vec<Value>
pub fn scan(&self, start: usize, count: usize) -> Vec<Value>
Scan a range of buffered values (inclusive start, exclusive end).
Panics if the range is out of bounds.
Sourcepub fn flush_to_column(&mut self, column: &mut Column) -> Result<usize>
pub fn flush_to_column(&mut self, column: &mut Column) -> Result<usize>
Flush all buffered values into a Column via append_value, then
clear the buffer.
Returns the number of values flushed.
Sourcepub fn flush_copy_to_column(&self, column: &mut Column) -> Result<usize>
pub fn flush_copy_to_column(&self, column: &mut Column) -> Result<usize>
Flush all buffered values into a Column, but keep the data in the
buffer afterwards (for cases where the caller still needs it).
Sourcepub fn to_arrow_array(&self, phys_type: PhysicalTypeID) -> ArrayRef
pub fn to_arrow_array(&self, phys_type: PhysicalTypeID) -> ArrayRef
Convert buffered values directly into an Arrow array, skipping
intermediate Vec<Vec<Value>> materialization.
This is the key optimization for the scan path: instead of cloning
every Value into a Vec<Vec<Value>> and then building Arrow arrays
from that, we read directly from self.values into Arrow builders.
Trait Implementations§
Source§impl Clone for ColumnChunk
impl Clone for ColumnChunk
Source§fn clone(&self) -> ColumnChunk
fn clone(&self) -> ColumnChunk
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ColumnChunk
impl Debug for ColumnChunk
Source§impl Default for ColumnChunk
impl Default for ColumnChunk
Auto Trait Implementations§
impl !Freeze for ColumnChunk
impl RefUnwindSafe for ColumnChunk
impl Send for ColumnChunk
impl Sync for ColumnChunk
impl Unpin for ColumnChunk
impl UnsafeUnpin for ColumnChunk
impl UnwindSafe for ColumnChunk
Blanket Implementations§
impl<T> Allocation for T
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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