Class Descriptor


  • public class Descriptor
    extends java.lang.Object
    A SSTable is described by the keyspace and column family it contains data for, a 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 Detail

      • TMP_EXT

        public static java.lang.String TMP_EXT
      • directory

        public final java.io.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 java.lang.String ksname
      • cfname

        public final java.lang.String cfname
      • generation

        public final int generation
    • Constructor Detail

      • Descriptor

        public Descriptor​(java.io.File directory,
                          java.lang.String ksname,
                          java.lang.String cfname,
                          int generation)
        A descriptor that assumes CURRENT_VERSION.
      • Descriptor

        public Descriptor​(java.io.File directory,
                          java.lang.String ksname,
                          java.lang.String cfname,
                          int generation,
                          SSTableFormat.Type formatType)
        Constructor for sstable writers only.
      • Descriptor

        public Descriptor​(java.lang.String version,
                          java.io.File directory,
                          java.lang.String ksname,
                          java.lang.String cfname,
                          int generation,
                          SSTableFormat.Type formatType)
      • Descriptor

        public Descriptor​(Version version,
                          java.io.File directory,
                          java.lang.String ksname,
                          java.lang.String cfname,
                          int generation,
                          SSTableFormat.Type formatType)
    • Method Detail

      • withGeneration

        public Descriptor withGeneration​(int newGeneration)
      • tmpFilenameFor

        public java.lang.String tmpFilenameFor​(Component component)
      • tmpFilenameForStreaming

        public java.lang.String tmpFilenameForStreaming​(Component component)
        Returns:
        a unique temporary file name for given component during entire-sstable-streaming.
      • filenameFor

        public java.lang.String filenameFor​(Component component)
      • baseFilename

        public java.lang.String baseFilename()
      • relativeFilenameFor

        public java.lang.String relativeFilenameFor​(Component component)
      • getTemporaryFiles

        public java.util.List<java.io.File> getTemporaryFiles()
        Return any temporary files found in the directory
      • isValidFile

        public static boolean isValidFile​(java.io.File file)
      • fromFilename

        public static Descriptor fromFilename​(java.lang.String filename)
        Parse a sstable filename into a Descriptor.

        This is a shortcut for fromFilename(new File(filename)).

        Parameters:
        filename - the filename to a sstable component.
        Returns:
        the descriptor for the parsed file.
        Throws:
        java.lang.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.
      • fromFilename

        public static Descriptor fromFilename​(java.io.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:
        java.lang.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.
      • fromFilenameWithComponent

        public static Pair<Descriptor,​Component> fromFilenameWithComponent​(java.io.File file)
        Parse a sstable filename, extracting both the Descriptor and Component part.
        Parameters:
        file - the File object for the filename to parse.
        Returns:
        a pair of the descriptor and component corresponding to the provided file.
        Throws:
        java.lang.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.
      • isCompatible

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

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object