public abstract class CassandraIndex extends java.lang.Object implements Index
Index.CollatedViewIndexBuildingSupport, Index.IndexBuildingSupport, Index.Indexer, Index.LoadType, Index.Searcher
Modifier and Type | Field and Description |
---|---|
ColumnFamilyStore |
baseCfs |
protected CassandraIndexFunctions |
functions |
protected ColumnFamilyStore |
indexCfs |
protected ColumnMetadata |
indexedColumn |
protected IndexMetadata |
metadata |
INDEX_BUILDER_SUPPORT
Modifier | Constructor and Description |
---|---|
protected |
CassandraIndex(ColumnFamilyStore baseCfs,
IndexMetadata indexDef) |
Modifier and Type | Method and Description |
---|---|
protected abstract <T> CBuilder |
buildIndexClusteringPrefix(java.nio.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.
|
AbstractType<?> |
customExpressionValueType()
If the index supports custom search expressions using the
SELECT * FROM table WHERE expr(index_name, expression) syntax, this
method should return the expected type of the expression argument.
|
abstract IndexEntry |
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.
|
void |
deleteStaleEntry(DecoratedKey indexKey,
Clustering<?> indexClustering,
DeletionTime deletion,
WriteContext ctx)
Specific to internal indexes, this is called by a
searcher when it encounters a stale entry in the index
|
boolean |
dependsOn(ColumnMetadata column)
Called to determine whether this index targets a specific column.
|
java.util.Optional<ColumnFamilyStore> |
getBackingTable()
If the index implementation uses a local table to store its index data this method should return a
handle to it.
|
java.util.concurrent.Callable<java.lang.Void> |
getBlockingFlushTask()
Return a task which performs a blocking flush of the index's data to persistent storage.
|
long |
getEstimatedResultRows()
Return an estimate of the number of results this index is expected to return for any given
query that it can be used to answer.
|
ColumnFamilyStore |
getIndexCfs() |
ClusteringComparator |
getIndexComparator() |
ColumnMetadata |
getIndexedColumn() |
protected abstract java.nio.ByteBuffer |
getIndexedValue(java.nio.ByteBuffer partitionKey,
Clustering<?> clustering,
CellPath path,
java.nio.ByteBuffer cellValue)
Extract the value to be inserted into the index from the components of the base data
|
IndexMetadata |
getIndexMetadata()
Returns the IndexMetadata which configures and defines the index instance.
|
java.util.concurrent.Callable<?> |
getInitializationTask()
Return a task to perform any initialization work when a new index instance is created.
|
java.util.concurrent.Callable<?> |
getInvalidateTask()
Return a task which invalidates the index, indicating it should no longer be considered usable.
|
java.util.concurrent.Callable<?> |
getMetadataReloadTask(IndexMetadata indexDef)
Return a task to reload the internal metadata of an index.
|
RowFilter |
getPostIndexQueryFilter(RowFilter filter)
Transform an initial RowFilter into the filter that will still need to applied
to a set of Rows after the index has performed it's initial scan.
|
java.util.concurrent.Callable<?> |
getTruncateTask(long truncatedAt)
Return a task to truncate the index with the specified truncation timestamp.
|
static TableMetadata |
indexCfsMetadata(TableMetadata baseCfsMetadata,
IndexMetadata indexMetadata)
Construct the TableMetadata for an index table, the clustering columns in the index table
vary dependent on the kind of the indexed value.
|
Index.Indexer |
indexerFor(DecoratedKey key,
RegularAndStaticColumns columns,
int nowInSec,
WriteContext ctx,
IndexTransaction.Type transactionType)
Creates an new
Indexer object for updates to a given partition. |
abstract boolean |
isStale(Row row,
java.nio.ByteBuffer indexValue,
int nowInSec)
Check whether a value retrieved from an index is still valid by comparing it to current row from the base table.
|
static CassandraIndex |
newIndex(ColumnFamilyStore baseCfs,
IndexMetadata indexMetadata)
Factory method for new CassandraIndex instances
|
java.util.function.BiFunction<PartitionIterator,ReadCommand,PartitionIterator> |
postProcessorFor(ReadCommand command)
No post processing of query results, just return them unchanged
|
void |
register(IndexRegistry registry)
An index must be registered in order to be able to either subscribe to update events on the base
table and/or to provide Searcher functionality for reads.
|
Index.Searcher |
searcherFor(ReadCommand command)
Factory method for query time search helper.
|
boolean |
shouldBuildBlocking()
Return true if this index can be built or rebuilt when the index manager determines it is necessary.
|
boolean |
supportsExpression(ColumnMetadata column,
Operator operator)
Called to determine whether this index can provide a searcher to execute a query on the
supplied column using the specified operator.
|
protected boolean |
supportsOperator(ColumnMetadata indexedColumn,
Operator operator)
Returns true if an index of this type can support search predicates of the form [column] OPERATOR [value]
|
void |
validate(PartitionUpdate update)
Called at write time to ensure that values present in the update
are valid according to the rules of all registered indexes which
will process it.
|
void |
validate(ReadCommand command)
Used to validate the various parameters of a supplied ReadCommand,
this is called prior to execution.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBuildTaskSupport, getFlushObserver, getPreJoinTask, getRecoveryTaskSupport, getSupportedLoadTypeOnFailure, supportsReplicaFilteringProtection
public final ColumnFamilyStore baseCfs
protected IndexMetadata metadata
protected ColumnFamilyStore indexCfs
protected ColumnMetadata indexedColumn
protected CassandraIndexFunctions functions
protected CassandraIndex(ColumnFamilyStore baseCfs, IndexMetadata indexDef)
protected boolean supportsOperator(ColumnMetadata indexedColumn, Operator operator)
indexedColumn
- operator
- protected abstract <T> CBuilder buildIndexClusteringPrefix(java.nio.ByteBuffer partitionKey, ClusteringPrefix<T> prefix, CellPath path)
partitionKey
- from the base data being indexedprefix
- from the base data being indexedpath
- from the base data being indexedpublic abstract IndexEntry decodeEntry(DecoratedKey indexedValue, Row indexEntry)
indexedValue
- the partition key of the indexed table (i.e. the value that was indexed)indexEntry
- a row from the index tablepublic abstract boolean isStale(Row row, java.nio.ByteBuffer indexValue, int nowInSec)
row
- the current row from the primary data tableindexValue
- the value we retrieved from the indexnowInSec
- protected abstract java.nio.ByteBuffer getIndexedValue(java.nio.ByteBuffer partitionKey, Clustering<?> clustering, CellPath path, java.nio.ByteBuffer cellValue)
partitionKey
- from the primary dataclustering
- from the primary datapath
- from the primary datacellValue
- from the primary datapublic ColumnMetadata getIndexedColumn()
public ClusteringComparator getIndexComparator()
public ColumnFamilyStore getIndexCfs()
public void register(IndexRegistry registry)
Index
public java.util.concurrent.Callable<?> getInitializationTask()
Index
getInitializationTask
in interface Index
public IndexMetadata getIndexMetadata()
Index
getIndexMetadata
in interface Index
public java.util.Optional<ColumnFamilyStore> getBackingTable()
Index
getBackingTable
in interface Index
public java.util.concurrent.Callable<java.lang.Void> getBlockingFlushTask()
Index
getBlockingFlushTask
in interface Index
public java.util.concurrent.Callable<?> getInvalidateTask()
Index
getInvalidateTask
in interface Index
public java.util.concurrent.Callable<?> getMetadataReloadTask(IndexMetadata indexDef)
Index
getMetadataReloadTask
in interface Index
public void validate(ReadCommand command) throws InvalidRequestException
Index
validate
in interface Index
command
- a ReadCommand whose parameters are to be verifiedInvalidRequestException
- if the details of the command fail to meet the
index's validation rulespublic java.util.concurrent.Callable<?> getTruncateTask(long truncatedAt)
Index
getTruncateTask
in interface Index
truncatedAt
- timestamp of the truncation operation. This will be the same timestamp used
in the truncation of the base table.public boolean shouldBuildBlocking()
Index
shouldBuildBlocking
in interface Index
public boolean dependsOn(ColumnMetadata column)
Index
public boolean supportsExpression(ColumnMetadata column, Operator operator)
Index
supportsExpression
in interface Index
column
- the target column of a search query predicateoperator
- the operator of a search query predicatepublic AbstractType<?> customExpressionValueType()
Index
customExpressionValueType
in interface Index
public long getEstimatedResultRows()
Index
getEstimatedResultRows
in interface Index
public java.util.function.BiFunction<PartitionIterator,ReadCommand,PartitionIterator> postProcessorFor(ReadCommand command)
postProcessorFor
in interface Index
public RowFilter getPostIndexQueryFilter(RowFilter filter)
Index
getPostIndexQueryFilter
in interface Index
filter
- the intial filter belonging to a ReadCommandpublic Index.Searcher searcherFor(ReadCommand command)
Index
searcherFor
in interface Index
command
- the read command being executedpublic void validate(PartitionUpdate update) throws InvalidRequestException
Index
validate
in interface Index
update
- PartitionUpdate containing the values to be validated by registered Index implementationsInvalidRequestException
public Index.Indexer indexerFor(DecoratedKey key, RegularAndStaticColumns columns, int nowInSec, WriteContext ctx, IndexTransaction.Type transactionType)
Index
Indexer
object for updates to a given partition.indexerFor
in interface Index
key
- key of the partition being modifiedcolumns
- the regular and static columns the created indexer will have to deal with.
This can be empty as an update might only contain partition, range and row deletions, but
the indexer is guaranteed to not get any cells for a column that is not part of columns
.nowInSec
- current time of the update operationctx
- WriteContext spanning the update operationtransactionType
- indicates what kind of update is being performed on the base data
i.e. a write time insert/update/delete or the result of compactionnull
if the index is not interested by the update
(this could be because the index doesn't care about that particular partition, doesn't care about
that type of transaction, ...).public void deleteStaleEntry(DecoratedKey indexKey, Clustering<?> indexClustering, DeletionTime deletion, WriteContext ctx)
indexKey
- the partition key in the index tableindexClustering
- the clustering in the index tabledeletion
- deletion timestamp etcctx
- the write context under which to perform the deletionpublic static TableMetadata indexCfsMetadata(TableMetadata baseCfsMetadata, IndexMetadata indexMetadata)
baseCfsMetadata
- indexMetadata
- public static CassandraIndex newIndex(ColumnFamilyStore baseCfs, IndexMetadata indexMetadata)
baseCfs
- indexMetadata
- Copyright © 2009-2021 The Apache Software Foundation