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:

  1. Prevent accidental mutation.
  2. Allow it to be used as a template when fetching a new totals table or changing the totals table in use.
This class has limited methods found on 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.

  • Constructor Details

    • JsTotalsTable

      public JsTotalsTable(JsTable wrappedTable, String directive, elemental2.core.JsArray<String> groupBy)
  • Method Details

    • getConnection

      public WorkerConnection getConnection()
      Specified by:
      getConnection in interface ServerObject
    • 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

      @JsIgnore public ClientTableState state()
      The configuration used when creating this Totals Table.
      Specified by:
      state in interface JoinableTable
      Returns:
      ClientTableState
    • typedTicket

      public TypedTicket typedTicket()
      Specified by:
      typedTicket in interface ServerObject
    • getTotalsTableConfig

      @JsProperty public JsTotalsTableConfig 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.
      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()
      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(Object options)
      Creates a subscription to this table, with the given options. See JsTable.createSubscription(Object) for more information.
      Parameters:
      options - options for the subscription; see DataOptions.SubscriptionOptions for details
      Returns:
      a new TableSubscription
    • createViewportSubscription

      @JsMethod public TableViewportSubscription createViewportSubscription(Object options)
      Creates a viewport subscription to this table, with the given options. See JsTable.createViewportSubscription(Object) for more information.
      Parameters:
      options - options for the viewport subscription; see DataOptions.ViewportSubscriptionOptions for details
      Returns:
      a new TableViewportSubscription
    • createSnapshot

      @JsMethod public elemental2.promise.Promise<TableData> createSnapshot(Object options)
      Creates a snapshot of this table on the server, with the given options. See JsTable.createSnapshot(Object) for more information.
      Parameters:
      options - options for the snapshot; see DataOptions.SnapshotOptions for details
      Returns:
      Promise of TableData
    • getColumns

      @JsProperty public elemental2.core.JsArray<Column> 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:
      Column array
    • findColumn

      @JsMethod public Column findColumn(String key)
      A column by the given name. You should prefer to always retrieve a new Column instance instead of caching a returned value.
      Parameters:
      key -
      Returns:
      Column
    • findColumns

      @JsMethod public Column[] findColumns(String[] keys)
      Multiple columns specified by the given names.
      Parameters:
      keys -
      Returns:
      Column array
    • isRefreshing

      @JsProperty(name="isRefreshing") public boolean isRefreshing()
      true if 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()
      true if 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

      public String toString()
      Gets a string representation of this Totals Table instance.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this totals table.
    • addEventListener

      @JsMethod public <T> RemoverFn addEventListener(String name, EventFn<T> callback)
      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

      @JsMethod public <T> boolean removeEventListener(String name, EventFn<T> callback)
      Removes an event listener from this table.
      Parameters:
      name - The event name.
      callback - The callback to remove.
      Returns:
      true if a listener was removed; false otherwise.
    • 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

      @JsMethod public boolean hasListeners(String name)
      Checks whether this table has any listeners for the given event name.
      Parameters:
      name - The event name.
      Returns:
      true if there is at least one listener; false otherwise.
    • applySort

      @JsMethod public elemental2.core.JsArray<Sort> applySort(Sort[] sort)
      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:
      Sort array
    • 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

      @JsMethod public elemental2.core.JsArray<FilterCondition> applyFilter(FilterCondition[] filter)
      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:
      FilterCondition array
    • getWrappedTable

      public JsTable getWrappedTable()
      Gets the underlying JsTable instance used to back this Totals Table.
      Returns:
      The wrapped table.
    • getSort

      @JsProperty public elemental2.core.JsArray<Sort> getSort()
      An ordered list of Sorts to apply to the table. To update, call applySort. 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:
      Sort array
    • getFilter

      @JsProperty public elemental2.core.JsArray<FilterCondition> getFilter()
      An ordered list of Filters to apply to the table. To update, call applyFilter. 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 filterchanged event to know when to update the UI.
      Returns:
      FilterCondition array
    • getCustomColumns

      @JsProperty public elemental2.core.JsArray<CustomColumn> 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, call applyCustomColumns.
      Returns:
      CustomColumn array
    • freeze

      @JsMethod public elemental2.promise.Promise<JsTable> 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:
      freeze in interface JoinableTable
      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 of baseTable when this table updates.
      Specified by:
      snapshot in interface JoinableTable
      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:
      join in interface JoinableTable
      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 is AJ/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:
      asOfJoin in interface JoinableTable
      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:
      crossJoin in interface JoinableTable
      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:
      exactJoin in interface JoinableTable
      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:
      naturalJoin in interface JoinableTable
      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.