org.apache.cassandra.db.rows

## Interface Row.Builder

- All Known Implementing Classes:
    BTreeRow.Builder
  Enclosing interface:
    Row

      public static interface Row.Builder

  Interface for building rows.

  The builder of a row should always abid to the following rules: 1) `newRow(org.apache.cassandra.db.Clustering)` is always called as the first thing for the row. 2) `addPrimaryKeyLivenessInfo(org.apache.cassandra.db.LivenessInfo)` and `addRowDeletion(org.apache.cassandra.db.rows.Row.Deletion)`, if called, are called before any `addCell(org.apache.cassandra.db.rows.Cell)`/`addComplexDeletion(org.apache.cassandra.config.ColumnDefinition, org.apache.cassandra.db.DeletionTime)` call. 3) `build()` is called to construct the new row. The builder can then be reused. There is 2 variants of a builder: sorted and unsorted ones. A sorted builder expects user to abid to the following additional rules: 4) Calls to `addCell(org.apache.cassandra.db.rows.Cell)`/`addComplexDeletion(org.apache.cassandra.config.ColumnDefinition, org.apache.cassandra.db.DeletionTime)` are done in strictly increasing column order. In other words, all calls to these methods for a give column `c` are done after any call for any column before `c` and before any call for any column after `c`. 5) Calls to `addCell(org.apache.cassandra.db.rows.Cell)` are further done in strictly increasing cell order (the one defined by `Cell.comparator`. That is, for a give column, cells are passed in `CellPath` order. 6) No shadowed data should be added. Concretely, this means that if a a row deletion is added, it doesn't deletes the row timestamp or any cell added later, and similarly no cell added is deleted by the complex deletion of the column this is a cell of. An unsorted builder will not expect those last rules however: `addCell(org.apache.cassandra.db.rows.Cell)` and `addComplexDeletion(org.apache.cassandra.config.ColumnDefinition, org.apache.cassandra.db.DeletionTime)` can be done in any order. And in particular unsorted builder allows multiple calls for the same column/cell. In that latter case, the result will follow the usual reconciliation rules (so equal cells are reconciled with `Cells.reconcile(org.apache.cassandra.db.rows.Cell, org.apache.cassandra.db.rows.Cell, org.apache.cassandra.db.DeletionTime, org.apache.cassandra.db.rows.Row.Builder, int)` and the "biggest" of multiple complex deletion for the same column wins).

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addCell(Cell cell)` Adds a cell to this builder.
    `void` | `addComplexDeletion(ColumnDefinition column, DeletionTime complexDeletion)` Adds a complex deletion.
    `void` | `addPrimaryKeyLivenessInfo(LivenessInfo info)` Adds the liveness information for the partition key columns of this row.
    `void` | `addRowDeletion(Row.Deletion deletion)` Adds the deletion information for this row.
    `Row` | `build()` Builds and return built row.
    `Clustering` | `clustering()` The clustering for the row that is currently being built.
    `Row.Builder` | `copy()` Creates a copy of this `Builder`.
    `boolean` | `isSorted()` Whether the builder is a sorted one or not.
    `void` | `newRow(Clustering clustering)` Prepares the builder to build a new row of clustering `clustering`.

- - ### Method Detail

    - #### copy

          Row.Builder copy()

      Creates a copy of this `Builder`.
      Returns:
        a copy of this `Builder`

    - #### isSorted

          boolean isSorted()

      Whether the builder is a sorted one or not.
      Returns:
        if the builder requires calls to be done in sorted order or not (see above).

    - #### newRow

          void newRow(Clustering clustering)

      Prepares the builder to build a new row of clustering `clustering`.

      This should always be the first call for a given row.

      Parameters:
        `clustering` - the clustering for the new row.

    - #### clustering

          Clustering clustering()

      The clustering for the row that is currently being built.
      Returns:
        the clustering for the row that is currently being built, or `null` if `newRow(org.apache.cassandra.db.Clustering)` hasn't yet been called.

    - #### addPrimaryKeyLivenessInfo

          void addPrimaryKeyLivenessInfo(LivenessInfo info)

      Adds the liveness information for the partition key columns of this row. This call is optional (skipping it is equivalent to calling `addPartitionKeyLivenessInfo(LivenessInfo.NONE)`).
      Parameters:
        `info` - the liveness information for the partition key columns of the built row.

    - #### addRowDeletion

          void addRowDeletion(Row.Deletion deletion)

      Adds the deletion information for this row. This call is optional and can be skipped if the row is not deleted.
      Parameters:
        `deletion` - the row deletion time, or `Deletion.LIVE` if the row isn't deleted.

    - #### addCell

          void addCell(Cell cell)

      Adds a cell to this builder.
      Parameters:
        `cell` - the cell to add.

    - #### addComplexDeletion

          void addComplexDeletion(ColumnDefinition column,
                                  DeletionTime complexDeletion)

      Adds a complex deletion.
      Parameters:
        `column` - the column for which to add the `complexDeletion`.
        `complexDeletion` - the complex deletion time to add.

    - #### build

          Row build()

      Builds and return built row.
      Returns:
        the last row built by this builder.

Copyright © 2018 The Apache Software Foundation