Package org.apache.cassandra.schema
Class KeyspaceMetadata
- java.lang.Object
-
- org.apache.cassandra.schema.KeyspaceMetadata
-
- All Implemented Interfaces:
SchemaElement
public final class KeyspaceMetadata extends java.lang.Object implements SchemaElement
An immutable representation of keyspace metadata (name, params, tables, types, and functions).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKeyspaceMetadata.KeyspaceDiffstatic classKeyspaceMetadata.Kind-
Nested classes/interfaces inherited from interface org.apache.cassandra.cql3.SchemaElement
SchemaElement.SchemaElementType
-
-
Field Summary
Fields Modifier and Type Field Description FunctionsfunctionsKeyspaceMetadata.Kindkindjava.lang.StringnameKeyspaceParamsparamsTablestablesTypestypesViewsviews-
Fields inherited from interface org.apache.cassandra.cql3.SchemaElement
NAME_COMPARATOR
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static KeyspaceMetadatacreate(java.lang.String name, KeyspaceParams params)static KeyspaceMetadatacreate(java.lang.String name, KeyspaceParams params, Tables tables)static KeyspaceMetadatacreate(java.lang.String name, KeyspaceParams params, Tables tables, Views views, Types types, Functions functions)AbstractReplicationStrategycreateReplicationStrategy()java.lang.StringelementKeyspace()Returns the CQL name of the keyspace to which this schema element belong.java.lang.StringelementName()Returns the CQL name of this schema element.SchemaElement.SchemaElementTypeelementType()Return the schema element typeKeyspaceMetadataempty()booleanequals(java.lang.Object o)java.lang.StringfindAvailableIndexName(java.lang.String baseName)java.util.Optional<TableMetadata>findIndexedTable(java.lang.String indexName)TableMetadatagetTableNullable(java.lang.String tableName)TableMetadatagetTableOrViewNullable(java.lang.String tableOrViewName)inthashCode()booleanhasIndex(java.lang.String indexName)booleanhasTable(java.lang.String tableName)booleanhasView(java.lang.String viewName)booleanisVirtual()java.lang.Iterable<TableMetadata>tablesAndViews()java.lang.StringtoCqlString(boolean withInternals, boolean ifNotExists)Returns a CQL representation of this elementjava.lang.StringtoString()voidvalidate()static <T extends RequestValidationException>
voidvalidateKeyspaceName(java.lang.String keyspaceName, java.util.function.Function<java.lang.String,T> exceptionBuilder)Validates the keyspace name for valid characters and correct length.static KeyspaceMetadatavirtual(java.lang.String name, Tables tables)KeyspaceMetadatawithSwapped(Functions functions)KeyspaceMetadatawithSwapped(KeyspaceParams params)KeyspaceMetadatawithSwapped(Tables regular)KeyspaceMetadatawithSwapped(Types types)KeyspaceMetadatawithSwapped(Views views)KeyspaceMetadatawithUpdatedUserType(UserType udt)Returns a new KeyspaceMetadata with all instances of old UDT replaced with the updated version.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.cql3.SchemaElement
elementKeyspaceQuotedIfNeeded, elementNameQuotedIfNeeded
-
-
-
-
Field Detail
-
name
public final java.lang.String name
-
kind
public final KeyspaceMetadata.Kind kind
-
params
public final KeyspaceParams params
-
tables
public final Tables tables
-
views
public final Views views
-
types
public final Types types
-
functions
public final Functions functions
-
-
Method Detail
-
validateKeyspaceName
public static <T extends RequestValidationException> void validateKeyspaceName(java.lang.String keyspaceName, java.util.function.Function<java.lang.String,T> exceptionBuilder)
Validates the keyspace name for valid characters and correct length. Throws an exception if it's invalid.- Parameters:
keyspaceName- The name of the keyspace to validateexceptionBuilder- The exception constructor to throw if validation fails
-
create
public static KeyspaceMetadata create(java.lang.String name, KeyspaceParams params)
-
create
public static KeyspaceMetadata create(java.lang.String name, KeyspaceParams params, Tables tables)
-
create
public static KeyspaceMetadata create(java.lang.String name, KeyspaceParams params, Tables tables, Views views, Types types, Functions functions)
-
virtual
public static KeyspaceMetadata virtual(java.lang.String name, Tables tables)
-
withSwapped
public KeyspaceMetadata withSwapped(KeyspaceParams params)
-
withSwapped
public KeyspaceMetadata withSwapped(Tables regular)
-
withSwapped
public KeyspaceMetadata withSwapped(Views views)
-
withSwapped
public KeyspaceMetadata withSwapped(Types types)
-
withSwapped
public KeyspaceMetadata withSwapped(Functions functions)
-
empty
public KeyspaceMetadata empty()
-
isVirtual
public boolean isVirtual()
-
withUpdatedUserType
public KeyspaceMetadata withUpdatedUserType(UserType udt)
Returns a new KeyspaceMetadata with all instances of old UDT replaced with the updated version. Replaces all instances in tables, views, types, and functions.
-
tablesAndViews
public java.lang.Iterable<TableMetadata> tablesAndViews()
-
getTableOrViewNullable
@Nullable public TableMetadata getTableOrViewNullable(java.lang.String tableOrViewName)
-
getTableNullable
@Nullable public TableMetadata getTableNullable(java.lang.String tableName)
-
hasTable
public boolean hasTable(java.lang.String tableName)
-
hasView
public boolean hasView(java.lang.String viewName)
-
hasIndex
public boolean hasIndex(java.lang.String indexName)
-
findAvailableIndexName
public java.lang.String findAvailableIndexName(java.lang.String baseName)
-
findIndexedTable
public java.util.Optional<TableMetadata> findIndexedTable(java.lang.String indexName)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
elementType
public SchemaElement.SchemaElementType elementType()
Description copied from interface:SchemaElementReturn the schema element type- Specified by:
elementTypein interfaceSchemaElement- Returns:
- the schema element type
-
elementKeyspace
public java.lang.String 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
public java.lang.String 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
public java.lang.String toCqlString(boolean withInternals, boolean ifNotExists)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
-
validate
public void validate()
-
createReplicationStrategy
public AbstractReplicationStrategy createReplicationStrategy()
-
-