Package org.apache.cassandra.db.rows
Class Cell<V>
- java.lang.Object
-
- org.apache.cassandra.db.rows.ColumnData
-
- org.apache.cassandra.db.rows.Cell<V>
-
- All Implemented Interfaces:
IMeasurableMemory
- Direct Known Subclasses:
AbstractCell
public abstract class Cell<V> extends ColumnData
A cell is our atomic unit for a single value of a single column.A cell always holds at least a timestamp that gives us how the cell reconcile. We then have 3 main types of cells: 1) live regular cells: those will also have a value and, if for a complex column, a path. 2) expiring cells: on top of regular cells, those have a ttl and a local deletion time (when they are expired). 3) tombstone cells: those won't have value, but they have a local deletion time (when the tombstone was created).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Cell.Factory<V>
-
Nested classes/interfaces inherited from class org.apache.cassandra.db.rows.ColumnData
ColumnData.PostReconciliationFunction, ColumnData.Reconciler
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<Cell<?>>
comparator
static long
INVALID_DELETION_TIME
static long
MAX_DELETION_TIME
static int
MAX_DELETION_TIME_2038_LEGACY_CAP
static int
MAX_DELETION_TIME_UNSIGNED_INTEGER
static long
NO_DELETION_TIME
static int
NO_DELETION_TIME_UNSIGNED_INTEGER
static int
NO_TTL
static org.apache.cassandra.db.rows.Cell.Serializer
serializer
-
Fields inherited from class org.apache.cassandra.db.rows.ColumnData
column, noOp
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Cell(ColumnMetadata column)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ValueAccessor<V>
accessor()
java.nio.ByteBuffer
buffer()
abstract Cell<?>
clone(ByteBufferCloner cloner)
Cell<?>
clone(Cloner cloner)
static long
decodeLocalDeletionTime(long localDeletionTime, int ttl, DeserializationHelper helper)
Handle unsigned encoding and potentially invalid localDeletionTime.static int
deletionTimeLongToUnsignedInteger(long deletionTime)
static long
deletionTimeUnsignedIntegerToLong(int deletionTimeUnsignedInteger)
static long
getVersionedMaxDeletiontionTime()
abstract boolean
isCounterCell()
Whether the cell is a counter cell or not.CassandraUIntabstract boolean
isExpiring()
Whether the cell is an expiring one or not.abstract boolean
isLive(long nowInSec)
Whether the cell is live or not given the current time.abstract boolean
isTombstone()
Whether the cell is a tombstone or not.long
localDeletionTime()
The cell local deletion time.protected abstract int
localDeletionTimeAsUnsignedInt()
abstract Cell<?>
markCounterLocalToBeCleared()
abstract CellPath
path()
For cells belonging to complex types (non-frozen collection and UDT), the path to the cell.abstract Cell<?>
purge(DeletionPurger purger, long nowInSec)
abstract Cell<?>
purgeDataOlderThan(long timestamp)
abstract long
timestamp()
The cell timestamp.abstract int
ttl()
The cell ttl.abstract V
value()
int
valueSize()
abstract Cell<?>
withSkippedValue()
Used to apply the same optimization as inCell.Serializer.deserialize(org.apache.cassandra.io.util.DataInputPlus, org.apache.cassandra.db.LivenessInfo, org.apache.cassandra.schema.ColumnMetadata, org.apache.cassandra.db.SerializationHeader, org.apache.cassandra.db.rows.DeserializationHelper, org.apache.cassandra.db.marshal.ValueAccessor<V>)
when the column is not queried but eventhough it's used for digest calculation.abstract Cell<?>
withUpdatedColumn(ColumnMetadata newColumn)
abstract Cell<?>
withUpdatedTimestampAndLocalDeletionTime(long newTimestamp, long newLocalDeletionTime)
abstract Cell<?>
withUpdatedValue(java.nio.ByteBuffer newValue)
-
Methods inherited from class org.apache.cassandra.db.rows.ColumnData
column, dataSize, digest, digest, hasInvalidDeletions, maxTimestamp, reconciler, unsharedHeapSize, unsharedHeapSizeExcludingData, updateAllTimestamp, validate
-
-
-
-
Field Detail
-
NO_TTL
public static final int NO_TTL
- See Also:
- Constant Field Values
-
NO_DELETION_TIME
public static final long NO_DELETION_TIME
- See Also:
- Constant Field Values
-
NO_DELETION_TIME_UNSIGNED_INTEGER
public static final int NO_DELETION_TIME_UNSIGNED_INTEGER
-
MAX_DELETION_TIME
public static final long MAX_DELETION_TIME
-
MAX_DELETION_TIME_UNSIGNED_INTEGER
public static final int MAX_DELETION_TIME_UNSIGNED_INTEGER
-
INVALID_DELETION_TIME
public static final long INVALID_DELETION_TIME
-
MAX_DELETION_TIME_2038_LEGACY_CAP
public static final int MAX_DELETION_TIME_2038_LEGACY_CAP
- See Also:
- Constant Field Values
-
comparator
public static final java.util.Comparator<Cell<?>> comparator
-
serializer
public static final org.apache.cassandra.db.rows.Cell.Serializer serializer
-
-
Constructor Detail
-
Cell
protected Cell(ColumnMetadata column)
-
-
Method Detail
-
deletionTimeLongToUnsignedInteger
public static int deletionTimeLongToUnsignedInteger(long deletionTime)
-
deletionTimeUnsignedIntegerToLong
public static long deletionTimeUnsignedIntegerToLong(int deletionTimeUnsignedInteger)
-
getVersionedMaxDeletiontionTime
public static long getVersionedMaxDeletiontionTime()
-
isCounterCell
public abstract boolean isCounterCell()
Whether the cell is a counter cell or not.CassandraUInt- Returns:
- whether the cell is a counter cell or not.
-
value
public abstract V value()
-
accessor
public abstract ValueAccessor<V> accessor()
-
valueSize
public int valueSize()
-
buffer
public java.nio.ByteBuffer buffer()
-
timestamp
public abstract long timestamp()
The cell timestamp.- Returns:
- the cell timestamp.
-
ttl
public abstract int ttl()
The cell ttl.- Returns:
- the cell ttl, or
NO_TTL
if the cell isn't an expiring one.
-
localDeletionTime
public long localDeletionTime()
The cell local deletion time.- Returns:
- the cell local deletion time, or
NO_DELETION_TIME
if the cell is neither a tombstone nor an expiring one.
-
isTombstone
public abstract boolean isTombstone()
Whether the cell is a tombstone or not.- Returns:
- whether the cell is a tombstone or not.
-
isExpiring
public abstract boolean isExpiring()
Whether the cell is an expiring one or not.Note that this only correspond to whether the cell liveness info have a TTL or not, but doesn't tells whether the cell is already expired or not. You should use
isLive(long)
for that latter information.- Returns:
- whether the cell is an expiring one or not.
-
isLive
public abstract boolean isLive(long nowInSec)
Whether the cell is live or not given the current time.- Parameters:
nowInSec
- the current time in seconds. This is used to decide if an expiring cell is expired or live.- Returns:
- whether the cell is live or not at
nowInSec
.
-
path
public abstract CellPath path()
For cells belonging to complex types (non-frozen collection and UDT), the path to the cell.- Returns:
- the cell path for cells of complex column, and
null
for other cells.
-
withUpdatedColumn
public abstract Cell<?> withUpdatedColumn(ColumnMetadata newColumn)
-
withUpdatedValue
public abstract Cell<?> withUpdatedValue(java.nio.ByteBuffer newValue)
-
withUpdatedTimestampAndLocalDeletionTime
public abstract Cell<?> withUpdatedTimestampAndLocalDeletionTime(long newTimestamp, long newLocalDeletionTime)
-
withSkippedValue
public abstract Cell<?> withSkippedValue()
Used to apply the same optimization as inCell.Serializer.deserialize(org.apache.cassandra.io.util.DataInputPlus, org.apache.cassandra.db.LivenessInfo, org.apache.cassandra.schema.ColumnMetadata, org.apache.cassandra.db.SerializationHeader, org.apache.cassandra.db.rows.DeserializationHelper, org.apache.cassandra.db.marshal.ValueAccessor<V>)
when the column is not queried but eventhough it's used for digest calculation.- Returns:
- a cell with an empty buffer as value
-
clone
public final Cell<?> clone(Cloner cloner)
- Specified by:
clone
in classColumnData
-
clone
public abstract Cell<?> clone(ByteBufferCloner cloner)
-
markCounterLocalToBeCleared
public abstract Cell<?> markCounterLocalToBeCleared()
- Specified by:
markCounterLocalToBeCleared
in classColumnData
-
purge
public abstract Cell<?> purge(DeletionPurger purger, long nowInSec)
- Specified by:
purge
in classColumnData
-
purgeDataOlderThan
public abstract Cell<?> purgeDataOlderThan(long timestamp)
- Specified by:
purgeDataOlderThan
in classColumnData
-
localDeletionTimeAsUnsignedInt
protected abstract int localDeletionTimeAsUnsignedInt()
-
decodeLocalDeletionTime
public static long decodeLocalDeletionTime(long localDeletionTime, int ttl, DeserializationHelper helper)
Handle unsigned encoding and potentially invalid localDeletionTime.
-
-