Class ClusteringColumnIndex

  • All Implemented Interfaces:
    Index

    public class ClusteringColumnIndex
    extends CassandraIndex
    Index on a CLUSTERING_COLUMN column definition. A cell indexed by this index will have the general form: ck_0 ... ck_n c_name : v where ck_i are the cluster keys, c_name the last component of the cell composite name (or second to last if collections are in use, but this has no impact) and v the cell value. Such a cell is always indexed by this index (or rather, it is indexed if n >= columnDef.componentIndex, which will always be the case in practice) and it will generate (makeIndexColumnName()) an index entry whose: - row key will be ck_i (getIndexedValue()) where i == columnDef.componentIndex. - cell name will rk ck_0 ... ck_{i-1} ck_{i+1} ck_n where rk is the row key of the initial cell and i == columnDef.componentIndex.
    • Method Detail

      • getIndexedValue

        public java.nio.ByteBuffer getIndexedValue​(java.nio.ByteBuffer partitionKey,
                                                   Clustering<?> clustering,
                                                   CellPath path,
                                                   java.nio.ByteBuffer cellValue)
        Description copied from class: CassandraIndex
        Extract the value to be inserted into the index from the components of the base data
        Specified by:
        getIndexedValue in class CassandraIndex
        Parameters:
        partitionKey - from the primary data
        clustering - from the primary data
        path - from the primary data
        cellValue - from the primary data
        Returns:
        a ByteBuffer containing the value to be inserted in the index. This will be used to make the partition key in the index table
      • buildIndexClusteringPrefix

        public <T> CBuilder buildIndexClusteringPrefix​(java.nio.ByteBuffer partitionKey,
                                                       ClusteringPrefix<T> prefix,
                                                       CellPath path)
        Description copied from class: CassandraIndex
        Used to construct an the clustering for an entry in the index table based on values from the base data. The clustering columns in the index table encode the values required to retrieve the correct data from the base table and varies depending on the kind of the indexed column. See indexCfsMetadata for more details Used whenever a row in the index table is written or deleted.
        Specified by:
        buildIndexClusteringPrefix in class CassandraIndex
        Parameters:
        partitionKey - from the base data being indexed
        prefix - from the base data being indexed
        path - from the base data being indexed
        Returns:
        a clustering prefix to be used to insert into the index table
      • decodeEntry

        public IndexEntry decodeEntry​(DecoratedKey indexedValue,
                                      Row indexEntry)
        Description copied from class: CassandraIndex
        Used at search time to convert a row in the index table into a simple struct containing the values required to retrieve the corresponding row from the base table.
        Specified by:
        decodeEntry in class CassandraIndex
        Parameters:
        indexedValue - the partition key of the indexed table (i.e. the value that was indexed)
        indexEntry - a row from the index table
        Returns:
      • isStale

        public boolean isStale​(Row data,
                               java.nio.ByteBuffer indexValue,
                               long nowInSec)
        Description copied from class: CassandraIndex
        Check whether a value retrieved from an index is still valid by comparing it to current row from the base table. Used at read time to identify out of date index entries so that they can be excluded from search results and repaired
        Specified by:
        isStale in class CassandraIndex
        Parameters:
        data - the current row from the primary data table
        indexValue - the value we retrieved from the index
        Returns:
        true if the index is out of date and the entry should be dropped