org.apache.cassandra.config
Class Schema

java.lang.Object
  extended by org.apache.cassandra.config.Schema

public class Schema
extends java.lang.Object


Field Summary
static java.util.UUID INITIAL_VERSION
           
static Schema instance
           
 
Constructor Summary
Schema(java.util.UUID initialVersion)
          Initialize empty schema object with given version
 
Method Summary
 void addSystemTable(KSMetaData systemTable)
          Add a new system table
 void clearTableDefinition(KSMetaData ksm, java.util.UUID newVersion)
          Remove table definition from system and update schema version
 void fixCFMaxId()
          This gets called after initialization to make sure that id generation happens properly.
 Pair<java.lang.String,java.lang.String> getCF(java.lang.Integer cfId)
           
 CFMetaData getCFMetaData(Descriptor descriptor)
           
 CFMetaData getCFMetaData(java.lang.Integer cfId)
          Get ColumnFamily metadata by its identifier
 CFMetaData getCFMetaData(java.lang.String tableName, java.lang.String cfName)
          Given a table name & column family name, get the column family meta data.
 ColumnFamilyType getColumnFamilyType(java.lang.String ksName, java.lang.String cfName)
          Get type of the ColumnFamily but it's keyspace/name
 AbstractType getComparator(java.lang.String ksName, java.lang.String cfName)
          Get column comparator for ColumnFamily but it's keyspace/name
 java.lang.Integer getId(java.lang.String ksName, java.lang.String cfName)
          Lookup keyspace/ColumnFamily identifier
 KSMetaData getKSMetaData(java.lang.String table)
          Get metadata about table by its name
 java.util.List<java.lang.String> getNonSystemTables()
           
 AbstractType getSubComparator(java.lang.String ksName, java.lang.String cfName)
          Get subComparator of the ColumnFamily
 KSMetaData getTableDefinition(java.lang.String table)
          Get metadata about table by its name
 java.util.Collection<KSMetaData> getTableDefinitions()
           
 Table getTableInstance(java.lang.String tableName)
          Get table instance by name
 java.util.Map<java.lang.String,CFMetaData> getTableMetaData(java.lang.String tableName)
          Get metadata about table inner ColumnFamilies
 java.util.Set<java.lang.String> getTables()
           
 AbstractType getValueValidator(java.lang.String ksName, java.lang.String cfName, java.nio.ByteBuffer column)
          Get value validator for specific column
 java.util.UUID getVersion()
           
 void load(CFMetaData cfm)
          Load individual ColumnFamily Definition to the schema (to make ColumnFamily lookup faster)
 Schema load(java.util.Collection<KSMetaData> tableDefs, java.util.UUID version)
          Load up non-system tables and set schema version to the given value
 int nextCFId()
           
 void purge(CFMetaData cfm)
          Used for ColumnFamily data eviction out from the schema
 Table removeTableInstance(java.lang.String tableName)
          Remove table from schema
 void setTableDefinition(KSMetaData ksm, java.util.UUID newVersion)
          Update (or insert) new table definition and change schema version
 void setVersion(java.util.UUID newVersion)
          Set new version of the schema
 void storeTableInstance(Table table)
          Store given Table instance to the schema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_VERSION

public static final java.util.UUID INITIAL_VERSION

instance

public static final Schema instance
Constructor Detail

Schema

public Schema(java.util.UUID initialVersion)
Initialize empty schema object with given version

Parameters:
initialVersion - The initial version of the schema
Method Detail

load

public Schema load(java.util.Collection<KSMetaData> tableDefs,
                   java.util.UUID version)
Load up non-system tables and set schema version to the given value

Parameters:
tableDefs - The non-system table definitions
version - The version of the schema
Returns:
self to support chaining calls

getTableInstance

public Table getTableInstance(java.lang.String tableName)
Get table instance by name

Parameters:
tableName - The name of the table
Returns:
Table object or null if table was not found

storeTableInstance

public void storeTableInstance(Table table)
Store given Table instance to the schema

Parameters:
table - The Table instance to store
Throws:
java.lang.IllegalArgumentException - if Table is already stored

removeTableInstance

public Table removeTableInstance(java.lang.String tableName)
Remove table from schema

Parameters:
tableName - The name of the table to remove
Returns:
removed table instance or null if it wasn't found

clearTableDefinition

public void clearTableDefinition(KSMetaData ksm,
                                 java.util.UUID newVersion)
Remove table definition from system and update schema version

Parameters:
ksm - The table definition to remove
newVersion - New version of the system

getCFMetaData

public CFMetaData getCFMetaData(java.lang.String tableName,
                                java.lang.String cfName)
