public abstract class CassandraIndex extends java.lang.Object implements Index
Index.Indexer, Index.Searcher| Modifier and Type | Field and Description |
|---|---|
ColumnFamilyStore |
baseCfs |
protected CassandraIndexFunctions |
functions |
protected ColumnFamilyStore |
indexCfs |
protected ColumnDefinition |
indexedColumn |
protected IndexMetadata |
metadata |
static java.util.regex.Pattern |
TARGET_REGEX |
| Modifier | Constructor and Description |
|---|---|
protected |
CassandraIndex(ColumnFamilyStore baseCfs,
IndexMetadata indexDef) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract CBuilder |
buildIndexClusteringPrefix(java.nio.ByteBuffer partitionKey,
ClusteringPrefix 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,
OpOrder.Group opGroup)
Specific to internal indexes, this is called by a
searcher when it encounters a stale entry in the index
|
boolean |
dependsOn(ColumnDefinition 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() |
ColumnDefinition |
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 CFMetaData |
indexCfsMetadata(CFMetaData baseCfsMetadata,
IndexMetadata indexMetadata)
Construct the CFMetadata 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,
PartitionColumns columns,
int nowInSec,
OpOrder.Group opGroup,
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
|
static Pair<ColumnDefinition,IndexTarget.Type> |
parseTarget(CFMetaData cfm,
IndexMetadata indexDef) |
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(ColumnDefinition 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(ColumnDefinition 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.
|
public static final java.util.regex.Pattern TARGET_REGEX
public final ColumnFamilyStore baseCfs
protected IndexMetadata metadata
protected ColumnFamilyStore indexCfs
protected ColumnDefinition indexedColumn
protected CassandraIndexFunctions functions
protected CassandraIndex(ColumnFamilyStore baseCfs, IndexMetadata indexDef)
protected boolean supportsOperator(ColumnDefinition indexedColumn, Operator operator)
indexedColumn - operator - protected abstract CBuilder buildIndexClusteringPrefix(java.nio.ByteBuffer partitionKey, ClusteringPrefix 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 ColumnDefinition getIndexedColumn()
public ClusteringComparator getIndexComparator()
public ColumnFamilyStore getIndexCfs()
public void register(IndexRegistry registry)
Indexpublic java.util.concurrent.Callable<?> getInitializationTask()
IndexgetInitializationTask in interface Indexpublic IndexMetadata getIndexMetadata()
IndexgetIndexMetadata in interface Indexpublic java.util.Optional<ColumnFamilyStore> getBackingTable()
IndexgetBackingTable in interface Indexpublic java.util.concurrent.Callable<java.lang.Void> getBlockingFlushTask()
IndexgetBlockingFlushTask in interface Indexpublic java.util.concurrent.Callable<?> getInvalidateTask()
IndexgetInvalidateTask in interface Indexpublic java.util.concurrent.Callable<?> getMetadataReloadTask(IndexMetadata indexDef)
IndexgetMetadataReloadTask in interface Indexpublic void validate(ReadCommand command) throws InvalidRequestException
Indexvalidate in interface Indexcommand - 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)
IndexgetTruncateTask in interface IndextruncatedAt - timestamp of the truncation operation. This will be the same timestamp used
in the truncation of the base table.public boolean shouldBuildBlocking()
IndexshouldBuildBlocking in interface Indexpublic boolean dependsOn(ColumnDefinition column)
Indexpublic boolean supportsExpression(ColumnDefinition column, Operator operator)
IndexsupportsExpression in interface Indexcolumn - the target column of a search query predicateoperator - the operator of a search query predicatepublic AbstractType<?> customExpressionValueType()
IndexcustomExpressionValueType in interface Indexpublic long getEstimatedResultRows()
IndexgetEstimatedResultRows in interface Indexpublic java.util.function.BiFunction<PartitionIterator,ReadCommand,PartitionIterator> postProcessorFor(ReadCommand command)
postProcessorFor in interface Indexpublic RowFilter getPostIndexQueryFilter(RowFilter filter)
IndexgetPostIndexQueryFilter in interface Indexfilter - the intial filter belonging to a ReadCommandpublic Index.Searcher searcherFor(ReadCommand command)
IndexsearcherFor in interface Indexcommand - the read command being executedpublic void validate(PartitionUpdate update) throws InvalidRequestException
Indexvalidate in interface Indexupdate - PartitionUpdate containing the values to be validated by registered Index implementationsInvalidRequestExceptionpublic Index.Indexer indexerFor(DecoratedKey key, PartitionColumns columns, int nowInSec, OpOrder.Group opGroup, IndexTransaction.Type transactionType)
IndexIndexer object for updates to a given partition.indexerFor in interface Indexkey - 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 operationopGroup - operation group 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, OpOrder.Group opGroup)
indexKey - the partition key in the index tableindexClustering - the clustering in the index tabledeletion - deletion timestamp etcopGroup - the operation under which to perform the deletionpublic static final CFMetaData indexCfsMetadata(CFMetaData baseCfsMetadata, IndexMetadata indexMetadata)
baseCfsMetadata - indexMetadata - public static CassandraIndex newIndex(ColumnFamilyStore baseCfs, IndexMetadata indexMetadata)
baseCfs - indexMetadata - public static Pair<ColumnDefinition,IndexTarget.Type> parseTarget(CFMetaData cfm, IndexMetadata indexDef)
Copyright © 2016 The Apache Software Foundation