Skip to content

Invoke V8 views from host #3488

@joshua-spacetime

Description

@joshua-spacetime

Extend JsInstance with methods for calling views.

impl JsInstance {

We need an interface for the following contexts:

SQL (http/remote query):
This is a read only context. A view in this context can still use a mutable transaction, but it won't update any internal state. It can either fully evaluate the view every time, or it can check if it has a backing table and scan that.

Subscribe:
A view in this context will run in a mutable transaction. If already subscribed to and materialized, it should just return the materialized results. Otherwise we should:

  1. Update st_view_arg if necessary
  2. Update st_view_client
  3. Evaluate the view
  4. Update read sets and backing table
  5. Return result

Unsubscribe:
A view in this context will run in a mutable transaction. The client is already subscribed so we know the result set is materialized. We should:

  1. Scan and return the materialized result
  2. Drop the materialized result (delete rows from the backing table)
  3. Update st_view_client (remove subscriber)
  4. Update st_view_arg potentially (if no one is subscribed to this set of args)

Subscription Update:
A view in this context will run in a mutable transaction. When evaluating a view in this context, we have already checked and determined that the view is stale, hence we are always evaluating the view (not reading cached results) and updating its read set. We also must update the backing table in this case. Note that technically it is not necessary to return the result of the view to the caller because in this case the caller only cares about the table diff which it will get when downgrading the transaction before dispatching to the subscription engine.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions