public final class Schema extends java.lang.Object implements SchemaProvider
Modifier and Type | Class and Description |
---|---|
static class |
Schema.TransformationResult |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all KS/CF metadata and reset version.
|
java.util.Optional<Function> |
findFunction(FunctionName name,
java.util.List<AbstractType<?>> argTypes)
Find the function with the specified name
|
ColumnFamilyStore |
getColumnFamilyStoreInstance(TableId id) |
java.util.Collection<Function> |
getFunctions(FunctionName name)
Get all function overloads with the specified name
|
TableMetadataRef |
getIndexTableMetadataRef(java.lang.String keyspace,
java.lang.String index) |
Keyspace |
getKeyspaceInstance(java.lang.String keyspaceName)
Get keyspace instance by name
|
KeyspaceMetadata |
getKeyspaceMetadata(java.lang.String keyspaceName)
Get metadata about keyspace by its name
|
java.util.Set<java.lang.String> |
getKeyspaces() |
java.util.List<java.lang.String> |
getNonLocalStrategyKeyspaces() |
com.google.common.collect.ImmutableList<java.lang.String> |
getNonSystemKeyspaces() |
int |
getNumberOfTables() |
TableMetadata |
getTableMetadata(Descriptor descriptor) |
TableMetadata |
getTableMetadata(java.lang.String keyspace,
java.lang.String table)
Given a keyspace name and table name, get the table
meta data.
|
TableMetadata |
getTableMetadata(TableId id) |
TableMetadataRef |
getTableMetadataRef(Descriptor descriptor) |
TableMetadataRef |
getTableMetadataRef(java.lang.String keyspace,
java.lang.String table)
Given a keyspace name and table/view name, get the table metadata
reference.
|
TableMetadataRef |
getTableMetadataRef(TableId id)
Get Table metadata by its identifier
|
java.lang.Iterable<TableMetadata> |
getTablesAndViews(java.lang.String keyspaceName)
Get metadata about keyspace inner ColumnFamilies
|
java.util.List<java.lang.String> |
getUserKeyspaces() |
java.util.UUID |
getVersion() |
ViewMetadata |
getView(java.lang.String keyspaceName,
java.lang.String viewName) |
boolean |
isEmpty()
Checks whether the current schema is empty.
|
boolean |
isSameVersion(java.util.UUID schemaVersion)
Checks whether the given schema version is the same as the current local schema.
|
void |
load(KeyspaceMetadata ksm)
Update (or insert) new keyspace definition
|
void |
loadFromDisk()
load keyspace (keyspace) definitions, but do not initialize the keyspace instances.
|
void |
loadFromDisk(boolean updateVersion)
Load schema definitions from disk.
|
void |
registerListener(SchemaChangeListener listener) |
void |
reloadSchemaAndAnnounceVersion() |
Keyspace |
removeKeyspaceInstance(java.lang.String keyspaceName)
Remove keyspace from schema
|
static java.lang.String |
schemaVersionToString(java.util.UUID version)
Converts the given schema version to a string.
|
Keyspaces |
snapshot() |
void |
storeKeyspaceInstance(Keyspace keyspace)
Store given Keyspace instance to the schema
|
Schema.TransformationResult |
transform(SchemaTransformation transformation,
boolean locally,
long now) |
void |
unregisterListener(SchemaChangeListener listener) |
void |
updateVersion()
Read schema from system keyspace and calculate MD5 digest of every row, resulting digest
will be converted into UUID which would act as content-based version of the schema.
|
void |
updateVersionAndAnnounce() |
TableMetadata |
validateTable(java.lang.String keyspaceName,
java.lang.String tableName) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getExistingTableMetadata
public static final Schema instance
public void loadFromDisk()
public void loadFromDisk(boolean updateVersion)
updateVersion
- true if schema version needs to be updatedpublic void load(KeyspaceMetadata ksm)
ksm
- The metadata about keyspacepublic void registerListener(SchemaChangeListener listener)
public void unregisterListener(SchemaChangeListener listener)
public Keyspace getKeyspaceInstance(java.lang.String keyspaceName)
getKeyspaceInstance
in interface SchemaProvider
keyspaceName
- The name of the keyspacepublic ColumnFamilyStore getColumnFamilyStoreInstance(TableId id)
public void storeKeyspaceInstance(Keyspace keyspace)
storeKeyspaceInstance
in interface SchemaProvider
keyspace
- The Keyspace instance to storejava.lang.IllegalArgumentException
- if Keyspace is already storedpublic Keyspace removeKeyspaceInstance(java.lang.String keyspaceName)
keyspaceName
- The name of the keyspace to removepublic Keyspaces snapshot()
public int getNumberOfTables()
public ViewMetadata getView(java.lang.String keyspaceName, java.lang.String viewName)
public KeyspaceMetadata getKeyspaceMetadata(java.lang.String keyspaceName)
getKeyspaceMetadata
in interface SchemaProvider
keyspaceName
- The name of the keyspacepublic com.google.common.collect.ImmutableList<java.lang.String> getNonSystemKeyspaces()
public java.util.List<java.lang.String> getNonLocalStrategyKeyspaces()
public java.util.List<java.lang.String> getUserKeyspaces()
public java.lang.Iterable<TableMetadata> getTablesAndViews(java.lang.String keyspaceName)
keyspaceName
- The name of the keyspacepublic java.util.Set<java.lang.String> getKeyspaces()
public TableMetadataRef getTableMetadataRef(java.lang.String keyspace, java.lang.String table)
getTableMetadataRef
in interface SchemaProvider
public TableMetadataRef getIndexTableMetadataRef(java.lang.String keyspace, java.lang.String index)
public TableMetadataRef getTableMetadataRef(TableId id)
getTableMetadataRef
in interface SchemaProvider
id
- table or view identifierpublic TableMetadataRef getTableMetadataRef(Descriptor descriptor)
getTableMetadataRef
in interface SchemaProvider
public TableMetadata getTableMetadata(java.lang.String keyspace, java.lang.String table)
getTableMetadata
in interface SchemaProvider
keyspace
- The keyspace nametable
- The table namepublic TableMetadata getTableMetadata(TableId id)
getTableMetadata
in interface SchemaProvider
public TableMetadata validateTable(java.lang.String keyspaceName, java.lang.String tableName)
public TableMetadata getTableMetadata(Descriptor descriptor)
public java.util.Collection<Function> getFunctions(FunctionName name)
name
- fully qualified function nameFunction
otherwisepublic java.util.Optional<Function> findFunction(FunctionName name, java.util.List<AbstractType<?>> argTypes)
name
- fully qualified function nameargTypes
- function argument typesOptional
if the keyspace or the function name are not found;
a non-empty optional of Function
otherwisepublic java.util.UUID getVersion()
public boolean isSameVersion(java.util.UUID schemaVersion)
public boolean isEmpty()
public void updateVersion()
public void updateVersionAndAnnounce()
public void clear()
public void reloadSchemaAndAnnounceVersion()
public Schema.TransformationResult transform(SchemaTransformation transformation, boolean locally, long now)
public static java.lang.String schemaVersionToString(java.util.UUID version)
unknown
, if version
is null
or "(empty)"
, if version
refers to an {@link SchemaConstants#emptyVersion empty) schema.Copyright © 2009-2020 The Apache Software Foundation