Package org.apache.cassandra.db.memtable
Class ShardedSkipListMemtable
- java.lang.Object
-
- org.apache.cassandra.db.memtable.AbstractMemtable
-
- org.apache.cassandra.db.memtable.AbstractMemtableWithCommitlog
-
- org.apache.cassandra.db.memtable.AbstractAllocatorMemtable
-
- org.apache.cassandra.db.memtable.ShardedSkipListMemtable
-
- All Implemented Interfaces:
java.lang.Comparable<Memtable>,Memtable,UnfilteredSource
public class ShardedSkipListMemtable extends AbstractAllocatorMemtable
A proof-of-concept sharded memtable implementation. This implementation splits the partition skip-list into several independent skip-lists each covering a roughly equal part of the token space served by this node. This reduces congestion of the skip-list from concurrent writes and can lead to improved write throughput. The implementation takes two parameters: - shards: the number of shards to split into. - serialize_writes: if false, each shard may serve multiple writes in parallel; if true, writes to each shard are synchronized. Also see Memtable_API.md.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShardedSkipListMemtable.MemtableUnfilteredPartitionIterator-
Nested classes/interfaces inherited from class org.apache.cassandra.db.memtable.AbstractMemtable
AbstractMemtable.AbstractFlushablePartitionSet<P extends Partition>, AbstractMemtable.ColumnsCollector, AbstractMemtable.StatsCollector
-
Nested classes/interfaces inherited from interface org.apache.cassandra.db.memtable.Memtable
Memtable.FlushablePartitionSet<P extends Partition>, Memtable.LastCommitLogPosition, Memtable.MemoryUsage, Memtable.Owner
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLOCKING_OPTIONstatic java.lang.StringSHARD_COUNT_PROPERTYstatic java.lang.StringSHARDS_OPTION-
Fields inherited from class org.apache.cassandra.db.memtable.AbstractAllocatorMemtable
allocator, initialComparator, MEMORY_POOL, owner
-
Fields inherited from class org.apache.cassandra.db.memtable.AbstractMemtable
columnsCollector, currentOperations, metadata, minLocalDeletionTime, minTimestamp, statsCollector
-
Fields inherited from interface org.apache.cassandra.db.memtable.Memtable
NO_MIN_TIMESTAMP
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Memtable.Factoryfactory()static org.apache.cassandra.db.memtable.ShardedSkipListMemtable.Factoryfactory(java.util.Map<java.lang.String,java.lang.String> optionsCopy)Memtable.FlushablePartitionSet<AtomicBTreePartition>getFlushSet(PartitionPosition from, PartitionPosition to)Get the collection of data between the given partition boundaries in a form suitable for flushing.longgetLiveDataSize()Technically we should scatter gather on all the core threads because the size in following calls are not using volatile variables, but for metrics purpose this should be good enough.intgetMinLocalDeletionTime()Minimum local deletion time in the memtablelonggetMinTimestamp()Returns the minTS if one available, otherwise NO_MIN_TIMESTAMP.booleanisClean()True if the memtable contains no datalongoperationCount()Number of "operations" (in the sense defined inPartitionUpdate.operationCount()) the memtable has executed.longpartitionCount()Number of partitions stored in the memtableShardedSkipListMemtable.MemtableUnfilteredPartitionIteratorpartitionIterator(ColumnFilter columnFilter, DataRange dataRange, SSTableReadsListener readsListener)Returns a partition iterator for the given data range.longput(PartitionUpdate update, UpdateTransaction indexer, OpOrder.Group opGroup)Should only be called by ColumnFamilyStore.apply via Keyspace.apply, which supplies the appropriate OpOrdering.UnfilteredRowIteratorrowIterator(DecoratedKey key)UnfilteredRowIteratorrowIterator(DecoratedKey key, Slices slices, ColumnFilter selectedColumns, boolean reversed, SSTableReadsListener listener)Returns a row iterator for the given partition, applying the specified row and column filters.-
Methods inherited from class org.apache.cassandra.db.memtable.AbstractAllocatorMemtable
addMemoryUsageTo, createMemtableAllocatorPoolInternal, discard, flushLargestMemtable, getAllocator, localRangesUpdated, markExtraOffHeapUsed, markExtraOnHeapUsed, metadataUpdated, performSnapshot, shouldSwitch, switchOut, toString
-
Methods inherited from class org.apache.cassandra.db.memtable.AbstractMemtableWithCommitlog
accepts, getApproximateCommitLogLowerBound, getCommitLogLowerBound, getFinalCommitLogUpperBound, mayContainDataBefore
-
Methods inherited from class org.apache.cassandra.db.memtable.AbstractMemtable
metadata, updateMin, updateMin
-
-
-
-
Field Detail
-
SHARDS_OPTION
public static final java.lang.String SHARDS_OPTION
- See Also:
- Constant Field Values
-
LOCKING_OPTION
public static final java.lang.String LOCKING_OPTION
- See Also:
- Constant Field Values
-
SHARD_COUNT_PROPERTY
public static final java.lang.String SHARD_COUNT_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
isClean
public boolean isClean()
Description copied from interface:MemtableTrue if the memtable contains no data
-
factory
protected Memtable.Factory factory()
- Specified by:
factoryin classAbstractAllocatorMemtable
-
put
public long put(PartitionUpdate update, UpdateTransaction indexer, OpOrder.Group opGroup)
Should only be called by ColumnFamilyStore.apply via Keyspace.apply, which supplies the appropriate OpOrdering. commitLogSegmentPosition should only be null if this is a secondary index, in which case it is *expected* to be null- Parameters:
update- the partition update, may be a new partition or an update to an existing oneindexer- receives information about the update's effectopGroup- write operation group, used to permit the operation to complete if it is needed to complete a flush to free space.- Returns:
- the smallest timestamp delta between corresponding rows from existing and update. A
timestamp delta being computed as the difference between the cells and DeletionTimes from any existing partition
and those in
update. See CASSANDRA-7979.
-
getLiveDataSize
public long getLiveDataSize()
Technically we should scatter gather on all the core threads because the size in following calls are not using volatile variables, but for metrics purpose this should be good enough.
-
operationCount
public long operationCount()
Description copied from interface:MemtableNumber of "operations" (in the sense defined inPartitionUpdate.operationCount()) the memtable has executed.- Specified by:
operationCountin interfaceMemtable- Overrides:
operationCountin classAbstractMemtable
-
partitionCount
public long partitionCount()
Description copied from interface:MemtableNumber of partitions stored in the memtable
-
getMinTimestamp
public long getMinTimestamp()
Returns the minTS if one available, otherwise NO_MIN_TIMESTAMP. EncodingStats uses a synthetic epoch TS at 2015. We don't want to leak that (CASSANDRA-18118) so we return NO_MIN_TIMESTAMP instead.- Specified by:
getMinTimestampin interfaceUnfilteredSource- Overrides:
getMinTimestampin classAbstractMemtable- Returns:
- The minTS or NO_MIN_TIMESTAMP if none available
-
getMinLocalDeletionTime
public int getMinLocalDeletionTime()
Description copied from interface:UnfilteredSourceMinimum local deletion time in the memtable- Specified by:
getMinLocalDeletionTimein interfaceUnfilteredSource- Overrides:
getMinLocalDeletionTimein classAbstractMemtable
-
partitionIterator
public ShardedSkipListMemtable.MemtableUnfilteredPartitionIterator partitionIterator(ColumnFilter columnFilter, DataRange dataRange, SSTableReadsListener readsListener)
Description copied from interface:UnfilteredSourceReturns a partition iterator for the given data range.- Parameters:
columnFilter- filter to apply to all returned partitionsdataRange- the partition and clustering range queriedreadsListener- a listener used to handle internal read events
-
rowIterator
public UnfilteredRowIterator rowIterator(DecoratedKey key, Slices slices, ColumnFilter selectedColumns, boolean reversed, SSTableReadsListener listener)
Description copied from interface:UnfilteredSourceReturns a row iterator for the given partition, applying the specified row and column filters.- Parameters:
key- the partition keyslices- the row ranges to returnselectedColumns- filter to apply to all returned partitionsreversed- true if the content should be returned in reverse orderlistener- a listener used to handle internal read events
-
rowIterator
public UnfilteredRowIterator rowIterator(DecoratedKey key)
-
getFlushSet
public Memtable.FlushablePartitionSet<AtomicBTreePartition> getFlushSet(PartitionPosition from, PartitionPosition to)
Description copied from interface:MemtableGet the collection of data between the given partition boundaries in a form suitable for flushing.
-
factory
public static org.apache.cassandra.db.memtable.ShardedSkipListMemtable.Factory factory(java.util.Map<java.lang.String,java.lang.String> optionsCopy)
-
-