pub struct ColumnarMemtable { /* private fields */ }Expand description
In-memory columnar buffer that accumulates INSERTs.
Each column is stored as a typed vector. The memtable flushes to a compressed segment when the row count reaches the threshold.
Implementations§
Source§impl ColumnarMemtable
impl ColumnarMemtable
Sourcepub fn new(schema: &ColumnarSchema) -> Self
pub fn new(schema: &ColumnarSchema) -> Self
Create a new empty memtable for the given schema.
Sourcepub fn with_threshold(schema: &ColumnarSchema, flush_threshold: usize) -> Self
pub fn with_threshold(schema: &ColumnarSchema, flush_threshold: usize) -> Self
Create with a custom flush threshold.
Sourcepub fn should_flush(&self) -> bool
pub fn should_flush(&self) -> bool
Whether the memtable has reached its flush threshold.
Sourcepub fn flush_threshold(&self) -> usize
pub fn flush_threshold(&self) -> usize
Row count at which Self::should_flush turns true.
Sourcepub fn schema(&self) -> &ColumnarSchema
pub fn schema(&self) -> &ColumnarSchema
Access the schema.
Sourcepub fn columns(&self) -> &[ColumnData]
pub fn columns(&self) -> &[ColumnData]
Access the raw column data (for the segment writer).
Sourcepub fn add_column(
&mut self,
name: String,
column_type: ColumnType,
nullable: bool,
)
pub fn add_column( &mut self, name: String, column_type: ColumnType, nullable: bool, )
Add a new column to the schema, backfilling existing rows with nulls/defaults.
Source§impl ColumnarMemtable
impl ColumnarMemtable
Sourcepub fn iter_rows(&self) -> MemtableRowIter<'_> ⓘ
pub fn iter_rows(&self) -> MemtableRowIter<'_> ⓘ
Iterate rows as Vec<Value>. For scan/read operations.
Every cell is typed by its column’s declared type, so a time cell comes back as the instant variant the schema declares.
Source§impl ColumnarMemtable
impl ColumnarMemtable
Sourcepub fn append_row(&mut self, values: &[Value]) -> Result<(), ColumnarError>
pub fn append_row(&mut self, values: &[Value]) -> Result<(), ColumnarError>
Append a row of values. Validates types and nullability.
The append is all-or-nothing. On an error, every column is cut back
to row_count, so the memtable holds exactly the rows it held before
the call. A rolled-back push to a DictEncoded column can leave one
dictionary entry that no row references. Every id stays valid.
Sourcepub fn try_dict_encode_columns(&mut self, max_cardinality: u32)
pub fn try_dict_encode_columns(&mut self, max_cardinality: u32)
Convert low-cardinality String columns to DictEncoded in-place.
Sourcepub fn truncate_to(&mut self, n: usize)
pub fn truncate_to(&mut self, n: usize)
Truncate the memtable to n rows, discarding all rows beyond that point.
Used by transaction rollback to restore the memtable to its pre-write state.
No-op if n >= self.row_count.
Sourcepub fn drain(&mut self) -> (ColumnarSchema, Vec<ColumnData>, usize)
pub fn drain(&mut self) -> (ColumnarSchema, Vec<ColumnData>, usize)
Drain the memtable: return all column data and reset to empty.
Sourcepub fn drain_optimized(&mut self) -> (ColumnarSchema, Vec<ColumnData>, usize)
pub fn drain_optimized(&mut self) -> (ColumnarSchema, Vec<ColumnData>, usize)
Drain with automatic dictionary encoding for low-cardinality String columns.
Sourcepub fn ingest_row_refs(
&mut self,
values: &[IngestValue<'_>],
) -> Result<(), ColumnarError>
pub fn ingest_row_refs( &mut self, values: &[IngestValue<'_>], ) -> Result<(), ColumnarError>
Zero-copy row ingest for timeseries and high-throughput paths.
Accepts borrowed values via IngestValue<'_>, avoiding string cloning
for tag columns that are already interned in the DictEncoded dictionary.
The ingest is all-or-nothing, as in Self::append_row.
Auto Trait Implementations§
impl Freeze for ColumnarMemtable
impl RefUnwindSafe for ColumnarMemtable
impl Send for ColumnarMemtable
impl Sync for ColumnarMemtable
impl Unpin for ColumnarMemtable
impl UnsafeUnpin for ColumnarMemtable
impl UnwindSafe for ColumnarMemtable
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.