updateView
The updateView
method creates a new table containing a new, formula column for each argument.
When using updateView
, the new columns are not stored in memory. Rather, a formula is stored that is used to recalculate each cell every time it is accessed.
The syntax for the updateView
, update
, and lazyUpdate
methods is identical, as is the resulting table. updateView
is recommended when:
- the formula is fast to compute,
- only a small portion of the data is being accessed,
- cells are accessed very few times, or
- memory usage must be minimized.
For other cases, consider using select
, view
, update
, or lazyUpdate
. These methods have different memory and computation expenses.
Syntax
table.updateView(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 formula columns.
Examples
In the following example, a new table containing the columns from the source table plus two new columns, X
and Y
, is created.
source = newTable(
stringCol("A", "The", "At", "Is", "On"),
intCol("B", 1, 2, 3, 4),
intCol("C", 5, 6, 7, 8)
)
result = source.updateView("X = B", "Y = sqrt(C)")
- source
- result