Interface Row
-
- All Superinterfaces:
Clusterable
,IMeasurableMemory
,java.lang.Iterable<ColumnData>
,Unfiltered
- All Known Implementing Classes:
AbstractRow
,BTreeRow
public interface Row extends Unfiltered, java.lang.Iterable<ColumnData>, IMeasurableMemory
Storage engine representation of a row. A row mainly contains the following informations: 1) ItsClustering
, which holds the values for the clustering columns identifying the row. 2) Its row level informations: the primary key liveness infos and the row deletion (seeprimaryKeyLivenessInfo()
anddeletion()
for more details). 3) Data for the columns it contains, or in other words, it's a (sorted) collection ofColumnData
. Also note that as for every other storage engine object, aRow
object cannot shadow it's own data. For instance, aRow
cannot contains a cell that is deleted by its own row deletion.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Row.Builder
Interface for building rows.static class
Row.Deletion
A row deletion/tombstone.static class
Row.Merger
Utility class to help merging rows from multiple inputs (UnfilteredRowIterators).static interface
Row.SimpleBuilder
Row builder interface geared towards human.-
Nested classes/interfaces inherited from interface org.apache.cassandra.db.rows.Unfiltered
Unfiltered.Kind
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <A> long
accumulate(BiLongAccumulator<A,ColumnData> accumulator, A arg, long initialValue)
<A> long
accumulate(BiLongAccumulator<A,ColumnData> accumulator, A arg, java.util.Comparator<ColumnData> comparator, ColumnData from, long initialValue)
long
accumulate(LongAccumulator<ColumnData> accumulator, long initialValue)
Apply an accumulation funtion to every column in a rowlong
accumulate(LongAccumulator<ColumnData> accumulator, java.util.Comparator<ColumnData> comparator, ColumnData from, long initialValue)
<A> void
apply(java.util.function.BiConsumer<A,ColumnData> function, A arg)
Apply a function to every column in a rowvoid
apply(java.util.function.Consumer<ColumnData> function)
Apply a function to every column in a rowjava.lang.Iterable<Cell<?>>
cells()
An iterable over the cells of this row.java.lang.Iterable<Cell<?>>
cellsInLegacyOrder(TableMetadata metadata, boolean reversed)
An iterable over the cells of this row that return cells in "legacy order".Row
clone(Cloner cloner)
Clustering<?>
clustering()
The clustering values for this row.int
columnCount()
The number of columns for which data (incl.java.util.Collection<ColumnData>
columnData()
A collection of the ColumnData representation of this row, for columns with some data (possibly not live) presentjava.util.Collection<ColumnMetadata>
columns()
An in-natural-order collection of the columns for which data (incl.int
dataSize()
Row.Deletion
deletion()
The row deletion.Row
filter(ColumnFilter filter, DeletionTime activeDeletion, boolean setActiveDeletionToRow, TableMetadata metadata)
Returns a copy of this row that: 1) only includes the data for the column included byfilter
.Row
filter(ColumnFilter filter, TableMetadata metadata)
Returns a copy of this row that: 1) only includes the data for the column included byfilter
.Cell<?>
getCell(ColumnMetadata c)
Returns a cell for a simple column.Cell<?>
getCell(ColumnMetadata c, CellPath path)
Return a cell for a given complex column and cell path.ColumnData
getColumnData(ColumnMetadata c)
Returns theColumnData
for the specified column.ComplexColumnData
getComplexColumnData(ColumnMetadata c)
The data for a complex column.boolean
hasComplex()
Whether the row stores any (non-RT) data for any complex column.boolean
hasComplexDeletion()
Whether the row stores any (non-live) complex deletion for any complex column.boolean
hasDeletion(long nowInSec)
Whether the row has any deletion info (row deletion, cell tombstone, expired cell or complex deletion).boolean
hasLiveData(long nowInSec, boolean enforceStrictLiveness)
Whether the row has some live information (i.e.boolean
isEmpty()
Whether the row has no information whatsoever.boolean
isStatic()
Whether the row correspond to a static row or not.Row
markCounterLocalToBeCleared()
Returns a copy of this row where all counter cells have they "local" shard marked for clearing.LivenessInfo
primaryKeyLivenessInfo()
Liveness information for the primary key columns of this row.Row
purge(DeletionPurger purger, long nowInSec, boolean enforceStrictLiveness)
Returns a copy of this row without any deletion info that should be purged according topurger
.Row
purgeDataOlderThan(long timestamp, boolean enforceStrictLiveness)
SearchIterator<ColumnMetadata,ColumnData>
searchIterator()
An iterator to efficiently search data for a given column.java.lang.String
toString(TableMetadata metadata, boolean fullDetails)
Row
transformAndFilter(java.util.function.Function<ColumnData,ColumnData> function)
Requires thatfunction
returns eithernull
orColumnData
for the same column.Row
transformAndFilter(LivenessInfo info, Row.Deletion deletion, java.util.function.Function<ColumnData,ColumnData> function)
Requires thatfunction
returns eithernull
orColumnData
for the same column.long
unsharedHeapSize()
long
unsharedHeapSizeExcludingData()
Row
updateAllTimestamp(long newTimestamp)
Returns a copy of this row where all live timestamp have been replaced bynewTimestamp
and every deletion timestamp bynewTimestamp - 1
.Row
withOnlyQueriedData(ColumnFilter filter)
Returns a copy of this row which only include the data queried byfilter
, excluding anything _fetched_ for internal reasons but not queried by the user (seeColumnFilter
for details).Row
withRowDeletion(DeletionTime deletion)
Returns a copy of this row with the new deletion as row deletion if it is more recent than the current row deletion.-
Methods inherited from interface org.apache.cassandra.db.rows.Unfiltered
digest, hasInvalidDeletions, isRangeTombstoneMarker, isRow, kind, toString, toString, validateData
-
-
-
-
Method Detail
-
clustering
Clustering<?> clustering()
The clustering values for this row.- Specified by:
clustering
in interfaceClusterable
- Specified by:
clustering
in interfaceUnfiltered
-
columns
java.util.Collection<ColumnMetadata> columns()
An in-natural-order collection of the columns for which data (incl. simple tombstones) is present in this row.
-
columnCount
int columnCount()
The number of columns for which data (incl. simple tombstones) is present in this row.
-
deletion
Row.Deletion deletion()
The row deletion. This correspond to the last row deletion done on this row.- Returns:
- the row deletion.
-
primaryKeyLivenessInfo
LivenessInfo primaryKeyLivenessInfo()
Liveness information for the primary key columns of this row.As a row is uniquely identified by its primary key, all its primary key columns share the same
LivenessInfo
. This liveness information is what allows us to distinguish between a dead row (it has no live cells and its primary key liveness info is empty) and a live row but where all non PK columns are null (it has no live cells, but its primary key liveness is not empty). Please note that the liveness info (including it's eventually ttl/local deletion time) only apply to the primary key columns and has no impact on the row content.Note in particular that a row may have live cells but no PK liveness info, because the primary key liveness informations are only set on
INSERT
(which makes sense in itself, see #6782) but live cells can be added throughUPDATE
even if the row wasn't pre-existing (which users are encouraged not to do, but we can't validate).
-
isStatic
boolean isStatic()
Whether the row correspond to a static row or not.- Returns:
- whether the row correspond to a static row or not.
-
isEmpty
boolean isEmpty()
Whether the row has no information whatsoever. This means no PK liveness info, no row deletion, no cells and no complex deletion info.- Specified by:
isEmpty
in interfaceUnfiltered
- Returns:
true
if the row has no data,false
otherwise.
-
hasLiveData
boolean hasLiveData(long nowInSec, boolean enforceStrictLiveness)
Whether the row has some live information (i.e. it's not just deletion informations).- Parameters:
nowInSec
- the current time to decide what is deleted and what isn'tenforceStrictLiveness
- whether the row should be purged if there is no PK liveness info, normally retrieved fromTableMetadata.enforceStrictLiveness()
- Returns:
- true if there is some live information
-
getCell
Cell<?> getCell(ColumnMetadata c)
Returns a cell for a simple column.- Parameters:
c
- the simple column for which to fetch the cell.- Returns:
- the corresponding cell or
null
if the row has no such cell.
-
getCell
Cell<?> getCell(ColumnMetadata c, CellPath path)
Return a cell for a given complex column and cell path.- Parameters:
c
- the complex column for which to fetch the cell.path
- the cell path for which to fetch the cell.- Returns:
- the corresponding cell or
null
if the row has no such cell.
-
getComplexColumnData
ComplexColumnData getComplexColumnData(ColumnMetadata c)
The data for a complex column.The returned object groups all the cells for the column, as well as it's complex deletion (if relevant).
- Parameters:
c
- the complex column for which to return the complex data.- Returns:
- the data for
c
ornull
if the row has no data for this column.
-
getColumnData
ColumnData getColumnData(ColumnMetadata c)
Returns theColumnData
for the specified column.- Parameters:
c
- the column for which to fetch the data.- Returns:
- the data for the column or
null
if the row has no data for this column.
-
cells
java.lang.Iterable<Cell<?>> cells()
An iterable over the cells of this row.The iterable guarantees that cells are returned in order of
Cell.comparator
.- Returns:
- an iterable over the cells of this row.
-
columnData
java.util.Collection<ColumnData> columnData()
A collection of the ColumnData representation of this row, for columns with some data (possibly not live) presentThe data is returned in column order.
- Returns:
- a Collection of the non-empty ColumnData for this row.
-
cellsInLegacyOrder
java.lang.Iterable<Cell<?>> cellsInLegacyOrder(TableMetadata metadata, boolean reversed)
An iterable over the cells of this row that return cells in "legacy order".In 3.0+, columns are sorted so that all simple columns are before all complex columns. Previously however, the cells where just sorted by the column name. This iterator return cells in that legacy order. It's only ever meaningful for backward/thrift compatibility code.
- Parameters:
metadata
- the table this is a row of.reversed
- if cells should returned in reverse order.- Returns:
- an iterable over the cells of this row in "legacy order".
-
hasComplexDeletion
boolean hasComplexDeletion()
Whether the row stores any (non-live) complex deletion for any complex column.
-
hasComplex
boolean hasComplex()
Whether the row stores any (non-RT) data for any complex column.
-
hasDeletion
boolean hasDeletion(long nowInSec)
Whether the row has any deletion info (row deletion, cell tombstone, expired cell or complex deletion).- Parameters:
nowInSec
- the current time in seconds to decid if a cell is expired.
-
searchIterator
SearchIterator<ColumnMetadata,ColumnData> searchIterator()
An iterator to efficiently search data for a given column.- Returns:
- a search iterator for the cells of this row.
-
filter
Row filter(ColumnFilter filter, TableMetadata metadata)
Returns a copy of this row that: 1) only includes the data for the column included byfilter
. 2) doesn't include any data that belongs to a dropped column (recorded inmetadata
).
-
filter
Row filter(ColumnFilter filter, DeletionTime activeDeletion, boolean setActiveDeletionToRow, TableMetadata metadata)
Returns a copy of this row that: 1) only includes the data for the column included byfilter
. 2) doesn't include any data that belongs to a dropped column (recorded inmetadata
). 3) doesn't include any data that is shadowed/deleted byactiveDeletion
. 4) usesactiveDeletion
as row deletion iffsetActiveDeletionToRow
andactiveDeletion
supersedes the row deletion.
-
transformAndFilter
Row transformAndFilter(LivenessInfo info, Row.Deletion deletion, java.util.function.Function<ColumnData,ColumnData> function)
Requires thatfunction
returns eithernull
orColumnData
for the same column. Returns a copy of this row that: 1)function
has been applied to the members of 2) doesn't include anynull
results offunction
3) has precisely the providedLivenessInfo
andDeletion
-
transformAndFilter
Row transformAndFilter(java.util.function.Function<ColumnData,ColumnData> function)
Requires thatfunction
returns eithernull
orColumnData
for the same column. Returns a copy of this row that: 1)function
has been applied to the members of 2) doesn't include anynull
results offunction
-
purge
Row purge(DeletionPurger purger, long nowInSec, boolean enforceStrictLiveness)
Returns a copy of this row without any deletion info that should be purged according topurger
.- Parameters:
purger
- theDeletionPurger
to use to decide what can be purged.nowInSec
- the current time to decide what is deleted and what isn't (in the case of expired cells).enforceStrictLiveness
- whether the row should be purged if there is no PK liveness info, normally retrieved fromTableMetadata.enforceStrictLiveness()
When enforceStrictLiveness is set, rows with empty PK liveness info and no row deletion are purged. Currently this is only used by views with normal base column as PK column so updates to other base columns do not make the row live when the PK column is not live. See CASSANDRA-11500.- Returns:
- this row but without any deletion info purged by
purger
. If the purged row is empty, returnsnull
.
-
withOnlyQueriedData
Row withOnlyQueriedData(ColumnFilter filter)
Returns a copy of this row which only include the data queried byfilter
, excluding anything _fetched_ for internal reasons but not queried by the user (seeColumnFilter
for details).- Parameters:
filter
- theColumnFilter
to use when deciding what is user queried. This should be the filter that was used when querying the row on which this method is called.- Returns:
- the row but with all data that wasn't queried by the user skipped.
-
purgeDataOlderThan
Row purgeDataOlderThan(long timestamp, boolean enforceStrictLiveness)
-
markCounterLocalToBeCleared
Row markCounterLocalToBeCleared()
Returns a copy of this row where all counter cells have they "local" shard marked for clearing.
-
updateAllTimestamp
Row updateAllTimestamp(long newTimestamp)
Returns a copy of this row where all live timestamp have been replaced bynewTimestamp
and every deletion timestamp bynewTimestamp - 1
.- Parameters:
newTimestamp
- the timestamp to use for all live data in the returned row.- See Also:
for why we need this.
-
withRowDeletion
Row withRowDeletion(DeletionTime deletion)
Returns a copy of this row with the new deletion as row deletion if it is more recent than the current row deletion.WARNING: this method does not check that nothing in the row is shadowed by the provided deletion and if that is the case, the created row will be invalid. It is thus up to the caller to verify that this is not the case and the only reasonable use case of this is probably when the row and the deletion comes from the same
UnfilteredRowIterator
since that gives use this guarantee.
-
dataSize
int dataSize()
-
unsharedHeapSizeExcludingData
long unsharedHeapSizeExcludingData()
-
toString
java.lang.String toString(TableMetadata metadata, boolean fullDetails)
- Specified by:
toString
in interfaceUnfiltered
-
unsharedHeapSize
long unsharedHeapSize()
- Specified by:
unsharedHeapSize
in interfaceIMeasurableMemory
- Returns:
- the amount of on-heap memory retained by the object that might be reclaimed if the object were reclaimed, i.e. it should try to exclude globally cached data where possible, or counting portions of arrays that are referenced by the object but used by other objects only (e.g. slabbed byte-buffers), etc.
-
apply
void apply(java.util.function.Consumer<ColumnData> function)
Apply a function to every column in a row
-
apply
<A> void apply(java.util.function.BiConsumer<A,ColumnData> function, A arg)
Apply a function to every column in a row
-
accumulate
long accumulate(LongAccumulator<ColumnData> accumulator, long initialValue)
Apply an accumulation funtion to every column in a row
-
accumulate
long accumulate(LongAccumulator<ColumnData> accumulator, java.util.Comparator<ColumnData> comparator, ColumnData from, long initialValue)
-
accumulate
<A> long accumulate(BiLongAccumulator<A,ColumnData> accumulator, A arg, long initialValue)
-
accumulate
<A> long accumulate(BiLongAccumulator<A,ColumnData> accumulator, A arg, java.util.Comparator<ColumnData> comparator, ColumnData from, long initialValue)
-
-