Package io.deephaven.web.client.api
Class JsTotalsTable
java.lang.Object
io.deephaven.web.client.api.JsTotalsTable
- All Implemented Interfaces:
JoinableTable,JsITable,ServerObject
@TsInterface
@TsName(namespace="dh",
name="TotalsTable")
public class JsTotalsTable
extends Object
implements JoinableTable, ServerObject, JsITable
Behaves like a
dh.Table, but doesn't expose all of its API for changing the internal state. Instead,
state is driven by the upstream table - when its handle changes, this table listens and rebuilds its totals from the
new state. If that rebuild fails, a requestfailed event fires with the failure message as its detail, and this
table keeps the totals it last built until the upstream table changes again. If the rebuild succeeds but a filter,
sort or custom column set on this table cannot be re-applied to it, the requestfailed event is the one any
dh.Table fires for a rejected change, and this table shows the rebuilt totals without that change.
A new config is returned any time it is accessed. This is to:
- Prevent accidental mutation.
- Allow it to be used as a template when fetching a new totals table or changing the totals table in use.
dh.Table. Instances of this type usually have a size of one
when no groupBy is set on the config, but may potentially contain as few as zero
rows if the parent table was empty, or as many as the parent table if each row gets its own group.
When using the groupBy feature, it may be desirable to also provide a row to the
user with all values across all rows. To achieve this, request the same Totals Table again, but remove the
groupBy setting.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.deephaven.web.client.api.ServerObject
ServerObject.Union -
Constructor Summary
ConstructorsConstructorDescriptionJsTotalsTable(JsTable wrappedTable, String directive, elemental2.core.JsArray<String> groupBy) -
Method Summary
Modifier and TypeMethodDescription<T> RemoverFnaddEventListener(String name, EventFn<T> callback) Adds an event listener to this table.elemental2.core.JsArray<CustomColumn> applyCustomColumns(elemental2.core.JsArray<JsTable.CustomColumnArgUnionType> customColumns) Replace the current custom columns with a new set.elemental2.core.JsArray<FilterCondition> applyFilter(FilterCondition[] filter) Replace the currently set filters on the table.elemental2.core.JsArray<Sort> Replace the currently set sort on this table.elemental2.promise.Promise<JsTable> asOfJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd, @JsNullable String asOfMatchRule) Performs an as-of join between this table and the provided table.voidclose()Signals that the table is no longer used, so the server can release its resources.elemental2.promise.Promise<TableData> createSnapshot(@TsTypeRef(SnapshotOptions.class) Object options) Returns a promise of aTableDatainstance containing a snapshot of the current state of the table, within the bounds of the specified rows and columns.createSubscription(@TsTypeRef(SubscriptionOptions.class) Object options) Creates a subscription to the specified columns, across all rows in the table.createViewportSubscription(@TsTypeRef(ViewportSubscriptionOptions.class) Object options) Creates a viewport subscription to the specified columns, across the specified rows in the table.elemental2.promise.Promise<JsTable> crossJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd, @JsNullable Double reserveBits) Performs a cross join between this table and the provided table.elemental2.promise.Promise<JsTable> exactJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd) Performs an exact join between this table and the provided table.findColumn(String key) A column by the given name.Column[]findColumns(String[] keys) Multiple columns specified by the given names.elemental2.promise.Promise<JsTable> freeze()A server-side snapshot of this table (a server-side snapshot of the entire source table).@JsNullable ObjectgetAttribute(String attributeName) Reads an attribute's value as a string.elemental2.core.JsArray<String> The names of all attributes defined on this table.elemental2.core.JsArray<Column> The columns present on this table.elemental2.promise.Promise<JsColumnStatistics> Computes statistics for one column of this table, such as its count, sum and average for a numeric column, or its most common values for other types.elemental2.core.JsArray<CustomColumn> Read-only.elemental2.core.JsArray<FilterCondition> An ordered list of Filters to apply to the table.doublegetSize()The total number of rows in this table.elemental2.core.JsArray<Sort> getSort()An ordered list of Sorts to apply to the table.Gets the configuration used when creating this Totals Table.elemental2.promise.Promise<@TsTypeRef(ViewportData.class) AbstractTableSubscription.UpdateEventData> Deprecated.Gets the underlyingJsTableinstance used to back this Totals Table.booleanhasListeners(String name) Checks whether this table has any listeners for the given event name.booleanisClosed()trueif this table has been closed.booleantrueif this table may receive updates from the server, including size changed events, updated events after initial snapshot.elemental2.promise.Promise<JsTable> join(String joinType, JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd, @JsNullable String asOfMatchRule) Joins this table to the provided table.elemental2.promise.Promise<JsTable> naturalJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd) Performs a natural join between this table and the provided table.<T> elemental2.promise.Promise<Event<T>> Returns a promise that resolves with the next occurrence of the specified event.voidRe-applies the most recently set viewport options, if any.<T> booleanremoveEventListener(String name, EventFn<T> callback) Removes an event listener from this table.voidsetViewport(double firstRow, double lastRow, @JsNullable elemental2.core.JsArray<Column> columns, @JsNullable Double updateIntervalMs, @JsNullable Boolean isReverseViewport) Deprecated.UsecreateViewportSubscription(Object)instead.elemental2.promise.Promise<JsTable> snapshot(JsTableReference baseTable, @JsNullable Boolean doInitialSnapshot, @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> stampColumns) Creates a server-side snapshot ofbaseTablewhen this table updates.state()The configuration used when creating this Totals Table.toString()Gets a string representation of this Totals Table instance.
-
Constructor Details
-
JsTotalsTable
-
-
Method Details
-
getConnection
- Specified by:
getConnectionin interfaceServerObject
-
refreshViewport
public void refreshViewport()Re-applies the most recently set viewport options, if any. Does nothing once this table is closed, since a rebase that was in flight when it closed may still call this. -
state
The configuration used when creating this Totals Table.- Specified by:
statein interfaceJoinableTable- Returns:
ClientTableState
-
typedTicket
- Specified by:
typedTicketin interfaceServerObject
-
getAttributes
Description copied from interface:JsITableThe names of all attributes defined on this table.- Specified by:
getAttributesin interfaceJsITable- Returns:
- an array of attributes defined on this table
-
getAttribute
Description copied from interface:JsITableReads an attribute's value as a string. Only primitive and string values are sent to the client. An attribute listed byJsITable.getAttributes()with any other value cannot be read here.- Specified by:
getAttributein interfaceJsITable- Parameters:
attributeName- the name of the attribute to read- Returns:
- the value of the attribute or null if none with that name exists
-
getColumnStatistics
@JsMethod public elemental2.promise.Promise<JsColumnStatistics> getColumnStatistics(Column.ColumnOrName column) Description copied from interface:JsITableComputes statistics for one column of this table, such as its count, sum and average for a numeric column, or its most common values for other types.- Specified by:
getColumnStatisticsin interfaceJsITable- Parameters:
column- the column, or the name of the column, to compute statistics for- Returns:
- a promise of the
ColumnStatisticsfor that column
-
getTotalsTableConfig
Gets the configuration used when creating this Totals Table.- Returns:
dh.TotalsTableConfig
-
setViewport
@JsMethod @Deprecated public void setViewport(double firstRow, double lastRow, @JsOptional @JsNullable elemental2.core.JsArray<Column> columns, @JsOptional @JsNullable Double updateIntervalMs, @JsOptional @JsNullable Boolean isReverseViewport) Deprecated.UsecreateViewportSubscription(Object)instead.Specifies the range of items to pass to the client and update as they change. If the columns parameter is not provided, all columns will be used. Until this is called, no data will be available. Invoking this will result in events to be fired once data becomes available, starting with an updated event and one rowadded event per row in that range.- Parameters:
firstRow-lastRow-columns-updateIntervalMs-
-
getViewportData
@JsMethod @Deprecated public elemental2.promise.Promise<@TsTypeRef(ViewportData.class) AbstractTableSubscription.UpdateEventData> getViewportData()Deprecated.useTableViewportSubscription.getViewportData()on the result fromcreateViewportSubscription(Object)instead.the currently visible viewport. If the current set of operations has not yet resulted in data, it will not resolve until that data is ready.- Returns:
- Promise of
TableData
-
createSubscription
@JsMethod public TableSubscription createSubscription(@TsTypeRef(SubscriptionOptions.class) @TsTypeRef(SubscriptionOptions.class) Object options) Description copied from interface:JsITableCreates a subscription to the specified columns, across all rows in the table. Useful for charts or taking a snapshot of the table atomically. The initial snapshot arrives in a single event, and later changes arrive as updates. However, this may still be very expensive to run from a browser for very large tables. Each call creates a new subscription, which must haveAbstractTableSubscription.close()called on it to stop it and release its resources, and all events are fired from theTableSubscriptioninstance.- Specified by:
createSubscriptionin interfaceJsITable- Parameters:
options- the subscription options, described inDataOptions.SubscriptionOptions- Returns:
- a new
TableSubscription
-
createViewportSubscription
@JsMethod public TableViewportSubscription createViewportSubscription(@TsTypeRef(ViewportSubscriptionOptions.class) @TsTypeRef(ViewportSubscriptionOptions.class) Object options) Description copied from interface:JsITableCreates a viewport subscription to the specified columns, across the specified rows in the table. The returnedTableViewportSubscriptioninstance allows the viewport to be changed over time, and events are fired from it when the data changes or when a viewport change is applied. Each call creates a new subscription, which must haveTableViewportSubscription.close()called on it to stop it and release its resources.- Specified by:
createViewportSubscriptionin interfaceJsITable- Parameters:
options- the viewport subscription options, described inDataOptions.ViewportSubscriptionOptions- Returns:
- a new
TableViewportSubscription
-
createSnapshot
@JsMethod public elemental2.promise.Promise<TableData> createSnapshot(@TsTypeRef(SnapshotOptions.class) @TsTypeRef(SnapshotOptions.class) Object options) Description copied from interface:JsITableReturns a promise of aTableDatainstance containing a snapshot of the current state of the table, within the bounds of the specified rows and columns.- Specified by:
createSnapshotin interfaceJsITable- Parameters:
options- the snapshot options, described inDataOptions.SnapshotOptions- Returns:
- a promise of
TableData
-
getColumns
The columns present on this table. Note that this may not include all columns in the parent table, and in cases where a given column has more than one aggregation applied, the column name will have a suffix indicating the aggregation used. This suffixed name will be of the form columnName + '__' + aggregationName.- Specified by:
getColumnsin interfaceJsITable- Returns:
Columnarray
-
findColumn
A column by the given name. You should prefer to always retrieve a newColumninstance instead of caching a returned value.- Specified by:
findColumnin interfaceJsITable- Parameters:
key-- Returns:
Column
-
findColumns
Multiple columns specified by the given names.- Parameters:
keys-- Returns:
Columnarray
-
isRefreshing
@JsProperty(name="isRefreshing") public boolean isRefreshing()trueif this table may receive updates from the server, including size changed events, updated events after initial snapshot.- Returns:
- boolean
-
isClosed
@JsProperty(name="isClosed") public boolean isClosed()trueif this table has been closed.- Returns:
- boolean
-
close
@JsMethod public void close()Description copied from interface:JsITableSignals that the table is no longer used, so the server can release its resources. Logs a warning if called more than once. -
getSize
@JsProperty public double getSize()The total number of rows in this table. This may change as the base table's configuration, filter, or contents change. -
toString
Gets a string representation of this Totals Table instance. -
addEventListener
Adds an event listener to this table.- Parameters:
name- The event name.callback- The callback to invoke when the event fires.- Returns:
- A function that removes this event listener when invoked.
-
removeEventListener
Removes an event listener from this table.- Parameters:
name- The event name.callback- The callback to remove.- Returns:
trueif a listener was removed;falseotherwise.
-
nextEvent
@JsMethod public <T> elemental2.promise.Promise<Event<T>> nextEvent(String eventName, @JsOptional Double timeoutInMillis) Returns a promise that resolves with the next occurrence of the specified event.- Parameters:
eventName- The event name.timeoutInMillis- Optional timeout in milliseconds.- Returns:
- A promise that resolves to the next event.
-
hasListeners
Checks whether this table has any listeners for the given event name.- Parameters:
name- The event name.- Returns:
trueif there is at least one listener;falseotherwise.
-
applySort
Replace the currently set sort on this table. Returns the previously set value. Note that the sort property will immediately return the new value, but you may receive update events using the old sort before the new sort is applied, and the sortchanged event fires. Reusing existing, applied sorts may enable this to perform better on the server. The updated event will also fire, but rowadded and rowremoved will not.- Parameters:
sort-- Returns:
Sortarray
-
applyCustomColumns
@JsMethod public elemental2.core.JsArray<CustomColumn> applyCustomColumns(elemental2.core.JsArray<JsTable.CustomColumnArgUnionType> customColumns) Replace the current custom columns with a new set. These columns can be used when adding new filter and sort operations to the table, as long as they are present.- Parameters:
customColumns-- Returns:
-
applyFilter
Replace the currently set filters on the table. Returns the previously set value. Note that the filter property will immediately return the new value, but you may receive update events using the old filter before the new one is applied, and the filterchanged event fires. Reusing existing, applied filters may enable this to perform better on the server. The updated event will also fire, but rowadded and rowremoved will not.- Parameters:
filter-- Returns:
FilterConditionarray
-
getWrappedTable
Gets the underlyingJsTableinstance used to back this Totals Table.- Returns:
- The wrapped table.
-
getSort
An ordered list of Sorts to apply to the table. To update, callapplySort. Note that this getter will return the new value immediately, even though it may take a little time to update on the server. You may listen for the sortchanged event to know when to update the UI.- Returns:
Sortarray
-
getFilter
An ordered list of Filters to apply to the table. To update, callapplyFilter. Note that this getter will return the new value immediately, even though it may take a little time to update on the server. You may listen for thefilterchangedevent to know when to update the UI.- Returns:
FilterConditionarray
-
getCustomColumns
Read-only. An ordered list of custom column formulas to add to the table, either adding new columns or replacing existing ones. To update, callapplyCustomColumns.- Returns:
CustomColumnarray
-
freeze
A server-side snapshot of this table (a server-side snapshot of the entire source table). Subscriptions on the snapshot table will not update. This does not change the original table, and the new table will not have any of the client side sorts/filters/columns. New client side sorts/filters/columns can be added to the snapshot copy.- Specified by:
freezein interfaceJoinableTable- Returns:
- a promise of the snapshot table
-
snapshot
@JsMethod public elemental2.promise.Promise<JsTable> snapshot(JsTableReference baseTable, @JsOptional @JsNullable Boolean doInitialSnapshot, @JsOptional @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> stampColumns) Creates a server-side snapshot ofbaseTablewhen this table updates.- Specified by:
snapshotin interfaceJoinableTable- Parameters:
baseTable- The table to snapshot.doInitialSnapshot- Whether to create an initial snapshot immediately.stampColumns- Optional list of stamp column match pairs to include in the result.- Returns:
- a promise of the snapshot table
-
join
@JsMethod public elemental2.promise.Promise<JsTable> join(String joinType, JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsOptional @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd, @JsOptional @JsNullable String asOfMatchRule) Joins this table to the provided table.- Specified by:
joinin interfaceJoinableTable- Parameters:
joinType- The join type.rightTable- The table to join to.columnsToMatch- Columns that should match.columnsToAdd- Columns from the right table to add to the result.asOfMatchRule- If joinType isAJ/RAJ/ReverseAJ, the match rule to use.- Returns:
- a promise of the joined table
-
asOfJoin
@JsMethod public elemental2.promise.Promise<JsTable> asOfJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsOptional @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd, @JsOptional @JsNullable String asOfMatchRule) Performs an as-of join between this table and the provided table.- Specified by:
asOfJoinin interfaceJoinableTable- Parameters:
rightTable- The table to join to.columnsToMatch- Columns that should match.columnsToAdd- Columns from the right table to add to the result.asOfMatchRule- The match rule to use.- Returns:
- a promise of the joined table
-
crossJoin
@JsMethod public elemental2.promise.Promise<JsTable> crossJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsOptional @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd, @JsOptional @JsNullable Double reserveBits) Performs a cross join between this table and the provided table.- Specified by:
crossJoinin interfaceJoinableTable- Parameters:
rightTable- The table to join to.columnsToMatch- Columns that should match.columnsToAdd- Columns from the right table to add to the result.reserveBits- Optional reserve bits for the join.- Returns:
- a promise of the joined table
-
exactJoin
@JsMethod public elemental2.promise.Promise<JsTable> exactJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsOptional @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd) Performs an exact join between this table and the provided table.- Specified by:
exactJoinin interfaceJoinableTable- Parameters:
rightTable- The table to join to.columnsToMatch- Columns that should match.columnsToAdd- Columns from the right table to add to the result.- Returns:
- a promise of the joined table
-
naturalJoin
@JsMethod public elemental2.promise.Promise<JsTable> naturalJoin(JsTableReference rightTable, elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToMatch, @JsOptional @JsNullable elemental2.core.ReadonlyArray<JsTable.MatchPairUnion> columnsToAdd) Performs a natural join between this table and the provided table.- Specified by:
naturalJoinin interfaceJoinableTable- Parameters:
rightTable- The table to join to.columnsToMatch- Columns that should match.columnsToAdd- Columns from the right table to add to the result.- Returns:
- a promise of the joined table
-
TableViewportSubscription.getViewportData()on the result fromcreateViewportSubscription(Object)instead.