Package org.apache.cassandra.db
Class SchemaCQLHelper
- java.lang.Object
-
- org.apache.cassandra.db.SchemaCQLHelper
-
public class SchemaCQLHelper extends java.lang.Object
Helper methods to represent TableMetadata and related objects in CQL format
-
-
Constructor Summary
Constructors Constructor Description SchemaCQLHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.stream.Stream<java.lang.String>
getIndexesAsCQL(TableMetadata metadata, boolean ifNotExists)
Build a CQL String representation of Indexes on columns in the given Column Familystatic java.lang.String
getTableMetadataAsCQL(TableMetadata metadata, KeyspaceMetadata keyspaceMetadata)
Build a CQL String representation of Column Family Metadata.static java.util.stream.Stream<java.lang.String>
getUserTypesAsCQL(TableMetadata metadata, Types types, boolean ifNotExists)
Build a CQL String representation of User Types used in the given table.static java.util.stream.Stream<java.lang.String>
reCreateStatementsForSchemaCql(TableMetadata metadata, KeyspaceMetadata keyspaceMetadata)
Generates the DDL statement for aschema.cql
snapshot file.static java.lang.String
toCqlType(AbstractType<?> type)
Converts the type to a CQL type.
-
-
-
Method Detail
-
reCreateStatementsForSchemaCql
public static java.util.stream.Stream<java.lang.String> reCreateStatementsForSchemaCql(TableMetadata metadata, KeyspaceMetadata keyspaceMetadata)
Generates the DDL statement for aschema.cql
snapshot file.
-
getTableMetadataAsCQL
public static java.lang.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 java.util.stream.Stream<java.lang.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 TYPE
statements corresponding to all the types used inmetadata
.
-
getIndexesAsCQL
public static java.util.stream.Stream<java.lang.String> getIndexesAsCQL(TableMetadata metadata, boolean ifNotExists)
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 INDEX
statements corresponding to tablemetadata
.
-
toCqlType
public static java.lang.String toCqlType(AbstractType<?> type)
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
-
-