Class Segment
java.lang.Object
org.apache.cassandra.index.sai.disk.v1.segment.Segment
- All Implemented Interfaces:
Closeable,AutoCloseable,SegmentOrdering
Each segment represents an on-disk index structure (balanced tree/terms/postings) flushed by memory limit or token boundaries.
It also helps to reduce resource consumption for read requests as only segments that intersect with read request data
range need to be loaded.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSegment(StorageAttachedIndex index, SSTableContext sstableContext, PerColumnIndexFiles indexFiles, SegmentMetadata metadata) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longbooleanintersects(AbstractBounds<PartitionPosition> keyRange) orderBy(Expression orderer, AbstractBounds<PartitionPosition> keyRange, QueryContext context) Order the on-disk index synchronously and produce an iterator in score orderorderResultsBy(QueryContext context, List<PrimaryKey> results, Expression orderer) Reorder, limit, and put back into original order the results from a single sstablesearch(Expression expression, AbstractBounds<PartitionPosition> keyRange, QueryContext context) Search on-disk index synchronouslytoString()
-
Field Details
-
metadata
-
-
Constructor Details
-
Segment
public Segment(StorageAttachedIndex index, SSTableContext sstableContext, PerColumnIndexFiles indexFiles, SegmentMetadata metadata) throws IOException - Throws:
IOException
-
Segment
-
-
Method Details
-
intersects
- Returns:
- true if current segment intersects with query key range
-
indexFileCacheSize
public long indexFileCacheSize() -
search
public KeyRangeIterator search(Expression expression, AbstractBounds<PartitionPosition> keyRange, QueryContext context) throws IOException Search on-disk index synchronously- Parameters:
expression- to filter on disk indexcontext- to track per sstable cache and per query metrics- Returns:
- range iterator that matches given expression
- Throws:
IOException
-
orderBy
public CloseableIterator<PrimaryKeyWithScore> orderBy(Expression orderer, AbstractBounds<PartitionPosition> keyRange, QueryContext context) throws IOException Order the on-disk index synchronously and produce an iterator in score order- Parameters:
orderer- the expression to use when searching the on disk indexkeyRange- key range specific in read command, used by ANN indexcontext- to track per sstable cache and per query metrics- Returns:
- an iterator of
PrimaryKeyWithScorein score order - Throws:
IOException
-
orderResultsBy
public CloseableIterator<PrimaryKeyWithScore> orderResultsBy(QueryContext context, List<PrimaryKey> results, Expression orderer) throws IOException Description copied from interface:SegmentOrderingReorder, limit, and put back into original order the results from a single sstable- Specified by:
orderResultsByin interfaceSegmentOrdering- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
toString
-