Package org.apache.cassandra.db
Class SchemaCQLHelper
java.lang.Object
org.apache.cassandra.db.SchemaCQLHelper
Helper methods to represent TableMetadata and related objects in CQL format
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetIndexesAsCQL(TableMetadata metadata, boolean ifNotExists) Build a CQL String representation of Indexes on columns in the given Column Familystatic StringgetTableMetadataAsCQL(TableMetadata metadata, KeyspaceMetadata keyspaceMetadata) Build a CQL String representation of Column Family Metadata.getUserTypesAsCQL(TableMetadata metadata, Types types, boolean ifNotExists) Build a CQL String representation of User Types used in the given table.reCreateStatementsForSchemaCql(TableMetadata metadata, KeyspaceMetadata keyspaceMetadata) Generates the DDL statement for aschema.cqlsnapshot file.static StringtoCqlType(AbstractType<?> type) Converts the type to a CQL type.
-
Constructor Details
-
SchemaCQLHelper
public SchemaCQLHelper()
-
-
Method Details
-
reCreateStatementsForSchemaCql
public static Stream<String> reCreateStatementsForSchemaCql(TableMetadata metadata, KeyspaceMetadata keyspaceMetadata) Generates the DDL statement for aschema.cqlsnapshot file. -
getTableMetadataAsCQL
public static String getTableMetadataAsCQL(TableMetadata metadata, KeyspaceMetadata keyspaceMetadata) Build a CQL String representation of Column Family Metadata. *Note*: this is _only_ visible for testing; you generally shouldn't re-create a single table in isolation as that will not contain everything needed for user types. -
getUserTypesAsCQL
public static Stream<String> getUserTypesAsCQL(TableMetadata metadata, Types types, boolean ifNotExists) Build a CQL String representation of User Types used in the given table. Type order is ensured as types are built incrementally: from the innermost (most nested) to the outermost.- Parameters:
metadata- the table for which to extract the user types CQL statements.types- the user types defined in the keyspace of the dumped table (which will thus contain any user type used bymetadata).ifNotExists- set to true if IF NOT EXISTS should be appended after CREATE TYPE string.- Returns:
- a list of
CREATE TYPEstatements corresponding to all the types used inmetadata.
-
getIndexesAsCQL
Build a CQL String representation of Indexes on columns in the given Column Family- Parameters:
metadata- the table for which to extract the index CQL statements.ifNotExists- set to true if IF NOT EXISTS should be appended after CREATE INDEX string.- Returns:
- a list of
CREATE INDEXstatements corresponding to tablemetadata.
-
toCqlType
Converts the type to a CQL type. This method special cases empty and UDTs so the string can be used in a create statement. Special cases- empty - replaces with 'org.apache.cassandra.db.marshal.EmptyType'. empty is the tostring of the type in CQL but not allowed to create as empty, but fully qualified name is allowed
- UserType - replaces with TupleType
-