Class SSTableReader
- All Implemented Interfaces:
Comparable<SSTableReader>,UnfilteredSource,RefCounted<SSTableReader>,SelfRefCounted<SSTableReader>
- Direct Known Subclasses:
SSTableReaderWithFilter
A reader's SSTableReader.OpenReason describes its current stage in its lifecycle. Note that in parallel to this, there are
two different Descriptor types; TMPLINK and FINAL; the latter corresponds to SSTableReader.OpenReason.NORMAL state readers
and all readers that replace a SSTableReader.OpenReason.NORMAL one. TMPLINK is used for SSTableReader.OpenReason.EARLY state
readers and no others.
When a reader is being compacted, if the result is large its replacement may be opened as SSTableReader.OpenReason.EARLY
before compaction completes in order to present the result to consumers earlier. In this case the reader will itself
be changed to a SSTableReader.OpenReason.MOVED_START state, where its start no longer represents its on-disk minimum key.
This is to permit reads to be directed to only one reader when the two represent the same data.
The SSTableReader.OpenReason.EARLY file can represent a compaction result that is either partially complete and still
in-progress, or a complete and immutable sstable that is part of a larger macro compaction action that has not yet
fully completed.
Currently ALL compaction results at least briefly go through an SSTableReader.OpenReason.EARLY open state prior to completion,
regardless of if early opening is enabled.
Since a reader can be created multiple times over the same shared underlying resources, and the exact resources it
shares between each instance differ subtly, we track the lifetime of any underlying resource with its own reference
count, which each instance takes a Ref to. Each instance then tracks references to itself, and once these
all expire it releases all its Ref to these underlying resources.
There is some shared cleanup behaviour needed only once all readers in a certain stage of their lifecycle
(i.e. SSTableReader.OpenReason.EARLY or SSTableReader.OpenReason.NORMAL opening), and some that must only occur once all readers
of any kind over a single logical sstable have expired. These are managed by the SSTableReader.InstanceTidier and
SSTableReader.GlobalTidy classes at the bottom, and are effectively managed as another resource each instance tracks its
own Ref instance to, to ensure all of these resources are cleaned up safely and can be debugged otherwise.
TODO: fill in details about Tracker and lifecycle interactions for tools, and for compaction strategies
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSSTableReader.Builder<R extends SSTableReader,B extends SSTableReader.Builder<R, B>> A builder of this sstable reader.static classprotected static final classOne instance per SSTableReader we create.static enumstatic classTODO: Move someplace reusablestatic classstatic final classNested 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
FieldsModifier and TypeFieldDescriptionfinal AbstractBounds<Token>protected final FileHandleprotected final DecoratedKeystatic final Comparator<SSTableReader>static final com.google.common.collect.Ordering<SSTableReader>final SerializationHeaderstatic final Comparator<SSTableReader>static final Comparator<SSTableReader>final AtomicBooleanprotected final DecoratedKeystatic final Comparator<SSTableReader>final longmaxDataAge is a timestamp in local server time (e.g.static final Comparator<SSTableReader>static final Comparator<SSTableReader>final SSTableReader.OpenReasonstatic final Comparator<SSTableReader>protected StatsMetadatastatic final TimeUUID.Generator.Factory<SSTableReader.UniqueIdentifier>Fields 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
ConstructorsModifierConstructorDescriptionprotectedSSTableReader(SSTableReader.Builder<?, ?> builder, SSTable.Owner owner) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTo(Ref.IdentityCollection identities) longabstract SSTableReadercloneWithNewStart(DecoratedKey newStart) abstract SSTableReadercloneWithRestoredStart(DecoratedKey restoredStart) protected voidcloseInternalComponent(AutoCloseable closeable) All the resources which should be released upon closing this sstable reader are registered with inSSTableReader.GlobalTidy.intcompareTo(SSTableReader other) voidcreateLinks(String snapshotDirectoryPath) voidcreateLinks(String snapshotDirectoryPath, com.google.common.util.concurrent.RateLimiter rateLimiter) static voidcreateLinks(Descriptor descriptor, Set<Component> components, String snapshotDirectoryPath) static voidcreateLinks(Descriptor descriptor, Set<Component> components, String snapshotDirectoryPath, com.google.common.util.concurrent.RateLimiter limiter) booleanabstract longCalculates an estimate of the number of keys in the sstable represented by this reader.abstract longestimatedKeysForRanges(Collection<Range<Token>> ranges) Calculates an estimate of the number of keys for the given ranges in the sstable represented by this reader.abstract DecoratedKeyfirstKeyBeyond(PartitionPosition token) Finds and returns the first key beyond a given token in this SSTable or null if no such key exists.static longgetApproximateKeyCount(Iterable<SSTableReader> sstables) Calculate approximate key count.intReturns the compression metadata for this sstable.longReturns the amount of memory in bytes used off heap by the compression meta-data.doubledoublelongdoublegetDroppableTombstonesBefore(long gcBefore) doublegetEstimatedDroppableTombstoneRatio(long gcBefore) getFileDataInput(long position) Create aFileDataInputfor the data file of the sstable represented by this reader.getFirst()abstract Iterable<DecoratedKey>getKeySamples(Range<Token> range) Returns sample keys for the provided token range.getLast()longlongintlongMinimum local deletion time in the memtablelongMinimum timestamp of all stored dataintfinal longRetrieves the position while updating the key cache and the stats.final longgetPosition(PartitionPosition key, SSTableReader.Operator op, boolean updateStats) protected longgetPosition(PartitionPosition key, SSTableReader.Operator op, boolean updateStats, SSTableReadsListener listener) Retrieve a position in data file according to the provided key and operator.final longgetPosition(PartitionPosition key, SSTableReader.Operator op, SSTableReadsListener listener) Determine the data positions in this SSTable that cover the given bounds.getPositionsForBoundsIterator(Iterator<AbstractBounds<PartitionPosition>> boundsList) Get a list of data positions in this SSTable that correspond to the given list of bounds.Return an [offset,end) pair that covers the whole file.getPositionsForRanges(Collection<Range<Token>> ranges) Determine the minimal set of sections that can be extracted from this SSTable to cover the given ranges.longprotected abstract AbstractRowIndexEntrygetRowIndexEntry(PartitionPosition key, SSTableReader.Operator op, boolean updateStats, SSTableReadsListener listener) Retrieve an index entry for the partition found according to the provided key and operator.Direct I/O SSTableScanner over the entirety of the sstable.getScanner(Collection<Range<Token>> ranges) Direct I/O SSTableScanner over a defined collection of ranges of tokens.getScanner(Iterator<AbstractBounds<PartitionPosition>> boundsIterator) Direct I/O SSTableScanner over an iterator of bounds.getScanner(Range<Token> range) Direct I/O SSTableScanner over a defined range of tokens.intstatic longgetTotalBytes(Iterable<SSTableReader> sstables) longlongstatic longgetTotalUncompressedBytes(Iterable<SSTableReader> sstables) abstract IVerifiergetVerifier(ColumnFamilyStore cfs, OutputHandler outputHandler, boolean isOffline, IVerifier.Options options) Returns a new verifier for this sstable.inthashCode()voidIncrement the total read count and read rate for this SSTable.booleanintersects(Collection<Range<Token>> ranges) abstract booleanReturns whether methods likeestimatedKeys()orestimatedKeysForRanges(Collection)can return sensible estimations.booleanbooleanbooleanbooleanbooleanbooleanabstract DecoratedKeykeyAtPositionFromSecondaryIndex(long keyPositionFromSecondaryIndex) Reads the key stored at the position saved in SASI.Returns aKeyIteratorover all keys in the sstable.abstract KeyReaderReturns aKeyReaderover all keys in the sstable.longvoidmarkObsolete(Runnable tidier) Mark the sstable as obsolete, i.e., compacted into newer sstables.voidvoidabstract booleanThe method verifies whether the sstable may contain the provided key.booleanWhether the sstable may contain tombstones or if it is guaranteed to not contain any.static SSTableReadermoveAndOpenSSTable(ColumnFamilyStore cfs, Descriptor oldDescriptor, Descriptor newDescriptor, Set<Component> components, boolean copyData) Moves the sstable in oldDescriptor to a new place (with generation etc) in newDescriptor.voidmutateLevelAndReload(int newLevel) Mutate sstable level with a lock to avoid racing with entire-sstable-streaming and then reload sstable metadatavoidmutateRepairedAndReload(long newRepairedAt, TimeUUID newPendingRepair, boolean isTransient) Mutate sstable repair metadata with a lock to avoid racing with entire-sstable-streaming and then reload sstable metadatabooleannewSince(long timestampMillis) Tests if the sstable contains data newer than the given age param (in localhost currentMillis time).protected voidnotifySelected(SSTableReadsListener.SelectionReason reason, SSTableReadsListener localListener, SSTableReader.Operator op, boolean updateStats, AbstractRowIndexEntry entry) A method to be called bygetPosition(PartitionPosition, Operator, boolean, SSTableReadsListener)andgetRowIndexEntry(PartitionPosition, Operator, boolean, SSTableReadsListener)methods when a searched key is found.protected voidnotifySkipped(SSTableReadsListener.SkippingReason reason, SSTableReadsListener localListener, SSTableReader.Operator op, boolean updateStats) A method to be called bygetPosition(PartitionPosition, Operator, boolean, SSTableReadsListener)andgetRowIndexEntry(PartitionPosition, Operator, boolean, SSTableReadsListener)methods when a searched key is not found.longThe length in bytes of the on disk size for this SSTable.longCalculate a total on-disk (compressed) size for the given partition positions.static SSTableReaderopen(SSTable.Owner owner, Descriptor descriptor) static SSTableReaderopen(SSTable.Owner owner, Descriptor descriptor, Set<Component> components, TableMetadataRef metadata) static SSTableReaderopen(SSTable.Owner owner, Descriptor descriptor, Set<Component> components, TableMetadataRef metadata, boolean validate, boolean isOffline) Open an SSTable for readingstatic SSTableReaderopen(SSTable.Owner owner, Descriptor desc, TableMetadataRef metadata) static Collection<SSTableReader>openAll(SSTable.Owner owner, Set<Map.Entry<Descriptor, Set<Component>>> entries, TableMetadataRef metadata) openDataReader(com.google.common.util.concurrent.RateLimiter limiter) static SSTableReaderopenForBatch(SSTable.Owner owner, Descriptor descriptor, Set<Component> components, TableMetadataRef metadata) Open SSTable reader to be used in batch mode(such as sstableloader).static SSTableReaderopenNoValidation(Descriptor descriptor, Set<Component> components, ColumnFamilyStore cfs) static SSTableReaderopenNoValidation(SSTable.Owner owner, Descriptor descriptor, TableMetadataRef metadata) voidoverrideReadMeter(RestorableMeter readMeter) ref()abstract 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).voidReloads the sstable metadata from disk.static voidvoidrunOnClose(Runnable runOnClose) The runnable passed to this method must not be an anonymous or non-static inner class.<R,E extends Exception>
RrunWithLock(CheckedFunction<Descriptor, R, E> task) Execute provided task with sstable lock to avoid racing with index summary redistribution, SEE CASSANDRA-15861.selfRef()voidsetCrcCheckChance(double crcCheckChance) Set the value of CRC check chance.voidvoidsetup(boolean trackHotness) protected List<AutoCloseable>setupInstance(boolean trackHotness) voidstatic voidshutdownBlocking(long timeout, TimeUnit unit) simpleIterator(FileDataInput file, DecoratedKey key, long dataPosition, boolean tombstoneOnly) stats()doubletryRef()voidprotected final <B extends SSTableReader.Builder<?,B>>
BunbuildTo(B builder, boolean sharedCopy) The method sets fields specific to thisSSTableReaderand the parentSSTableon the providedSSTableReader.Builder.longReturns the length in bytes of the (uncompressed) data for this SSTable.voidvoidvalidate()Perform any validation needed for the reader upon creation before returning it from theSSTableReader.Builder.Methods 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
partitionIterator, rowIterator, rowIterator
-
Field Details
-
maxTimestampAscending
-
maxTimestampDescending
-
UNIQUE_IDENTIFIER_FACTORY
public static final TimeUUID.Generator.Factory<SSTableReader.UniqueIdentifier> UNIQUE_IDENTIFIER_FACTORY -
instanceId
-
firstKeyComparator
-
firstKeyOrdering
-
lastKeyComparator
-
idComparator
-
idReverseComparator
-
sizeComparator
-
maxDataAge
public final long maxDataAgemaxDataAge is a timestamp in local server time (e.g. Global.currentTimeMilli) which represents an upper bound to the newest piece of data stored in the sstable. In other words, this sstable does not contain items created later than maxDataAge.The field is not serialized to disk, so relying on it for more than what truncate does is not advised.
When a new sstable is flushed, maxDataAge is set to the time of creation. When a sstable is created from compaction, maxDataAge is set to max of all merged sstables.
The age is in milliseconds since epoc and is local to this host.
-
openReason
-
dfile
-
isSuspect
-
sstableMetadata
-
header
-
first
-
last
-
bounds
-
-
Constructor Details
-
SSTableReader
-
-
Method Details
-
getApproximateKeyCount
Calculate approximate key count. If cardinality estimator is available on all given sstables, then this method use them to estimate key count. If not, then this uses index summaries.- Parameters:
sstables- SSTables to calculate key count- Returns:
- estimated key count
-
open
-
open
-
open
public static SSTableReader open(SSTable.Owner owner, Descriptor descriptor, Set<Component> components, TableMetadataRef metadata) -
openNoValidation
public static SSTableReader openNoValidation(Descriptor descriptor, Set<Component> components, ColumnFamilyStore cfs) -
openNoValidation
public static SSTableReader openNoValidation(SSTable.Owner owner, Descriptor descriptor, TableMetadataRef metadata) -
openForBatch
public static SSTableReader openForBatch(SSTable.Owner owner, Descriptor descriptor, Set<Component> components, TableMetadataRef metadata) Open SSTable reader to be used in batch mode(such as sstableloader). -
open
public static SSTableReader open(SSTable.Owner owner, Descriptor descriptor, Set<Component> components, TableMetadataRef metadata, boolean validate, boolean isOffline) Open an SSTable for reading- Parameters:
owner- owning entitydescriptor- SSTable to opencomponents- Components included with this SSTablemetadata- for this SSTables CFvalidate- Check SSTable for corruption (limited)isOffline- Whether we are opening this SSTable "offline", for example from an external tool or not for inclusion in queries (validations) This stops regenerating BF + Summaries and also disables tracking of hotness for the SSTable.- Returns:
SSTableReader
-
openAll
public static Collection<SSTableReader> openAll(SSTable.Owner owner, Set<Map.Entry<Descriptor, Set<Component>>> entries, TableMetadataRef metadata) -
getFirst
-
getLast
-
getInterval
-
getBounds
-
maybeGetChecksumValidator
- Throws:
IOException
-
maybeGetDigestValidator
- Throws:
IOException
-
getTotalBytes
-
getTotalUncompressedBytes
-
equals
-
hashCode
public int hashCode() -
getFilename
- Overrides:
getFilenamein classSSTable
-
setupOnline
public void setupOnline() -
runWithLock
Execute provided task with sstable lock to avoid racing with index summary redistribution, SEE CASSANDRA-15861.- Parameters:
task- to be guarded by sstable lock- Throws:
E extends Exception
-
setReplaced
public void setReplaced() -
isReplaced
public boolean isReplaced() -
runOnClose
The runnable passed to this method must not be an anonymous or non-static inner class. It can be a lambda or a method reference provided that it does not retain a reference chain to this reader. -
unbuildTo
The method sets fields specific to thisSSTableReaderand the parentSSTableon the providedSSTableReader.Builder. The method is intended to be called from the overloadedunbuildTomethod in subclasses.- Parameters:
builder- the builder on which the fields should be setsharedCopy- whether theSharedCloseableresources should be passed as shared copies or directly; note that the method will overwrite the fields representingSharedCloseableonly if they are not set in the builder yet (the relevant fields in the builder arenull).- Returns:
- the same instance of builder as provided
-
cloneWithRestoredStart
-
cloneWithNewStart
-
getReadMeter
-
closeInternalComponent
All the resources which should be released upon closing this sstable reader are registered with inSSTableReader.GlobalTidy. This method lets close a provided resource explicitly any time and unregister it fromSSTableReader.GlobalTidyso that it is not tried to be released twice.- Parameters:
closeable- a resource to be closed
-
releaseInMemoryComponents
public abstract void releaseInMemoryComponents()This 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 callcloseInternalComponent(AutoCloseable)for each such component. Leaving the implementation empty is valid given there are not such resources to release. -
validate
public void validate()Perform any validation needed for the reader upon creation before returning it from theSSTableReader.Builder. -
getCompressionMetadata
Returns the compression metadata for this sstable. Note that the compression metdata is a resource and should not be closed by the caller. TODO do not return a closeable resource or return a shared copy- Throws:
IllegalStateException- if the sstable is not compressed
-
getCompressionMetadataOffHeapSize
public long getCompressionMetadataOffHeapSize()Returns the amount of memory in bytes used off heap by the compression meta-data.- Returns:
- the amount of memory in bytes used off heap by the compression meta-data
-
estimatedKeys
public abstract long estimatedKeys()Calculates an estimate of the number of keys in the sstable represented by this reader. -
estimatedKeysForRanges
Calculates an estimate of the number of keys for the given ranges in the sstable represented by this reader. -
isEstimationInformative
public abstract boolean isEstimationInformative()Returns whether methods likeestimatedKeys()orestimatedKeysForRanges(Collection)can return sensible estimations. -
getKeySamples
Returns sample keys for the provided token range. -
getPositionsForRanges
public List<SSTableReader.PartitionPositionBounds> getPositionsForRanges(Collection<Range<Token>> ranges) Determine the minimal set of sections that can be extracted from this SSTable to cover the given ranges.- Returns:
- A sorted list of [offset,end) pairs that cover the given ranges in the datafile for this SSTable.
-
getPositionsForBoundsIterator
public List<SSTableReader.PartitionPositionBounds> getPositionsForBoundsIterator(Iterator<AbstractBounds<PartitionPosition>> boundsList) Get a list of data positions in this SSTable that correspond to the given list of bounds. This method will remove non-covered intervals, but will not correct order or overlap in the supplied list, e.g. if bounds overlap, the result will be sections of the data file that repeat the same positions.- Returns:
- A sorted list of [offset,end) pairs corresponding to the given boundsList in the datafile for this SSTable.
-
getPositionsForBounds
public SSTableReader.PartitionPositionBounds getPositionsForBounds(AbstractBounds<PartitionPosition> bounds) Determine the data positions in this SSTable that cover the given bounds.- Returns:
- An [offset,end) pair that cover the given bounds in the datafile for this SSTable, or null if the range is not covered by the sstable or is empty.
-
getPositionsForFullRange
Return an [offset,end) pair that covers the whole file. This could be null if the sstable's moved start has made the sstable effectively empty. -
onDiskSizeForPartitionPositions
public long onDiskSizeForPartitionPositions(Collection<SSTableReader.PartitionPositionBounds> positionBounds) Calculate a total on-disk (compressed) size for the given partition positions. For uncompressed files this is equal to the sum of the size of the covered ranges. For compressed files this is the sum of the size of the chunks that contain the requested ranges and may be significantly bigger than the size of the requested ranges.- Parameters:
positionBounds- a list of [offset,end) pairs that specify the relevant sections of the data file; this must be non-overlapping and in ascending order.
-
getPosition
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.
-
getPosition
public final long getPosition(PartitionPosition key, SSTableReader.Operator op, SSTableReadsListener listener) -
getPosition
public final long getPosition(PartitionPosition key, SSTableReader.Operator op, boolean updateStats) -
getPosition
protected long getPosition(PartitionPosition key, SSTableReader.Operator op, boolean updateStats, SSTableReadsListener listener) Retrieve a position in data file according to the provided key and operator.- 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.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
-
getRowIndexEntry
protected abstract AbstractRowIndexEntry getRowIndexEntry(PartitionPosition key, SSTableReader.Operator op, boolean updateStats, SSTableReadsListener listener) Retrieve an index entry for the partition found according to the provided key and operator.- 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.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
-
simpleIterator
public UnfilteredRowIterator simpleIterator(FileDataInput file, DecoratedKey key, long dataPosition, boolean tombstoneOnly) -
keyReader
Returns aKeyReaderover all keys in the sstable.- Throws:
IOException
-
keyIterator
Returns aKeyIteratorover all keys in the sstable.- Throws:
IOException
-
firstKeyBeyond
Finds and returns the first key beyond a given token in this SSTable or null if no such key exists. -
uncompressedLength
public long uncompressedLength()Returns the length in bytes of the (uncompressed) data for this SSTable. For compressed files, this is not the same thing as the on disk size (seeonDiskLength()). -
tokenSpaceCoverage
public double tokenSpaceCoverage()- Returns:
- the fraction of the token space for which this sstable has content. In the simplest case this is just the
size of the interval returned by
getBounds(), but the sstable may contain "holes" when the locally-owned range is not contiguous (e.g. with vnodes). As this is affected by the local ranges which can change, the token space fraction is calculated at the time of writing the sstable and stored with its metadata. For older sstables that do not contain this metadata field, this method returns NaN.
-
onDiskLength
public long onDiskLength()The length in bytes of the on disk size for this SSTable. For compressed files, this is not the same thing as the data length (seeuncompressedLength()). -
getCrcCheckChance
public double getCrcCheckChance() -
setCrcCheckChance
public void setCrcCheckChance(double crcCheckChance) Set the value of CRC check chance. The argument supplied is obtained from the property of the owning CFS. Called when either the SSTR is initialized, or the CFS's property is updated via JMX -
markObsolete
Mark the sstable as obsolete, i.e., compacted into newer sstables.When calling this function, the caller must ensure that the SSTableReader is not referenced anywhere except for threads holding a reference.
Calling it multiple times is usually buggy.
-
isMarkedCompacted
public boolean isMarkedCompacted() -
markSuspect
public void markSuspect() -
unmarkSuspect
public void unmarkSuspect() -
isMarkedSuspect
public boolean isMarkedSuspect() -
getScanner
Direct I/O SSTableScanner over a defined range of tokens.- Parameters:
range- the range of keys to cover- Returns:
- A Scanner for seeking over the rows of the SSTable.
-
getScanner
Direct I/O SSTableScanner over the entirety of the sstable.- Returns:
- A Scanner over the full content of the SSTable.
-
getScanner
Direct I/O SSTableScanner over a defined collection of ranges of tokens.- Parameters:
ranges- the range of keys to cover- Returns:
- A Scanner for seeking over the rows of the SSTable.
-
getScanner
Direct I/O SSTableScanner over an iterator of bounds.- Parameters:
boundsIterator- the keys to cover- Returns:
- A Scanner for seeking over the rows of the SSTable.
-
getFileDataInput
Create aFileDataInputfor the data file of the sstable represented by this reader. This method returns a newly opened resource which must be closed by the caller.- Parameters:
position- the data input will be opened and seek to this position
-
newSince
public boolean newSince(long timestampMillis) Tests if the sstable contains data newer than the given age param (in localhost currentMillis time). This works in conjunction with maxDataAge which is an upper bound on the data in the sstable represented by this reader.- Returns:
trueiff this sstable contains data that's newer than the given timestamp
-
createLinks
-
createLinks
public void createLinks(String snapshotDirectoryPath, com.google.common.util.concurrent.RateLimiter rateLimiter) -
createLinks
public static void createLinks(Descriptor descriptor, Set<Component> components, String snapshotDirectoryPath) -
createLinks
public static void createLinks(Descriptor descriptor, Set<Component> components, String snapshotDirectoryPath, com.google.common.util.concurrent.RateLimiter limiter) -
isRepaired
public boolean isRepaired() -
keyAtPositionFromSecondaryIndex
public abstract DecoratedKey keyAtPositionFromSecondaryIndex(long keyPositionFromSecondaryIndex) throws IOException Reads 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.- Returns:
- key if found,
nullotherwise - Throws:
IOException
-
isPendingRepair
public boolean isPendingRepair() -
getPendingRepair
-
getRepairedAt
public long getRepairedAt() -
isTransient
public boolean isTransient() -
intersects
-
getEstimatedPartitionSize
-
getEstimatedCellPerPartitionCount
-
getEstimatedDroppableTombstoneRatio
public double getEstimatedDroppableTombstoneRatio(long gcBefore) -
getDroppableTombstonesBefore
public double getDroppableTombstonesBefore(long gcBefore) -
getCompressionRatio
public double getCompressionRatio() -
getMinTimestamp
public long getMinTimestamp()Description copied from interface:UnfilteredSourceMinimum timestamp of all stored data- Specified by:
getMinTimestampin interfaceUnfilteredSource
-
getMaxTimestamp
public long getMaxTimestamp() -
getMinLocalDeletionTime
public long getMinLocalDeletionTime()Description copied from interface:UnfilteredSourceMinimum local deletion time in the memtable- Specified by:
getMinLocalDeletionTimein interfaceUnfilteredSource
-
getMaxLocalDeletionTime
public long getMaxLocalDeletionTime() -
mayHaveTombstones
public boolean mayHaveTombstones()Whether the sstable may contain tombstones or if it is guaranteed to not contain any.Note that having that method return
falseguarantees the sstable has no tombstones whatsoever (so no cell tombstone, no range tombstone maker and no expiring columns), but having it returntruedoesn't guarantee it contains any as it may simply have non-expired cells. -
getMinTTL
public int getMinTTL() -
getMaxTTL
public int getMaxTTL() -
getTotalColumnsSet
public long getTotalColumnsSet() -
getTotalRows
public long getTotalRows() -
getAvgColumnSetPerRow
public int getAvgColumnSetPerRow() -
getSSTableLevel
public int getSSTableLevel() -
mutateLevelAndReload
Mutate sstable level with a lock to avoid racing with entire-sstable-streaming and then reload sstable metadata- Throws:
IOException
-
mutateRepairedAndReload
public void mutateRepairedAndReload(long newRepairedAt, TimeUUID newPendingRepair, boolean isTransient) throws IOException Mutate sstable repair metadata with a lock to avoid racing with entire-sstable-streaming and then reload sstable metadata- Throws:
IOException
-
reloadSSTableMetadata
Reloads the sstable metadata from disk.Called after level is changed on sstable, for example if the sstable is dropped to L0
Might be possible to remove in future versions
- Throws:
IOException
-
getSSTableMetadata
-
openDataReader
-
openDataReader
-
openDataReaderForScan
-
trySkipFileCacheBefore
-
getDataChannel
-
getDataCreationTime
public long getDataCreationTime()- Returns:
- last modified time for data component. 0 if given component does not exist or IO error occurs.
-
incrementReadCount
public void incrementReadCount()Increment the total read count and read rate for this SSTable. This should not be incremented for non-query reads, like compaction. -
stats
-
tryRef
- Specified by:
tryRefin interfaceRefCounted<SSTableReader>- Returns:
- the a new Ref() to the managed object, incrementing its refcount, or null if it is already released
-
selfRef
- Specified by:
selfRefin interfaceSelfRefCounted<SSTableReader>
-
ref
- Specified by:
refin interfaceRefCounted<SSTableReader>
-
setupInstance
-
setup
public void setup(boolean trackHotness) -
overrideReadMeter
-
addTo
-
mayContainAssumingKeyIsInRange
The method verifies whether the sstable may contain the provided key. The method does approximation using Bloom filter if it is present and if it is not, performs accurate check in the index. -
resetTidying
public static void resetTidying() -
moveAndOpenSSTable
public static SSTableReader moveAndOpenSSTable(ColumnFamilyStore cfs, Descriptor oldDescriptor, Descriptor newDescriptor, Set<Component> components, boolean copyData) Moves the sstable in oldDescriptor to a new place (with generation etc) in newDescriptor.All components given will be moved/renamed
-
shutdownBlocking
public static void shutdownBlocking(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException - Throws:
InterruptedExceptionTimeoutException
-
bytesOnDisk
public long bytesOnDisk()- Returns:
- the physical size on disk of all components for this SSTable in bytes
-
logicalBytesOnDisk
public long logicalBytesOnDisk()- Returns:
- the total logical/uncompressed size in bytes of all components for this SSTable
-
maybePersistSSTableReadMeter
public void maybePersistSSTableReadMeter() -
getVerifier
public abstract IVerifier getVerifier(ColumnFamilyStore cfs, OutputHandler outputHandler, boolean isOffline, IVerifier.Options options) Returns a new verifier for this sstable. Note that the reader must match the provided cfs. -
instanceId
-
compareTo
- Specified by:
compareToin interfaceComparable<SSTableReader>
-
notifySelected
protected void notifySelected(SSTableReadsListener.SelectionReason reason, SSTableReadsListener localListener, SSTableReader.Operator op, boolean updateStats, AbstractRowIndexEntry entry) A method to be called bygetPosition(PartitionPosition, Operator, boolean, SSTableReadsListener)andgetRowIndexEntry(PartitionPosition, Operator, boolean, SSTableReadsListener)methods when a searched key is found. It adds a trace message and notify the provided listener. -
notifySkipped
protected void notifySkipped(SSTableReadsListener.SkippingReason reason, SSTableReadsListener localListener, SSTableReader.Operator op, boolean updateStats) A method to be called bygetPosition(PartitionPosition, Operator, boolean, SSTableReadsListener)andgetRowIndexEntry(PartitionPosition, Operator, boolean, SSTableReadsListener)methods when a searched key is not found. It adds a trace message and notify the provided listener.
-