Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


IDIEP-127
Author
Sponsor
Created

  

Status
Status
colourGrey
titleDRAFT


Table of Contents

Motivation

...

  • Operations triggered by user – these are operation of acquiring tables by name, resolving objects during query planning, or operations involving data manipulation. All these operations use transaction to resolve particular version of catalog. Catalog must not be compacted by version which activation time is greater than or equal to earliest active transaction in the cluster. 
  • Internal processes of the cluster – these are:
    • Operations of replication – update commands in raft log refers to a particular version, this version is required to replay the log on recovery. Catalog must not be compacted by version which can be required to replay the log during recovery.
    • Build of the index – process of backfilling is stick with particular version of catalog. This version must not be truncated. 
    • Rebalance – process of rebalance is stick with particular version of catalog. This version must not be truncated.

...

Code Block
languagejava
public class CatalogTableDescriptor extends CatalogObjectDescriptor {
    // private properties and constructors

    /**
     * 
Returns an identifier of a schema this table descriptor belongs to.
     */
    public int schemaId() {
        return schemaId;
    ...}

    /**
     * Returns versions of this table descriptor.
     */
    public CatalogTableSchemaVersions schemaVersions() {
        return schemaVersions;
    ...}

    /**
     * Returns an identifier of a distribution zone this table descriptor belongs to.
     */
    public int zoneId() {
        return zoneId;
    ...}

    /**
     * Returns a identifier of the primary key index.
     */
    public int primaryKeyIndexId() {...}

    /**
    return pkIndexId;
    }

    /**
     * Returns a version of this table descriptor.
     */
    public int tableVersion() {
        return schemaVersions.latestVersion();
    ...}

    /**
     * Returns a list primary key column names.
     */
    public List<String> primaryKeyColumns() {
        return primaryKeyColumns;
    ...}

    /**
     * Returns a list colocation key column names.
     */
    public List<String> colocationColumns() {...}

        return colocationColumns;
    }

    //**
     * Returns a list column descriptors for the table.
     */
    public List<CatalogTableColumnDescriptor> columns() {
        return columns;
    ...}

    /** Returns a column descriptor for column with given name, {@code null} if absent. */
    public @Nullable CatalogTableColumnDescriptor column(String name) {...}

    /**
    Entry<Integer, CatalogTableColumnDescriptor>* columnReturns = columnsMap.get(name);
        if (column != null) {
            return column.getValue();
        } else {
            return null;
        }
    }

    /**
     * Returns an index of a column with the given name, or {@code -1} if such column does not exist.
     */
    public int columnIndex(String name) {
        Entry<Integer, CatalogTableColumnDescriptor> column = columnsMap.get(name);
        if (column != null) {
            return column.getKey();
        } else {
            return -1;
        }
    }

    /**
     * Returns {@code true} if this the given column is a part of the primary keyan index of a column with the given name, or {@code -1} if such column does not exist.
     */
    public booleanint isPrimaryKeyColumncolumnIndex(String name) {
        return primaryKeyColumns.contains(name);
    ...}

    /**
     * Returns {@code true} if this the given column is a part of the collocationprimary key.
     */
    public boolean isColocationColumnisPrimaryKeyColumn(String name) {...}

    /**
    return colocationColumns.contains(name);
    }

    @Override
    public String toString() { * Returns {@code true} if this the given column is a part of collocation key.
     */
   return S.toString(CatalogTableDescriptor.class, this, super.toString());
     public boolean isColocationColumn(String name) {...}

    /**
     * Returns a name of a storage profile.
     */
    public String storageProfile() {
        return storageProfile;
    ...}
}

Write API

Here is a complete example of creating new table in catalog:

...

Code Block
languagejava
/**
 * The catalog manager provides schema manipulation methods and is responsible for managing distributed operations.
 */
public interface CatalogManager extends IgniteComponent {
    /**
     * Executes given command.
     *
     * @param command Command to execute.
     * @return Future representing result of execution (it will be completed with the created catalog version).
     */
    CompletableFuture<Integer> execute(CatalogCommand command);

    /**
     * Executes given list of commands atomically. That is, either all commands will be applied at once
     * or neither of them. The whole bulk will increment catalog's version by a single point.
     *
     * @param commands Commands to execute.
     * @return Future representing result of execution (it will be completed with the created catalog version).
     */
    CompletableFuture<Integer> execute(List<CatalogCommand> commands);
}

and , builder for CreateTable command is defined as follow:

...