Package com.terracottatech.store
Interface UpdateOperation.WriteOperationBuilder<T,D extends CellDefinition<T>>
- Type Parameters:
T
- the type of the cellD
- the type of the associated definition
- All Known Subinterfaces:
UpdateOperation.BoolWriteOperationBuilder
,UpdateOperation.DoubleWriteOperationBuilder
,UpdateOperation.IntWriteOperationBuilder
,UpdateOperation.LongWriteOperationBuilder
- Enclosing interface:
- UpdateOperation<K extends Comparable<K>>
public static interface UpdateOperation.WriteOperationBuilder<T,D extends CellDefinition<T>>
A builder for a transform that writes a single cell.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <K extends Comparable<K>>
UpdateOperation.CellUpdateOperation<K,T> Creates a transform that writes a cell with the supplied definition and value derived by applying the function to the existing record.<K extends Comparable<K>>
UpdateOperation.CellUpdateOperation<K,T> Creates a transform that writes a cell with the supplied definition and value.<K extends Comparable<K>>
UpdateOperation.CellUpdateOperation<K,T> Creates a transform that writes a cell with the supplied definition and a value derived via a function of that definition.
-
Method Details
-
value
Creates a transform that writes a cell with the supplied definition and value.- Type Parameters:
K
- the type of the key- Parameters:
value
- cell value- Returns:
- a single cell writing transform
-
valueFrom
<K extends Comparable<K>> UpdateOperation.CellUpdateOperation<K,T> valueFrom(Function<D, Function<? super Record<?>, T>> function) Creates a transform that writes a cell with the supplied definition and a value derived via a function of that definition.This allows for a less verbose and error-prone approach to performing operations on single cells:
datasetWriter.update(id, write(BYTES_CELL).valueFrom( cell -> cell.valueOr(new byte[0]).append(data) ) );
This above reads as:- Update the record with key
id
. - Write to the cell
BYTES_CELL
... - the existing cell value or an empty byte array...
- with
data
appended on the end.
Note that the function object passed to this method is always executed locally and does not need to be
behaviorally transparent
. It is the result of this function that will be a candidate for remote execution and optimization by the implementation. Performance may benefit if the result of this function is behaviorally transparent due to the use of the functional DSL.- Type Parameters:
K
- the type of the key- Parameters:
function
- cell value function generator- Returns:
- a single cell writing transform
- Update the record with key
-
resultOf
default <K extends Comparable<K>> UpdateOperation.CellUpdateOperation<K,T> resultOf(Function<? super Record<?>, T> function) Creates a transform that writes a cell with the supplied definition and value derived by applying the function to the existing record.- Type Parameters:
K
- the type of the key- Parameters:
function
- cell value function- Returns:
- a single cell writing transform
-