Interface TotalsTable

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 dh.groupBy | 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 dh.groupBy | 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 dh.groupBy | groupBy setting.

Hierarchy

Accessors

  • get columns(): Column[]
  • 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[]

    Column array

  • get customColumns(): CustomColumn[]
  • 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[]

    CustomColumn array

  • get filter(): FilterCondition[]
  • 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[]

    FilterCondition array

  • get isClosed(): boolean
  • true if this table has been closed.

    Returns boolean

    boolean

  • get isRefreshing(): boolean
  • true if this table may receive updates from the server, including size changed events, updated events after initial snapshot.

    Returns boolean

    boolean

  • get size(): number
  • The total number of rows in this table. This may change as the base table's configuration, filter, or contents change.

    Returns number

    double

  • get sort(): Sort[]
  • 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[]

    Sort array

Methods

  • Adds an event listener to this table.

    Type Parameters

    • T

    Parameters

    • name: string

      The event name.

    • callback: ((e) => void)

      The callback to invoke when the event fires.

        • (e): void
        • Parameters

          Returns void

    Returns (() => void)

    A function that removes this event listener when invoked.

      • (): void
      • Adds an event listener to this table.

        Returns void

        A function that removes this event listener when invoked.

  • 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

    Returns CustomColumn[]

  • 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

    Returns FilterCondition[]

    FilterCondition array

  • 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

    Returns Sort[]

    Sort array

  • Performs an inexact timeseries join, where rows in this table will have columns added from the closest matching row from the right table.

    The `asOfMatchRule` value can be one of:

    • LESS_THAN_EQUAL
    • LESS_THAN
    • GREATER_THAN_EQUAL
    • GREATER_THAN

    Parameters

    • rightTable: JoinableTable

      The table to match to values in this table.

    • columnsToMatch: string[]

      The columns that should match, according to the asOfMatchRole.

    • Optional columnsToAdd: string[]

      Columns from the right table to add to the resulting table, empty/null/absent to add all columns.

    • Optional asOfMatchRule: string

      The match rule to use, see above.

    Returns Promise<Table>

    A promise that will resolve to the joined table.

  • Indicates that the table will no longer be used, and resources used to provide it can be freed up on the server.

    Returns void

  • Creates a snapshot of this table on the server, with the given options. See createSnapshot for more information.

    Parameters

    • options: object

      options for the snapshot; see SnapshotOptions for details

    Returns Promise<TableData>

    Promise of TableData

  • A promise that will be resolved with the newly created table holding the results of the specified cross join operation. The columnsToAdd parameter is optional, not specifying it will result in all columns from the right table being added to the output. The reserveBits optional parameter lets the client control how the key space is distributed between the rows in the two tables, see the Java Table class for details.

    Parameters

    • rightTable: JoinableTable

      The table to match to values in this table.

    • columnsToMatch: string[]

      The columns that should match exactly.

    • Optional columnsToAdd: string[]

      Columns from the right table to add to the resulting table, empty/null/absent to add all columns.

    • Optional reserveBits: number

      The number of bits of key-space to initially reserve per group, null/absent will let the server select a value.

    Returns Promise<Table>

    A promise that will resolve to the joined table.

  • A promise that will be resolved with the newly created table holding the results of the specified exact join operation. The columnsToAdd parameter is optional, not specifying it will result in all columns from the right table being added to the output.

    Parameters

    • rightTable: JoinableTable

      The table to match to values in this table.

    • columnsToMatch: string[]

      The columns that should match exactly.

    • Optional columnsToAdd: string[]

      Columns from the right table to add to the resulting table, empty/null/absent to add all columns.

    Returns Promise<Table>

    A promise that will resolve to the joined table.

  • A column by the given name. You should prefer to always retrieve a new Column instance instead of caching a returned value.

    Parameters

    • key: string

    Returns Column

    Column

  • Multiple columns specified by the given names.

    Parameters

    • keys: string[]

    Returns Column[]

    Column array

  • Checks whether this table has any listeners for the given event name.

    Parameters

    • name: string

      The event name.

    Returns boolean

    true if there is at least one listener; false otherwise.

  • Joins this table to the provided table, using one of the specified join types:

    • `AJ`, `ReverseAJ` (or `RAJ`) - Inexact timeseries joins, based on the provided matching rule.
    • `CROSS_JOIN` (or `Join`) - Cross join of all rows that have matching values in both tables.
    • `EXACT_JOIN` (or `ExactJoin`) - Matches values in exactly one row in the right table, with errors if there is not exactly one.
    • `NATURAL_JOIN` (or `Natural`) - Matches values in at most one row in the right table, with nulls if there is no match or errors if there are multiple matches.

    Note that Left join is not supported here, unlike DHE.

    See the Choose a join method document for more guidance on picking a join operation.

    Parameters

    • joinType: string

      The type of join to perform, see the list above.

    • rightTable: JoinableTable

      The table to match to values in this table.

    • columnsToMatch: string[]

      Columns that should match.

    • Optional columnsToAdd: string[]

      Columns from the right table to add to the result - empty/null/absent to add all columns.

    • Optional asOfMatchRule: string

      If joinType is AJ/RAJ/ReverseAJ, the match rule to use.

    Returns Promise<Table>

    A promise that will resolve to the joined table.

    Deprecated

    Instead, call the specific method for the join type.

  • A promise that will be resolved with the newly created table holding the results of the specified natural join operation. The columnsToAdd parameter is optional, not specifying it will result in all columns from the right table being added to the output.

    Parameters

    • rightTable: JoinableTable

      The table to match to values in this table.

    • columnsToMatch: string[]

      The columns that should match exactly.

    • Optional columnsToAdd: string[]

      Columns from the right table to add to the resulting table. Empty/null/absent to add all columns.

    Returns Promise<Table>

    A promise that will resolve to the joined table.

  • Returns a promise that resolves with the next occurrence of the specified event.

    Type Parameters

    • T

    Parameters

    • eventName: string

      The event name.

    • Optional timeoutInMillis: number

      Optional timeout in milliseconds.

    Returns Promise<Event<T>>

    A promise that resolves to the next event.

  • Removes an event listener from this table.

    Type Parameters

    • T

    Parameters

    • name: string

      The event name.

    • callback: ((e) => void)

      The callback to remove.

        • (e): void
        • Parameters

          Returns void

    Returns boolean

    true if a listener was removed; false otherwise.

  • 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: number
    • lastRow: number
    • Optional columns: Column[]
    • Optional updateIntervalMs: number
    • Optional isReverseViewport: boolean

    Returns void

    Deprecated

    Use #createViewportSubscription(Object) instead.

  • Creates a server-side snapshot of baseTable when this table updates.

    Parameters

    • baseTable: Table

      The table to snapshot.

    • Optional doInitialSnapshot: boolean

      Whether to create an initial snapshot immediately.

    • Optional stampColumns: string[]

      Optional list of column names to include in the result.

    Returns Promise<Table>

    A promise that resolves to the snapshot table.