Package org.apache.cassandra.index.sai
Class StorageAttachedIndexGroup
java.lang.Object
org.apache.cassandra.index.sai.StorageAttachedIndexGroup
- All Implemented Interfaces:
Index.Group,INotificationConsumer
@ThreadSafe
public class StorageAttachedIndexGroup
extends Object
implements Index.Group, INotificationConsumer
Orchestrates building of storage-attached indices, and manages lifecycle of resources shared between them.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.cassandra.index.Index.Group
Index.Group.Key -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specifiedIndexas a member of this group.booleancontainsIndex(Index index) Returns if this group contains the specifiedIndex.longReturns the SSTable-attachedComponents created by this index group.getFlushObserver(Descriptor descriptor, LifecycleNewTracker tracker, TableMetadata tableMetadata) Get flush observer to observe partition/cell events generated by flushing SSTable (memtable flush or compaction).Returns the indexes that are members of this group.static StorageAttachedIndexGroupgetLiveComponents(SSTableReader sstable, Collection<StorageAttachedIndex> indices) voidhandleNotification(INotification notification, Object sender) booleanhandles(IndexTransaction.Type type) indexerFor(Predicate<Index> indexSelector, DecoratedKey key, RegularAndStaticColumns columns, long nowInSec, WriteContext ctx, IndexTransaction.Type transactionType, Memtable memtable) Creates an newIndexerobject for updates to a given partition.voidCalled when the table associated with this group has been invalidated or all indexes in the group are removed.booleanReturns whether this group can only ever contain a single index.metadata()intopen index files by checking number ofSSTableContextandSSTableIndex, so transient open files during validation and files that are still open for in-flight requests will not be tracked.queryPlanFor(RowFilter rowFilter) Returns a newIndex.QueryPlanfor the specifiedRowFilter, ornullif none of the indexes in this group supports the expression in the row filter.voidremoveIndex(Index index) Removes the specifiedIndexfrom the members of this group.voidreset()Simulate the index going through a restart of nodebooleanWhether this index group supports sharding when flushing memtables, e.g.table()longintintintvoidsimulate index loading on restart with index file validationbooleanvalidateSSTableAttachedIndexes(Collection<SSTableReader> sstables, boolean throwOnIncomplete, boolean validateChecksum) Validates all indexes in the group against the specified SSTables.
-
Field Details
-
GROUP_KEY
-
-
Method Details
-
getIndexGroup
-
getIndexes
Description copied from interface:Index.GroupReturns the indexes that are members of this group.- Specified by:
getIndexesin interfaceIndex.Group- Returns:
- the indexes that are members of this group
-
addIndex
Description copied from interface:Index.GroupAdds the specifiedIndexas a member of this group.- Specified by:
addIndexin interfaceIndex.Group- Parameters:
index- the index to be added
-
removeIndex
Description copied from interface:Index.GroupRemoves the specifiedIndexfrom the members of this group.- Specified by:
removeIndexin interfaceIndex.Group- Parameters:
index- the index to be removed
-
invalidate
public void invalidate()Description copied from interface:Index.GroupCalled when the table associated with this group has been invalidated or all indexes in the group are removed. Implementations should dispose of any resources tied to the lifecycle of theIndex.Group.- Specified by:
invalidatein interfaceIndex.Group
-
containsIndex
Description copied from interface:Index.GroupReturns if this group contains the specifiedIndex.- Specified by:
containsIndexin interfaceIndex.Group- Parameters:
index- the index to be removed- Returns:
trueif this group containsindex,falseotherwise
-
isSingleton
public boolean isSingleton()Description copied from interface:Index.GroupReturns whether this group can only ever contain a single index.- Specified by:
isSingletonin interfaceIndex.Group- Returns:
trueif this group only contains a single index,falseotherwise
-
indexerFor
public Index.Indexer indexerFor(Predicate<Index> indexSelector, DecoratedKey key, RegularAndStaticColumns columns, long nowInSec, WriteContext ctx, IndexTransaction.Type transactionType, Memtable memtable) Description copied from interface:Index.GroupCreates an newIndexerobject for updates to a given partition.- Specified by:
indexerForin interfaceIndex.Group- Parameters:
indexSelector- a predicate selecting the targeted memberskey- 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 ofcolumns.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 compactionmemtable- theMemtableto which the updates are being applied ornullif the source of the updates is an existingSSTable- Returns:
- the newly created indexer or
nullif 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, ...).
-
queryPlanFor
Description copied from interface:Index.GroupReturns a newIndex.QueryPlanfor the specifiedRowFilter, ornullif none of the indexes in this group supports the expression in the row filter.- Specified by:
queryPlanForin interfaceIndex.Group- Parameters:
rowFilter- a row filter- Returns:
- a new query plan for the specified
RowFilterif it's supported,nullotherwise
-
getFlushObserver
public SSTableFlushObserver getFlushObserver(Descriptor descriptor, LifecycleNewTracker tracker, TableMetadata tableMetadata) Description copied from interface:Index.GroupGet flush observer to observe partition/cell events generated by flushing SSTable (memtable flush or compaction).- Specified by:
getFlushObserverin interfaceIndex.Group- Parameters:
descriptor- The descriptor of the sstable observer is requested for.tracker- TheLifecycleNewTrackerassociated with the SSTable being writtentableMetadata- The immutable metadata of the table at the moment the SSTable is flushed- Returns:
- SSTable flush observer.
-
handles
- Specified by:
handlesin interfaceIndex.Group- Parameters:
type- index transaction type- Returns:
- true if index will be able to handle given index transaction type
-
getComponents
Description copied from interface:Index.GroupReturns the SSTable-attachedComponents created by this index group.- Specified by:
getComponentsin interfaceIndex.Group- Returns:
- the SSTable components created by this group
-
getLiveComponents
public static Set<Component> getLiveComponents(SSTableReader sstable, Collection<StorageAttachedIndex> indices) -
handleNotification
- Specified by:
handleNotificationin interfaceINotificationConsumer
-
validateSSTableAttachedIndexes
public boolean validateSSTableAttachedIndexes(Collection<SSTableReader> sstables, boolean throwOnIncomplete, boolean validateChecksum) Description copied from interface:Index.GroupValidates all indexes in the group against the specified SSTables.- Specified by:
validateSSTableAttachedIndexesin interfaceIndex.Group- Parameters:
sstables- SSTables for which indexes in the group should be builtthrowOnIncomplete- whether to throw an error if any index in the group is incompletevalidateChecksum- whether checksum will be tested as part of the validation- Returns:
- true if all indexes in the group are complete and valid
false if any index is incomplete and
throwOnIncompleteis false
-
supportsL0Shards
public boolean supportsL0Shards()Description copied from interface:Index.GroupWhether this index group supports sharding when flushing memtables, e.g. level 0 of UCS.- Specified by:
supportsL0Shardsin interfaceIndex.Group- Returns:
- true iff all indexes in the group support L0 sharding.
-
openIndexFiles
public int openIndexFiles()open index files by checking number ofSSTableContextandSSTableIndex, so transient open files during validation and files that are still open for in-flight requests will not be tracked.- Returns:
- total number of open files for all
StorageAttachedIndexes.
-
diskUsage
public long diskUsage()- Returns:
- total disk usage (in bytes) of all per-sstable index files
-
totalIndexBuildsInProgress
public int totalIndexBuildsInProgress()- Returns:
- count of indexes building
-
totalQueryableIndexCount
public int totalQueryableIndexCount()- Returns:
- count of queryable indexes
-
totalIndexCount
public int totalIndexCount()- Returns:
- count of indexes
-
totalDiskUsage
public long totalDiskUsage()- Returns:
- total disk usage of all per-sstable index files and per-column index files
-
metadata
-
table
-
sstableContextManager
-
unsafeReload
public void unsafeReload()simulate index loading on restart with index file validation -
reset
public void reset()Simulate the index going through a restart of node
-