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.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Schema()` Initialize empty schema object and load the hardcoded system tables

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAggregate(UDAggregate udf)`
    `void` | `addFunction(UDFunction udf)`
    `void` | `addKeyspace(KSMetaData ksm)`
    `void` | `addTable(CFMetaData cfm)`
    `void` | `addType(UserType ut)`
    `void` | `clear()` Clear all KS/CF metadata and reset version.
    `void` | `clearKeyspaceDefinition(KSMetaData ksm)` Remove keyspace definition from system
    `void` | `dropAggregate(UDAggregate udf)`
    `void` | `dropFunction(UDFunction udf)`
    `void` | `dropKeyspace(java.lang.String ksName)`
    `void` | `dropTable(java.lang.String ksName, java.lang.String tableName)`
    `void` | `dropType(UserType ut)`
    `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.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.List<java.lang.String>` | `getUserKeyspaces()`
    `java.util.UUID` | `getVersion()`
    `boolean` | `hasCF(Pair<java.lang.String,java.lang.String> ksAndCFName)`
    `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
    `Schema` | `loadFromDisk()` load keyspace (keyspace) definitions, but do not initialize the keyspace instances.
    `Schema` | `loadFromDisk(boolean updateVersion)` Load schema definitions from disk.
    `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` | `updateAggregate(UDAggregate udf)`
    `void` | `updateFunction(UDFunction udf)`
    `void` | `updateKeyspace(java.lang.String ksName)`
    `void` | `updateTable(java.lang.String ksName, java.lang.String tableName)`
    `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()`

    - ### 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

  - ### Constructor Detail

    - #### Schema

          public Schema()

      Initialize empty schema object and load the hardcoded system tables

  - ### Method Detail

    - #### loadFromDisk

          public Schema loadFromDisk()

      load keyspace (keyspace) definitions, but do not initialize the keyspace instances. Schema version may be updated as the result.

    - #### loadFromDisk

          public Schema loadFromDisk(boolean updateVersion)

      Load schema definitions from disk.
      Parameters:
        `updateVersion` - true if schema version needs to be updated

    - #### 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

    - #### getColumnFamilyStoreIncludingIndexes

          public 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
      Parameters:
        `ksNameAndCFName` -
      Returns:
        The named CFS or null if the keyspace, base table, or index don't exist

    - #### 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 and 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)

    - #### 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 (note that this count as system only the non replicated keyspaces, so keyspace like system_traces which are replicated are actually returned. See getUserKeyspace() below if you don't want those)

    - #### getUserKeyspaces

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

      Returns:
        collection of the user defined 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(Pair<java.lang.String,java.lang.String> ksAndCFName)

      Parameters:
        `ksAndCFName` - The identifier of the ColumnFamily to lookup
      Returns:
        true if the KS and CF pair 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.

    - #### addKeyspace

          public void addKeyspace(KSMetaData ksm)

    - #### updateKeyspace

          public void updateKeyspace(java.lang.String ksName)

    - #### dropKeyspace

          public void dropKeyspace(java.lang.String ksName)

    - #### addTable

          public void addTable(CFMetaData cfm)

    - #### updateTable

          public void updateTable(java.lang.String ksName,
                                  java.lang.String tableName)

    - #### dropTable

          public void dropTable(java.lang.String ksName,
                                java.lang.String tableName)

    - #### addType

          public void addType(UserType ut)

    - #### updateType

          public void updateType(UserType ut)

    - #### dropType

          public void dropType(UserType ut)

    - #### addFunction

          public void addFunction(UDFunction udf)

    - #### updateFunction

          public void updateFunction(UDFunction udf)

    - #### dropFunction

          public void dropFunction(UDFunction udf)

    - #### addAggregate

          public void addAggregate(UDAggregate udf)

    - #### updateAggregate

          public void updateAggregate(UDAggregate udf)

    - #### dropAggregate

          public void dropAggregate(UDAggregate udf)

Copyright © 2018 The Apache Software Foundation