All Implemented Interfaces:
IIndex, IOptionContainer, ISearchPath, ISimpleColumnContainer, ISimpleOptionContainer, IStatement, ISubElement, IHashable

public class ChIndex extends ChAbstractStatement implements IIndex
Represents a ClickHouse table index. ClickHouse's indexes are used for data skipping and include expression, type, and granularity settings.
  • Constructor Details

    • ChIndex

      public ChIndex(String name)
      Creates a new ClickHouse index with the specified name.
      Parameters:
      name - the name of the index
  • Method Details

    • getCreationSQL

      public void getCreationSQL(SQLScript script)
      Description copied from interface: IStatement
      Generates the SQL statements needed to create this database object. This is an abstract method that must be implemented by subclasses to provide the specific CREATE SQL for each object type.
      Specified by:
      getCreationSQL in interface IStatement
      Parameters:
      script - the SQL script to append creation statements to
    • appendAlterSQL

      public ObjectState appendAlterSQL(IStatement newCondition, SQLScript script)
      Description copied from interface: IStatement
      Fill script with object changes and return change type
      Specified by:
      appendAlterSQL in interface IStatement
      Parameters:
      newCondition - new object state
      script - script to collect changes
      Returns:
      object change type
    • getDropSQL

      public void getDropSQL(SQLScript script, boolean optionExists)
      Description copied from interface: IStatement
      Generates DROP SQL for this statement.
      Specified by:
      getDropSQL in interface IStatement
      Overrides:
      getDropSQL in class AbstractStatement
      Parameters:
      script - the SQL script to append the DROP statement to
      optionExists - whether to include "IF EXISTS" in the DROP statement
    • compareColumns

      public boolean compareColumns(Collection<String> refs)
      Description copied from interface: IIndex
      Compares the columns of this index with a collection of column references.
      Specified by:
      compareColumns in interface IIndex
      Parameters:
      refs - the collection of column references to compare against
      Returns:
      true if the columns match in order and count
    • setClustered

      public void setClustered(boolean isClustered)
    • isClustered

      public boolean isClustered()
    • addColumn

      public void addColumn(SimpleColumn column)
      Description copied from interface: ISimpleColumnContainer
      Adds a column reference to this container.
      Specified by:
      addColumn in interface ISimpleColumnContainer
      Parameters:
      column - the simple column to add
    • addInclude

      public void addInclude(String column)
      Description copied from interface: ISimpleColumnContainer
      Adds an included column to this container.
      Specified by:
      addInclude in interface ISimpleColumnContainer
      Parameters:
      column - the column name to include
    • isUnique

      public boolean isUnique()
      Specified by:
      isUnique in interface IIndex
      Returns:
      true if unique index
    • setUnique

      public void setUnique(boolean unique)
    • setWhere

      public void setWhere(String where)
    • getTablespace

      public String getTablespace()
    • setTablespace

      public void setTablespace(String tableSpace)
    • getOptions

      public Map<String,String> getOptions()
      Description copied from interface: IOptionContainer
      Gets all options for this container.
      Specified by:
      getOptions in interface IOptionContainer
      Returns:
      a map of option keys to values
    • addOption

      public void addOption(String key, String value)
      Description copied from interface: IOptionContainer
      Adds an option to this container.
      Specified by:
      addOption in interface IOptionContainer
      Parameters:
      key - the option key
      value - the option value
    • setExpr

      public void setExpr(String expr)
    • setType

      public void setType(String type)
    • setGranVal

      public void setGranVal(int granVal)
    • computeHash

      public void computeHash(Hasher hasher)
      Description copied from interface: IHashable
      Computes the hash of the implementing object using the provided hasher. The implementation should call appropriate put methods on the hasher for all fields that should contribute to the hash value.
      Specified by:
      computeHash in interface IHashable
      Parameters:
      hasher - the hasher instance to use for hash computation
    • compare

      public boolean compare(IStatement obj)
      Description copied from class: AbstractStatement
      This method does not account for nested child PgStatements. Shallow version of AbstractStatement.equals(Object)
      Specified by:
      compare in interface IStatement
      Overrides:
      compare in class AbstractStatement