rollup
The deephaven rollup
method creates a rollup table from a source table given zero or more aggregations and zero or more grouping columns to create hierarchy from.
Syntax
source.rollup(aggregations)
source.rollup(aggregations, includeConstituents)
source.rollup(aggregations, groupByColumns...)
source.rollup(aggregations, includeConstituents, groupByColumns...)
Parameters
Parameter | Type | Description |
---|---|---|
aggregations | Collection<? extends Aggregation> | One or more aggregations. |
includeConstituents optional | boolean | Whether or not to include constituent rows at the leaf level. The default value is |
groupByColumns | String... | One or more columns to group on and create hierarchy from. |
Methods
Instance
getAggregations
- Get the aggregations performed in therollup
operation.getGroupByColumns
- Get thegroupByColumns
used for therollup
operation.getLeafNodeType
- Get theNodeType
at the leaf level.getNodeDefinition(nodeType)
- Get theTableDefinition
that should be exposed to node table consumers.includesConstituents
- Returns a boolean indicating whether or not the constituent rows at the lowest level are included.makeNodeOperationsRecorder(nodeType)
- Get arecorder
for per-node operations to apply during snapshots of the requestedNodeType
.translateAggregatedNodeOperationsForConstituentNodes(aggregatedNodeOperationsToTranslate)
- Translate node operations for aggregated nodes to the closest equivalent for a constituent node.withFilters(filters...)
- Create a new rollup table that will apply a set of filters to thegroupByColumns
of the rollup table.withNodeOperations(nodeOperations...)
- Create a new rollup table that will apply therecorded
operations to nodes when gathering snapshots.
Returns
A rollup table.
Examples
The following example creates a rollup table from a source table of insurance expense data. The aggregated average of the bmi
and expenses
columns are calculated, then the table is rolled up by the region
and age
column.
import static io.deephaven.csv.CsvTools.readCsv
import io.deephaven.api.agg.spec.AggSpec
import io.deephaven.api.agg.Aggregation
insurance = readCsv("https://media.githubusercontent.com/media/deephaven/examples/main/Insurance/csv/insurance.csv")
aggList = [Aggregation.of(AggSpec.avg(), "bmi", "expenses")]
insuranceRollup = insurance.rollup(aggList, false, "region", "age")
- insurance
- insuranceRollup
The following example creates a rollup table from real-time source data. The source data updates 10,000 times per second. The result
rollup table can be expanded by the N
column to show unique values of M
for each N
. The aggregated average and sum are calculated for the Value
and Weight
, respectively.
import io.deephaven.api.agg.spec.AggSpec
import io.deephaven.api.agg.Aggregation
aggList = [Aggregation.of(AggSpec.avg(), "Value"), Aggregation.of(AggSpec.sum(), "Weight")]
rows = emptyTable(1_000_000).updateView("Group = i", "N = i % 347", "M = i % 29")
changes = timeTable("PT00:00:00.0001").view("Group = i % 1_000_000", "LastModified = Timestamp", "Value = (i * Math.sin(i)) % 6977", "Weight = (i * Math.sin(i)) % 7151").lastBy("Group")
source = rows.join(changes, "Group")
result = source.rollup(aggList, false, "N", "M")