Class BigTableReader
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.big.BigTableReader
- All Implemented Interfaces:
Comparable<SSTableReader>,UnfilteredSource,IndexSummarySupport<BigTableReader>,KeyCacheSupport<BigTableReader>,RefCounted<SSTableReader>,SelfRefCounted<SSTableReader>
public class BigTableReader
extends SSTableReaderWithFilter
implements IndexSummarySupport<BigTableReader>, KeyCacheSupport<BigTableReader>
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) cloneWithNewSummarySamplingLevel(ColumnFamilyStore parent, int samplingLevel) Returns a new SSTableReader with the same properties as this SSTableReader except that a new IndexSummary will be built at the target samplingLevel.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.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.getLowerBoundPrefixFromCache(DecoratedKey partitionKey, boolean isReversed) Should quickly get a lower bound prefix from cache only if everything is already availabe in memory and does not need to be loaded from disk.protected longgetPosition(PartitionPosition key, SSTableReader.Operator op, boolean updateCacheAndStats, SSTableReadsListener listener) Retrieve a position in data file according to the provided key and operator.final RowIndexEntryRetrieves the position while updating the key cache and the stats.getRowIndexEntry(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 the number of entries in the IndexSummary > 2.keyAtPositionFromSecondaryIndex(long keyPositionFromSecondaryIndex) Reads the key stored at the position saved in SASI.Returns aKeyReaderover all keys in the sstable.partitionIterator(ColumnFilter columns, 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 file, DecoratedKey key, RowIndexEntry indexEntry, Slices slices, ColumnFilter selectedColumns, boolean reversed) protected List<AutoCloseable>setupInstance(boolean trackHotness) protected final BigTableReader.BuilderunbuildTo(BigTableReader.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, 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.io.sstable.keycache.KeyCacheSupport
cacheKey, getCachedPosition, getCachedPosition, getCacheKey, getCacheKeyMethods inherited from interface org.apache.cassandra.db.rows.UnfilteredSource
rowIterator
-
Constructor Details
-
BigTableReader
-
-
Method Details
-
setupInstance
- Overrides:
setupInstancein classSSTableReaderWithFilter
-
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
-
getIndexSummary
- Specified by:
getIndexSummaryin interfaceIndexSummarySupport<BigTableReader>
-
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.- Specified by:
rowIteratorin interfaceUnfilteredSource- 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 file, DecoratedKey key, RowIndexEntry indexEntry, Slices slices, ColumnFilter selectedColumns, boolean reversed) -
partitionIterator
public ISSTableScanner partitionIterator(ColumnFilter columns, DataRange dataRange, SSTableReadsListener listener) Description copied from interface:UnfilteredSourceReturns a partition iterator for the given data range.- Specified by:
partitionIteratorin interfaceUnfilteredSource- Parameters:
columns- filter to apply to all returned partitionsdataRange- the partition and clustering range queriedlistener- a listener used to handle internal read events
-
keyReader
Description copied from class:SSTableReaderReturns aKeyReaderover all keys in the sstable.- Specified by:
keyReaderin classSSTableReader- Throws:
IOException
-
firstKeyBeyond
Finds and returns the first key beyond a given token in this SSTable or null if no such key exists.- Specified by:
firstKeyBeyondin classSSTableReader
-
getRowIndexEntry
Retrieves the position while updating the key cache and the stats.- 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 != * EQop- The Operator defining matching keys: the nearest key to the target matching the operator wins.
-
getRowIndexEntry
public RowIndexEntry 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
-
getPosition
protected long getPosition(PartitionPosition key, SSTableReader.Operator op, boolean updateCacheAndStats, SSTableReadsListener listener) Description copied from class:SSTableReaderRetrieve a position in data file according to the provided key and operator.- Overrides:
getPositionin 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 != * EQop- The Operator defining matching keys: the nearest key to the target matching the operator wins.updateCacheAndStats- 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
-
deserializeKeyCacheValue
- Specified by:
deserializeKeyCacheValuein interfaceKeyCacheSupport<BigTableReader>- Throws:
IOException
-
getLowerBoundPrefixFromCache
public ClusteringBound<?> getLowerBoundPrefixFromCache(DecoratedKey partitionKey, boolean isReversed) Description copied from interface:KeyCacheSupportShould quickly get a lower bound prefix from cache only if everything is already availabe in memory and does not need to be loaded from disk.- Specified by:
getLowerBoundPrefixFromCachein interfaceKeyCacheSupport<BigTableReader>
-
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- Returns:
- An estimate of the number of keys in this SSTable based on the index summary.
-
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- Returns:
- An estimate of the number of keys for given ranges in this SSTable.
-
isEstimationInformative
public boolean isEstimationInformative()Returns whether the number of entries in the IndexSummary > 2. At full sampling, this is approximately 1/INDEX_INTERVALth of the keys in this SSTable.- Specified by:
isEstimationInformativein classSSTableReader
-
getKeySamples
Description copied from class:SSTableReaderReturns sample keys for the provided token range.- Specified by:
getKeySamplesin classSSTableReader
-
openIndexReader
-
getIndexFile
-
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
-
unbuildTo
protected final BigTableReader.Builder unbuildTo(BigTableReader.Builder builder, boolean sharedCopy) -
cloneAndReplace
- Specified by:
cloneAndReplacein classSSTableReaderWithFilter
-
cloneWithRestoredStart
- Specified by:
cloneWithRestoredStartin classSSTableReader
-
cloneWithNewStart
- Specified by:
cloneWithNewStartin classSSTableReader
-
cloneWithNewSummarySamplingLevel
public BigTableReader cloneWithNewSummarySamplingLevel(ColumnFamilyStore parent, int samplingLevel) throws IOException Returns a new SSTableReader with the same properties as this SSTableReader except that a new IndexSummary will be built at the target samplingLevel. This (original) SSTableReader instance will be marked as replaced, have its DeletingTask removed, and have its periodic read-meter sync task cancelled.- Specified by:
cloneWithNewSummarySamplingLevelin interfaceIndexSummarySupport<BigTableReader>- Parameters:
samplingLevel- the desired sampling level for the index summary on the new SSTableReader- Returns:
- a new SSTableReader
- Throws:
IOException
-
getKeyCache
- Specified by:
getKeyCachein interfaceKeyCacheSupport<BigTableReader>
-