Class PartitionKeyIndex
java.lang.Object
org.apache.cassandra.index.internal.CassandraIndex
org.apache.cassandra.index.internal.composites.PartitionKeyIndex
- All Implemented Interfaces:
Index
Index on a PARTITION_KEY column definition.
This suppose a composite row key:
rk = rk_0 ... rk_n
The corresponding index entry will be:
- index row key will be rk_i (where i == columnDef.componentIndex)
- cell name will be: rk ck
where rk is the fully partition key and ck the clustering keys of the
original cell names (thus excluding the last column name as we want to refer to
the whole CQL3 row, not just the cell itself)
Note that contrarily to other type of index, we repeat the indexed value in
the index cell name (we use the whole partition key). The reason is that we
want to order the index cell name by partitioner first, and skipping a part
of the row key would change the order.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.cassandra.index.Index
Index.CollatedViewIndexBuildingSupport, Index.Group, Index.IndexBuildingSupport, Index.Indexer, Index.LoadType, Index.QueryPlan, Index.Searcher, Index.Status -
Field Summary
Fields inherited from class org.apache.cassandra.index.internal.CassandraIndex
baseCfs, functions, indexCfs, indexedColumn, metadata, NAMEFields inherited from interface org.apache.cassandra.index.Index
INDEX_BUILDER_SUPPORT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> CBuilderbuildIndexClusteringPrefix(ByteBuffer partitionKey, ClusteringPrefix<T> prefix, CellPath path) Used to construct an the clustering for an entry in the index table based on values from the base data.decodeEntry(DecoratedKey indexedValue, Row indexEntry) 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.getIndexedValue(ByteBuffer partitionKey, Clustering<?> clustering, CellPath path, ByteBuffer cellValue) Extract the value to be inserted into the index from the components of the base databooleanisStale(Row data, ByteBuffer indexValue, long nowInSec) Check whether a value retrieved from an index is still valid by comparing it to current row from the base table.Methods inherited from class org.apache.cassandra.index.internal.CassandraIndex
customExpressionValueType, deleteStaleEntry, dependsOn, getBackingTable, getBlockingFlushTask, getEstimatedResultRows, getIndexCfs, getIndexComparator, getIndexedColumn, getIndexMetadata, getInitializationTask, getInvalidateTask, getMetadataReloadTask, getPostIndexQueryFilter, getTruncateTask, indexCfsMetadata, indexerFor, isQueryable, newIndex, register, searcherFor, shouldBuildBlocking, supportsExpression, supportsOperator, validate, validateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.cassandra.index.Index
filtersMultipleContains, getBlockingFlushTask, getBuildTaskSupport, getComponents, getFlushObserver, getPostQueryOrdering, getPreJoinTask, getRecoveryTaskSupport, getSupportedLoadTypeOnFailure, isSSTableAttached, notifyIndexerAboutRowsInFullyExpiredSSTables, unregister
-
Constructor Details
-
PartitionKeyIndex
-
-
Method Details
-
getIndexedValue
public ByteBuffer getIndexedValue(ByteBuffer partitionKey, Clustering<?> clustering, CellPath path, ByteBuffer cellValue) Description copied from class:CassandraIndexExtract the value to be inserted into the index from the components of the base data- Specified by:
getIndexedValuein classCassandraIndex- Parameters:
partitionKey- from the primary dataclustering- from the primary datapath- from the primary datacellValue- 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(ByteBuffer partitionKey, ClusteringPrefix<T> prefix, CellPath path) Description copied from class:CassandraIndexUsed 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:
buildIndexClusteringPrefixin classCassandraIndex- Parameters:
partitionKey- from the base data being indexedprefix- from the base data being indexedpath- from the base data being indexed- Returns:
- a clustering prefix to be used to insert into the index table
-
decodeEntry
Description copied from class:CassandraIndexUsed 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:
decodeEntryin classCassandraIndex- 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
Description copied from class:CassandraIndexCheck 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:
isStalein classCassandraIndex- Parameters:
data- the current row from the primary data tableindexValue- the value we retrieved from the index- Returns:
- true if the index is out of date and the entry should be dropped
-