Skip to main content

ColumnChunk

Struct ColumnChunk 

Source
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: ColumnChunkStats

Min/max stats for zone map predicate pushdown.

Implementations§

Source§

impl ColumnChunk

Source

pub fn new() -> Self

Create a new empty chunk with the default capacity (NODE_GROUP_SIZE).

Source

pub fn with_capacity(capacity: usize) -> Self

Create a new empty chunk with a custom capacity.

Source

pub fn enable_update_info(&mut self)

Enable MVCC update tracking for this chunk.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn num_values(&self) -> usize

Number of buffered values.

Source

pub fn is_full(&self) -> bool

Whether the chunk has reached its capacity and should be flushed.

Source

pub fn is_empty(&self) -> bool

Whether the chunk is empty.

Source

pub fn as_slice(&self) -> &[Value]

Borrow the buffered values as a slice.

Source

pub fn drain(&mut self) -> Vec<Value>

Drain all buffered values (leaves the chunk empty).

Source

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.

Source

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.

Source

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).

Source

pub fn clear(&mut self)

Clear the buffer without flushing.

Source

pub fn remaining(&self) -> usize

Remaining capacity before the chunk is full.

Source

pub fn get(&self, index: usize) -> Option<&Value>

Access a single buffered value by index.

Source

pub fn capacity(&self) -> usize

Capacity of this chunk.

Source

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

Source§

fn clone(&self) -> ColumnChunk

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ColumnChunk

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ColumnChunk

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<Vec<Value>> for ColumnChunk

Source§

fn from(values: Vec<Value>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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