Interface JsTableOperations
- All Superinterfaces:
ServerObject
- All Known Subinterfaces:
JsPendingTable<T>,JsResolvedTable
- All Known Implementing Classes:
MicrotaskBatchImpl
Every instance represents one server-side table, with its definition fixed when created. Compared with a
JsTable, it is "immutable", and has no methods to change its columns, filters, sort, etc. A ticking table's
rows still change as the server's update graph adds, removes, and modifies them. Each operation returns a new pending
table, so the caller decides the order of operations by how they chain them.
Each table holds server resources until it is closed, by whoever owns it:
- Awaiting a
JsPendingTablegives the table it produces, andJsPendingTable.resolve(Object)gives it as aJsResolvedTable. Use one or the other, not both; repeating the same one gives the same instance, as awaiting a promise twice does. A pending table has no owner: whoever awaits or resolves it owns that instance, and is responsible for closing it. - A
JsResolvedTableis already the table: it cannot be awaited, since awaiting a thenable would also await what it resolves to, and needs no resolving. - Code that receives a table and its caller agree on whether that code may close it. Code given a
TableOperationscan only chain on it, so it never retains a table its caller cannot reach to close. Code that reads a table should take aJsResolvedTable, which the sender resolves before handing it over, and code that keeps one it was lent can callJsResolvedTable.copy()for a new instance with its own lifetime.
const t = await pending; popupA.show(t.copy()); popupB.show(t.copy()); t.close();
No method throws: as from an async function, every failure rejects the pending table it returns. That includes
invalid arguments, an operand from another connection and a closed table, which reject with the error and send
nothing to the server, as well as a failure on the server or of a table the operation uses, if it was canceled,
failed, or used too late. JsPendingTable describes how long a pending table may be used.
async function process(table: dh.TableOperations) {
const result = await table
.where([dh.FilterValue.ofColumn("A").greaterThan(dh.FilterValue.ofNumber(5))])
.sort([{column: "B", direction: "DESC"}])
.head(10);
// From here on, `table` may already be closed. This function did not retain it, and cannot tell whether the
// caller did.
try {
const a = result.findColumn("A");
const data = await result.createSnapshot({
rows: {first: 0, last: 9},
columns: [a, "B"]
});
return data.getData(0, a);
} finally {
result.close();
}
}
The process example only chains on the table it is given, so it works whether the caller passes a pending or
a resolved table, and closes only what its own chain produced. To keep a table for later, take a
ResolvedTable and copy it: below, SwapFilters owns its copy and each filtered table it makes, and closes each
when replaced or when it is closed.
class SwapFilters {
private readonly table: dh.ResolvedTable;
private filteredTable: Promise<dh.ResolvedTable> | null = null;
constructor(table: dh.ResolvedTable) {
// The caller keeps its own table; this class owns the copy
this.table = table.copy();
}
changeFilters(filters: ReadonlyArray<dh.FilterCondition>) {
if (this.filteredTable) {
// A table that failed has nothing to close
this.filteredTable.then(t => t.close(), () => {});
}
this.filteredTable = Promise.resolve(this.table.where(filters));
}
async loadData(): Promise<dh.TableData> {
if (!this.filteredTable) {
throw new Error("no filters set");
}
const t = await this.filteredTable;
return t.createSnapshot({
rows: {first:0, last:1_000_000},
columns: t.columns
})
}
close() {
this.table.close();
if (this.filteredTable) {
this.filteredTable.then(t => t.close(), () => {});
}
}
}
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic interfaceSpecifies the type of natural join to perform - specifically, how to handle duplicate and missing right hand table rows.static interfacestatic classThe range part of arangeJoin(io.deephaven.web.client.api.JsTableReference, elemental2.core.ReadonlyArray<java.lang.String>, io.deephaven.web.client.api.JsTableOperations.RangeJoinMatch, elemental2.core.ReadonlyArray<io.deephaven.web.client.api.agg.AggregationUnion>): a right row matches a left row when itsrightRangeColumnvalue lies between the left row'sleftStartColumnandleftEndColumnvalues, as the two rules say.static interfacestatic classstatic classNested classes/interfaces inherited from interface io.deephaven.web.client.api.ServerObject
ServerObject.Union -
Method Summary
Modifier and TypeMethodDescriptiondefault JsPendingTable<JsResolvedTable> absSumBy(@JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the sum of absolute values of each column within each group.default JsPendingTable<JsResolvedTable> aggAllBy(AggAllByUnion aggUnion, @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Applies a single aggregation to all columns.default JsPendingTable<JsResolvedTable> aggBy(AggByOptions options) Aggregates the contents of this table into a new table.default JsPendingTable<JsResolvedTable> aj(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd) Performs an as-of join of this table with the right table: each row takes the right table's row with the closest as-of value at or before its own.default JsPendingTable<JsResolvedTable> avgBy(@JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the arithmetic mean of each column within each group.default JsPendingTable<JsResolvedTable> call(Ticket resultId, BatchTableRequest.Operation.Builder operation) Ascall(Ticket, BatchTableRequest.Operation.Builder, JsTableReference), with no other table.call(Ticket resultId, BatchTableRequest.Operation.Builder operation, @Nullable JsTableReference operand) Internal method to make the async call to the server.default JsPendingTable<JsResolvedTable> countBy(String columnName, @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Counts the number of rows in each group, storing the result in a new column.default JsPendingTable<JsResolvedTable> Creates a table with fewer rows than this one that draws the same as a line plot at the given width, for plotting large time series.default JsPendingTable<JsResolvedTable> dropColumns(elemental2.core.ReadonlyArray<Column.ColumnOrName> columnsToDrop) Creates a new table without the specified columns.default JsPendingTable<JsResolvedTable> exactJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd) Performs an exact join of this table with the right table.default JsPendingTable<JsResolvedTable> firstBy(@JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Returns the first row of each group.default JsPendingTable<JsResolvedTable> flatten()Creates a version of this table with a flat rowset.default JsPendingTable<JsResolvedTable> groupBy(@JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Groups the table by the specified columns, accumulating the other columns into arrays.default JsPendingTable<JsResolvedTable> Creates a table with the given number of rows from the beginning of this table.default JsPendingTable<JsResolvedTable> join(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd, @JsNullable Double reserveBits) Performs a cross join (Cartesian product) of this table with the right table, filtered to matching rows.default JsPendingTable<JsResolvedTable> lastBy(@JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Returns the last row of each group.default JsPendingTable<JsResolvedTable> lazyUpdate(elemental2.core.ReadonlyArray<JsTable.CustomColumnArgUnionType> columns) Creates a new table appending or replacing the specified columns.default JsPendingTable<JsResolvedTable> maxBy(@JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Returns the maximum value of each column within each group.default JsPendingTable<JsResolvedTable> medianBy(@JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the median of each column within each group.default JsPendingTable<JsResolvedTable> minBy(@JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Returns the minimum value of each column within each group.default JsPendingTable<JsResolvedTable> naturalJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd, @JsNullable JsTableOperations.NaturalJoinType joinType) Perform a natural-join with therightTable.default JsPendingTable<JsResolvedTable> raj(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd) Performs a reverse as-of join of this table with the right table: each row takes the right table's row with the closest as-of value at or after its own.default JsPendingTable<JsResolvedTable> rangeJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<String> exactMatches, JsTableOperations.RangeJoinMatch rangeMatch, elemental2.core.ReadonlyArray<AggregationUnion> aggregations) Joins each row of this table to the rows ofrightTablethat match it exactly onexactMatchesand fall in its range, and aggregates those right rows into columns of the result.Internal method: a pending table that rejects withfailure, which each operation returns instead of throwing, as an async function would.default JsPendingTable<JsResolvedTable> reverse()Creates a table with all the rows of this table in reverse order.default JsPendingTable<JsResolvedTable> select(elemental2.core.ReadonlyArray<JsTable.CustomColumnArgUnionType> columns) Creates a new table with only the specified columns.default JsPendingTable<JsResolvedTable> selectDistinct(@JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> columnNames) Creates a new table with only the distinct values of the specified columns.default JsPendingTable<JsResolvedTable> slice(TableData.RowPositionUnion firstPositionInclusive, TableData.RowPositionUnion lastPositionExclusive) Extracts a subset of a table by row position.default JsPendingTable<JsResolvedTable> snapshot()A server-side snapshot of the entire table as of the time the request is processed.default JsPendingTable<JsResolvedTable> snapshotWhen(JsTableReference trigger, @JsNullable JsTableOperations.SnapshotWhenOptions options) Creates a table that captures a snapshot of this table whenever the trigger table updates.default JsPendingTable<JsResolvedTable> sort(elemental2.core.ReadonlyArray<Sort.SortUnion> sorts) Sorts the table by the given columns.default JsPendingTable<JsResolvedTable> stdBy(@JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the sample standard deviation of each column within each group, using Bessel's correction.default JsPendingTable<JsResolvedTable> sumBy(@JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the sum of each column within each group.default JsPendingTable<JsResolvedTable> Creates a table with the given number of rows from the end of this table.default JsPendingTable<JsResolvedTable> ungroup(@JsNullable JsTableOperations.UngroupOptions options) Ungroups a table by expanding columns of arrays or vectors into columns of singular values, creating one row in the output table for each value in the columns being ungrouped.default JsPendingTable<JsResolvedTable> update(elemental2.core.ReadonlyArray<JsTable.CustomColumnArgUnionType> columns) Creates a new table, appending or replacing the specified columns.default JsPendingTable<JsResolvedTable> updateBy(UpdateByOptions options) Adds or replaces columns whose value in each row depends on the rows around it in its group: cumulative operations, rolling windows, exponential moving statistics, fills and deltas.default JsPendingTable<JsResolvedTable> updateView(elemental2.core.ReadonlyArray<JsTable.CustomColumnArgUnionType> columns) Creates a new table, appending or replacing the specified columns.default JsPendingTable<JsResolvedTable> varBy(@JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the sample variance of each column within each group, using Bessel's correction.default JsPendingTable<JsResolvedTable> view(elemental2.core.ReadonlyArray<JsTable.CustomColumnArgUnionType> columns) Creates a new table with only the specified columns.default JsPendingTable<JsResolvedTable> wavgBy(Column.ColumnOrName weightColumn, @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the weighted average of each column within each group: the sum of each value multiplied by its weight, divided by the sum of the weights.default JsPendingTable<JsResolvedTable> where(elemental2.core.ReadonlyArray<FilterCondition> conditions) Creates a table that filters the contents of this table based on the provided conditions.default JsPendingTable<JsResolvedTable> whereIn(JsTableReference rightTable, elemental2.core.ReadonlyArray<Column.ColumnOrName> columnsToMatch) Filters the contents of this table based on the set of values that match the provided right table.default JsPendingTable<JsResolvedTable> whereNotIn(JsTableReference rightTable, elemental2.core.ReadonlyArray<Column.ColumnOrName> columnsToMatch) Filters the contents of this table based on the set of values that do not match the provided right table.default JsPendingTable<JsResolvedTable> wsumBy(Column.ColumnOrName weightColumn, @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the weighted sum of each column within each group: the sum of each value multiplied by its weight.Methods inherited from interface io.deephaven.web.client.api.ServerObject
getConnection, typedTicket
-
Method Details
-
call
JsPendingTable<JsResolvedTable> call(Ticket resultId, BatchTableRequest.Operation.Builder operation, @Nullable JsTableReference operand) Internal method to make the async call to the server.- Parameters:
resultId- the ticket that the server populates with this resultoperation- the operation to performoperand- the other table the operation reads, if any. A pending table is checked and held along with the source table- Returns:
- a table operations instance that more calls can be chained on, or can be awaited
-
call
default JsPendingTable<JsResolvedTable> call(Ticket resultId, BatchTableRequest.Operation.Builder operation) Ascall(Ticket, BatchTableRequest.Operation.Builder, JsTableReference), with no other table. -
rejected
Internal method: a pending table that rejects withfailure, which each operation returns instead of throwing, as an async function would. -
head
Creates a table with the given number of rows from the beginning of this table.- Parameters:
size- the number of rows to keep from the beginning of this table- Returns:
- a new table with at most that many rows
-
tail
Creates a table with the given number of rows from the end of this table.- Parameters:
size- the number of rows to keep from the end of this table- Returns:
- a new table with at most that many rows
-
reverse
Creates a table with all the rows of this table in reverse order.- Returns:
- a new table with the rows in reverse order
-
snapshot
A server-side snapshot of the entire table as of the time the request is processed. The result does not update. This is whatJsTable.freeze()does. The name here follows the other Deephaven clients.- Returns:
- a new, non-ticking table with the same contents as this table at that moment
-
snapshotWhen
@JsMethod default JsPendingTable<JsResolvedTable> snapshotWhen(JsTableReference trigger, @JsOptional @JsNullable JsTableOperations.SnapshotWhenOptions options) Creates a table that captures a snapshot of this table whenever the trigger table updates.- Parameters:
trigger- the table to use as a trigger for when to take a snapshot of this tableoptions- options controlling when and how the result table updates. If omitted, every option takes its default.- Returns:
- the snapshot table
-
sort
@JsMethod default JsPendingTable<JsResolvedTable> sort(elemental2.core.ReadonlyArray<Sort.SortUnion> sorts) Sorts the table by the given columns.- Parameters:
sorts- the sorts to apply, in order of precedence- Returns:
- a sorted table
-
where
@JsMethod default JsPendingTable<JsResolvedTable> where(elemental2.core.ReadonlyArray<FilterCondition> conditions) Creates a table that filters the contents of this table based on the provided conditions.- Parameters:
conditions- the conditions to filter on.FilterValue.ofColumn(java.lang.String)names a column without a resolved table- Returns:
- a filtered table
-
whereIn
@JsMethod default JsPendingTable<JsResolvedTable> whereIn(JsTableReference rightTable, elemental2.core.ReadonlyArray<Column.ColumnOrName> columnsToMatch) Filters the contents of this table based on the set of values that match the provided right table.When the right table ticks, all the rows in this table are re-evaluated.
- Parameters:
rightTable- the table with the filter criteriacolumnsToMatch- the column matches between the two tables- Returns:
- a new filtered table
-
whereNotIn
@JsMethod default JsPendingTable<JsResolvedTable> whereNotIn(JsTableReference rightTable, elemental2.core.ReadonlyArray<Column.ColumnOrName> columnsToMatch) Filters the contents of this table based on the set of values that do not match the provided right table.When the right table ticks, all the rows in this table are re-evaluated.
- Parameters:
rightTable- the table with the filter criteriacolumnsToMatch- the column matches between the two tables- Returns:
- a new filtered table
-
slice
@JsMethod default JsPendingTable<JsResolvedTable> slice(TableData.RowPositionUnion firstPositionInclusive, TableData.RowPositionUnion lastPositionExclusive) Extracts a subset of a table by row position.If both
firstPositionInclusiveandlastPositionExclusiveare positive, both count from the beginning of the table. ThefirstPositionInclusiveis inclusive, and thelastPositionExclusiveis exclusive. Thehead(N)call is equivalent toslice(0, N). ThefirstPositionInclusivemust be less than or equal to thelastPositionExclusive.If
firstPositionInclusiveis positive andlastPositionExclusiveis negative, thefirstPositionInclusivecounts from the beginning of the table, inclusively. ThelastPositionExclusivecounts from the end of the table. For example,slice(1, -1)includes all rows but the first and last. If thelastPositionExclusivewould be before thefirstPositionInclusive, the result is an empty table.If
firstPositionInclusiveis negative andlastPositionExclusiveis zero, thefirstPositionInclusivecounts from the end of the table, and the slice ends at the end of the table. Callingslice(-N, 0)is equivalent totail(N).If the
firstPositionInclusiveis negative and thelastPositionExclusiveis negative, both count from the end of the table. For example,slice(-2, -1)returns the second to last row of the table.If
firstPositionInclusiveis negative andlastPositionExclusiveis positive, thefirstPositionInclusivecounts from the end of the table, inclusively. ThelastPositionExclusivecounts from the beginning of the table, exclusively. For example,slice(-3, 5)returns all rows starting from the third-last row to the fifth row of the table. If there are no rows between these positions, the result is an empty table.- Parameters:
firstPositionInclusive- the first position to include in the resultlastPositionExclusive- the position after the last one to include in the result- Returns:
- a new table with the subset of rows from the original table
-
view
@JsMethod default JsPendingTable<JsResolvedTable> view(elemental2.core.ReadonlyArray<JsTable.CustomColumnArgUnionType> columns) Creates a new table with only the specified columns. Computes each formula every time a value is read, and stores nothing.- Parameters:
columns- the columns or expressions to have in the new table- Returns:
- a new table with only those columns.
-
updateView
@JsMethod default JsPendingTable<JsResolvedTable> updateView(elemental2.core.ReadonlyArray<JsTable.CustomColumnArgUnionType> columns) Creates a new table, appending or replacing the specified columns. Computes each formula every time a value is read, and stores nothing.- Parameters:
columns- the columns or expressions to have in the new table- Returns:
- a new table with those columns appended
-
update
@JsMethod default JsPendingTable<JsResolvedTable> update(elemental2.core.ReadonlyArray<JsTable.CustomColumnArgUnionType> columns) Creates a new table, appending or replacing the specified columns. Computes all formulas eagerly and stores their values in memory.- Parameters:
columns- the columns or expressions to have in the new table- Returns:
- a new table with those columns appended
-
lazyUpdate
@TsIgnore @JsMethod default JsPendingTable<JsResolvedTable> lazyUpdate(elemental2.core.ReadonlyArray<JsTable.CustomColumnArgUnionType> columns) Creates a new table appending or replacing the specified columns. Computes each formula only when a value is read, and caches each result by the combination of the formula's inputs, reusing it when that combination repeats. The cache is never cleared, so this suits columns with few distinct inputs.- Parameters:
columns- the columns or expressions to have in the new table- Returns:
- a new table with those columns appended
-
select
@JsMethod default JsPendingTable<JsResolvedTable> select(elemental2.core.ReadonlyArray<JsTable.CustomColumnArgUnionType> columns) Creates a new table with only the specified columns. Computes all formulas eagerly and stores their values in memory.- Parameters:
columns- the columns or expressions to have in the new table- Returns:
- a new table with only those columns.
-
naturalJoin
@JsMethod default JsPendingTable<JsResolvedTable> naturalJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsOptional @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd, @JsOptional @JsNullable JsTableOperations.NaturalJoinType joinType) Perform a natural-join with therightTable.- Parameters:
rightTable- the right side table on the joincolumnsToMatch- the match pair conditionscolumnsToAdd- the columns from the right table to add to the result. If omitted, adds all non-match columnsjoinType- the type of join to perform- Returns:
- the natural-joined table
-
exactJoin
@JsMethod default JsPendingTable<JsResolvedTable> exactJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsOptional @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd) Performs an exact join of this table with the right table. Each row in this table must have exactly one matching row in the right table based on the match columns. If a row has no match, the operation fails.- Parameters:
rightTable- the table to join withcolumnsToMatch- the columns to match on, in "LeftCol=RightCol" formatcolumnsToAdd- the columns to add from the right table. If omitted, adds all non-match columns- Returns:
- a new table with the joined columns
-
join
@JsMethod default JsPendingTable<JsResolvedTable> join(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsOptional @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd, @JsOptional @JsNullable Double reserveBits) Performs a cross join (Cartesian product) of this table with the right table, filtered to matching rows. Each row in this table is paired with every matching row in the right table.- Parameters:
rightTable- the table to join withcolumnsToMatch- the columns to match on, in "LeftCol=RightCol" formatcolumnsToAdd- the columns to add from the right table. If omitted, adds all non-match columnsreserveBits- the number of bits of key-space to initially reserve per group. The default is 10- Returns:
- a new table with the joined columns
-
aj
@JsMethod default JsPendingTable<JsResolvedTable> aj(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsOptional @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd) Performs an as-of join of this table with the right table: each row takes the right table's row with the closest as-of value at or before its own.- Parameters:
rightTable- the table to join withcolumnsToMatch- the columns to match on. All but the last are exact matches ("LeftCol=RightCol"or a name in both tables). The last is the as-of match:"LeftCol>=RightCol","LeftCol>RightCol", or a name in both tables, which means>=.columnsToAdd- the columns to add from the right table. If omitted, adds all non-match columns- Returns:
- a new table with the joined columns
-
raj
@JsMethod default JsPendingTable<JsResolvedTable> raj(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsOptional @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd) Performs a reverse as-of join of this table with the right table: each row takes the right table's row with the closest as-of value at or after its own.- Parameters:
rightTable- the table to join withcolumnsToMatch- the columns to match on. All but the last are exact matches ("LeftCol=RightCol"or a name in both tables). The last is the as-of match:"LeftCol<=RightCol","LeftCol<RightCol", or a name in both tables, which means<=.columnsToAdd- the columns to add from the right table. If omitted, adds all non-match columns- Returns:
- a new table with the joined columns
-
rangeJoin
@JsMethod default JsPendingTable<JsResolvedTable> rangeJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<String> exactMatches, JsTableOperations.RangeJoinMatch rangeMatch, elemental2.core.ReadonlyArray<AggregationUnion> aggregations) Joins each row of this table to the rows ofrightTablethat match it exactly onexactMatchesand fall in its range, and aggregates those right rows into columns of the result. The result has one row per row of this table.At this time, the server supports only static (not refreshing) tables and
Groupaggregations. This operation remains under active development.- Parameters:
rightTable- the table to join toexactMatches- columns that must be equal in both tables, as"Col"or"LeftCol=RightCol"rangeMatch- the columns and rules of the range matchaggregations- the aggregations to apply to each row's matching right rows- Returns:
- a table with one row per row of this table, and a column for each aggregation
-
groupBy
@JsMethod default JsPendingTable<JsResolvedTable> groupBy(@JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Groups the table by the specified columns, accumulating the other columns into arrays. If no columns are provided, the resulting table has a single row.- Parameters:
groupByColumns- columns to group- Returns:
- a table with one row per group
-
aggAllBy
@JsMethod default JsPendingTable<JsResolvedTable> aggAllBy(AggAllByUnion aggUnion, @JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Applies a single aggregation to all columns.- Parameters:
aggUnion- the aggregation to applygroupByColumns- columns to group by- Returns:
- a new table with these aggregations applied to the data in this table
-
aggBy
Aggregates the contents of this table into a new table. Each aggregation adds columns computed over each group, and can be made with adh.agg.Aggregationfactory or written as an object literal:const summary = await table.aggBy({ aggregations: [ dh.agg.Aggregation.AggWAvg("W", ["WAvgX = X"]), dh.agg.Aggregation.AggAvg(["AvgX = X"]), { type: "Count", col: "N" }, ], groupByColumns: ["Key"], });- Parameters:
options- the aggregations, and optionally the columns to group by and the groups to start with- Returns:
- a table with one row per group, and a column for each aggregation
-
updateBy
Adds or replaces columns whose value in each row depends on the rows around it in its group: cumulative operations, rolling windows, exponential moving statistics, fills and deltas. WithoutUpdateByOptions.groupByColumns, the whole table is one group. For example, a weighted average over each row and the two before it in its group:const rolling = await table.updateBy({ operations: [{ spec: { type: "UpdateByRollingWAvg", weightColumn: "W", reverseWindowScale: { type: "ticks", ticks: 3 }, }, matchPairs: ["RollWAvgX = X"], }], groupByColumns: ["Key"], });- Parameters:
options- the operations to apply, and optionally the columns to group by and control settings- Returns:
- a table with the same rows as this table, and each operation's output columns added or replacing the columns of the same name
-
downsample
@JsMethod default JsPendingTable<JsResolvedTable> downsample(JsTableOperations.DownsampleTableOptions options) Creates a table with fewer rows than this one that draws the same as a line plot at the given width, for plotting large time series. Each pixel of the width keeps the rows that set its first, last, minimum and maximum values. If the table has fewer rows than that, the result is the table unchanged.- Parameters:
options- the columns to plot, the plot width, and optionally the visible X range- Returns:
- the downsampled table
-
selectDistinct
@JsMethod default JsPendingTable<JsResolvedTable> selectDistinct(@JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> columnNames) Creates a new table with only the distinct values of the specified columns. If no columns are specified, uses all columns.- Parameters:
columnNames- the column names to distinct on. If empty/null, uses all columns- Returns:
- a new table with only the distinct values of the specified columns
-
countBy
@JsMethod default JsPendingTable<JsResolvedTable> countBy(String columnName, @JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Counts the number of rows in each group, storing the result in a new column.- Parameters:
columnName- the name of the new column to hold the row countsgroupByColumns- columns to group by. If omitted, counts all rows into a single result- Returns:
- a new table with a count column and optional group-by columns
-
firstBy
@JsMethod default JsPendingTable<JsResolvedTable> firstBy(@JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Returns the first row of each group.- Parameters:
groupByColumns- columns to group by. If omitted, returns the first row of the table- Returns:
- a new table with the first row from each group
-
lastBy
@JsMethod default JsPendingTable<JsResolvedTable> lastBy(@JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Returns the last row of each group.- Parameters:
groupByColumns- columns to group by. If omitted, returns the last row of the table- Returns:
- a new table with the last row from each group
-
minBy
@JsMethod default JsPendingTable<JsResolvedTable> minBy(@JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Returns the minimum value of each column within each group.- Parameters:
groupByColumns- columns to group by. If omitted, computes the minimum across all rows- Returns:
- a new table with the minimum values
-
maxBy
@JsMethod default JsPendingTable<JsResolvedTable> maxBy(@JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Returns the maximum value of each column within each group.- Parameters:
groupByColumns- columns to group by. If omitted, computes the maximum across all rows- Returns:
- a new table with the maximum values
-
sumBy
@JsMethod default JsPendingTable<JsResolvedTable> sumBy(@JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the sum of each column within each group.- Parameters:
groupByColumns- columns to group by. If omitted, computes the sum across all rows- Returns:
- a new table with the sums
-
avgBy
@JsMethod default JsPendingTable<JsResolvedTable> avgBy(@JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the arithmetic mean of each column within each group.- Parameters:
groupByColumns- columns to group by. If omitted, computes the average across all rows- Returns:
- a new table with the averages
-
medianBy
@JsMethod default JsPendingTable<JsResolvedTable> medianBy(@JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the median of each column within each group. When the group size is even, averages the two middle values ofint,long,floatanddoublecolumns, and uses the larger value for other types.- Parameters:
groupByColumns- columns to group by. If omitted, computes the median across all rows- Returns:
- a new table with the medians
-
stdBy
@JsMethod default JsPendingTable<JsResolvedTable> stdBy(@JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the sample standard deviation of each column within each group, using Bessel's correction.- Parameters:
groupByColumns- columns to group by. If omitted, computes the standard deviation across all rows- Returns:
- a new table with the standard deviations
-
varBy
@JsMethod default JsPendingTable<JsResolvedTable> varBy(@JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the sample variance of each column within each group, using Bessel's correction.- Parameters:
groupByColumns- columns to group by. If omitted, computes the variance across all rows- Returns:
- a new table with the variances
-
absSumBy
@JsMethod default JsPendingTable<JsResolvedTable> absSumBy(@JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the sum of absolute values of each column within each group.- Parameters:
groupByColumns- columns to group by. If omitted, computes the absolute sum across all rows- Returns:
- a new table with the absolute sums
-
wsumBy
@JsMethod default JsPendingTable<JsResolvedTable> wsumBy(Column.ColumnOrName weightColumn, @JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the weighted sum of each column within each group: the sum of each value multiplied by its weight.- Parameters:
weightColumn- the column containing the weightsgroupByColumns- columns to group by. If omitted, computes the weighted sum across all rows- Returns:
- a new table with the weighted sums
-
wavgBy
@JsMethod default JsPendingTable<JsResolvedTable> wavgBy(Column.ColumnOrName weightColumn, @JsOptional @JsNullable elemental2.core.ReadonlyArray<Column.ColumnOrName> groupByColumns) Computes the weighted average of each column within each group: the sum of each value multiplied by its weight, divided by the sum of the weights. It averages every column other than the weight and the group-by columns, so each must be numeric. To choose and rename columns, or to combine with other aggregations, useaggBy(AggByOptions)withdh.agg.Aggregation.AggWAvg.const byKey = await table.wavgBy("W", ["Key"]);- Parameters:
weightColumn- the column containing the weightsgroupByColumns- columns to group by. If omitted, computes the weighted average across all rows- Returns:
- a new table with the weighted averages
-
ungroup
@JsMethod default JsPendingTable<JsResolvedTable> ungroup(@JsOptional @JsNullable JsTableOperations.UngroupOptions options) Ungroups a table by expanding columns of arrays or vectors into columns of singular values, creating one row in the output table for each value in the columns being ungrouped. Each output row repeats the values of the other columns from its input row.- Parameters:
options- options to specify the behavior of the ungroup operation- Returns:
- an ungrouped table
-
dropColumns
@JsMethod default JsPendingTable<JsResolvedTable> dropColumns(elemental2.core.ReadonlyArray<Column.ColumnOrName> columnsToDrop) Creates a new table without the specified columns.- Parameters:
columnsToDrop- the columns to drop. Should not be empty.- Returns:
- a new table without those columns
-
flatten
Creates a version of this table with a flat rowset.- Returns:
- a new table with a flat rowset
-