Package org.apache.cassandra.schema
Class TableMetadata
java.lang.Object
org.apache.cassandra.schema.TableMetadata
- All Implemented Interfaces:
SchemaElement
- Direct Known Subclasses:
TableMetadata.CompactTableMetadata
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic classstatic enumstatic enumNested classes/interfaces inherited from interface org.apache.cassandra.cql3.SchemaElement
SchemaElement.SchemaElementType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.google.common.collect.ImmutableList<ColumnMetadata>final ClusteringComparatorfinal com.google.common.collect.ImmutableMap<ByteBuffer,DroppedColumn> final com.google.common.collect.ImmutableSet<TableMetadata.Flag>final TableIdfinal Indexesfinal Stringfinal TableMetadata.Kindfinal Stringfinal TableParamsfinal IPartitionerprotected final com.google.common.collect.ImmutableList<ColumnMetadata>final AbstractType<?>protected final RegularAndStaticColumnsfinal DataResourcefinal TriggersFields inherited from interface org.apache.cassandra.cql3.SchemaElement
NAME_COMPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns an iterator over all column definitions that respect the order of the CREATE statement.voidappendCqlTo(CqlBuilder builder, boolean includeDroppedColumns, boolean withInternals, boolean ifNotExists) static TableMetadata.Builderstatic TableMetadata.Buildercom.google.common.collect.ImmutableList<ColumnMetadata>com.google.common.collect.ImmutableCollection<ColumnMetadata>columns()booleanReturns the CQL name of the keyspace to which this schema element belong.Returns the CQL name of this schema element.Return the schema element typebooleanA table with strict liveness filters/ignores rows without PK liveness info, effectively tying the row liveness to its primary key liveness.booleanprotected voidgetColumn(ByteBuffer name) getColumn(ColumnIdentifier name) Returns the ColumnMetadata forname.getDroppedColumn(ByteBuffer name) getDroppedColumn(ByteBuffer name, boolean isStatic) Returns a "fake" ColumnMetadata corresponding to the dropped columnnameofnullif there is no such dropped column.Returns the column of the provided name if it exists, but throws a user-visible exception if that column doesn't exist.Returns the index name from the name of an index table including the dot prefixing the index name, seeindexTableName(org.apache.cassandra.schema.IndexMetadata).Returns the names of all the user types referenced by this table.Generates a directory name for the table by using table part of the (index) table name and table id.Returns the table part of the index table name or the entire table name if not an index table.inthashCode()booleanbooleanindexTableName(IndexMetadata info) Generate a table name for an index corresponding to the given column.booleanbooleanbooleanbooleanisIndex()booleanbooleanisView()booleanstatic TableMetadataThere is a couple of places in the code where we need a TableMetadata object and don't have one readily available and know that only the keyspace and name matter.partitionKeyAsCQLLiteral(ByteBuffer partitionKey) Returns a string representation of a partition in a CQL-friendly format.com.google.common.collect.ImmutableList<ColumnMetadata>primaryKeyAsCQLLiteral(ByteBuffer partitionKey, Clustering<?> clustering) Returns a string representation of a primary key in a CQL-friendly format.toCqlString(boolean withInternals, boolean ifNotExists) Returns a CQL representation of this elementtoCqlString(boolean includeDroppedColumns, boolean withInternals, boolean ifNotExists) toString()unbuild()updateIndexTableMetadata(TableParams baseTableParams) voidvalidate()voidvalidateCompatibility(TableMetadata previous) withSwapped(Set<TableMetadata.Flag> flags) withSwapped(Indexes indexes) withSwapped(TableParams params) withSwapped(Triggers triggers) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.cassandra.cql3.SchemaElement
elementKeyspaceQuotedIfNeeded, elementNameQuotedIfNeeded
-
Field Details
-
keyspace
-
name
-
id
-
partitioner
-
kind
-
params
-
flags
-
droppedColumns
-
partitionKeyColumns
-
clusteringColumns
-
regularAndStaticColumns
-
indexes
-
triggers
-
partitionKeyType
-
comparator
-
resource
-
-
Constructor Details
-
TableMetadata
-
-
Method Details
-
builder
-
builder
-
unbuild
-
isIndex
public boolean isIndex() -
withSwapped
-
withSwapped
-
withSwapped
-
withSwapped
-
isView
public boolean isView() -
isVirtual
public boolean isVirtual() -
indexName
-
isCounter
public boolean isCounter() -
isCompactTable
public boolean isCompactTable() -
isIncrementalBackupsEnabled
public boolean isIncrementalBackupsEnabled() -
isStaticCompactTable
public boolean isStaticCompactTable() -
columns
-
-
partitionKeyColumns
-
clusteringColumns
-
regularAndStaticColumns
-
regularColumns
-
staticColumns
-
allColumnsInSelectOrder
-
allColumnsInCreateOrder
Returns an iterator over all column definitions that respect the order of the CREATE statement. -
getColumn
Returns the ColumnMetadata forname. -
getExistingColumn
Returns the column of the provided name if it exists, but throws a user-visible exception if that column doesn't exist.This method is for finding columns from a name provided by the user, and as such it does _not_ returne hidden columns (throwing that the column is unknown instead).
- Parameters:
name- the name of an existing non-hidden column of this table.- Returns:
- the column metadata corresponding to
name. - Throws:
InvalidRequestException- if there is no non-hidden column namednamein this table.
-
getColumn
-
getDroppedColumn
-
getDroppedColumn
Returns a "fake" ColumnMetadata corresponding to the dropped columnnameofnullif there is no such dropped column.- Parameters:
name- - the column nameisStatic- - whether the column was a static column, if known
-
hasStaticColumns
public boolean hasStaticColumns() -
hasMaskedColumns
public boolean hasMaskedColumns()- Returns:
trueif the table has any masked column,falseotherwise.
-
dependsOn
- Parameters:
function- a user function- Returns:
trueif the table has any masked column depending on the specified user function,falseotherwise.
-
validate
public void validate() -
validateCompatibility
-
partitionKeyAsClusteringComparator
-
indexTableName
Generate a table name for an index corresponding to the given column. This is NOT the same as the index's name! This is only used in sstable filenames and is not exposed to users.- Parameters:
info- A definition of the column with index- Returns:
- name of the index table
-
getTableName
Returns the table part of the index table name or the entire table name if not an index table.- Returns:
- table name part
-
getTableDirectoryName
Generates a directory name for the table by using table part of the (index) table name and table id.- Returns:
- directory name
-
getIndexNameWithDot
Returns the index name from the name of an index table including the dot prefixing the index name, seeindexTableName(org.apache.cassandra.schema.IndexMetadata). If not an index table, returns null.- Returns:
- index name prefixed with dot prefix or null
-
minimal
There is a couple of places in the code where we need a TableMetadata object and don't have one readily available and know that only the keyspace and name matter. This creates such "fake" metadata. Use only if you know what you're doing. -
updateIndexTableMetadata
-
withUpdatedUserType
-
except
-
equals
-
hashCode
public int hashCode() -
toString
-
toDebugString
-
enforceStrictLiveness
public boolean enforceStrictLiveness()A table with strict liveness filters/ignores rows without PK liveness info, effectively tying the row liveness to its primary key liveness. Currently this is only used by views with normal base column as PK column so updates to other columns do not make the row live when the base column is not live. See CASSANDRA-11500. TODO: does not belong here, should be gone -
getReferencedUserTypes
Returns the names of all the user types referenced by this table.- Returns:
- the names of all the user types referenced by this table.
-
elementType
Description copied from interface:SchemaElementReturn the schema element type- Specified by:
elementTypein interfaceSchemaElement- Returns:
- the schema element type
-
elementKeyspace
Description copied from interface:SchemaElementReturns the CQL name of the keyspace to which this schema element belong.- Specified by:
elementKeyspacein interfaceSchemaElement- Returns:
- the keyspace name.
-
elementName
Description copied from interface:SchemaElementReturns the CQL name of this schema element.- Specified by:
elementNamein interfaceSchemaElement- Returns:
- the name of this schema element.
-
toCqlString
Description copied from interface:SchemaElementReturns a CQL representation of this element- Specified by:
toCqlStringin interfaceSchemaElement- Parameters:
withInternals- if the internals part of the CQL should be exposed.ifNotExists- if "IF NOT EXISTS" should be included.- Returns:
- a CQL representation of this element
-
toCqlString
public String toCqlString(boolean includeDroppedColumns, boolean withInternals, boolean ifNotExists) -
appendCqlTo
public void appendCqlTo(CqlBuilder builder, boolean includeDroppedColumns, boolean withInternals, boolean ifNotExists) -
partitionKeyAsCQLLiteral
Returns a string representation of a partition in a CQL-friendly format. For non-composite types it returns the result ofCQL3Type.toCQLLiteral(java.nio.ByteBuffer)applied to the partition key. For composite types it appliesCQL3Type.toCQLLiteral(java.nio.ByteBuffer)to each subkey and combines the results into a tuple.- Parameters:
partitionKey- a partition key- Returns:
- CQL-like string representation of a partition key
-
primaryKeyAsCQLLiteral
Returns a string representation of a primary key in a CQL-friendly format.- Parameters:
partitionKey- the partition key part of the primary keyclustering- the clustering key part of the primary key- Returns:
- a CQL-like string representation of the specified primary key
-