public class Schema
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.UUID |
emptyVersion |
static Schema |
instance |
static int |
NAME_LENGTH
longest permissible KS or CF name.
|
static java.util.Set<java.lang.String> |
REPLICATED_SYSTEM_KEYSPACE_NAMES |
static java.util.Set<java.lang.String> |
SYSTEM_KEYSPACE_NAMES |
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
|
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() |
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() |
ViewDefinition |
getView(java.lang.String keyspaceName,
java.lang.String viewName) |
boolean |
hasCF(Pair<java.lang.String,java.lang.String> ksAndCFName) |
static boolean |
isSystemKeyspace(java.lang.String keyspaceName) |
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
|
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() |
void |
updateView(ViewDefinition view) |
public static final Schema instance
public static final java.util.Set<java.lang.String> SYSTEM_KEYSPACE_NAMES
public static final java.util.Set<java.lang.String> REPLICATED_SYSTEM_KEYSPACE_NAMES
public static final int NAME_LENGTH
public static final java.util.UUID emptyVersion
public Schema()
public static boolean isSystemKeyspace(java.lang.String keyspaceName)
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 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 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()
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)
Copyright © 2016 The Apache Software Foundation