Class TrieMemoryIndex
java.lang.Object
org.apache.cassandra.index.sai.memory.MemoryIndex
org.apache.cassandra.index.sai.memory.TrieMemoryIndex
- All Implemented Interfaces:
MemtableOrdering
This is an in-memory index using the
InMemoryTrie to store a ByteComparable
representation of the indexed values. Data is stored on-heap or off-heap and follows the
settings of the TrieMemtable to determine where.-
Field Summary
Fields inherited from class org.apache.cassandra.index.sai.memory.MemoryIndex
index -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongadd(DecoratedKey key, Clustering<?> clustering, ByteBuffer value) Adds an index value to the in-memory indexbooleanisEmpty()iterator()Returns anIteratorover the entire dataset contained in the trie.orderBy(QueryContext queryContext, Expression orderer, AbstractBounds<PartitionPosition> keyRange) Order the index based on the given orderer (expression).orderResultsBy(QueryContext context, List<PrimaryKey> results, Expression orderer) Order the given list ofPrimaryKeyresults corresponding to the given orderer.search(QueryContext queryContext, Expression expression, AbstractBounds<PartitionPosition> keyRange) Search for an expression in the in-memory index within theAbstractBoundsdefined by keyRange.longupdate(DecoratedKey key, Clustering<?> clustering, ByteBuffer oldValue, ByteBuffer newValue) writeDirect(IndexDescriptor indexDescriptor, IndexIdentifier indexIdentifier, Function<PrimaryKey, Integer> postingTransformer)
-
Constructor Details
-
TrieMemoryIndex
-
-
Method Details
-
add
Adds an index value to the in-memory index- Specified by:
addin classMemoryIndex- Parameters:
key- partition key for the indexed valueclustering- clustering for the indexed valuevalue- indexed value- Returns:
- amount of heap allocated by the new value
-
update
public long update(DecoratedKey key, Clustering<?> clustering, ByteBuffer oldValue, ByteBuffer newValue) - Specified by:
updatein classMemoryIndex
-
search
public KeyRangeIterator search(QueryContext queryContext, Expression expression, AbstractBounds<PartitionPosition> keyRange) Search for an expression in the in-memory index within theAbstractBoundsdefined by keyRange. This can either be an exact match or a range match.- Specified by:
searchin classMemoryIndex- Parameters:
expression- theExpressionto search forkeyRange- theAbstractBoundscontaining the key range to restrict the search to- Returns:
- a
KeyRangeIteratorcontaining the search results
-
iterator
Returns anIteratorover the entire dataset contained in the trie. This is used when the index is flushed to disk.- Specified by:
iteratorin classMemoryIndex- Returns:
- the iterator containing the trie data
-
writeDirect
public SegmentMetadata.ComponentMetadataMap writeDirect(IndexDescriptor indexDescriptor, IndexIdentifier indexIdentifier, Function<PrimaryKey, Integer> postingTransformer) - Specified by:
writeDirectin classMemoryIndex
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin classMemoryIndex
-
getMinTerm
- Specified by:
getMinTermin classMemoryIndex
-
getMaxTerm
- Specified by:
getMaxTermin classMemoryIndex
-
orderBy
public CloseableIterator<PrimaryKeyWithScore> orderBy(QueryContext queryContext, Expression orderer, AbstractBounds<PartitionPosition> keyRange) Description copied from interface:MemtableOrderingOrder the index based on the given orderer (expression).- Parameters:
queryContext- - the query contextorderer- - the expression to order bykeyRange- - the key range to search- Returns:
- an iterator over the results in score order.
-
orderResultsBy
public CloseableIterator<PrimaryKeyWithScore> orderResultsBy(QueryContext context, List<PrimaryKey> results, Expression orderer) Description copied from interface:MemtableOrderingOrder the given list ofPrimaryKeyresults corresponding to the given orderer. Returns an iterator over the results in score order. Assumes that the given spans the same rows as the implementing index's segment.
-