Package org.apache.cassandra.io.sstable
Class Descriptor
- java.lang.Object
-
- org.apache.cassandra.io.sstable.Descriptor
-
public class Descriptor extends java.lang.ObjectA 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 Summary
Fields Modifier and Type Field Description java.lang.StringcfnameFiledirectorycanonicalized path to the directory where SSTable residesstatic charFILENAME_SEPARATORSSTableFormat.TypeformatTypeSSTableIdidjava.lang.Stringksnamestatic java.lang.StringTMP_EXTVersionversionversion has the following format:[a-z]+
-
Constructor Summary
Constructors Constructor Description Descriptor(java.lang.String version, File directory, java.lang.String ksname, java.lang.String cfname, SSTableId id, SSTableFormat.Type formatType)Descriptor(Version version, File directory, java.lang.String ksname, java.lang.String cfname, SSTableId id, SSTableFormat.Type formatType)Descriptor(File directory, java.lang.String ksname, java.lang.String cfname, SSTableId id)A descriptor that assumes CURRENT_VERSION.Descriptor(File directory, java.lang.String ksname, java.lang.String cfname, SSTableId id, SSTableFormat.Type formatType)Constructor for sstable writers only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringbaseFilename()booleanequals(java.lang.Object o)FilefileFor(Component component)java.lang.StringfilenameFor(Component component)static DescriptorfromFilename(java.lang.String filename)Parse a sstable filename into a Descriptor.static DescriptorfromFilename(File file)Parse a sstable filename into a Descriptor.static Pair<Descriptor,Component>fromFilenameWithComponent(File file)Parse a sstable filename, extracting both theDescriptorandComponentpart.SSTableFormatgetFormat()IMetadataSerializergetMetadataSerializer()java.util.List<File>getTemporaryFiles()Return any temporary files found in the directoryinthashCode()booleanisCompatible()static booleanisValidFile(File file)java.lang.StringrelativeFilenameFor(Component component)java.lang.StringtmpFilenameFor(Component component)java.lang.StringtmpFilenameForStreaming(Component component)java.lang.StringtoString()
-
-
-
Field Detail
-
TMP_EXT
public static java.lang.String TMP_EXT
-
FILENAME_SEPARATOR
public static final char FILENAME_SEPARATOR
- See Also:
- Constant Field Values
-
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 java.lang.String ksname
-
cfname
public final java.lang.String cfname
-
id
public final SSTableId id
-
formatType
public final SSTableFormat.Type formatType
-
-
Constructor Detail
-
Descriptor
public Descriptor(File directory, java.lang.String ksname, java.lang.String cfname, SSTableId id)
A descriptor that assumes CURRENT_VERSION.
-
Descriptor
public Descriptor(File directory, java.lang.String ksname, java.lang.String cfname, SSTableId id, SSTableFormat.Type formatType)
Constructor for sstable writers only.
-
Descriptor
public Descriptor(java.lang.String version, File directory, java.lang.String ksname, java.lang.String cfname, SSTableId id, SSTableFormat.Type formatType)
-
Descriptor
public Descriptor(Version version, File directory, java.lang.String ksname, java.lang.String cfname, SSTableId id, SSTableFormat.Type formatType)
-
-
Method Detail
-
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)
-
getFormat
public SSTableFormat getFormat()
-
getTemporaryFiles
public java.util.List<File> getTemporaryFiles()
Return any temporary files found in the directory
-
isValidFile
public static boolean isValidFile(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 providedfiledoes 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(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- theFileobject for the filename to parse.- Returns:
- the descriptor for the parsed file.
- Throws:
java.lang.IllegalArgumentException- if the providedfiledoes 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(File file)
Parse a sstable filename, extracting both theDescriptorandComponentpart.- Parameters:
file- theFileobject for the filename to parse.- Returns:
- a pair of the descriptor and component corresponding to the provided
file. - Throws:
java.lang.IllegalArgumentException- if the providedfiledoes 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
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-