Class Descriptor

java.lang.Object
org.apache.cassandra.io.sstable.Descriptor

public class Descriptor extends Object
A SSTable is described by the keyspace and column family it contains data for, an id (generation - where higher generations contain more recent data) and an alphabetic version string. A descriptor can be marked as temporary, which influences generated filenames.
  • Field Details

    • EXTENSION

      public static final String EXTENSION
      See Also:
    • TMP_EXT

      public static String TMP_EXT
    • FILENAME_SEPARATOR

      public static final char FILENAME_SEPARATOR
      See Also:
    • directory

      public final File directory
      canonicalized path to the directory where SSTable resides
    • version

      public final Version version
      version has the following format: [a-z]+
    • ksname

      public final String ksname
    • cfname

      public final String cfname
    • id

      public final SSTableId id
  • Constructor Details

  • Method Details

    • tmpFileFor

      public File tmpFileFor(Component component)
    • tmpFileForStreaming

      public File tmpFileForStreaming(Component component)
      Returns:
      a unique temporary file name for given component during entire-sstable-streaming.
    • fileFor

      public File fileFor(Component component)
    • baseFile

      public File baseFile()
    • relativeFilenameFor

      public String relativeFilenameFor(Component component)
    • getFormat

      public SSTableFormat<?,?> getFormat()
    • getTemporaryFiles

      public List<File> getTemporaryFiles()
      Return any temporary files found in the directory
    • getComponents

      public Set<Component> getComponents(Set<Component> mandatory, Set<Component> optional)
      Returns the set of components consisting of the provided mandatory components and those optional components for which the corresponding file exists.
    • isValidFile

      public static boolean isValidFile(File file)
    • fromFile

      public static Descriptor fromFile(File file)
      Parse a sstable filename into a Descriptor.

      SSTables files are all located within subdirectories of the form <keyspace>/<table>/. Normal sstables are are directly within that subdirectory structure while 2ndary index, backups and snapshot are each inside an additional subdirectory. The file themselves have the form: <version>-<gen>-<format>-<component>.

      Note that this method will only sucessfully parse sstable files of supported versions.

      Parameters:
      file - the File object for the filename to parse.
      Returns:
      the descriptor for the parsed file.
      Throws:
      IllegalArgumentException - if the provided file does point to a valid sstable filename. This could mean either that the filename doesn't look like a sstable file, or that it is for an old and unsupported versions.
    • componentFromFile

      public static Component componentFromFile(File file)
    • fromFileWithComponent

      public static Pair<Descriptor,Component> fromFileWithComponent(File file)
      Parse a sstable filename, extracting both the Descriptor and Component part. The keyspace/table name will be extracted from the directory path.
      Parameters:
      file - the File object for the filename to parse.
      Returns:
      a pair of the descriptor and component corresponding to the provided file.
      Throws:
      IllegalArgumentException - if the provided file does point to a valid sstable filename. This could mean either that the filename doesn't look like a sstable file, or that it is for an old and unsupported versions.
    • fromFileWithComponent

      public static Pair<Descriptor,Component> fromFileWithComponent(File file, boolean validateDirs)
    • fromFileWithComponent

      public static Pair<Descriptor,Component> fromFileWithComponent(File file, String keyspace, String table)
      Parse a sstable filename, extracting both the Descriptor and Component part.
      Parameters:
      file - the File object for the filename to parse.
      keyspace - The keyspace name of the file. If null, then the keyspace name will be extracted from the directory path.
      table - The table name of the file. If null, then the table name will be extracted from the directory path.
      Returns:
      a pair of the descriptor and component corresponding to the provided file.
      Throws:
      IllegalArgumentException - if the provided file does point to a valid sstable filename. This could mean either that the filename doesn't look like a sstable file, or that it is for an old and unsupported versions.
    • getMetadataSerializer

      public IMetadataSerializer getMetadataSerializer()
    • isCompatible

      public boolean isCompatible()
      Returns:
      true if the current Cassandra version can read the given sstable version
    • discoverComponents

      public Set<Component> discoverComponents()
    • toString

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object