Skip to content

Commit df53e68

Browse files
committed
comments addressing
1 parent 3aa1a00 commit df53e68

File tree

7 files changed

+29
-30
lines changed

7 files changed

+29
-30
lines changed

crates/core/src/host/instance_env.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use core::mem;
99
use parking_lot::{Mutex, MutexGuard};
1010
use smallvec::SmallVec;
1111
use spacetimedb_datastore::locking_tx_datastore::state_view::StateView;
12-
use spacetimedb_datastore::locking_tx_datastore::{MutTxId, UniqueView};
12+
use spacetimedb_datastore::locking_tx_datastore::{MutTxId, ViewCall};
1313
use spacetimedb_lib::{ConnectionId, Identity, Timestamp};
1414
use spacetimedb_primitives::{ColId, ColList, IndexId, TableId};
1515
use spacetimedb_sats::{
@@ -31,7 +31,7 @@ pub struct InstanceEnv {
3131
pub tx: TxSlot,
3232
/// The timestamp the current reducer began running.
3333
pub start_time: Timestamp,
34-
pub view: Option<UniqueView>,
34+
pub view: Option<ViewCall>,
3535
}
3636

3737
#[derive(Clone, Default)]
@@ -189,7 +189,7 @@ impl InstanceEnv {
189189
}
190190

191191
/// Signal to this `InstanceEnv` that a view is starting.
192-
pub fn start_view(&mut self, ts: Timestamp, view: UniqueView) {
192+
pub fn start_view(&mut self, ts: Timestamp, view: ViewCall) {
193193
self.start_time = ts;
194194
self.view = Some(view);
195195
}

crates/core/src/host/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl FunctionArgs {
6969

7070
#[derive(Debug, Clone)]
7171
pub struct ArgsTuple {
72-
pub tuple: ProductValue,
72+
tuple: ProductValue,
7373
bsatn: OnceCell<Bytes>,
7474
json: OnceCell<ByteString>,
7575
}

crates/core/src/host/wasmtime/wasm_instance_env.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::host::wasm_common::{err_to_errno_and_log, RowIterIdx, RowIters, Timin
99
use crate::host::AbiCall;
1010
use anyhow::Context as _;
1111
use spacetimedb_data_structures::map::IntMap;
12-
use spacetimedb_datastore::locking_tx_datastore::UniqueView;
12+
use spacetimedb_datastore::locking_tx_datastore::ViewCall;
1313
use spacetimedb_lib::{ConnectionId, Timestamp};
1414
use spacetimedb_primitives::{errno, ColId};
1515
use std::future::Future;
@@ -130,7 +130,7 @@ type RtResult<T> = anyhow::Result<T>;
130130
pub enum FuncCallType {
131131
Reducer,
132132
Procedure,
133-
View(UniqueView),
133+
View(ViewCall),
134134
}
135135

136136
/// Wraps an `InstanceEnv` with the magic necessary to push
@@ -257,7 +257,6 @@ impl WasmInstanceEnv {
257257
self.instance_env.start_view(ts, view);
258258
}
259259
}
260-
self.instance_env.start_funcall(ts);
261260

262261
(args, errors)
263262
}

crates/core/src/host/wasmtime/wasmtime_module.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::host::wasm_common::*;
1010
use crate::host::wasmtime::wasm_instance_env::FuncCallType;
1111
use crate::util::string_from_utf8_lossy_owned;
1212
use futures_util::FutureExt;
13-
use spacetimedb_datastore::locking_tx_datastore::UniqueView;
13+
use spacetimedb_datastore::locking_tx_datastore::ViewCall;
1414
use spacetimedb_lib::{ConnectionId, Identity};
1515
use spacetimedb_primitives::errno::HOST_CALL_FAILURE;
1616
use wasmtime::{
@@ -393,7 +393,7 @@ impl module_host_actor::WasmInstance for WasmtimeInstance {
393393
let store = &mut self.store;
394394
prepare_store_for_call(store, budget);
395395

396-
let view = UniqueView::with_identity(*op.caller_identity, op.id, op.args.get_bsatn().clone());
396+
let view = ViewCall::with_identity(*op.caller_identity, op.id, op.args.get_bsatn().clone());
397397

398398
// Prepare sender identity and connection ID, as LITTLE-ENDIAN byte arrays.
399399
let [sender_0, sender_1, sender_2, sender_3] = prepare_identity_for_call(*op.caller_identity);
@@ -419,8 +419,8 @@ impl module_host_actor::WasmInstance for WasmtimeInstance {
419419
),
420420
);
421421

422-
// Signal that this reducer call is finished. This gets us the timings
423-
// associated to our reducer call, and clears all of the instance state
422+
// Signal that this view call is finished. This gets us the timings
423+
// associated to our view call, and clears all of the instance state
424424
// associated to the call.
425425
let (timings, result_bytes) = store.data_mut().finish_funcall();
426426

@@ -450,7 +450,7 @@ impl module_host_actor::WasmInstance for WasmtimeInstance {
450450
let store = &mut self.store;
451451
prepare_store_for_call(store, budget);
452452

453-
let view = UniqueView::anonymous(op.id, op.args.get_bsatn().clone());
453+
let view = ViewCall::anonymous(op.id, op.args.get_bsatn().clone());
454454
// Prepare arguments to the reducer + the error sink & start timings.
455455
let args_bytes = op.args.get_bsatn().clone();
456456

@@ -462,8 +462,8 @@ impl module_host_actor::WasmInstance for WasmtimeInstance {
462462
let call_result =
463463
call_sync_typed_func(&self.call_view_anon, &mut *store, (op.id.0, args_source.0, errors_sink));
464464

465-
// Signal that this reducer call is finished. This gets us the timings
466-
// associated to our reducer call, and clears all of the instance state
465+
// Signal that this view call is finished. This gets us the timings
466+
// associated to our view call, and clears all of the instance state
467467
// associated to the call.
468468
let (timings, result_bytes) = store.data_mut().finish_funcall();
469469

crates/datastore/src/locking_tx_datastore/committed_state.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
error::{DatastoreError, IndexError, TableError},
1212
execution_context::ExecutionContext,
1313
locking_tx_datastore::{
14-
mut_tx::{UniqueView, ViewReadSets},
14+
mut_tx::{ViewCall, ViewReadSets},
1515
state_view::iter_st_column_for_table,
1616
},
1717
system_tables::{
@@ -53,12 +53,12 @@ use std::collections::BTreeMap;
5353
use std::sync::Arc;
5454
use thin_vec::ThinVec;
5555

56-
type IndexKeyReadSet = HashMap<AlgebraicValue, HashSet<UniqueView>>;
56+
type IndexKeyReadSet = HashMap<AlgebraicValue, HashSet<ViewCall>>;
5757
type IndexColReadSet = HashMap<ColList, IndexKeyReadSet>;
5858

5959
#[derive(Default)]
6060
struct CommittedReadSets {
61-
tables: IntMap<TableId, HashSet<UniqueView>>,
61+
tables: IntMap<TableId, HashSet<ViewCall>>,
6262
index_keys: IntMap<TableId, IndexColReadSet>,
6363
}
6464

@@ -72,12 +72,12 @@ impl MemoryUsage for CommittedReadSets {
7272

7373
impl CommittedReadSets {
7474
/// Record in the [`CommittedState`] that this view scans this table
75-
fn view_scans_table(&mut self, view: UniqueView, table_id: TableId) {
75+
fn view_scans_table(&mut self, view: ViewCall, table_id: TableId) {
7676
self.tables.entry(table_id).or_default().insert(view);
7777
}
7878

7979
/// Record in the [`CommittedState`] that this view reads this index `key` for these table `cols`
80-
fn view_reads_index_key(&mut self, view: UniqueView, table_id: TableId, cols: ColList, key: &AlgebraicValue) {
80+
fn view_reads_index_key(&mut self, view: ViewCall, table_id: TableId, cols: ColList, key: &AlgebraicValue) {
8181
self.index_keys
8282
.entry(table_id)
8383
.or_default()
@@ -98,7 +98,7 @@ impl CommittedReadSets {
9898

9999
/// Returns true if the given view exists in any read set.
100100
/// This is used to determine whether a view needs to be re-evaluated.
101-
fn is_materialized(&self, view: &UniqueView) -> bool {
101+
fn is_materialized(&self, view: &ViewCall) -> bool {
102102
self.tables.values().any(|views| views.contains(view))
103103
|| self.index_keys.values().any(|col_map| {
104104
col_map
@@ -724,7 +724,7 @@ impl CommittedState {
724724
tx_data
725725
}
726726

727-
fn merge_read_set(&mut self, view: UniqueView, read_set: ReadSet) {
727+
fn merge_read_set(&mut self, view: ViewCall, read_set: ReadSet) {
728728
for table_id in read_set.tables_scanned() {
729729
self.read_sets.view_scans_table(view.clone(), *table_id);
730730
}
@@ -1061,7 +1061,7 @@ impl CommittedState {
10611061
.set(self.blob_store.bytes_used_by_blobs() as _);
10621062
}
10631063

1064-
pub(super) fn is_materialized(&self, view: &UniqueView) -> bool {
1064+
pub(super) fn is_materialized(&self, view: &ViewCall) -> bool {
10651065
self.read_sets.is_materialized(view)
10661066
}
10671067
}

crates/datastore/src/locking_tx_datastore/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pub mod committed_state;
44
pub mod datastore;
55
mod mut_tx;
6-
pub use mut_tx::{MutTxId, UniqueView};
6+
pub use mut_tx::{MutTxId, ViewCall};
77
mod sequence;
88
pub mod state_view;
99
pub use state_view::{IterByColEqTx, IterByColRangeTx};

crates/datastore/src/locking_tx_datastore/mut_tx.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ impl ReadSet {
123123
}
124124

125125
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
126-
pub struct UniqueView {
126+
pub struct ViewCall {
127127
identity: Option<Identity>,
128128
view_id: ViewId,
129129
//TODO: use arg_id from [`ST_VIEW_ARGS`]
130130
args: Bytes,
131131
}
132132

133-
impl UniqueView {
133+
impl ViewCall {
134134
pub fn anonymous(view_id: ViewId, args: Bytes) -> Self {
135135
Self {
136136
identity: None,
@@ -152,7 +152,7 @@ impl UniqueView {
152152
}
153153
}
154154

155-
pub type ViewReadSets = HashMap<UniqueView, ReadSet>;
155+
pub type ViewReadSets = HashMap<ViewCall, ReadSet>;
156156

157157
/// Represents a Mutable transaction. Holds locks for its duration
158158
///
@@ -176,7 +176,7 @@ static_assert_size!(MutTxId, 448);
176176

177177
impl MutTxId {
178178
/// Record that a view performs a table scan in this transaction's read set
179-
pub fn record_table_scan(&mut self, view: Option<UniqueView>, table_id: TableId) {
179+
pub fn record_table_scan(&mut self, view: Option<ViewCall>, table_id: TableId) {
180180
if let Some(view) = view {
181181
self.read_sets.entry(view).or_default().insert_table_scan(table_id)
182182
}
@@ -185,7 +185,7 @@ impl MutTxId {
185185
/// Record that a view performs an index scan in this transaction's read set
186186
pub fn record_index_scan(
187187
&mut self,
188-
view: Option<UniqueView>,
188+
view: Option<ViewCall>,
189189
table_id: TableId,
190190
index_id: IndexId,
191191
lower: Bound<AlgebraicValue>,
@@ -754,9 +754,9 @@ impl MutTxId {
754754
.ok_or_else(|| anyhow::anyhow!("view `{view_name}` not found"))?;
755755

756756
let unique_view = if is_anonymous {
757-
UniqueView::anonymous(view_id, args)
757+
ViewCall::anonymous(view_id, args)
758758
} else {
759-
UniqueView::with_identity(sender, view_id, args)
759+
ViewCall::with_identity(sender, view_id, args)
760760
};
761761

762762
let is_materialized =

0 commit comments

Comments
 (0)