org.apache.cassandra.io.sstable
Class SSTable

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

public abstract class SSTable
extends java.lang.Object

This class is built on top of the SequenceFile. It stores data on disk in sorted fashion. However the sorting is upto the application. This class expects keys to be handed to it in sorted order. A separate index file is maintained as well, containing the SSTable keys and the offset into the SSTable at which they are found. Every 1/indexInterval key is read into memory when the SSTable is opened. Finally, a bloom filter file is also kept for the keys in each SSTable.


Field Summary
static java.lang.String COMPONENT_DATA
           
static java.lang.String COMPONENT_FILTER
           
static java.lang.String COMPONENT_INDEX
           
static java.lang.String COMPONENT_STATS
           
protected  java.util.Set<Component> components
           
 Descriptor descriptor
           
protected  EstimatedHistogram estimatedColumnCount
           
protected  EstimatedHistogram estimatedRowSize
           
 CFMetaData metadata
           
 IPartitioner partitioner
           
 ReplayPosition replayPosition
           
static java.lang.String TEMPFILE_MARKER
           
 
Constructor Summary
protected SSTable(Descriptor descriptor, CFMetaData metadata, ReplayPosition replayPosition, IPartitioner partitioner)
           
protected SSTable(Descriptor descriptor, java.util.Set<Component> components, CFMetaData metadata, ReplayPosition replayPosition, IPartitioner partitioner)
           
protected SSTable(Descriptor descriptor, java.util.Set<Component> components, CFMetaData metadata, ReplayPosition replayPosition, IPartitioner partitioner, EstimatedHistogram rowSizes, EstimatedHistogram columnCounts)
           
 
Method Summary
 long bytesOnDisk()
           
static boolean delete(Descriptor desc, java.util.Set<Component> components)
          We use a ReferenceQueue to manage deleting files that have been compacted and for which no more SSTable references exist.
 java.lang.String getColumnFamilyName()
           
 EstimatedHistogram getEstimatedColumnCount()
           
 EstimatedHistogram getEstimatedRowSize()
           
 java.lang.String getFilename()
           
 java.lang.String getTableName()
           
static long getTotalBytes(java.lang.Iterable<SSTableReader> sstables)
           
 java.lang.String toString()
           
static Pair<Descriptor,Component> tryComponentFromFilename(java.io.File dir, java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPONENT_DATA

public static final java.lang.String COMPONENT_DATA

COMPONENT_INDEX

public static final java.lang.String COMPONENT_INDEX

COMPONENT_FILTER

public static final java.lang.String COMPONENT_FILTER

COMPONENT_STATS

public static final java.lang.String COMPONENT_STATS

TEMPFILE_MARKER

public static final java.lang.String TEMPFILE_MARKER
See Also:
Constant Field Values

descriptor

public final Descriptor descriptor

components

protected final java.util.Set<Component> components

metadata

public final CFMetaData metadata

partitioner

public final IPartitioner partitioner

replayPosition

public final ReplayPosition replayPosition

estimatedRowSize

protected final EstimatedHistogram estimatedRowSize

estimatedColumnCount

protected final EstimatedHistogram estimatedColumnCount
Constructor Detail

SSTable

protected SSTable(Descriptor descriptor,
                  CFMetaData metadata,
                  ReplayPosition replayPosition,
                  IPartitioner partitioner)

SSTable

protected SSTable(Descriptor descriptor,
                  java.util.Set<Component> components,
                  CFMetaData metadata,
                  ReplayPosition replayPosition,
                  IPartitioner partitioner)

SSTable

protected SSTable(Descriptor descriptor,
                  java.util.Set<Component> components,
                  CFMetaData metadata,
                  ReplayPosition replayPosition,
                  IPartitioner partitioner,
                  EstimatedHistogram rowSizes,
                  EstimatedHistogram columnCounts)
Method Detail

getEstimatedRowSize

public EstimatedHistogram getEstimatedRowSize()

getEstimatedColumnCount

public EstimatedHistogram getEstimatedColumnCount()

delete

public static boolean delete(Descriptor desc,
                             java.util.Set<Component> components)
We use a ReferenceQueue to manage deleting files that have been compacted and for which no more SSTable references exist. But this is not guaranteed to run for each such file because of the semantics of the JVM gc. So, we write a marker to `compactedFilename` when a file is compacted; if such a marker exists on startup, the file should be removed. This method will also remove SSTables that are marked as temporary.

Returns:
true if the file was deleted

getFilename

public java.lang.String getFilename()

getColumnFamilyName

public java.lang.String getColumnFamilyName()

getTableName

public java.lang.String getTableName()

tryComponentFromFilename

public static Pair<Descriptor,Component> tryComponentFromFilename(java.io.File dir,
                                                                  java.lang.String name)
Returns:
A Descriptor,Component pair, or null if not a valid sstable component.

getTotalBytes

public static long getTotalBytes(java.lang.Iterable<SSTableReader> sstables)

bytesOnDisk

public long bytesOnDisk()

toString

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


Copyright © 2011 The Apache Software Foundation