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:

  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
    • getAttributes

      @JsMethod public elemental2.core.JsArray<String> getAttributes()
      Description copied from interface: JsITable
      The names of all attributes defined on this table.
      Specified by:
      getAttributes in interface JsITable
      Returns:
      an array of attributes defined on this table
    • getAttribute

      @JsMethod public @JsNullable Object getAttribute(String attributeName)
      Description copied from interface: JsITable
      Reads an attribute's value as a string. Only primitive and string values are sent to the client. An attribute listed by JsITable.getAttributes() with any other value cannot be read here.
      Specified by:
      getAttribute in interface JsITable
      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: JsITable
      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.
      Specified by:
      getColumnStatistics in interface JsITable
      Parameters:
      column - the column, or the name of the column, to compute statistics for
      Returns:
      a promise of the ColumnStatistics for that column
    • 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(@TsTypeRef(SubscriptionOptions.class) @TsTypeRef(SubscriptionOptions.class) Object options)
      Description copied from interface: JsITable
      Creates 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 have AbstractTableSubscription.close() called on it to stop it and release its resources, and all events are fired from the TableSubscription instance.
      Specified by:
      createSubscription in interface JsITable
      Parameters:
      options - the subscription options, described in DataOptions.SubscriptionOptions
      Returns:
      a new TableSubscription
    • createViewportSubscription

      @JsMethod public TableViewportSubscription createViewportSubscription(@TsTypeRef(ViewportSubscriptionOptions.class) @TsTypeRef(ViewportSubscriptionOptions.class) Object options)
      Description copied from interface: JsITable
      Creates a viewport subscription to the specified columns, across the specified rows in the table. The returned TableViewportSubscription instance 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 have TableViewportSubscription.close() called on it to stop it and release its resources.
      Specified by:
      createViewportSubscription in interface JsITable
      Parameters:
      options - the viewport subscription options, described in DataOptions.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: JsITable
      Returns a promise of a TableData instance containing a snapshot of the current state of the table, within the bounds of the specified rows and columns.
      Specified by:
      createSnapshot in interface JsITable
      Parameters:
      options - the snapshot options, described in DataOptions.SnapshotOptions
      Returns:
      a 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.
      Specified by:
      getColumns in interface JsITable
      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.
      Specified by:
      findColumn in interface JsITable
      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()
      Description copied from interface: JsITable
      Signals that the table is no longer used, so the server can release its resources. Logs a warning if called more than once.
      Specified by:
      close in interface JsITable
    • 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.
      Specified by:
      getSize in interface JsITable
      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 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 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 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:
      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 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:
      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 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:
      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 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:
      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 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:
      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 of the joined table