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 class
KeyspaceMetadata.KeyspaceDiff
static class
KeyspaceMetadata.Kind
-
Nested classes/interfaces inherited from interface org.apache.cassandra.cql3.SchemaElement
SchemaElement.SchemaElementType
-
-
Field Summary
Fields Modifier and Type Field Description KeyspaceMetadata.Kind
kind
java.lang.String
name
KeyspaceParams
params
Tables
tables
Types
types
UserFunctions
userFunctions
Views
views
-
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 KeyspaceMetadata
create(java.lang.String name, KeyspaceParams params)
static KeyspaceMetadata
create(java.lang.String name, KeyspaceParams params, Tables tables)
static KeyspaceMetadata
create(java.lang.String name, KeyspaceParams params, Tables tables, Views views, Types types, UserFunctions functions)
AbstractReplicationStrategy
createReplicationStrategy()
java.lang.String
elementKeyspace()
Returns the CQL name of the keyspace to which this schema element belong.java.lang.String
elementName()
Returns the CQL name of this schema element.SchemaElement.SchemaElementType
elementType()
Return the schema element typeKeyspaceMetadata
empty()
boolean
equals(java.lang.Object o)
java.lang.String
findAvailableIndexName(java.lang.String baseName)
java.util.Optional<TableMetadata>
findIndexedTable(java.lang.String indexName)
TableMetadata
getTableNullable(java.lang.String tableName)
TableMetadata
getTableOrViewNullable(java.lang.String tableOrViewName)
int
hashCode()
boolean
hasIndex(java.lang.String indexName)
boolean
hasTable(java.lang.String tableName)
boolean
hasView(java.lang.String viewName)
boolean
isVirtual()
java.lang.Iterable<TableMetadata>
tablesAndViews()
java.util.stream.Stream<TableMetadata>
tablesUsingFunction(Function function)
java.lang.String
toCqlString(boolean withInternals, boolean ifNotExists)
Returns a CQL representation of this elementjava.lang.String
toString()
void
validate()
static KeyspaceMetadata
virtual(java.lang.String name, Tables tables)
KeyspaceMetadata
withSwapped(KeyspaceParams params)
KeyspaceMetadata
withSwapped(Tables regular)
KeyspaceMetadata
withSwapped(Types types)
KeyspaceMetadata
withSwapped(UserFunctions functions)
KeyspaceMetadata
withSwapped(Views views)
KeyspaceMetadata
withUpdatedUserType(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
-
userFunctions
public final UserFunctions userFunctions
-
-
Method Detail
-
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, UserFunctions 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(UserFunctions 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)
-
tablesUsingFunction
public java.util.stream.Stream<TableMetadata> tablesUsingFunction(Function function)
- Parameters:
function
- a user function- Returns:
- a stream of tables within this keyspace that have column masks using the specified user function
-
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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
elementType
public SchemaElement.SchemaElementType elementType()
Description copied from interface:SchemaElement
Return the schema element type- Specified by:
elementType
in interfaceSchemaElement
- Returns:
- the schema element type
-
elementKeyspace
public java.lang.String elementKeyspace()
Description copied from interface:SchemaElement
Returns the CQL name of the keyspace to which this schema element belong.- Specified by:
elementKeyspace
in interfaceSchemaElement
- Returns:
- the keyspace name.
-
elementName
public java.lang.String elementName()
Description copied from interface:SchemaElement
Returns the CQL name of this schema element.- Specified by:
elementName
in interfaceSchemaElement
- Returns:
- the name of this schema element.
-
toCqlString
public java.lang.String toCqlString(boolean withInternals, boolean ifNotExists)
Description copied from interface:SchemaElement
Returns a CQL representation of this element- Specified by:
toCqlString
in 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()
-
-