## org.apache.cassandra.db
Class DefsTable

    java.lang.Object
      org.apache.cassandra.db.DefsTable

    public class DefsTable

extends java.lang.Object

SCHEMA_{KEYSPACES, COLUMNFAMILIES, COLUMNS}_CF are used to store Keyspace/ColumnFamily attributes to make schema load/distribution easy, it replaces old mechanism when local migrations where serialized, stored in system.Migrations and used for schema distribution. SCHEMA_KEYSPACES_CF layout: <key (AsciiType)> ascii => json_serialized_value ... </key> Where <key> is a name of keyspace e.g. "ks". SCHEMA_COLUMNFAMILIES_CF layout: <key (AsciiType)> composite(ascii, ascii) => json_serialized_value </key> Where <key> is a name of keyspace e.g. "ks"., first component of the column name is name of the ColumnFamily, last component is the name of the ColumnFamily attribute. SCHEMA_COLUMNS_CF layout: <key (AsciiType)> composite(ascii, ascii, ascii) => json_serialized value </key> Where <key> is a name of keyspace e.g. "ks". Column names where made composite to support 3-level nesting which represents following structure: "ColumnFamily name":"column name":"column attribute" => "value" Example of schema (using CLI): schema_keyspaces ---------------- RowKey: ks => (column=durable_writes, value=true, timestamp=1327061028312185000) => (column=name, value="ks", timestamp=1327061028312185000) => (column=replication_factor, value=0, timestamp=1327061028312185000) => (column=strategy_class, value="org.apache.cassandra.locator.NetworkTopologyStrategy", timestamp=1327061028312185000) => (column=strategy_options, value={"datacenter1":"1"}, timestamp=1327061028312185000) schema_columnfamilies --------------------- RowKey: ks => (column=cf:bloom_filter_fp_chance, value=0.0, timestamp=1327061105833119000) => (column=cf:caching, value="NONE", timestamp=1327061105833119000) => (column=cf:column_type, value="Standard", timestamp=1327061105833119000) => (column=cf:comment, value="ColumnFamily", timestamp=1327061105833119000) => (column=cf:default_validation_class, value="org.apache.cassandra.db.marshal.BytesType", timestamp=1327061105833119000) => (column=cf:gc_grace_seconds, value=864000, timestamp=1327061105833119000) => (column=cf:id, value=1000, timestamp=1327061105833119000) => (column=cf:key_alias, value="S0VZ", timestamp=1327061105833119000) ... part of the output omitted. schema_columns -------------- RowKey: ks => (column=cf:c:index_name, value=null, timestamp=1327061105833119000) => (column=cf:c:index_options, value=null, timestamp=1327061105833119000) => (column=cf:c:index_type, value=null, timestamp=1327061105833119000) => (column=cf:c:name, value="aGVsbG8=", timestamp=1327061105833119000) => (column=cf:c:validation_class, value="org.apache.cassandra.db.marshal.AsciiType", timestamp=1327061105833119000)

Field Summary
`static java.nio.ByteBuffer` `DEFINITION_SCHEMA_COLUMN_NAME`
`static java.lang.String` `OLD_MIGRATIONS_CF`
`static java.lang.String` `OLD_SCHEMA_CF`

Constructor Summary
`DefsTable()`

Method Summary

`static

`<T extends org.apache.avro.specific.SpecificRecord> T`

`

`deserializeAvro(org.apache.avro.Schema writer, java.nio.ByteBuffer bytes, T ob)`
Deserialize a single object based on the given Schema.

