Package org.apache.cassandra.io.sstable
Class SSTable
- java.lang.Object
-
- org.apache.cassandra.io.sstable.SSTable
-
- Direct Known Subclasses:
SSTableReader
,SSTableWriter
,SSTableZeroCopyWriter
public abstract class SSTable extends java.lang.Object
This class represents an abstract sstable on disk whose keys and corresponding partitions are stored in aSSTableFormat.Components.DATA
file in order as imposed byDecoratedKey.comparator
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SSTable.Builder<S extends SSTable,B extends SSTable.Builder<S,B>>
A builder of this sstable representation.static interface
SSTable.Owner
-
Field Summary
Fields Modifier and Type Field Description ChunkCache
chunkCache
protected java.util.Set<Component>
components
boolean
compression
Descriptor
descriptor
IOOptions
ioOptions
protected TableMetadataRef
metadata
static int
TOMBSTONE_HISTOGRAM_BIN_SIZE
static int
TOMBSTONE_HISTOGRAM_SPOOL_SIZE
static int
TOMBSTONE_HISTOGRAM_TTL_ROUND_SECONDS
-
Constructor Summary
Constructors Constructor Description SSTable(SSTable.Builder<?,?> builder, SSTable.Owner owner)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addComponents(java.util.Collection<Component> newComponents)
Registers new custom components.static void
copy(Descriptor tmpdesc, Descriptor newdesc, java.util.Set<Component> components)
DecoratedKey
decorateKey(java.nio.ByteBuffer key)
java.util.List<java.lang.String>
getAllFilePaths()
abstract AbstractBounds<Token>
getBounds()
java.lang.String
getColumnFamilyName()
java.util.Set<Component>
getComponents()
java.lang.String
getFilename()
abstract DecoratedKey
getFirst()
java.lang.String
getKeyspaceName()
abstract DecoratedKey
getLast()
IPartitioner
getPartitioner()
java.util.Set<Component>
getStreamingComponents()
Returns all SSTable components that should be streamed.static void
hardlink(Descriptor tmpdesc, Descriptor newdesc, java.util.Set<Component> components)
TableMetadata
metadata()
java.util.Optional<SSTable.Owner>
owner()
void
registerComponents(java.util.Collection<Component> newComponents, Tracker tracker)
Registers new custom components into sstable and update size trackingstatic void
rename(Descriptor tmpdesc, Descriptor newdesc, java.util.Set<Component> components)
java.lang.String
toString()
static Pair<Descriptor,Component>
tryComponentFromFilename(File file)
Parse a sstable filename into both aDescriptor
andComponent
object.static Pair<Descriptor,Component>
tryComponentFromFilename(File file, java.lang.String keyspace, java.lang.String table)
Parse a sstable filename into both aDescriptor
andComponent
object.static Descriptor
tryDescriptorFromFile(File file)
Parse a sstable filename into aDescriptor
object.protected <B extends SSTable.Builder<?,B>>
BunbuildTo(B builder, boolean sharedCopy)
The method sets fields for this sstable representation on the providedSSTable.Builder
.void
unregisterComponents(java.util.Collection<Component> removeComponents, Tracker tracker)
Unregisters custom components from sstable and update size trackingstatic void
validateRepairedMetadata(long repairedAt, TimeUUID pendingRepair, boolean isTransient)
-
-
-
Field Detail
-
TOMBSTONE_HISTOGRAM_BIN_SIZE
public static final int TOMBSTONE_HISTOGRAM_BIN_SIZE
- See Also:
- Constant Field Values
-
TOMBSTONE_HISTOGRAM_SPOOL_SIZE
public static final int TOMBSTONE_HISTOGRAM_SPOOL_SIZE
- See Also:
- Constant Field Values
-
TOMBSTONE_HISTOGRAM_TTL_ROUND_SECONDS
public static final int TOMBSTONE_HISTOGRAM_TTL_ROUND_SECONDS
-
descriptor
public final Descriptor descriptor
-
components
protected final java.util.Set<Component> components
-
compression
public final boolean compression
-
metadata
protected final TableMetadataRef metadata
-
chunkCache
public final ChunkCache chunkCache
-
ioOptions
public final IOOptions ioOptions
-
-
Constructor Detail
-
SSTable
public SSTable(SSTable.Builder<?,?> builder, SSTable.Owner owner)
-
-
Method Detail
-
owner
public final java.util.Optional<SSTable.Owner> owner()
-
rename
public static void rename(Descriptor tmpdesc, Descriptor newdesc, java.util.Set<Component> components)
-
copy
public static void copy(Descriptor tmpdesc, Descriptor newdesc, java.util.Set<Component> components)
-
hardlink
public static void hardlink(Descriptor tmpdesc, Descriptor newdesc, java.util.Set<Component> components)
-
getFirst
public abstract DecoratedKey getFirst()
-
getLast
public abstract DecoratedKey getLast()
-
getBounds
public abstract AbstractBounds<Token> getBounds()
-
getComponents
public java.util.Set<Component> getComponents()
-
getStreamingComponents
public java.util.Set<Component> getStreamingComponents()
Returns all SSTable components that should be streamed.
-
metadata
public TableMetadata metadata()
-
getPartitioner
public IPartitioner getPartitioner()
-
decorateKey
public DecoratedKey decorateKey(java.nio.ByteBuffer key)
-
getFilename
public java.lang.String getFilename()
-
getColumnFamilyName
public java.lang.String getColumnFamilyName()
-
getKeyspaceName
public java.lang.String getKeyspaceName()
-
getAllFilePaths
public java.util.List<java.lang.String> getAllFilePaths()
-
unbuildTo
protected final <B extends SSTable.Builder<?,B>> B unbuildTo(B builder, boolean sharedCopy)
The method sets fields for this sstable representation on the providedSSTable.Builder
. The method is intended to be called from the overloadedunbuildTo
method in subclasses.- Parameters:
builder
- the builder on which the fields should be setsharedCopy
- whether theSharedCloseable
resources should be passed as shared copies or directly; note that the method will overwrite the fields representingSharedCloseable
only if they are not set in the builder yet (the relevant fields in the builder arenull
). AlthoughSSTable
does not keep any references to resources, the parameters is added for the possible future fields and for consistency with the overloaded implementations in subclasses- Returns:
- the same instance of builder as provided
-
tryComponentFromFilename
public static Pair<Descriptor,Component> tryComponentFromFilename(File file)
Parse a sstable filename into both aDescriptor
andComponent
object.- Parameters:
file
- the filename to parse.- Returns:
- a pair of the
Descriptor
andComponent
corresponding tofile
if it corresponds to a valid and supported sstable filename,null
otherwise. Note that components of an unknown type will be returned as CUSTOM ones.
-
tryComponentFromFilename
public static Pair<Descriptor,Component> tryComponentFromFilename(File file, java.lang.String keyspace, java.lang.String table)
Parse a sstable filename into both aDescriptor
andComponent
object.- Parameters:
file
- the filename to parse.keyspace
- The keyspace name of the file.table
- The table name of the file.- Returns:
- a pair of the
Descriptor
andComponent
corresponding tofile
if it corresponds to a valid and supported sstable filename,null
otherwise. Note that components of an unknown type will be returned as CUSTOM ones.
-
tryDescriptorFromFile
public static Descriptor tryDescriptorFromFile(File file)
Parse a sstable filename into aDescriptor
object.Note that this method ignores the component part of the filename; if this is not what you want, use
tryComponentFromFilename(org.apache.cassandra.io.util.File)
instead.- Parameters:
file
- the filename to parse.- Returns:
- the
Descriptor
corresponding tofile
if it corresponds to a valid and supported sstable filename,null
otherwise.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
validateRepairedMetadata
public static void validateRepairedMetadata(long repairedAt, TimeUUID pendingRepair, boolean isTransient)
-
addComponents
public void addComponents(java.util.Collection<Component> newComponents)
Registers new custom components. Used by custom compaction strategies. Adding a component for the second time is a no-op. Don't remove this - this method is a part of the public API, intended for use by custom compaction strategies.- Parameters:
newComponents
- collection of components to be added
-
registerComponents
public void registerComponents(java.util.Collection<Component> newComponents, Tracker tracker)
Registers new custom components into sstable and update size tracking- Parameters:
newComponents
- collection of components to be addedtracker
- used to update on-disk size metrics
-
unregisterComponents
public void unregisterComponents(java.util.Collection<Component> removeComponents, Tracker tracker)
Unregisters custom components from sstable and update size tracking- Parameters:
removeComponents
- collection of components to be removetracker
- used to update on-disk size metrics
-
-