org.apache.cassandra.io.sstable
Class SSTableReader

java.lang.Object
  extended by org.apache.cassandra.io.sstable.SSTable
      extended by org.apache.cassandra.io.sstable.SSTableReader
All Implemented Interfaces:
java.lang.Comparable<SSTableReader>

public class SSTableReader
extends SSTable
implements java.lang.Comparable<SSTableReader>

SSTableReaders are open()ed by Table.onStart; after that they are created by SSTableWriter.renameAndOpen. Do not re-call open() on existing SSTable files; use the references kept by ColumnFamilyStore post-start instead.


Nested Class Summary
static class SSTableReader.Operator
          TODO: Move someplace reusable
 
Field Summary
 long maxDataAge
          maxDataAge is a timestamp in local server time (e.g.
 
Fields inherited from class org.apache.cassandra.io.sstable.SSTable
COMPONENT_DATA, COMPONENT_FILTER, COMPONENT_INDEX, COMPONENT_STATS, components, descriptor, estimatedColumnCount, estimatedRowSize, metadata, partitioner, TEMPFILE_MARKER
 
Method Summary
 int compareTo(SSTableReader o)
           
 ColumnFamily createColumnFamily()
           
 void createLinks(java.lang.String snapshotDirectoryPath)
           
static DecoratedKey decodeKey(IPartitioner p, Descriptor d, java.nio.ByteBuffer bytes)
          Conditionally use the deprecated 'IPartitioner.convertFromDiskFormat' method.
 long estimatedKeys()
           
 void forceFilterFailures()
          For testing purposes only.
static long getApproximateKeyCount(java.lang.Iterable<SSTableReader> sstables)
           
 BloomFilter getBloomFilter()
           
 long getBloomFilterFalsePositiveCount()
           
 long getBloomFilterTruePositiveCount()
           
 AbstractType getColumnComparator()
           
 ICompactSerializer2<IColumn> getColumnSerializer()
           
 FileDataInput getFileDataInput(DecoratedKey decoratedKey, int bufferSize)
           
 InstrumentedCache getKeyCache()
           
 java.util.Collection<DecoratedKey> getKeySamples()
           
 long getPosition(DecoratedKey decoratedKey, SSTableReader.Operator op)
           
 java.util.List<Pair<java.lang.Long,java.lang.Long>> getPositionsForRanges(java.util.Collection<Range> ranges)
          Determine the minimal set of sections that can be extracted from this SSTable to cover the given ranges.
 long getRecentBloomFilterFalsePositiveCount()
           
 long getRecentBloomFilterTruePositiveCount()
           
 SSTableScanner getScanner(int bufferSize)
           
 SSTableScanner getScanner(int bufferSize, QueryFilter filter)
           
 long length()
           
 void markCompacted()
           
 boolean newSince(long age)
          Tests if the sstable contains data newer than the given age param (in localhost currentMilli time).
static SSTableReader open(Descriptor desc)
           
static SSTableReader open(Descriptor descriptor, java.util.Set<Component> components, CFMetaData metadata, IPartitioner partitioner)
           
static SSTableReader open(Descriptor descriptor, java.util.Set<Component> components, java.util.Set<DecoratedKey> savedKeys, SSTableTracker tracker, CFMetaData metadata, IPartitioner partitioner)
           
static long readRowSize(java.io.DataInput in, Descriptor d)
           
 void setTrackedBy(SSTableTracker tracker)
           
 
Methods inherited from class org.apache.cassandra.io.sstable.SSTable
bytesOnDisk, delete, getColumnFamilyName, getEstimatedColumnCount, getEstimatedRowSize, getFilename, getTableName, getTotalBytes, toString, tryComponentFromFilename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

maxDataAge

public final long maxDataAge
maxDataAge is a timestamp in local server time (e.g. System.currentTimeMilli) which represents an uppper bound to the newest piece of data stored in the sstable. In other words, this sstable does not contain items created later than maxDataAge. The field is not serialized to disk, so relying on it for more than what truncate does is not advised. When a new sstable is flushed, maxDataAge is set to the time of creation. When a sstable is created from compaction, maxDataAge is set to max of all merged tables. The age is in milliseconds since epoc and is local to this host.

Method Detail

getApproximateKeyCount

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

open

public static SSTableReader open(Descriptor desc)
                          throws java.io.IOException
Throws:
java.io.IOException

open

public static SSTableReader open(Descriptor descriptor,
                                 java.util.Set<Component> components,
                                 CFMetaData metadata,
                                 IPartitioner partitioner)
                          throws java.io.IOException
Throws:
java.io.IOException

open

public static SSTableReader open(Descriptor descriptor,
                                 java.util.Set<Component> components,
                                 java.util.Set<DecoratedKey> savedKeys,
                                 SSTableTracker tracker,
                                 CFMetaData metadata,
                                 IPartitioner partitioner)
                          throws java.io.IOException
Throws:
java.io.IOException

setTrackedBy

public void setTrackedBy(SSTableTracker tracker)

forceFilterFailures

public void forceFilterFailures()
For testing purposes only.


getBloomFilter

public BloomFilter getBloomFilter()

getKeyCache

public InstrumentedCache getKeyCache()
Returns:
The key cache: for monitoring purposes.

estimatedKeys

public long estimatedKeys()
Returns:
An estimate of the number of keys in this SSTable.

getKeySamples

public java.util.Collection<DecoratedKey> getKeySamples()
Returns:
Approximately 1/INDEX_INTERVALth of the keys in this SSTable.

getPositionsForRanges

public java.util.List<Pair<java.lang.Long,java.lang.Long>> getPositionsForRanges(java.util.Collection<Range> ranges)
Determine the minimal set of sections that can be extracted from this SSTable to cover the given ranges.

Returns:
A sorted list of (offset,end) pairs that cover the given ranges in the datafile for this SSTable.

getPosition

public long getPosition(DecoratedKey decoratedKey,
                        SSTableReader.Operator op)
Parameters:
decoratedKey - The key to apply as the rhs to the given Operator.
op - The Operator defining matching keys: the nearest key to the target matching the operator wins.
Returns:
The position in the data file to find the key, or -1 if the key is not present

length

public long length()
Returns:
The length in bytes of the data file for this SSTable.

markCompacted

public void markCompacted()

getScanner

public SSTableScanner getScanner(int bufferSize)
Parameters:
bufferSize - Buffer size in bytes for this Scanner.
Returns:
A Scanner for seeking over the rows of the SSTable.

getScanner

public SSTableScanner getScanner(int bufferSize,
                                 QueryFilter filter)
Parameters:
bufferSize - Buffer size in bytes for this Scanner.
filter - filter to use when reading the columns
Returns:
A Scanner for seeking over the rows of the SSTable.

getFileDataInput

public FileDataInput getFileDataInput(DecoratedKey decoratedKey,
                                      int bufferSize)

compareTo

public int compareTo(SSTableReader o)
Specified by:
compareTo in interface java.lang.Comparable<SSTableReader>

getColumnComparator

public AbstractType getColumnComparator()

createColumnFamily

public ColumnFamily createColumnFamily()

getColumnSerializer

public ICompactSerializer2<IColumn> getColumnSerializer()

newSince

public boolean newSince(long age)
Tests if the sstable contains data newer than the given age param (in localhost currentMilli time). This works in conjunction with maxDataAge which is an upper bound on the create of data in this sstable.

Parameters:
age - The age to compare the maxDataAre of this sstable. Measured in millisec since epoc on this host
Returns:
True iff this sstable contains data that's newer than the given age parameter.

readRowSize

public static long readRowSize(java.io.DataInput in,
                               Descriptor d)
                        throws java.io.IOException
Throws:
java.io.IOException

createLinks

public void createLinks(java.lang.String snapshotDirectoryPath)
                 throws java.io.IOException
Throws:
java.io.IOException

decodeKey

public static DecoratedKey decodeKey(IPartitioner p,
                                     Descriptor d,
                                     java.nio.ByteBuffer bytes)
Conditionally use the deprecated 'IPartitioner.convertFromDiskFormat' method.


getBloomFilterFalsePositiveCount

public long getBloomFilterFalsePositiveCount()

getRecentBloomFilterFalsePositiveCount

public long getRecentBloomFilterFalsePositiveCount()

getBloomFilterTruePositiveCount

public long getBloomFilterTruePositiveCount()

getRecentBloomFilterTruePositiveCount

public long getRecentBloomFilterTruePositiveCount()


Copyright © 2010 The Apache Software Foundation