pub struct TableSchema {
pub keyspace: String,
pub table: String,
pub partition_keys: Vec<KeyColumn>,
pub clustering_keys: Vec<ClusteringColumn>,
pub columns: Vec<Column>,
pub comments: HashMap<String, String>,
pub dropped_columns: HashMap<String, i64>,
}Expand description
Table schema definition loaded from JSON
Fields§
§keyspace: StringKeyspace name
table: StringTable name
partition_keys: Vec<KeyColumn>Partition key columns (ordered)
clustering_keys: Vec<ClusteringColumn>Clustering key columns (ordered)
columns: Vec<Column>All columns in the table
comments: HashMap<String, String>Optional metadata
dropped_columns: HashMap<String, i64>Dropped-column drop times in microseconds (column name → drop_time_micros).
Populated from the schema-loading surface (JSON dropped_columns, or set
programmatically) since drop times are assigned at DDL-execution by the
cluster catalog (system_schema.dropped_columns) and are not recorded in
local SSTable files or the CQL DROP COLUMN text. Used during compaction
to discard cells of a dropped column whose timestamp ≤ the drop time
(Cassandra cb34ad47). See issues #904 (this plumbing) and #847 (the
merge-side filter).
Scope (#847): this map carries only the drop time, so the dropped column’s
pre-drop cells are decoded using its CURRENT type in Self::columns (the
decode contract enforced by Self::validate_dropped_columns). That is
byte-correct when the column’s type is unchanged — the common case. A
column dropped and later RE-ADDED with a DIFFERENT type is out of scope:
the historical cells would be decoded with the new type and could
misparse. Supporting per-version types requires carrying type metadata
here (or decoding from the SSTable serialization-header type) and is
follow-up work alongside the element-level representation in #899.
Filtering is also at row-timestamp granularity (the merge stream surfaces only the row write-time per cell); exact per-cell purging is tracked as follow-up #922.
Implementations§
Source§impl TableSchema
impl TableSchema
Sourcepub fn ordered_partition_keys(&self) -> Vec<&KeyColumn>
pub fn ordered_partition_keys(&self) -> Vec<&KeyColumn>
Get partition key columns ordered by position.
Returns the same order as a full sort_by_key(position) would, but skips
the sort when the keys are already in ascending position order (the
common case — see the module docs), so it is no longer re-sorted per call.
Sourcepub fn ordered_clustering_keys(&self) -> Vec<&ClusteringColumn>
pub fn ordered_clustering_keys(&self) -> Vec<&ClusteringColumn>
Get clustering key columns ordered by position.
Same order as before; the sort is skipped when the keys are already ordered.
Source§impl TableSchema
impl TableSchema
Sourcepub fn get_column_comparator(&self, column_name: &str) -> Result<ComparatorType>
pub fn get_column_comparator(&self, column_name: &str) -> Result<ComparatorType>
Get ComparatorType for a specific column
Sourcepub fn get_all_comparators(&self) -> Result<HashMap<String, ComparatorType>>
pub fn get_all_comparators(&self) -> Result<HashMap<String, ComparatorType>>
Get ComparatorTypes for all columns
Sourcepub fn get_partition_key_comparators(&self) -> Result<Vec<ComparatorType>>
pub fn get_partition_key_comparators(&self) -> Result<Vec<ComparatorType>>
Get ComparatorTypes for partition key columns in order
Sourcepub fn get_clustering_key_comparators(&self) -> Result<Vec<ComparatorType>>
pub fn get_clustering_key_comparators(&self) -> Result<Vec<ComparatorType>>
Get ComparatorTypes for clustering key columns in order
Source§impl TableSchema
impl TableSchema
Sourcepub fn from_sstable_header(header: &SSTableHeader) -> Result<Self>
pub fn from_sstable_header(header: &SSTableHeader) -> Result<Self>
Extract schema from SSTable header column metadata
This method constructs a TableSchema from the column information embedded in the SSTable header’s SerializationHeader.
Sourcepub fn for_compaction_output(&self, retained: &HashSet<String>) -> TableSchema
pub fn for_compaction_output(&self, retained: &HashSet<String>) -> TableSchema
The post-drop schema that compaction uses to write its output.
The decode schema retains dropped columns (carrying their type) so input
cells can be parsed and then purged by the merge filter (see
Self::validate_dropped_columns). The compaction output must keep its
serialization header / row column bitmap consistent with the cells that
actually survive the merge:
- A dropped column with no surviving cells (all cells were at or
before its drop time) is removed from
columnsso it does not appear in the output header. This lets a natural post-drop reader schema (which omits the column) read the output without the header-column / bitmap-index misalignment that retaining it would cause (roborev #847). - A dropped column with surviving cells (re-added: cells written after
drop_time) is RETAINED incolumns, because the merge still emits those cells and the writer needs a matching header column — otherwise the cell would be serialized with no header entry and corrupt the row.
retained is the set of dropped-column names that had surviving cells
(computed by compact_sstables from a merge pre-pass). The returned
schema carries an empty dropped_columns map: the purge has already
happened, so the output must not re-purge the surviving cells on a later
compaction.
Sourcepub fn validate_dropped_columns(&self) -> Result<()>
pub fn validate_dropped_columns(&self) -> Result<()>
Validate the dropped-column decode contract (#904/#847).
Dropped-column filtering during compaction discards a dropped column’s
cells after they are decoded. The schema-driven reader only decodes a
column whose name is present in Self::columns (it intersects the
on-disk serialization-header columns with the schema); a column absent
from columns is skipped without consuming its bytes, so its cells would
never reach the filter and surrounding columns could misalign.
Therefore every column named in dropped_columns MUST remain declared in
columns (carrying its type) so its cells decode and can be purged. This
mirrors Cassandra retaining a dropped column’s type in
system_schema.dropped_columns. Decoding a dropped column that is absent
from columns (purely from header type metadata) is follow-up work
related to #899 and intentionally out of scope here.
Sourcepub fn validate_udt_references(&self, registry: &UdtRegistry) -> Result<()>
pub fn validate_udt_references(&self, registry: &UdtRegistry) -> Result<()>
Validate that every UDT referenced by a column exists in the registry.
This is a schema-load-time pass that fails fast with a schema-category
error naming the missing UDT, instead of surfacing the problem later as a
confusing parse/deserialization error (issue #761). Nested references are
validated recursively: a UDT inside a collection, frozen<>, a tuple, or
another UDT is checked just like a top-level reference.
UDTs are looked up in the schema’s own keyspace; the system keyspace is
also consulted so built-in/system UDTs resolve regardless of the table’s
keyspace.
Sourcepub fn get_column(&self, name: &str) -> Option<&Column>
pub fn get_column(&self, name: &str) -> Option<&Column>
Get column by name
Sourcepub fn is_partition_key(&self, name: &str) -> bool
pub fn is_partition_key(&self, name: &str) -> bool
Check if column is a partition key
Sourcepub fn is_clustering_key(&self, name: &str) -> bool
pub fn is_clustering_key(&self, name: &str) -> bool
Check if column is a clustering key
Trait Implementations§
Source§impl Clone for TableSchema
impl Clone for TableSchema
Source§fn clone(&self) -> TableSchema
fn clone(&self) -> TableSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more