Collapses the group_by
row at row_index
.
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.
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 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.Expand the group_by
row at row_index
.
The expression schema of this [View
], which contains only the
expressions created on this [View
]. See [View::schema
] for
details.
A copy of the config object passed to the [Table::view
] method which
created this [View
].
Register a callback with this [View
]. Whenever the [View
] is
deleted, this callback will be invoked.
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.
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
].// 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" });
Optional
options: null | OnUpdateOptionsUnregister a previously registered [View::on_delete
] callback.
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.
Set expansion depth
of the group_by
tree.
Serializes a [View
] to the Apache Arrow data format.
Optional
window: null | ViewWindowSerializes this [View
] to JavaScript objects in a column-oriented
format.
Optional
window: null | ViewWindowSerializes this [View
] to a string of JSON data. Useful if you want to
save additional round trip serialize/deserialize cycles.
Optional
window: null | ViewWindowSerializes this [View
] to CSV data in a standard format.
Optional
window: null | ViewWindowSerializes this [View
] to JavaScript objects in a row-oriented
format.
Optional
window: null | ViewWindowRender this View
as a JSON string.
Optional
window: null | ViewWindowRenders this [View
] as an NDJSON
formatted [String
].
Optional
window: null | ViewWindow
The [
View
] struct is Perspective's query and serialization interface. It represents a query on theTable
's dataset and is always created from an existingTable
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.