Given a table name & column family name, get the column family meta data. If the table name or column family name is not valid this function returns null.

Parameters:
tableName - The table name
cfName - The ColumnFamily name
Returns:
ColumnFamily Metadata object or null if it wasn't found

getCFMetaData

public CFMetaData getCFMetaData(java.lang.Integer cfId)
Get ColumnFamily metadata by its identifier

Parameters:
cfId - The ColumnFamily identifier
Returns:
metadata about ColumnFamily

getCFMetaData

public CFMetaData getCFMetaData(Descriptor descriptor)

getColumnFamilyType

public ColumnFamilyType getColumnFamilyType(java.lang.String ksName,
                                            java.lang.String cfName)
Get type of the ColumnFamily but it's keyspace/name

Parameters:
ksName - The keyspace name
cfName - The ColumnFamily name
Returns:
The type of the ColumnFamily

getComparator

public AbstractType getComparator(java.lang.String ksName,
                                  java.lang.String cfName)
Get column comparator for ColumnFamily but it's keyspace/name

Parameters:
ksName - The keyspace name
cfName - The ColumnFamily name
Returns:
The comparator of the ColumnFamily

getSubComparator

public AbstractType getSubComparator(java.lang.String ksName,
                                     java.lang.String cfName)
Get subComparator of the ColumnFamily

Parameters:
ksName - The keyspace name
cfName - The ColumnFamily name
Returns:
The subComparator of the ColumnFamily

getValueValidator

public AbstractType getValueValidator(java.lang.String ksName,
                                      java.lang.String cfName,
                                      java.nio.ByteBuffer column)
Get value validator for specific column

Parameters:
ksName - The keyspace name
cfName - The ColumnFamily name
column - The name of the column
Returns:
value validator specific to the column or default (per-cf) one

getKSMetaData

public KSMetaData getKSMetaData(java.lang.String table)
Get metadata about table by its name

Parameters:
table - The name of the table
Returns:
The table metadata or null if it wasn't found

getNonSystemTables

public java.util.List<java.lang.String> getNonSystemTables()
Returns:
collection of the non-system tables

getTableDefinition

public KSMetaData getTableDefinition(java.lang.String table)
Get metadata about table by its name

Parameters:
table - The name of the table
Returns:
The table metadata or null if it wasn't found

getTableMetaData

public java.util.Map<java.lang.String,CFMetaData> getTableMetaData(java.lang.String tableName)
Get metadata about table inner ColumnFamilies

Parameters:
tableName - The name of the table
Returns:
metadata about ColumnFamilies the belong to the given table

getTables

public java.util.Set<java.lang.String> getTables()
Returns:
collection of the all table names registered in the system (system and non-system)

getTableDefinitions

public java.util.Collection<KSMetaData> getTableDefinitions()
Returns:
collection of the metadata about all tables registered in the system (system and non-system)

setTableDefinition

public void setTableDefinition(KSMetaData ksm,
                               java.util.UUID newVersion)
Update (or insert) new table definition and change schema version

Parameters:
ksm - The metadata about table
newVersion - New schema version

addSystemTable

public void addSystemTable(KSMetaData systemTable)
Add a new system table

Parameters:
systemTable - The metadata describing new system table

getCF

public Pair<java.lang.String,java.lang.String> getCF(java.lang.Integer cfId)
Parameters:
cfId - The identifier of the ColumnFamily to lookup
Returns:
The (ksname,cfname) pair for the given id, or null if it has been dropped.

getId

public java.lang.Integer getId(java.lang.String ksName,
                               java.lang.String cfName)
Lookup keyspace/ColumnFamily identifier

Parameters:
ksName - The keyspace name
cfName - The ColumnFamily name
Returns:
The id for the given (ksname,cfname) pair, or null if it has been dropped.

load

public void load(CFMetaData cfm)
          throws ConfigurationException
Load individual ColumnFamily Definition to the schema (to make ColumnFamily lookup faster)

Parameters:
cfm - The ColumnFamily definition to load
Throws:
ConfigurationException - if ColumnFamily was already loaded

purge

public void purge(CFMetaData cfm)
Used for ColumnFamily data eviction out from the schema

Parameters:
cfm - The ColumnFamily Definition to evict

fixCFMaxId

public void fixCFMaxId()
This gets called after initialization to make sure that id generation happens properly.


nextCFId

public int nextCFId()
Returns:
identifier for the new ColumnFamily (called primarily by CFMetaData constructor)

getVersion

public java.util.UUID getVersion()
Returns:
current schema version

setVersion

public void setVersion(java.util.UUID newVersion)
Set new version of the schema

Parameters:
newVersion - New version of the schema


Copyright © 2011 The Apache Software Foundation