update
The update
method creates a new table containing a new, in-memory column for each argument.
When using update
, the new columns are evaluated and stored in memory. Existing columns are referenced without additional memory allocation.
The syntax for the update
, updateView
, and lazyUpdate
methods is identical, as is the resulting table. update
is recommended when:
- all the source columns are desired in the result,
- the formula is expensive to evaluate,
- cells are accessed many times, and/or
- a large amount of memory is available.
When memory usage or computation needs to be reduced, consider using select
, view
, updateView
, or lazyUpdate
. These methods have different memory and computation expenses.
Syntax
table.update(columns...)
Parameters
Parameter | Type | Description |
---|---|---|
columns | String... | Formulas to compute columns in the new table; e.g., |
columns | Collection<? extends Selectable> | Formulas to compute columns in the new table; e.g., |
Returns
A new table that includes all the original columns from the source table and the newly defined in-memory columns.
Examples
In the following example, the new columns (A
, X
, and Y
) allocate memory and are immediately populated with values. Columns B
and C
refer to columns in the source table and do not allocate memory.
source = newTable(
stringCol("A", "The", "At", "Is", "On"),
intCol("B", 1, 2, 3, 4),
intCol("C", 5, 6, 7, 8)
)
result = source.update("A", "X = B", "Y = sqrt(C)")
- source
- result