Class SSTable

java.lang.Object
org.apache.cassandra.io.sstable.SSTable
Direct Known Subclasses:
SSTableReader, SSTableWriter, SSTableZeroCopyWriter

public abstract class SSTable extends Object
This class represents an abstract sstable on disk whose keys and corresponding partitions are stored in a SSTableFormat.Components.DATA file in order as imposed by DecoratedKey.comparator.
  • Field Details

    • TOMBSTONE_HISTOGRAM_BIN_SIZE

      public static final int TOMBSTONE_HISTOGRAM_BIN_SIZE
      See Also:
    • TOMBSTONE_HISTOGRAM_SPOOL_SIZE

      public static final int TOMBSTONE_HISTOGRAM_SPOOL_SIZE
      See Also:
    • TOMBSTONE_HISTOGRAM_TTL_ROUND_SECONDS

      public static final int TOMBSTONE_HISTOGRAM_TTL_ROUND_SECONDS
    • descriptor

      public final Descriptor descriptor
    • components

      protected final Set<Component> components
    • compression

      public final boolean compression
    • metadata

      protected final TableMetadataRef metadata
    • chunkCache

      public final ChunkCache chunkCache
    • ioOptions

      public final IOOptions ioOptions
  • Constructor Details

  • Method Details

    • owner

      public final Optional<SSTable.Owner> owner()
    • rename

      public static void rename(Descriptor tmpdesc, Descriptor newdesc, Set<Component> components)
    • copy

      public static void copy(Descriptor tmpdesc, Descriptor newdesc, Set<Component> components)
    • hardlink

      public static void hardlink(Descriptor tmpdesc, Descriptor newdesc, Set<Component> components)
    • getFirst

      public abstract DecoratedKey getFirst()
    • getLast

      public abstract DecoratedKey getLast()
    • getBounds

      public abstract AbstractBounds<Token> getBounds()
    • getComponents

      public Set<Component> getComponents()
    • getStreamingComponents

      public Set<Component> getStreamingComponents()
      Returns all SSTable components that should be streamed.
    • metadata

      public TableMetadata metadata()
    • getPartitioner

      public IPartitioner getPartitioner()
    • decorateKey

      public DecoratedKey decorateKey(ByteBuffer key)
    • getFilename

      public String getFilename()
    • getColumnFamilyName

      public String getColumnFamilyName()
    • getKeyspaceName

      public String getKeyspaceName()
    • getId

      public SSTableId getId()
    • getAllFilePaths

      public List<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 provided SSTable.Builder. The method is intended to be called from the overloaded unbuildTo method in subclasses.
      Parameters:
      builder - the builder on which the fields should be set
      sharedCopy - whether the SharedCloseable resources should be passed as shared copies or directly; note that the method will overwrite the fields representing SharedCloseable only if they are not set in the builder yet (the relevant fields in the builder are null). Although SSTable 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 a Descriptor and Component object.
      Parameters:
      file - the filename to parse.
      Returns:
      a pair of the Descriptor and Component corresponding to file 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, String keyspace, String table)
      Parse a sstable filename into both a Descriptor and Component 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 and Component corresponding to file 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 a Descriptor 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 to file if it corresponds to a valid and supported sstable filename, null otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • validateRepairedMetadata

      public static void validateRepairedMetadata(long repairedAt, TimeUUID pendingRepair, boolean isTransient)
    • addComponents

      public void addComponents(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(Collection<Component> newComponents, Tracker tracker)
      Registers new custom components into sstable and update size tracking
      Parameters:
      newComponents - collection of components to be added
      tracker - used to update on-disk size metrics
    • unregisterComponents

      public void unregisterComponents(Collection<Component> removeComponents, Tracker tracker)
      Unregisters custom components from sstable and update size tracking
      Parameters:
      removeComponents - collection of components to be removed
      tracker - used to update on-disk size metrics