@finos/perspective
    Preparing search index...

    The [View] struct is Perspective's query and serialization interface. It represents a query on the Table's dataset and is always created from an existing Table instance via the [Table::view] method.

    [View]s are immutable with respect to the arguments provided to the [Table::view] method; to change these parameters, you must create a new [View] on the same [Table]. However, each [View] is live with respect to the [Table]'s data, and will (within a conflation window) update with the latest state as its parent [Table] updates, including incrementally recalculating all aggregates, pivots, filters, etc. [View] query parameters are composable, in that each parameter works independently and in conjunction with each other, and there is no limit to the number of pivots, filters, etc. which can be applied.

    Index

    Methods

    • Returns View

    • Collapses the group_by row at row_index.

      Parameters

      • row_index: number

      Returns Promise<number>

    • Returns an array of strings containing the column paths of the [View] without any of the source columns.

      A column path shows the columns that a given cell belongs to after pivots are applied.

      Returns Promise<any>

    • Delete this [View] and clean up all resources associated with it. [View] objects do not stop consuming resources or processing updates when they are garbage collected - you must call this method to reclaim these.

      Returns Promise<void>

    • Returns this [View]'s dimensions, row and column count, as well as those of the [crate::Table] from which it was derived.

      • num_table_rows - The number of rows in the underlying [crate::Table].
      • num_table_columns - The number of columns in the underlying [crate::Table] (including the index column if this [crate::Table] was constructed with one).
      • num_view_rows - The number of rows in this [View]. If this [View] has a group_by clause, num_view_rows will also include aggregated rows.
      • num_view_columns - The number of columns in this [View]. If this [View] has a split_by clause, num_view_columns will include all column paths, e.g. the number of columns clause times the number of split_by groups.

      Returns Promise<any>

    • Expand the group_by row at row_index.

      Parameters

      • row_index: number

      Returns Promise<number>

    • The expression schema of this [View], which contains only the expressions created on this [View]. See [View::schema] for details.

      Returns Promise<any>

    • Returns void

    • A copy of the config object passed to the [Table::view] method which created this [View].

      Returns Promise<any>

    • Calculates the [min, max] of the leaf nodes of a column column_name.

      Returns

      A tuple of [min, max], whose types are column and aggregate dependent.

      Parameters

      • name: string

      Returns Promise<any[]>

    • The number of aggregated columns in this [View]. This is affected by the "split_by" configuration parameter supplied to this view's contructor.

      Returns

      The number of aggregated columns.

      Returns Promise<number>

    • The number of aggregated rows in this [View]. This is affected by the "group_by" configuration parameter supplied to this view's contructor.

      Returns

      The number of aggregated rows.

      Returns Promise<number>

    • Register a callback with this [View]. Whenever the [View] is deleted, this callback will be invoked.

      Parameters

      • on_delete: Function

      Returns Promise<any>

    • Register a callback with this [View]. Whenever the view's underlying table emits an update, this callback will be invoked with an object containing port_id, indicating which port the update fired on, and optionally delta, which is the new data that was updated for each cell or each row.

      Arguments

      • on_update - A callback function invoked on update, which receives an object with two keys: port_id, indicating which port the update was triggered on, and delta, whose value is dependent on the mode parameter.
      • options - If this is provided as OnUpdateOptions { mode: Some(OnUpdateMode::Row) }, then delta is an Arrow of the updated rows. Otherwise delta will be [Option::None].

      JavaScript Examples

      // Attach an `on_update` callback
      view.on_update((updated) => console.log(updated.port_id));
      // `on_update` with row deltas
      view.on_update((updated) => console.log(updated.delta), { mode: "row" });

      Parameters

      Returns Promise<any>

    • Unregister a previously registered [View::on_delete] callback.

      Parameters

      • callback_id: number

      Returns Promise<any>

    • Unregister a previously registered update callback with this [View].

      Arguments

      • id - A callback id as returned by a recipricol call to [View::on_update].

      Parameters

      • callback_id: number

      Returns Promise<void>

    • The schema of this [View].

      The [View] schema differs from the schema returned by [Table::schema]; it may have different column names due to expressions or columns configs, or it maye have different column types due to the application og group_by and aggregates config. You can think of [Table::schema] as the input schema and [View::schema] as the output schema of a Perspective pipeline.

      Returns Promise<any>

    • Set expansion depth of the group_by tree.

      Parameters

      • depth: number

      Returns Promise<void>

    • Serializes a [View] to the Apache Arrow data format.

      Parameters

      Returns Promise<ArrayBuffer>

    • Serializes this [View] to JavaScript objects in a column-oriented format.

      Parameters

      Returns Promise<object>

    • Serializes this [View] to a string of JSON data. Useful if you want to save additional round trip serialize/deserialize cycles.

      Parameters

      Returns Promise<string>

    • Serializes this [View] to CSV data in a standard format.

      Parameters

      Returns Promise<string>

    • Serializes this [View] to JavaScript objects in a row-oriented format.

      Parameters

      Returns Promise<any[]>

    • Render this View as a JSON string.

      Parameters

      Returns Promise<string>

    • Renders this [View] as an NDJSON formatted [String].

      Parameters

      Returns Promise<string>