`static void` `dumpToStorage(java.util.Collection<KSMetaData> keyspaces)`
`static void` `fixSchemaNanoTimestamps()`
`static java.util.Collection<KSMetaData>` `loadFromStorage(java.util.UUID version)` Loads a version of keyspace definitions from storage (using old SCHEMA_CF as a data source) Note: If definitions where found in SCHEMA_CF this method would load them into new schema handling table KEYSPACE_CF
`static java.util.Collection<KSMetaData>` `loadFromTable()` Load keyspace definitions for the system keyspace (system.SCHEMA_KEYSPACES_CF)
`static void` `mergeRemoteSchema(byte[] data, int version)` Merge remote schema in form of row mutations with local and mutate ks/cf metadata objects (which also involves fs operations on add/drop ks/cf)
`static void` `mergeSchema(java.util.Collection<RowMutation> mutations)`
`static java.nio.ByteBuffer` `searchComposite(java.lang.String name, boolean start)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFINITION_SCHEMA_COLUMN_NAME

    public static final java.nio.ByteBuffer DEFINITION_SCHEMA_COLUMN_NAME

### OLD_MIGRATIONS_CF

    public static final java.lang.String OLD_MIGRATIONS_CF

See Also:
  Constant Field Values

### OLD_SCHEMA_CF

    public static final java.lang.String OLD_SCHEMA_CF

See Also:
  Constant Field Values

Constructor Detail

### DefsTable

    public DefsTable()

Method Detail

### dumpToStorage

    public static void dumpToStorage(java.util.Collection<KSMetaData> keyspaces)
                              throws java.io.IOException

  Throws:
    `java.io.IOException`

### loadFromTable

    public static java.util.Collection<KSMetaData> loadFromTable()
                                                          throws java.io.IOException

  Load keyspace definitions for the system keyspace (system.SCHEMA_KEYSPACES_CF)

  Returns:
    Collection of found keyspace definitions
  Throws:
    `java.io.IOException` - if failed to read SCHEMA_KEYSPACES_CF

### fixSchemaNanoTimestamps

    public static void fixSchemaNanoTimestamps()
                                        throws java.io.IOException

  Throws:
    `java.io.IOException`

### searchComposite

    public static java.nio.ByteBuffer searchComposite(java.lang.String name,
                                                      boolean start)

### loadFromStorage

    public static java.util.Collection<KSMetaData> loadFromStorage(java.util.UUID version)
                                                            throws java.io.IOException

  Loads a version of keyspace definitions from storage (using old SCHEMA_CF as a data source) Note: If definitions where found in SCHEMA_CF this method would load them into new schema handling table KEYSPACE_CF

  Parameters:
    `version` - The version of the latest migration.
  Returns:
    Collection of found keyspace definitions
  Throws:
    `java.io.IOException` - if failed to read SCHEMA_CF or failed to deserialize Avro schema

### mergeRemoteSchema

    public static void mergeRemoteSchema(byte[] data,
                                         int version)
                                  throws ConfigurationException,
                                         java.io.IOException

  Merge remote schema in form of row mutations with local and mutate ks/cf metadata objects (which also involves fs operations on add/drop ks/cf)

  Parameters:
    `data` - The data of the message from remote node with schema information
    `version` - The version of the message
  Throws:
    `ConfigurationException` - If one of metadata attributes has invalid value
    `java.io.IOException` - If data was corrupted during transportation or failed to apply fs operations

### mergeSchema

    public static void mergeSchema(java.util.Collection<RowMutation> mutations)
                            throws ConfigurationException,
                                   java.io.IOException

  Throws:
    `ConfigurationException`
    `java.io.IOException`

### deserializeAvro

    public static <T extends org.apache.avro.specific.SpecificRecord> T deserializeAvro(org.apache.avro.Schema writer,
                                                                                        java.nio.ByteBuffer bytes,
                                                                                        T ob)
                                                                             throws java.io.IOException

  Deserialize a single object based on the given Schema.

  Parameters:
    `writer` - writer's schema
    `bytes` - Array to deserialize from
    `ob` - An empty object to deserialize into (must not be null).
  Returns:
    serialized Avro object
  Throws:
    `java.io.IOException` - if deserialization failed

Copyright © 2013 The Apache Software Foundation