Package io.deephaven.web.client.api
Class JsTotalsTable
java.lang.Object
io.deephaven.web.client.api.JsTotalsTable
- All Implemented Interfaces:
JoinableTable,ServerObject
@TsInterface
@TsName(namespace="dh",
name="TotalsTable")
public class JsTotalsTable
extends Object
implements JoinableTable, ServerObject
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(JoinableTable rightTable, elemental2.core.JsArray<String> columnsToMatch, @JsNullable elemental2.core.JsArray<String> columnsToAdd, @JsNullable String asOfMatchRule) Performs an as-of join between this table and the provided table.voidclose()Indicates that the table will no longer be used, and resources used to provide it can be freed up on the server.elemental2.promise.Promise<TableData> createSnapshot(Object options) Creates a snapshot of this table on the server, with the given options.createSubscription(Object options) Creates a subscription to this table, with the given options.createViewportSubscription(Object options) Creates a viewport subscription to this table, with the given options.elemental2.promise.Promise<JsTable> crossJoin(JoinableTable rightTable, elemental2.core.JsArray<String> columnsToMatch, @JsNullable elemental2.core.JsArray<String> columnsToAdd, @JsNullable Double reserveBits) Performs a cross join between this table and the provided table.elemental2.promise.Promise<JsTable> exactJoin(JoinableTable rightTable, elemental2.core.JsArray<String> columnsToMatch, @JsNullable elemental2.core.JsArray<String> 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).elemental2.core.JsArray<Column> The columns present on this table.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, JoinableTable rightTable, elemental2.core.JsArray<String> columnsToMatch, @JsNullable elemental2.core.JsArray<String> columnsToAdd, @JsNullable String asOfMatchRule) Joins this table to the provided table.elemental2.promise.Promise<JsTable> naturalJoin(JoinableTable rightTable, elemental2.core.JsArray<String> columnsToMatch, @JsNullable elemental2.core.JsArray<String> 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(JsTable baseTable, @JsNullable Boolean doInitialSnapshot, @JsNullable String[] 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
-
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
Creates a subscription to this table, with the given options. SeeJsTable.createSubscription(Object)for more information.- Parameters:
options- options for the subscription; seeDataOptions.SubscriptionOptionsfor details- Returns:
- a new
TableSubscription
-
createViewportSubscription
Creates a viewport subscription to this table, with the given options. SeeJsTable.createViewportSubscription(Object)for more information.- Parameters:
options- options for the viewport subscription; seeDataOptions.ViewportSubscriptionOptionsfor details- Returns:
- a new
TableViewportSubscription
-
createSnapshot
Creates a snapshot of this table on the server, with the given options. SeeJsTable.createSnapshot(Object)for more information.- Parameters:
options- options for the snapshot; seeDataOptions.SnapshotOptionsfor details- Returns:
- 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.- Returns:
Columnarray
-
findColumn
A column by the given name. You should prefer to always retrieve a newColumninstance instead of caching a returned value.- 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()Indicates that the table will no longer be used, and resources used to provide it can be freed up on the server. -
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.- Returns:
- double
-
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 that resolves to the snapshot table.
-
snapshot
@JsMethod public elemental2.promise.Promise<JsTable> snapshot(JsTable baseTable, @JsOptional @JsNullable Boolean doInitialSnapshot, @JsOptional @JsNullable String[] 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 column names to include in the result.- Returns:
- A promise that resolves to the snapshot table.
-
join
@JsMethod public elemental2.promise.Promise<JsTable> join(String joinType, JoinableTable rightTable, elemental2.core.JsArray<String> columnsToMatch, @JsOptional @JsNullable elemental2.core.JsArray<String> 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 that resolves to the joined table.
-
asOfJoin
@JsMethod public elemental2.promise.Promise<JsTable> asOfJoin(JoinableTable rightTable, elemental2.core.JsArray<String> columnsToMatch, @JsOptional @JsNullable elemental2.core.JsArray<String> 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 that resolves to the joined table.
-
crossJoin
@JsMethod public elemental2.promise.Promise<JsTable> crossJoin(JoinableTable rightTable, elemental2.core.JsArray<String> columnsToMatch, @JsOptional @JsNullable elemental2.core.JsArray<String> 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 that resolves to the joined table.
-
exactJoin
@JsMethod public elemental2.promise.Promise<JsTable> exactJoin(JoinableTable rightTable, elemental2.core.JsArray<String> columnsToMatch, @JsOptional @JsNullable elemental2.core.JsArray<String> 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 that resolves to the joined table.
-
naturalJoin
@JsMethod public elemental2.promise.Promise<JsTable> naturalJoin(JoinableTable rightTable, elemental2.core.JsArray<String> columnsToMatch, @JsOptional @JsNullable elemental2.core.JsArray<String> 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 that resolves to the joined table.
-
TableViewportSubscription.getViewportData()on the result fromcreateViewportSubscription(Object)instead.