org.apache.cassandra.schema

## Class SchemaKeyspace

- java.lang.Object
- - org.apache.cassandra.schema.SchemaKeyspace

-     public final class SchemaKeyspace
      extends java.lang.Object

  system_schema.* tables and methods for manipulating them.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `AGGREGATES`
    `static com.google.common.collect.ImmutableList<java.lang.String>` | `ALL` The order in this list matters.
    `static com.google.common.collect.ImmutableList<java.lang.String>` | `ALL_FOR_DIGEST` Until we upgrade the messaging service version, that is version 4.0, we must preserve the old order (before CASSANDRA-12213) for digest calculations, otherwise the nodes will never agree on the schema during a rolling upgrade, see CASSANDRA-13559.
    `static java.util.List<CFMetaData>` | `ALL_TABLE_METADATA`
    `static java.lang.String` | `COLUMNS`
    `static java.lang.String` | `DROPPED_COLUMNS`
    `static java.lang.String` | `FUNCTIONS`
    `static java.lang.String` | `INDEXES`
    `static java.lang.String` | `KEYSPACES`
    `static java.lang.String` | `TABLES`
    `static java.lang.String` | `TRIGGERS`
    `static java.lang.String` | `TYPES`
    `static java.lang.String` | `VIEWS`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Pair<java.util.UUID,java.util.UUID>` | `calculateSchemaDigest()` 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.
    `static java.util.Collection<Mutation>` | `convertSchemaToMutations()`
    `static ColumnDefinition` | `createColumnFromRow(UntypedResultSet.Row row, Types types)`
    `static TableParams` | `createTableParamsFromRow(UntypedResultSet.Row row)`
    `static Mutation.SimpleBuilder` | `dropTypeFromSchemaMutation(KeyspaceMetadata keyspace, UserType type, long timestamp)`
    `static Keyspaces` | `fetchNonSystemKeyspaces()`
    `static Mutation.SimpleBuilder` | `makeCreateAggregateMutation(KeyspaceMetadata keyspace, UDAggregate aggregate, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeCreateFunctionMutation(KeyspaceMetadata keyspace, UDFunction function, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeCreateKeyspaceMutation(KeyspaceMetadata keyspace, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeCreateKeyspaceMutation(java.lang.String name, KeyspaceParams params, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeCreateTableMutation(KeyspaceMetadata keyspace, CFMetaData table, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeCreateTypeMutation(KeyspaceMetadata keyspace, UserType type, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeCreateViewMutation(KeyspaceMetadata keyspace, ViewDefinition view, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeDropAggregateMutation(KeyspaceMetadata keyspace, UDAggregate aggregate, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeDropFunctionMutation(KeyspaceMetadata keyspace, UDFunction function, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeDropKeyspaceMutation(KeyspaceMetadata keyspace, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeDropTableMutation(KeyspaceMetadata keyspace, CFMetaData table, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeDropViewMutation(KeyspaceMetadata keyspace, ViewDefinition view, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeUpdateTableMutation(KeyspaceMetadata keyspace, CFMetaData oldTable, CFMetaData newTable, long timestamp)`
    `static Mutation.SimpleBuilder` | `makeUpdateViewMutation(Mutation.SimpleBuilder builder, ViewDefinition oldView, ViewDefinition newView)`
    `static void` | `mergeSchema(java.util.Collection<Mutation> mutations)`
    `static void` | `mergeSchemaAndAnnounceVersion(java.util.Collection<Mutation> mutations)` Merge remote schema in form of mutations with local and mutate ks/cf metadata objects (which also involves fs operations on add/drop ks/cf)
    `static KeyspaceMetadata` | `metadata()`
    `static void` | `reloadSchemaAndAnnounceVersion()`
    `static void` | `saveSystemKeyspacesSchema()` Add entries to system_schema.* for the hardcoded system keyspaces
    `static void` | `truncate()`

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

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

- - ### Field Detail

    - #### KEYSPACES

          public static final java.lang.String KEYSPACES

      See Also:
        Constant Field Values

    - #### TABLES

          public static final java.lang.String TABLES

      See Also:
        Constant Field Values

    - #### COLUMNS

          public static final java.lang.String COLUMNS

      See Also:
        Constant Field Values

    - #### DROPPED_COLUMNS

          public static final java.lang.String DROPPED_COLUMNS

      See Also:
        Constant Field Values

    - #### TRIGGERS

          public static final java.lang.String TRIGGERS

      See Also:
        Constant Field Values

    - #### VIEWS

          public static final java.lang.String VIEWS

      See Also:
        Constant Field Values

    - #### TYPES

          public static final java.lang.String TYPES

      See Also:
        Constant Field Values

    - #### FUNCTIONS

          public static final java.lang.String FUNCTIONS

      See Also:
        Constant Field Values

    - #### AGGREGATES

          public static final java.lang.String AGGREGATES

      See Also:
        Constant Field Values

    - #### INDEXES

          public static final java.lang.String INDEXES

      See Also:
        Constant Field Values

    - #### ALL

          public static final com.google.common.collect.ImmutableList<java.lang.String> ALL

      The order in this list matters. When flushing schema tables, we want to flush them in a way that mitigates the effects of an abrupt shutdown whilst the tables are being flushed. On startup, we load the schema from disk before replaying the CL, so we need to try to avoid problems like reading a table without columns or types, for example. So columns and types should be flushed before tables, which should be flushed before keyspaces. When truncating, the order should be reversed. For immutable lists this is an efficient operation that simply iterates in reverse order. See CASSANDRA-12213 for more details.

    - #### ALL_FOR_DIGEST

          public static final com.google.common.collect.ImmutableList<java.lang.String> ALL_FOR_DIGEST

      Until we upgrade the messaging service version, that is version 4.0, we must preserve the old order (before CASSANDRA-12213) for digest calculations, otherwise the nodes will never agree on the schema during a rolling upgrade, see CASSANDRA-13559.

    - #### ALL_TABLE_METADATA

          public static final java.util.List<CFMetaData> ALL_TABLE_METADATA

  - ### Method Detail

    - #### metadata

          public static KeyspaceMetadata metadata()

    - #### saveSystemKeyspacesSchema

          public static void saveSystemKeyspacesSchema()

      Add entries to system_schema.* for the hardcoded system keyspaces

    - #### truncate

          public static void truncate()

    - #### calculateSchemaDigest

          public static Pair<java.util.UUID,java.util.UUID> calculateSchemaDigest()

      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. This implementation is special cased for 3.11 as it returns the schema digests for 3.11 and 3.0 - i.e. with and without the beloved `cdc` column.

    - #### convertSchemaToMutations

          public static java.util.Collection<Mutation> convertSchemaToMutations()

    - #### makeCreateKeyspaceMutation

          public static Mutation.SimpleBuilder makeCreateKeyspaceMutation(java.lang.String name,
                                                                          KeyspaceParams params,
                                                                          long timestamp)

    - #### makeCreateKeyspaceMutation

          public static Mutation.SimpleBuilder makeCreateKeyspaceMutation(KeyspaceMetadata keyspace,
                                                                          long timestamp)

    - #### makeDropKeyspaceMutation

          public static Mutation.SimpleBuilder makeDropKeyspaceMutation(KeyspaceMetadata keyspace,
                                                                        long timestamp)

    - #### makeCreateTypeMutation

          public static Mutation.SimpleBuilder makeCreateTypeMutation(KeyspaceMetadata keyspace,
                                                                      UserType type,
                                                                      long timestamp)

    - #### dropTypeFromSchemaMutation

          public static Mutation.SimpleBuilder dropTypeFromSchemaMutation(KeyspaceMetadata keyspace,
                                                                          UserType type,
                                                                          long timestamp)

    - #### makeCreateTableMutation

          public static Mutation.SimpleBuilder makeCreateTableMutation(KeyspaceMetadata keyspace,
                                                                       CFMetaData table,
                                                                       long timestamp)

    - #### makeUpdateTableMutation

          public static Mutation.SimpleBuilder makeUpdateTableMutation(KeyspaceMetadata keyspace,
                                                                       CFMetaData oldTable,
                                                                       CFMetaData newTable,
                                                                       long timestamp)

    - #### makeDropTableMutation

          public static Mutation.SimpleBuilder makeDropTableMutation(KeyspaceMetadata keyspace,
                                                                     CFMetaData table,
                                                                     long timestamp)

    - #### makeCreateViewMutation

          public static Mutation.SimpleBuilder makeCreateViewMutation(KeyspaceMetadata keyspace,
                                                                      ViewDefinition view,
                                                                      long timestamp)

    - #### makeDropViewMutation

          public static Mutation.SimpleBuilder makeDropViewMutation(KeyspaceMetadata keyspace,
                                                                    ViewDefinition view,
                                                                    long timestamp)

    - #### makeUpdateViewMutation

          public static Mutation.SimpleBuilder makeUpdateViewMutation(Mutation.SimpleBuilder builder,
                                                                      ViewDefinition oldView,
                                                                      ViewDefinition newView)

    - #### makeCreateFunctionMutation

          public static Mutation.SimpleBuilder makeCreateFunctionMutation(KeyspaceMetadata keyspace,
                                                                          UDFunction function,
                                                                          long timestamp)

    - #### makeDropFunctionMutation

          public static Mutation.SimpleBuilder makeDropFunctionMutation(KeyspaceMetadata keyspace,
                                                                        UDFunction function,
                                                                        long timestamp)

    - #### makeCreateAggregateMutation

          public static Mutation.SimpleBuilder makeCreateAggregateMutation(KeyspaceMetadata keyspace,
                                                                           UDAggregate aggregate,
                                                                           long timestamp)

    - #### makeDropAggregateMutation

          public static Mutation.SimpleBuilder makeDropAggregateMutation(KeyspaceMetadata keyspace,
                                                                         UDAggregate aggregate,
                                                                         long timestamp)

    - #### fetchNonSystemKeyspaces

          public static Keyspaces fetchNonSystemKeyspaces()

    - #### createTableParamsFromRow

          public static TableParams createTableParamsFromRow(UntypedResultSet.Row row)

    - #### createColumnFromRow

          public static ColumnDefinition createColumnFromRow(UntypedResultSet.Row row,
                                                             Types types)

    - #### reloadSchemaAndAnnounceVersion

          public static void reloadSchemaAndAnnounceVersion()

    - #### mergeSchemaAndAnnounceVersion

          public static void mergeSchemaAndAnnounceVersion(java.util.Collection<Mutation> mutations)
                                                    throws ConfigurationException

      Merge remote schema in form of mutations with local and mutate ks/cf metadata objects (which also involves fs operations on add/drop ks/cf)
      Parameters:
        `mutations` - the schema changes to apply
      Throws:
        `ConfigurationException` - If one of metadata attributes has invalid value

    - #### mergeSchema

          public static void mergeSchema(java.util.Collection<Mutation> mutations)

Copyright © 2018 The Apache Software Foundation