public class Schema
extends java.lang.Object
Constructor and Description |
---|
Schema()
Initialize empty schema object and load the hardcoded system tables
|
Modifier and Type | Method and Description |
---|---|
void |
addAggregate(UDAggregate uda) |
void |
addFunction(UDFunction udf) |
void |
addKeyspace(KeyspaceMetadata ksm) |
void |
addTable(CFMetaData cfm) |
void |
addType(UserType ut) |
void |
addView(ViewDefinition view) |
void |
clear()
Clear all KS/CF metadata and reset version.
|
void |
clearKeyspaceMetadata(KeyspaceMetadata ksm)
Remove keyspace definition from system
|
void |
dropAggregate(UDAggregate uda) |
void |
dropFunction(UDFunction udf) |
void |
dropKeyspace(java.lang.String ksName) |
void |
dropTable(java.lang.String ksName,
java.lang.String tableName) |
void |
dropType(UserType ut) |
void |
dropView(java.lang.String ksName,
java.lang.String viewName) |
java.util.Optional<Function> |
findFunction(FunctionName name,
java.util.List<AbstractType<?>> argTypes)
Find the function with the specified name
|
java.util.UUID |
getAltVersion()
The "alternative" schema version, compatible to 3.0, always excludes the
cdc column. |
Pair<java.lang.String,java.lang.String> |
getCF(java.util.UUID cfId) |
CFMetaData |
getCFMetaData(Descriptor descriptor) |
CFMetaData |
getCFMetaData(java.lang.String keyspaceName,
java.lang.String cfName)
Given a keyspace name and column family name, get the column family
meta data.
|
CFMetaData |
getCFMetaData(java.util.UUID cfId)
Get ColumnFamily metadata by its identifier
|
ColumnFamilyStore |
getColumnFamilyStoreIncludingIndexes(Pair<java.lang.String,java.lang.String> ksNameAndCFName)
Retrieve a CFS by name even if that CFS is an index
An index is identified by looking for '.' in the CF name and separating to find the base table
containing the index
|
ColumnFamilyStore |
getColumnFamilyStoreInstance(java.util.UUID cfId) |
java.util.Collection<Function> |
getFunctions(FunctionName name)
Get all function overloads with the specified name
|
java.util.UUID |
getId(java.lang.String ksName,
java.lang.String cfName)
Lookup keyspace/ColumnFamily identifier
|
Keyspace |
getKeyspaceInstance(java.lang.String keyspaceName)
Get keyspace instance by name
|
java.util.Set<java.lang.String> |
getKeyspaces() |
Keyspaces |
getKeyspaces(java.util.Set<java.lang.String> includedKeyspaceNames) |
KeyspaceMetadata |
getKSMetaData(java.lang.String keyspaceName)
Get metadata about keyspace by its name
|
java.util.List<java.lang.String> |
getNonLocalStrategyKeyspaces() |
java.util.List<java.lang.String> |
getNonSystemKeyspaces() |
int |
getNumberOfTables() |
java.util.UUID |
getRealVersion()
The 3.11 schema version, always includes the
cdc column. |
Keyspaces |
getReplicatedKeyspaces() |
java.lang.Iterable<CFMetaData> |
getTablesAndViews(java.lang.String keyspaceName)
Get metadata about keyspace inner ColumnFamilies
|
java.util.List<java.lang.String> |
getUserKeyspaces() |
java.util.UUID |
getVersion()
The schema version to announce.
|
ViewDefinition |
getView(java.lang.String keyspaceName,
java.lang.String viewName) |
boolean |
hasCF(Pair<java.lang.String,java.lang.String> ksAndCFName) |
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
version, either the 3.0 compatible or "real" one.
|
void |
load(CFMetaData cfm)
Load individual ColumnFamily Definition to the schema
(to make ColumnFamily lookup faster)
|
Schema |
load(java.lang.Iterable<KeyspaceMetadata> keyspaceDefs)
Load up non-system keyspaces
|
Schema |
load(KeyspaceMetadata keyspaceDef)
Load specific keyspace into Schema
|
void |
load(ViewDefinition view)
Load individual View Definition to the schema
(to make View lookup faster)
|
Schema |
loadFromDisk()
load keyspace (keyspace) definitions, but do not initialize the keyspace instances.
|
Schema |
loadFromDisk(boolean updateVersion)
Load schema definitions from disk.
|
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.
|
void |
setKeyspaceMetadata(KeyspaceMetadata ksm)
Update (or insert) new keyspace definition
|
void |
storeKeyspaceInstance(Keyspace keyspace)
Store given Keyspace instance to the schema
|
void |
unload(CFMetaData cfm)
Used for ColumnFamily data eviction out from the schema
|
void |
updateAggregate(UDAggregate uda) |
void |
updateFunction(UDFunction udf) |
void |
updateKeyspace(java.lang.String ksName,
KeyspaceParams newParams) |
void |
updateTable(CFMetaData table) |
void |
updateType(UserType ut) |
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()
Like updateVersion, but also announces via gossip
3.11 note: we announce the "current" schema version, which can be either the 3.0
compatible one, if at least one node is still running 3.0, or the "real" schema version.
|
void |
updateView(ViewDefinition view) |
public static final Schema instance
public Schema()
public Schema loadFromDisk()
public Schema loadFromDisk(boolean updateVersion)
updateVersion
- true if schema version needs to be updatedpublic Schema load(java.lang.Iterable<KeyspaceMetadata> keyspaceDefs)
keyspaceDefs
- The non-system keyspace definitionspublic Schema load(KeyspaceMetadata keyspaceDef)
keyspaceDef
- The keyspace to load uppublic Keyspace getKeyspaceInstance(java.lang.String keyspaceName)
keyspaceName
- The name of the keyspacepublic ColumnFamilyStore getColumnFamilyStoreIncludingIndexes(Pair<java.lang.String,java.lang.String> ksNameAndCFName)
ksNameAndCFName
- public ColumnFamilyStore getColumnFamilyStoreInstance(java.util.UUID cfId)
public void storeKeyspaceInstance(Keyspace keyspace)
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 void clearKeyspaceMetadata(KeyspaceMetadata ksm)
ksm
- The keyspace definition to removepublic CFMetaData getCFMetaData(java.lang.String keyspaceName, java.lang.String cfName)
keyspaceName
- The keyspace namecfName
- The ColumnFamily namepublic CFMetaData getCFMetaData(java.util.UUID cfId)
cfId
- The ColumnFamily identifierpublic CFMetaData getCFMetaData(Descriptor descriptor)
public int getNumberOfTables()
public ViewDefinition getView(java.lang.String keyspaceName, java.lang.String viewName)
public KeyspaceMetadata getKSMetaData(java.lang.String keyspaceName)
keyspaceName
- The name of the keyspacepublic java.util.List<java.lang.String> getNonSystemKeyspaces()
public java.util.List<java.lang.String> getNonLocalStrategyKeyspaces()
public java.util.List<java.lang.String> getUserKeyspaces()
public Keyspaces getReplicatedKeyspaces()
public java.lang.Iterable<CFMetaData> getTablesAndViews(java.lang.String keyspaceName)
keyspaceName
- The name of the keyspacepublic java.util.Set<java.lang.String> getKeyspaces()
public Keyspaces getKeyspaces(java.util.Set<java.lang.String> includedKeyspaceNames)
public void setKeyspaceMetadata(KeyspaceMetadata ksm)
ksm
- The metadata about keyspacepublic Pair<java.lang.String,java.lang.String> getCF(java.util.UUID cfId)
cfId
- The identifier of the ColumnFamily to lookuppublic boolean hasCF(Pair<java.lang.String,java.lang.String> ksAndCFName)
ksAndCFName
- The identifier of the ColumnFamily to lookuppublic java.util.UUID getId(java.lang.String ksName, java.lang.String cfName)
ksName
- The keyspace namecfName
- The ColumnFamily namepublic void load(CFMetaData cfm)
cfm
- The ColumnFamily definition to loadpublic void load(ViewDefinition view)
view
- The View definition to loadpublic void unload(CFMetaData cfm)
cfm
- The ColumnFamily Definition to evictpublic 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()
cdc
column,
if no node in the cluster is running at 3.0, or a 3.0 compatible
schema version, with the cdc
column excluded, if at least one node is
running 3.0.public java.util.UUID getRealVersion()
cdc
column.public java.util.UUID getAltVersion()
cdc
column.public boolean isSameVersion(java.util.UUID schemaVersion)
public boolean isEmpty()
public void updateVersion()
public void updateVersionAndAnnounce()
public void clear()
public void addKeyspace(KeyspaceMetadata ksm)
public void updateKeyspace(java.lang.String ksName, KeyspaceParams newParams)
public void dropKeyspace(java.lang.String ksName)
public void addTable(CFMetaData cfm)
public void updateTable(CFMetaData table)
public void dropTable(java.lang.String ksName, java.lang.String tableName)
public void addView(ViewDefinition view)
public void updateView(ViewDefinition view)
public void dropView(java.lang.String ksName, java.lang.String viewName)
public void addType(UserType ut)
public void updateType(UserType ut)
public void dropType(UserType ut)
public void addFunction(UDFunction udf)
public void updateFunction(UDFunction udf)
public void dropFunction(UDFunction udf)
public void addAggregate(UDAggregate uda)
public void updateAggregate(UDAggregate uda)
public void dropAggregate(UDAggregate uda)
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-2022 The Apache Software Foundation