Schema (apache-cassandra API)
Date: 2014-10-21

org.apache.cassandra.config

## Class Schema

- java.lang.Object
- - org.apache.cassandra.config.Schema

-     public class Schema
      extends java.lang.Object

- - ### Field Summary

    Fields
    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 com.google.common.collect.ImmutableSet<java.lang.String>` | `systemKeyspaceNames`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Schema()` Initialize empty schema object

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clear all KS/CF metadata and reset version.
    `void` | `clearKeyspaceDefinition(KSMetaData ksm)` Remove keyspace definition from system
    `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 & column family name, get the column family meta data.
    `CFMetaData` | `getCFMetaData(java.util.UUID cfId)` Get ColumnFamily metadata by its identifier
    `ColumnFamilyStore` | `getColumnFamilyStoreInstance(java.util.UUID cfId)`
    `ColumnFamilyType` | `getColumnFamilyType(java.lang.String ksName, java.lang.String cfName)` Get type of the ColumnFamily but it's keyspace/name
    `java.util.UUID` | `getId(java.lang.String ksName, java.lang.String cfName)` Lookup keyspace/ColumnFamily identifier
    `java.util.Collection<KSMetaData>` | `getKeyspaceDefinitions()`
    `Keyspace` | `getKeyspaceInstance(java.lang.String keyspaceName)` Get keyspace instance by name
    `java.util.Map<java.lang.String,CFMetaData>` | `getKeyspaceMetaData(java.lang.String keyspaceName)` Get metadata about keyspace inner ColumnFamilies
    `java.util.Set<java.lang.String>` | `getKeyspaces()`
    `KSMetaData` | `getKSMetaData(java.lang.String keyspaceName)` Get metadata about keyspace by its name
    `java.util.List<java.lang.String>` | `getNonSystemKeyspaces()`
    `java.util.UUID` | `getVersion()`
    `boolean` | `hasCF(java.util.UUID cfId)`
    `static boolean` | `ignoredSchemaRow(Row row)`
    `static boolean` | `invalidSchemaRow(Row row)`
    `void` | `load(CFMetaData cfm)` Load individual ColumnFamily Definition to the schema (to make ColumnFamily lookup faster)
    `Schema` | `load(java.util.Collection<KSMetaData> keyspaceDefs)` Load up non-system keyspaces
    `Schema` | `load(KSMetaData keyspaceDef)` Load specific keyspace into Schema
    `void` | `purge(CFMetaData cfm)` Used for ColumnFamily data eviction out from the schema
    `Keyspace` | `removeKeyspaceInstance(java.lang.String keyspaceName)` Remove keyspace from schema
    `void` | `setKeyspaceDefinition(KSMetaData ksm)` Update (or insert) new keyspace definition
    `void` | `storeKeyspaceInstance(Keyspace keyspace)` Store given Keyspace instance to the schema
    `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()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### instance

          public static final Schema instance

    - #### NAME_LENGTH

          public static final int NAME_LENGTH

      longest permissible KS or CF name. Our main concern is that filename not be more than 255 characters; the filename will contain both the KS and CF names. Since non-schema-name components only take up ~64 characters, we could allow longer names than this, but on Windows, the entire path should be not greater than 255 characters, so a lower limit here helps avoid problems. See CASSANDRA-4110.
      See Also:
        Constant Field Values

    - #### emptyVersion

          public static final java.util.UUID emptyVersion

    - #### systemKeyspaceNames

          public static final com.google.common.collect.ImmutableSet<java.lang.String> systemKeyspaceNames

  - ### Constructor Detail

    - #### Schema

          public Schema()

      Initialize empty schema object

  - ### Method Detail

    - #### load

          public Schema load(java.util.Collection<KSMetaData> keyspaceDefs)

      Load up non-system keyspaces
      Parameters:
        `keyspaceDefs` - The non-system keyspace definitions
      Returns:
        self to support chaining calls

    - #### load

          public Schema load(KSMetaData keyspaceDef)

      Load specific keyspace into Schema
      Parameters:
        `keyspaceDef` - The keyspace to load up
      Returns:
        self to support chaining calls

    - #### getKeyspaceInstance

          public Keyspace getKeyspaceInstance(java.lang.String keyspaceName)

      Get keyspace instance by name
      Parameters:
        `keyspaceName` - The name of the keyspace
      Returns:
        Keyspace object or null if keyspace was not found

    - #### getColumnFamilyStoreInstance

          public ColumnFamilyStore getColumnFamilyStoreInstance(java.util.UUID cfId)

    - #### storeKeyspaceInstance

          public void storeKeyspaceInstance(Keyspace keyspace)

      Store given Keyspace instance to the schema
      Parameters:
        `keyspace` - The Keyspace instance to store
      Throws:
        `java.lang.IllegalArgumentException` - if Keyspace is already stored

    - #### removeKeyspaceInstance

          public Keyspace removeKeyspaceInstance(java.lang.String keyspaceName)

      Remove keyspace from schema
      Parameters:
        `keyspaceName` - The name of the keyspace to remove
      Returns:
        removed keyspace instance or null if it wasn't found

    - #### clearKeyspaceDefinition

          public void clearKeyspaceDefinition(KSMetaData ksm)

      Remove keyspace definition from system
      Parameters:
        `ksm` - The keyspace definition to remove

    - #### getCFMetaData

          public CFMetaData getCFMetaData(java.lang.String keyspaceName,
                                 java.lang.String cfName)

      Given a keyspace name & column family name, get the column family meta data. If the keyspace name or column family name is not valid this function returns null.
      Parameters:
        `keyspaceName` - The keyspace name
        `cfName` - The ColumnFamily name
      Returns:
        ColumnFamily Metadata object or null if it wasn't found

    - #### getCFMetaData

          public CFMetaData getCFMetaData(java.util.UUID 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

    - #### getKSMetaData

          public KSMetaData getKSMetaData(java.lang.String keyspaceName)

      Get metadata about keyspace by its name
      Parameters:
        `keyspaceName` - The name of the keyspace
      Returns:
        The keyspace metadata or null if it wasn't found

    - #### getNonSystemKeyspaces

          public java.util.List<java.lang.String> getNonSystemKeyspaces()

      Returns:
        collection of the non-system keyspaces

    - #### getKeyspaceMetaData

          public java.util.Map<java.lang.String,CFMetaData> getKeyspaceMetaData(java.lang.String keyspaceName)

      Get metadata about keyspace inner ColumnFamilies
      Parameters:
        `keyspaceName` - The name of the keyspace
      Returns:
        metadata about ColumnFamilies the belong to the given keyspace

    - #### getKeyspaces

          public java.util.Set<java.lang.String> getKeyspaces()

      Returns:
        collection of the all keyspace names registered in the system (system and non-system)

    - #### getKeyspaceDefinitions

          public java.util.Collection<KSMetaData> getKeyspaceDefinitions()

      Returns:
        collection of the metadata about all keyspaces registered in the system (system and non-system)

    - #### setKeyspaceDefinition

          public void setKeyspaceDefinition(KSMetaData ksm)

      Update (or insert) new keyspace definition
      Parameters:
        `ksm` - The metadata about keyspace

    - #### getCF

          public Pair<java.lang.String,java.lang.String> getCF(java.util.UUID 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.

    - #### hasCF

          public boolean hasCF(java.util.UUID cfId)

      Parameters:
        `cfId` - The identifier of the ColumnFamily to lookup
      Returns:
        true if the CF id is a known one, false otherwise.

    - #### getId

          public java.util.UUID 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)

      Load individual ColumnFamily Definition to the schema (to make ColumnFamily lookup faster)
      Parameters:
        `cfm` - The ColumnFamily definition to load

    - #### purge

          public void purge(CFMetaData cfm)

      Used for ColumnFamily data eviction out from the schema
      Parameters:
        `cfm` - The ColumnFamily Definition to evict

    - #### getVersion

          public java.util.UUID getVersion()

      Returns:
        current schema version

    - #### updateVersion

          public 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.

    - #### updateVersionAndAnnounce

          public void updateVersionAndAnnounce()

    - #### clear

          public void clear()

      Clear all KS/CF metadata and reset version.

    - #### invalidSchemaRow

          public static boolean invalidSchemaRow(Row row)

    - #### ignoredSchemaRow

          public static boolean ignoredSchemaRow(Row row)

Copyright © 2014 The Apache Software Foundation