Class RowWithSource

java.lang.Object
org.apache.cassandra.index.sai.utils.RowWithSource
All Implemented Interfaces:
Iterable<ColumnData>, IMeasurableMemory, Clusterable, Row, Unfiltered

public class RowWithSource extends Object implements Row
A Row wrapper that has a CellSourceIdentifier that gets added to cell as part of the getCell(ColumnMetadata) and getCell(ColumnMetadata, CellPath) calls. This class can only be initiallized validly when all the cells share a common CellSourceIdentifier.
  • Constructor Details

  • Method Details

    • kind

      public Unfiltered.Kind kind()
      Description copied from interface: Unfiltered
      The kind of the atom: either row or range tombstone marker.
      Specified by:
      kind in interface Unfiltered
    • clustering

      public Clustering<?> clustering()
      Description copied from interface: Row
      The clustering values for this row.
      Specified by:
      clustering in interface Clusterable
      Specified by:
      clustering in interface Row
      Specified by:
      clustering in interface Unfiltered
    • digest

      public void digest(Digest digest)
      Description copied from interface: Unfiltered
      Digest the atom using the provided Digest.
      Specified by:
      digest in interface Unfiltered
      Parameters:
      digest - the to use.
    • validateData

      public void validateData(TableMetadata metadata)
      Description copied from interface: Unfiltered
      Validate the data of this atom.
      Specified by:
      validateData in interface Unfiltered
      Parameters:
      metadata - the metadata for the table this atom is part of.
    • hasInvalidDeletions

      public boolean hasInvalidDeletions()
      Description copied from interface: Unfiltered
      Do a quick validation of the deletions of the unfiltered (if any)
      Specified by:
      hasInvalidDeletions in interface Unfiltered
      Returns:
      true if any deletion is invalid
    • columns

      public Collection<ColumnMetadata> columns()
      Description copied from interface: Row
      An in-natural-order collection of the columns for which data (incl. simple tombstones) is present in this row.
      Specified by:
      columns in interface Row
    • columnCount

      public int columnCount()
      Description copied from interface: Row
      The number of columns for which data (incl. simple tombstones) is present in this row.
      Specified by:
      columnCount in interface Row
    • deletion

      public Row.Deletion deletion()
      Description copied from interface: Row
      The row deletion. This correspond to the last row deletion done on this row.
      Specified by:
      deletion in interface Row
      Returns:
      the row deletion.
    • primaryKeyLivenessInfo

      public LivenessInfo primaryKeyLivenessInfo()
      Description copied from interface: Row
      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 through UPDATE even if the row wasn't pre-existing (which users are encouraged not to do, but we can't validate).

      Specified by:
      primaryKeyLivenessInfo in interface Row
    • isStatic

      public boolean isStatic()
      Description copied from interface: Row
      Whether the row correspond to a static row or not.
      Specified by:
      isStatic in interface Row
      Returns:
      whether the row correspond to a static row or not.
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Row
      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 interface Row
      Specified by:
      isEmpty in interface Unfiltered
      Returns:
      true if the row has no data, false otherwise.
    • toString

      public String toString(TableMetadata metadata)
      Specified by:
      toString in interface Unfiltered
    • hasLiveData

      public boolean hasLiveData(long nowInSec, boolean enforceStrictLiveness)
      Description copied from interface: Row
      Whether the row has some live information (i.e. it's not just deletion informations).
      Specified by:
      hasLiveData in interface Row
      Parameters:
      nowInSec - the current time to decide what is deleted and what isn't
      enforceStrictLiveness - whether the row should be purged if there is no PK liveness info, normally retrieved from TableMetadata.enforceStrictLiveness()
      Returns:
      true if there is some live information
    • getCell

      public Cell<?> getCell(ColumnMetadata c)
      Description copied from interface: Row
      Returns a cell for a simple column.
      Specified by:
      getCell in interface Row
      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

      public Cell<?> getCell(ColumnMetadata c, CellPath path)
      Description copied from interface: Row
      Return a cell for a given complex column and cell path.
      Specified by:
      getCell in interface Row
      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

      public ComplexColumnData getComplexColumnData(ColumnMetadata c)
      Description copied from interface: Row
      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).

      Specified by:
      getComplexColumnData in interface Row
      Parameters:
      c - the complex column for which to return the complex data.
      Returns:
      the data for c or null if the row has no data for this column.
    • getColumnData

      public ColumnData getColumnData(ColumnMetadata c)
      Description copied from interface: Row
      Returns the ColumnData for the specified column.
      Specified by:
      getColumnData in interface Row
      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

      public Iterable<Cell<?>> cells()
      Description copied from interface: Row
      An iterable over the cells of this row.

      The iterable guarantees that cells are returned in order of Cell.comparator.

      Specified by:
      cells in interface Row
      Returns:
      an iterable over the cells of this row.
    • columnData

      public Collection<ColumnData> columnData()
      Description copied from interface: Row
      A collection of the ColumnData representation of this row, for columns with some data (possibly not live) present

      The data is returned in column order.

      Specified by:
      columnData in interface Row
      Returns:
      a Collection of the non-empty ColumnData for this row.
    • cellsInLegacyOrder

      public Iterable<Cell<?>> cellsInLegacyOrder(TableMetadata metadata, boolean reversed)
      Description copied from interface: Row
      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.

      Specified by:
      cellsInLegacyOrder in interface Row
      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

      public boolean hasComplexDeletion()
      Description copied from interface: Row
      Whether the row stores any (non-live) complex deletion for any complex column.
      Specified by:
      hasComplexDeletion in interface Row
    • hasComplex

      public boolean hasComplex()
      Description copied from interface: Row
      Whether the row stores any (non-RT) data for any complex column.
      Specified by:
      hasComplex in interface Row
    • hasDeletion

      public boolean hasDeletion(long nowInSec)
      Description copied from interface: Row
      Whether the row has any deletion info (row deletion, cell tombstone, expired cell or complex deletion).
      Specified by:
      hasDeletion in interface Row
      Parameters:
      nowInSec - the current time in seconds to decid if a cell is expired.
    • searchIterator

      public SearchIterator<ColumnMetadata,ColumnData> searchIterator()
      Description copied from interface: Row
      An iterator to efficiently search data for a given column.
      Specified by:
      searchIterator in interface Row
      Returns:
      a search iterator for the cells of this row.
    • filter

      public Row filter(ColumnFilter filter, TableMetadata metadata)
      Description copied from interface: Row
      Returns a copy of this row that: 1) only includes the data for the column included by filter. 2) doesn't include any data that belongs to a dropped column (recorded in metadata).
      Specified by:
      filter in interface Row
    • filter

      public Row filter(ColumnFilter filter, DeletionTime activeDeletion, boolean setActiveDeletionToRow, TableMetadata metadata)
      Description copied from interface: Row
      Returns a copy of this row that: 1) only includes the data for the column included by filter. 2) doesn't include any data that belongs to a dropped column (recorded in metadata). 3) doesn't include any data that is shadowed/deleted by activeDeletion. 4) uses activeDeletion as row deletion iff setActiveDeletionToRow and activeDeletion supersedes the row deletion.
      Specified by:
      filter in interface Row
    • transformAndFilter

      public Row transformAndFilter(LivenessInfo info, Row.Deletion deletion, Function<ColumnData,ColumnData> function)
      Description copied from interface: Row
      Requires that function returns either null or ColumnData for the same column. Returns a copy of this row that: 1) function has been applied to the members of 2) doesn't include any null results of function 3) has precisely the provided LivenessInfo and Deletion
      Specified by:
      transformAndFilter in interface Row
    • transformAndFilter

      public Row transformAndFilter(Function<ColumnData,ColumnData> function)
      Description copied from interface: Row
      Requires that function returns either null or ColumnData for the same column. Returns a copy of this row that: 1) function has been applied to the members of 2) doesn't include any null results of function
      Specified by:
      transformAndFilter in interface Row
    • clone

      public Row clone(Cloner cloner)
      Specified by:
      clone in interface Row
    • purgeDataOlderThan

      public Row purgeDataOlderThan(long timestamp, boolean enforceStrictLiveness)
      Specified by:
      purgeDataOlderThan in interface Row
    • purge

      public Row purge(DeletionPurger purger, long nowInSec, boolean enforceStrictLiveness)
      Description copied from interface: Row
      Returns a copy of this row without any deletion info that should be purged according to purger.
      Specified by:
      purge in interface Row
      Parameters:
      purger - the DeletionPurger 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 from TableMetadata.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, returns null.
    • withOnlyQueriedData

      public Row withOnlyQueriedData(ColumnFilter filter)
      Description copied from interface: Row
      Returns a copy of this row which only include the data queried by filter, excluding anything _fetched_ for internal reasons but not queried by the user (see ColumnFilter for details).
      Specified by:
      withOnlyQueriedData in interface Row
      Parameters:
      filter - the ColumnFilter 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.
    • markCounterLocalToBeCleared

      public Row markCounterLocalToBeCleared()
      Description copied from interface: Row
      Returns a copy of this row where all counter cells have they "local" shard marked for clearing.
      Specified by:
      markCounterLocalToBeCleared in interface Row
    • updateAllTimestamp

      public Row updateAllTimestamp(long newTimestamp)
      Description copied from interface: Row
      Returns a copy of this row where all live timestamp have been replaced by newTimestamp and every deletion timestamp by newTimestamp - 1.
      Specified by:
      updateAllTimestamp in interface Row
      Parameters:
      newTimestamp - the timestamp to use for all live data in the returned row.
      See Also:
    • withRowDeletion

      public Row withRowDeletion(DeletionTime deletion)
      Description copied from interface: Row
      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.

      Specified by:
      withRowDeletion in interface Row
    • dataSize

      public int dataSize()
      Specified by:
      dataSize in interface Row
    • unsharedHeapSize

      public long unsharedHeapSize()
      Specified by:
      unsharedHeapSize in interface IMeasurableMemory
      Specified by:
      unsharedHeapSize in interface Row
      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.
    • unsharedHeapSizeExcludingData

      public long unsharedHeapSizeExcludingData()
      Specified by:
      unsharedHeapSizeExcludingData in interface Row
    • toString

      public String toString(TableMetadata metadata, boolean fullDetails)
      Specified by:
      toString in interface Row
      Specified by:
      toString in interface Unfiltered
    • toString

      public String toString(TableMetadata metadata, boolean includeClusterKeys, boolean fullDetails)
      Specified by:
      toString in interface Unfiltered
    • apply

      public void apply(Consumer<ColumnData> function)
      Description copied from interface: Row
      Apply a function to every column in a row
      Specified by:
      apply in interface Row
    • apply

      public <A> void apply(BiConsumer<A,ColumnData> function, A arg)
      Description copied from interface: Row
      Apply a function to every column in a row
      Specified by:
      apply in interface Row
    • accumulate

      public long accumulate(LongAccumulator<ColumnData> accumulator, long initialValue)
      Description copied from interface: Row
      Apply an accumulation funtion to every column in a row
      Specified by:
      accumulate in interface Row
    • accumulate

      public long accumulate(LongAccumulator<ColumnData> accumulator, Comparator<ColumnData> comparator, ColumnData from, long initialValue)
      Specified by:
      accumulate in interface Row
    • accumulate

      public <A> long accumulate(BiLongAccumulator<A,ColumnData> accumulator, A arg, long initialValue)
      Specified by:
      accumulate in interface Row
    • accumulate

      public <A> long accumulate(BiLongAccumulator<A,ColumnData> accumulator, A arg, Comparator<ColumnData> comparator, ColumnData from, long initialValue)
      Specified by:
      accumulate in interface Row
    • iterator

      public Iterator<ColumnData> iterator()
      Specified by:
      iterator in interface Iterable<ColumnData>
    • toString

      public String toString()
      Overrides:
      toString in class Object