pub struct Table<P = MemPager>{ /* private fields */ }Expand description
Handle for data operations on a table.
Implementations§
Source§impl<P> Table<P>
impl<P> Table<P>
Sourcepub fn create_from_columns(
display_name: &str,
canonical_name: &str,
columns: &[PlanColumnSpec],
metadata: Arc<MetadataManager<P>>,
catalog: Arc<TableCatalog>,
store: Arc<ColumnStore<P>>,
) -> LlkvResult<CreateTableResult<P>>
pub fn create_from_columns( display_name: &str, canonical_name: &str, columns: &[PlanColumnSpec], metadata: Arc<MetadataManager<P>>, catalog: Arc<TableCatalog>, store: Arc<ColumnStore<P>>, ) -> LlkvResult<CreateTableResult<P>>
Create a new table from column specifications.
Coordinates metadata persistence, catalog registration, and storage initialization.
Sourcepub fn create_from_schema(
display_name: &str,
canonical_name: &str,
schema: &Schema,
metadata: Arc<MetadataManager<P>>,
catalog: Arc<TableCatalog>,
store: Arc<ColumnStore<P>>,
) -> LlkvResult<CreateTableResult<P>>
pub fn create_from_schema( display_name: &str, canonical_name: &str, schema: &Schema, metadata: Arc<MetadataManager<P>>, catalog: Arc<TableCatalog>, store: Arc<ColumnStore<P>>, ) -> LlkvResult<CreateTableResult<P>>
Create a new table from an Arrow schema (for CREATE TABLE AS SELECT).
Sourcepub fn register_sort_index(&self, field_id: FieldId) -> LlkvResult<()>
pub fn register_sort_index(&self, field_id: FieldId) -> LlkvResult<()>
Register a persisted sort index for the specified user column.
Sourcepub fn unregister_sort_index(&self, field_id: FieldId) -> LlkvResult<()>
pub fn unregister_sort_index(&self, field_id: FieldId) -> LlkvResult<()>
Remove a persisted sort index for the specified user column if it exists.
Sourcepub fn list_registered_indexes(
&self,
field_id: FieldId,
) -> LlkvResult<Vec<IndexKind>>
pub fn list_registered_indexes( &self, field_id: FieldId, ) -> LlkvResult<Vec<IndexKind>>
List the persisted index kinds registered for the given user column.
Sourcepub fn append(&self, batch: &RecordBatch) -> LlkvResult<()>
pub fn append(&self, batch: &RecordBatch) -> LlkvResult<()>
Append a RecordBatch to the table.
The batch must include:
- A
row_idcolumn (typeUInt64) with unique row identifiers field_idmetadata for each user column, mapping to this table’s field IDs
§MVCC Columns
If the batch includes created_by or deleted_by columns, they are automatically
assigned the correct LogicalFieldId for this table’s MVCC metadata.
§Field ID Mapping
Each column’s field_id metadata is converted to a LogicalFieldId by combining
it with this table’s ID. This ensures columns from different tables don’t collide
in the underlying storage.
§Errors
Returns an error if:
- The batch is missing the
row_idcolumn - Any user column is missing
field_idmetadata - Field IDs are invalid or malformed
- The underlying storage operation fails
Sourcepub fn scan_stream<'a, I, T, F>(
&self,
projections: I,
filter_expr: &Expr<'a, FieldId>,
options: ScanStreamOptions<P>,
on_batch: F,
) -> LlkvResult<()>
pub fn scan_stream<'a, I, T, F>( &self, projections: I, filter_expr: &Expr<'a, FieldId>, options: ScanStreamOptions<P>, on_batch: F, ) -> LlkvResult<()>
Stream one or more projected columns as a sequence of RecordBatches.
- Avoids
concatand large materializations. - Uses the same filter machinery as the old
scanto producerow_ids. - Splits
row_idsinto fixed-size windows and gathers rows per window to form a smallRecordBatchthat is sent toon_batch.
Sourcepub fn scan_stream_with_exprs<'a, F>(
&self,
projections: &[ScanProjection],
filter_expr: &Expr<'a, FieldId>,
options: ScanStreamOptions<P>,
on_batch: F,
) -> LlkvResult<()>where
F: FnMut(RecordBatch),
pub fn scan_stream_with_exprs<'a, F>(
&self,
projections: &[ScanProjection],
filter_expr: &Expr<'a, FieldId>,
options: ScanStreamOptions<P>,
on_batch: F,
) -> LlkvResult<()>where
F: FnMut(RecordBatch),
Stream projections using fully resolved expression inputs.
Callers that already parsed expressions into ScanProjection values can
use this entry point to skip the iterator conversion performed by
Self::scan_stream. The execution semantics and callbacks are identical.
pub fn filter_row_ids<'a>( &self, filter_expr: &Expr<'a, FieldId>, ) -> LlkvResult<Vec<RowId>>
pub fn catalog(&self) -> SysCatalog<'_, P>
pub fn get_table_meta(&self) -> Option<TableMeta>
pub fn get_cols_meta(&self, col_ids: &[FieldId]) -> Vec<Option<ColMeta>>
Sourcepub fn schema(&self) -> LlkvResult<Arc<Schema>>
pub fn schema(&self) -> LlkvResult<Arc<Schema>>
Build and return an Arrow Schema that describes this table.
The returned schema includes the row_id field first, followed by
user fields. Each user field has its field_id stored in the field
metadata (under the “field_id” key) and the name is taken from the
catalog when available or falls back to col_<id>.
Sourcepub fn schema_recordbatch(&self) -> LlkvResult<RecordBatch>
pub fn schema_recordbatch(&self) -> LlkvResult<RecordBatch>
Return the table schema formatted as an Arrow RecordBatch suitable
for pretty printing. The batch has three columns: name (Utf8),
field_id (UInt32) and data_type (Utf8).
Sourcepub fn stream_columns(
&self,
logical_fields: impl Into<Arc<[LogicalFieldId]>>,
row_ids: Vec<RowId>,
policy: GatherNullPolicy,
) -> LlkvResult<ColumnStream<'_, P>>
pub fn stream_columns( &self, logical_fields: impl Into<Arc<[LogicalFieldId]>>, row_ids: Vec<RowId>, policy: GatherNullPolicy, ) -> LlkvResult<ColumnStream<'_, P>>
Create a streaming view over the provided row IDs for the specified logical fields.
pub fn store(&self) -> &ColumnStore<P>
pub fn table_id(&self) -> TableId
Sourcepub fn total_rows_for_col(&self, col_id: FieldId) -> Result<u64>
pub fn total_rows_for_col(&self, col_id: FieldId) -> Result<u64>
Return the total number of rows for a given user column id in this table.
This delegates to the ColumnStore descriptor for the logical field that corresponds to (table_id, col_id) and returns the persisted total_row_count.
Sourcepub fn total_rows(&self) -> Result<u64>
pub fn total_rows(&self) -> Result<u64>
Return the total number of rows for this table.
Prefer reading the dedicated row-id shadow column if present; otherwise fall back to inspecting any persisted user column descriptor.
Auto Trait Implementations§
impl<P = MemPager> !Freeze for Table<P>
impl<P> RefUnwindSafe for Table<P>where
P: RefUnwindSafe,
impl<P> Send for Table<P>
impl<P> Sync for Table<P>
impl<P> Unpin for Table<P>
impl<P> UnwindSafe for Table<P>where
P: RefUnwindSafe,
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
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