Class BtiTableReader
java.lang.Object
org.apache.cassandra.io.sstable.SSTable
org.apache.cassandra.io.sstable.format.SSTableReader
org.apache.cassandra.io.sstable.format.SSTableReaderWithFilter
org.apache.cassandra.io.sstable.format.bti.BtiTableReader
- All Implemented Interfaces:
Comparable<SSTableReader>,UnfilteredSource,RefCounted<SSTableReader>,SelfRefCounted<SSTableReader>
Reader of SSTable files in BTI format (see
BtiFormat), written by BtiTableWriter.
SSTableReaders are open()ed by Keyspace.onStart; after that they are created by SSTableWriter.renameAndOpen. Do not re-call open() on existing SSTable files; use the references kept by ColumnFamilyStore post-start instead.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.cassandra.io.sstable.format.SSTableReader
SSTableReader.IndexesBounds, SSTableReader.InstanceTidier, SSTableReader.OpenReason, SSTableReader.Operator, SSTableReader.PartitionPositionBounds, SSTableReader.UniqueIdentifierNested classes/interfaces inherited from class org.apache.cassandra.io.sstable.SSTable
SSTable.OwnerNested classes/interfaces inherited from interface org.apache.cassandra.utils.concurrent.RefCounted
RefCounted.Tidy -
Field Summary
Fields inherited from class org.apache.cassandra.io.sstable.format.SSTableReader
bounds, dfile, first, firstKeyComparator, firstKeyOrdering, header, idComparator, idReverseComparator, instanceId, isSuspect, last, lastKeyComparator, maxDataAge, maxTimestampAscending, maxTimestampDescending, openReason, sizeComparator, sstableMetadata, UNIQUE_IDENTIFIER_FACTORYFields inherited from class org.apache.cassandra.io.sstable.SSTable
chunkCache, components, compression, descriptor, ioOptions, metadata, TOMBSTONE_HISTOGRAM_BIN_SIZE, TOMBSTONE_HISTOGRAM_SPOOL_SIZE, TOMBSTONE_HISTOGRAM_TTL_ROUND_SECONDS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncloneAndReplace(IFilter filter) cloneWithNewStart(DecoratedKey newStart) cloneWithRestoredStart(DecoratedKey restoredStart) longCalculates an estimate of the number of keys in the sstable represented by this reader.longestimatedKeysForRanges(Collection<Range<Token>> ranges) Calculates an estimate of the number of keys for the given ranges in the sstable represented by this reader.protected booleanWhether to filter out data beforeSSTableReader.first.protected booleanWhether to filter out data afterSSTableReader.last.firstKeyBeyond(PartitionPosition token) Finds and returns the first key beyond a given token in this SSTable or null if no such key exists.getKeySamples(Range<Token> range) Returns sample keys for the provided token range.protected org.apache.cassandra.io.sstable.format.bti.TrieIndexEntrygetRowIndexEntry(PartitionPosition key, SSTableReader.Operator operator, boolean updateStats, SSTableReadsListener listener) Retrieve an index entry for the partition found according to the provided key and operator.getVerifier(ColumnFamilyStore cfs, OutputHandler outputHandler, boolean isOffline, IVerifier.Options options) Returns a new verifier for this sstable.booleanReturns whether methods likeSSTableReader.estimatedKeys()orSSTableReader.estimatedKeysForRanges(Collection)can return sensible estimations.keyAtPositionFromSecondaryIndex(long keyPositionFromSecondaryIndex) Reads the key stored at the position saved in SASI.org.apache.cassandra.io.sstable.format.bti.PartitionIteratorReturns aKeyReaderover all keys in the sstable.partitionIterator(ColumnFilter columnFilter, DataRange dataRange, SSTableReadsListener listener) Returns a partition iterator for the given data range.voidThis method is expected to close the components which occupy memory but are not needed when we just want to stream the components (for example, when SSTable is opened with SSTableLoader).rowIterator(DecoratedKey key, Slices slices, ColumnFilter selectedColumns, boolean reversed, SSTableReadsListener listener) Returns a row iterator for the given partition, applying the specified row and column filters.rowIterator(FileDataInput dataFileInput, DecoratedKey key, org.apache.cassandra.io.sstable.format.bti.TrieIndexEntry indexEntry, Slices slices, ColumnFilter selectedColumns, boolean reversed) protected List<AutoCloseable>setupInstance(boolean trackHotness) protected final BtiTableReader.BuilderunbuildTo(BtiTableReader.Builder builder, boolean sharedCopy) Methods inherited from class org.apache.cassandra.io.sstable.format.SSTableReaderWithFilter
getFilterOffHeapSize, getFilterSerializedSize, getFilterTracker, isPresentInFilter, mayContainAssumingKeyIsInRange, notifySelected, notifySkipped, unbuildToMethods inherited from class org.apache.cassandra.io.sstable.format.SSTableReader
addTo, bytesOnDisk, closeInternalComponent, compareTo, createLinks, createLinks, createLinks, createLinks, equals, getApproximateKeyCount, getAvgColumnSetPerRow, getBounds, getCompressionMetadata, getCompressionMetadataOffHeapSize, getCompressionRatio, getCrcCheckChance, getDataChannel, getDataCreationTime, getDroppableTombstonesBefore, getEstimatedCellPerPartitionCount, getEstimatedDroppableTombstoneRatio, getEstimatedPartitionSize, getFileDataInput, getFilename, getFirst, getInterval, getLast, getMaxLocalDeletionTime, getMaxTimestamp, getMaxTTL, getMinLocalDeletionTime, getMinTimestamp, getMinTTL, getPendingRepair, getPosition, getPosition, getPosition, getPosition, getPositionsForBounds, getPositionsForBoundsIterator, getPositionsForFullRange, getPositionsForRanges, getReadMeter, getRepairedAt, getScanner, getScanner, getScanner, getScanner, getSSTableLevel, getSSTableMetadata, getTotalBytes, getTotalColumnsSet, getTotalRows, getTotalUncompressedBytes, hashCode, incrementReadCount, instanceId, intersects, isMarkedCompacted, isMarkedSuspect, isPendingRepair, isRepaired, isReplaced, isTransient, keyIterator, logicalBytesOnDisk, markObsolete, markSuspect, maybeGetChecksumValidator, maybeGetDigestValidator, maybePersistSSTableReadMeter, mayHaveTombstones, moveAndOpenSSTable, mutateLevelAndReload, mutateRepairedAndReload, newSince, onDiskLength, onDiskSizeForPartitionPositions, open, open, open, open, openAll, openDataReader, openDataReader, openDataReaderForScan, openForBatch, openNoValidation, openNoValidation, overrideReadMeter, ref, reloadSSTableMetadata, resetTidying, runOnClose, runWithLock, selfRef, setCrcCheckChance, setReplaced, setup, setupOnline, shutdownBlocking, simpleIterator, stats, tokenSpaceCoverage, tryRef, trySkipFileCacheBefore, unbuildTo, uncompressedLength, unmarkSuspect, validateMethods inherited from class org.apache.cassandra.io.sstable.SSTable
addComponents, copy, decorateKey, getAllFilePaths, getColumnFamilyName, getComponents, getId, getKeyspaceName, getPartitioner, getStreamingComponents, hardlink, metadata, owner, registerComponents, rename, toString, tryComponentFromFilename, tryComponentFromFilename, tryDescriptorFromFile, unbuildTo, unregisterComponents, validateRepairedMetadataMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.cassandra.db.rows.UnfilteredSource
rowIterator
-
Constructor Details
-
BtiTableReader
-
-
Method Details
-
unbuildTo
protected final BtiTableReader.Builder unbuildTo(BtiTableReader.Builder builder, boolean sharedCopy) -
setupInstance
- Overrides:
setupInstancein classSSTableReaderWithFilter
-
filterFirst
protected boolean filterFirst()Whether to filter out data beforeSSTableReader.first. Needed for sources of data in a compaction, where the relevant output is opened early -- in this case the sstable's start is changed, but the data can still be found in the file. Range and point queries must filter it out. -
filterLast
protected boolean filterLast()Whether to filter out data afterSSTableReader.last. Early-open sstables may contain data beyond the switch point (because an early-opened sstable is not ready until buffers have been flushed), and leaving that data visible will give a redundant copy with all associated overheads. -
estimatedKeys
public long estimatedKeys()Description copied from class:SSTableReaderCalculates an estimate of the number of keys in the sstable represented by this reader.- Specified by:
estimatedKeysin classSSTableReader
-
getRowIndexEntry
protected org.apache.cassandra.io.sstable.format.bti.TrieIndexEntry getRowIndexEntry(PartitionPosition key, SSTableReader.Operator operator, boolean updateStats, SSTableReadsListener listener) Description copied from class:SSTableReaderRetrieve an index entry for the partition found according to the provided key and operator.- Specified by:
getRowIndexEntryin classSSTableReader- Parameters:
key- The key to apply as the rhs to the given Operator. A 'fake' key is allowed to allow key selection by token bounds but only if op != * EQoperator- The Operator defining matching keys: the nearest key to the target matching the operator wins.updateStats- true if updating stats and cachelistener- a listener used to handle internal events- Returns:
- The index entry corresponding to the key, or null if the key is not present
-
keyAtPositionFromSecondaryIndex
public DecoratedKey keyAtPositionFromSecondaryIndex(long keyPositionFromSecondaryIndex) throws IOException Description copied from class:SSTableReaderReads the key stored at the position saved in SASI.When SASI is created, it uses key locations retrieved from
KeyReader.keyPositionForSecondaryIndex(). This method is to read the key stored at such position. It is up to the concrete SSTable format implementation what that position means and which file it refers. The only requirement is that it is consistent with whatKeyReader.keyPositionForSecondaryIndex()returns.- Specified by:
keyAtPositionFromSecondaryIndexin classSSTableReader- Returns:
- key if found,
nullotherwise - Throws:
IOException
-
scrubPartitionsIterator
- Throws:
IOException
-
keyReader
Description copied from class:SSTableReaderReturns aKeyReaderover all keys in the sstable.- Specified by:
keyReaderin classSSTableReader- Throws:
IOException
-
getKeySamples
Description copied from class:SSTableReaderReturns sample keys for the provided token range.- Specified by:
getKeySamplesin classSSTableReader
-
estimatedKeysForRanges
Description copied from class:SSTableReaderCalculates an estimate of the number of keys for the given ranges in the sstable represented by this reader.- Specified by:
estimatedKeysForRangesin classSSTableReader
-
rowIterator
public UnfilteredRowIterator rowIterator(DecoratedKey key, Slices slices, ColumnFilter selectedColumns, boolean reversed, SSTableReadsListener listener) Description copied from interface:UnfilteredSourceReturns a row iterator for the given partition, applying the specified row and column filters.- Parameters:
key- the partition keyslices- the row ranges to returnselectedColumns- filter to apply to all returned partitionsreversed- true if the content should be returned in reverse orderlistener- a listener used to handle internal read events
-
rowIterator
public UnfilteredRowIterator rowIterator(FileDataInput dataFileInput, DecoratedKey key, org.apache.cassandra.io.sstable.format.bti.TrieIndexEntry indexEntry, Slices slices, ColumnFilter selectedColumns, boolean reversed) -
cloneAndReplace
- Specified by:
cloneAndReplacein classSSTableReaderWithFilter
-
cloneWithRestoredStart
- Specified by:
cloneWithRestoredStartin classSSTableReader
-
cloneWithNewStart
- Specified by:
cloneWithNewStartin classSSTableReader
-
firstKeyBeyond
Description copied from class:SSTableReaderFinds and returns the first key beyond a given token in this SSTable or null if no such key exists.- Specified by:
firstKeyBeyondin classSSTableReader
-
releaseInMemoryComponents
public void releaseInMemoryComponents()Description copied from class:SSTableReaderThis method is expected to close the components which occupy memory but are not needed when we just want to stream the components (for example, when SSTable is opened with SSTableLoader). The method should callSSTableReader.closeInternalComponent(AutoCloseable)for each such component. Leaving the implementation empty is valid given there are not such resources to release.- Specified by:
releaseInMemoryComponentsin classSSTableReader
-
isEstimationInformative
public boolean isEstimationInformative()Description copied from class:SSTableReaderReturns whether methods likeSSTableReader.estimatedKeys()orSSTableReader.estimatedKeysForRanges(Collection)can return sensible estimations.- Specified by:
isEstimationInformativein classSSTableReader
-
partitionIterator
public UnfilteredPartitionIterator partitionIterator(ColumnFilter columnFilter, DataRange dataRange, SSTableReadsListener listener) Description copied from interface:UnfilteredSourceReturns a partition iterator for the given data range.- Parameters:
columnFilter- filter to apply to all returned partitionsdataRange- the partition and clustering range queriedlistener- a listener used to handle internal read events
-
getVerifier
public IVerifier getVerifier(ColumnFamilyStore cfs, OutputHandler outputHandler, boolean isOffline, IVerifier.Options options) Description copied from class:SSTableReaderReturns a new verifier for this sstable. Note that the reader must match the provided cfs.- Specified by:
getVerifierin classSSTableReader
-