org.apache.cassandra.db.rows

## Class Cells

- java.lang.Object
- - org.apache.cassandra.db.rows.Cells

    public abstract class Cells
    extends java.lang.Object

Static methods to work on cells.

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `addNonShadowed(Cell existing, Cell update, DeletionTime deletion, Row.Builder builder, int nowInSec)` Adds to the builder a representation of the given existing cell that, when merged/reconciled with the given update cell, produces the same result as merging the original with the update.
`static void` `addNonShadowedComplex(ColumnDefinition column, java.util.Iterator<Cell> existing, java.util.Iterator<Cell> update, DeletionTime deletion, Row.Builder builder, int nowInSec)` Adds to the builder a representation of the given existing cell that, when merged/reconciled with the given update cell, produces the same result as merging the original with the update.
`static void` `collectStats(Cell cell, PartitionStatisticsCollector collector)` Collect statistics ont a given cell.
`static long` `reconcile(Cell existing, Cell update, DeletionTime deletion, Row.Builder builder, int nowInSec)` Reconciles/merges two cells, one being an update to an existing cell, yielding index updates if appropriate.
`static Cell` `reconcile(Cell c1, Cell c2, int nowInSec)` Reconciles/merge two cells.
`static long` `reconcileComplex(ColumnDefinition column, java.util.Iterator<Cell> existing, java.util.Iterator<Cell> update, DeletionTime deletion, Row.Builder builder, int nowInSec)` Computes the reconciliation of a complex column given its pre-existing cells and the ones it is updated with, and generating index update if appropriate.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### collectStats

    public static void collectStats(Cell cell,
                                    PartitionStatisticsCollector collector)

Collect statistics ont a given cell.

Parameters:
  `cell` - the cell for which to collect stats.
  `collector` - the stats collector.

#### reconcile

    public static long reconcile(Cell existing,
                                 Cell update,
                                 DeletionTime deletion,
                                 Row.Builder builder,
                                 int nowInSec)

Reconciles/merges two cells, one being an update to an existing cell, yielding index updates if appropriate.

Note that this method assumes that the provided cells can meaningfully be reconciled together, that is that those cells are for the same row and same column (and same cell path if the column is complex).

Also note that which cell is provided as `existing` and which is provided as `update` matters for index updates.

Parameters:
  `existing` - the pre-existing cell, the one that is updated. This can be `null` if this reconciliation correspond to an insertion.
  `update` - the newly added cell, the update. This can be `null` out of convenience, in which case this function simply copy `existing` to `writer`.
  `deletion` - the deletion time that applies to the cells being considered. This deletion time may delete both `existing` or `update`.
  `builder` - the row builder to which the result of the reconciliation is written.
  `nowInSec` - the current time in seconds (which plays a role during reconciliation because deleted cells always have precedence on timestamp equality and deciding if a cell is a live or not depends on the current time due to expiring cells).
Returns:
  the timestamp delta between existing and update, or `Long.MAX_VALUE` if one of them is `null` or deleted by `deletion`).

#### reconcile

    public static Cell reconcile(Cell c1,
                                 Cell c2,
                                 int nowInSec)

Reconciles/merge two cells.

Note that this method assumes that the provided cells can meaningfully be reconciled together, that is that cell are for the same row and same column (and same cell path if the column is complex).

This method is commutative over it's cells arguments: `reconcile(a, b, n) == reconcile(b, a, n)`.

Parameters:
  `c1` - the first cell participating in the reconciliation.
  `c2` - the second cell participating in the reconciliation.
  `nowInSec` - the current time in seconds (which plays a role during reconciliation because deleted cells always have precedence on timestamp equality and deciding if a cell is a live or not depends on the current time due to expiring cells).
Returns:
  a cell corresponding to the reconciliation of `c1` and `c2`. For non-counter cells, this will always be either `c1` or `c2`, but for counter cells this can be a newly allocated cell.

#### reconcileComplex

    public static long reconcileComplex(ColumnDefinition column,
                                        java.util.Iterator<Cell> existing,
                                        java.util.Iterator<Cell> update,
                                        DeletionTime deletion,
                                        Row.Builder builder,
                                        int nowInSec)

Computes the reconciliation of a complex column given its pre-existing cells and the ones it is updated with, and generating index update if appropriate.

Note that this method assumes that the provided cells can meaningfully be reconciled together, that is that the cells are for the same row and same complex column.

Also note that which cells is provided as `existing` and which are provided as `update` matters for index updates.

Parameters:
  `column` - the complex column the cells are for.
  `existing` - the pre-existing cells, the ones that are updated. This can be `null` if this reconciliation correspond to an insertion.
  `update` - the newly added cells, the update. This can be `null` out of convenience, in which case this function simply copy the cells from `existing` to `writer`.
  `deletion` - the deletion time that applies to the cells being considered. This deletion time may delete cells in both `existing` and `update`.
  `builder` - the row build to which the result of the reconciliation is written.
  `nowInSec` - the current time in seconds (which plays a role during reconciliation because deleted cells always have precedence on timestamp equality and deciding if a cell is a live or not depends on the current time due to expiring cells).
Returns:
  the smallest timestamp delta between corresponding cells from existing and update. A timestamp delta being computed as the difference between a cell from `update` and the cell in `existing` having the same cell path (if such cell exists). If the intersection of cells from `existing` and `update` having the same cell path is empty, this returns `Long.MAX_VALUE`.

#### addNonShadowed

    public static void addNonShadowed(Cell existing,
                                      Cell update,
                                      DeletionTime deletion,
                                      Row.Builder builder,
                                      int nowInSec)

Adds to the builder a representation of the given existing cell that, when merged/reconciled with the given update cell, produces the same result as merging the original with the update.

For simple cells that is either the original cell (if still live), or nothing (if shadowed).

Parameters:
  `existing` - the pre-existing cell, the one that is updated.
  `update` - the newly added cell, the update. This can be `null` out of convenience, in which case this function simply copy `existing` to `writer`.
  `deletion` - the deletion time that applies to the cells being considered. This deletion time may delete both `existing` or `update`.
  `builder` - the row builder to which the result of the filtering is written.
  `nowInSec` - the current time in seconds (which plays a role during reconciliation because deleted cells always have precedence on timestamp equality and deciding if a cell is a live or not depends on the current time due to expiring cells).

#### addNonShadowedComplex

    public static void addNonShadowedComplex(ColumnDefinition column,
                                             java.util.Iterator<Cell> existing,
                                             java.util.Iterator<Cell> update,
                                             DeletionTime deletion,
                                             Row.Builder builder,
                                             int nowInSec)

Adds to the builder a representation of the given existing cell that, when merged/reconciled with the given update cell, produces the same result as merging the original with the update.

For simple cells that is either the original cell (if still live), or nothing (if shadowed).

Parameters:
  `column` - the complex column the cells are for.
  `existing` - the pre-existing cells, the ones that are updated.
  `update` - the newly added cells, the update. This can be `null` out of convenience, in which case this function simply copy the cells from `existing` to `writer`.
  `deletion` - the deletion time that applies to the cells being considered. This deletion time may delete both `existing` or `update`.
  `builder` - the row builder to which the result of the filtering is written.
  `nowInSec` - the current time in seconds (which plays a role during reconciliation because deleted cells always have precedence on timestamp equality and deciding if a cell is a live or not depends on the current time due to expiring cells).