Skip to content

Commit 299ad96

Browse files
committed
is_materialised and Do not update st tables
1 parent 81e6007 commit 299ad96

File tree

5 files changed

+11
-19
lines changed

5 files changed

+11
-19
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/core/src/host/module_host.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ impl ModuleHost {
14631463

14641464
pub async fn call_view(
14651465
&self,
1466-
mut tx: MutTxId,
1466+
tx: MutTxId,
14671467
view_name: &str,
14681468
args: FunctionArgs,
14691469
caller_identity: Identity,
@@ -1478,15 +1478,6 @@ impl ModuleHost {
14781478
let view_seed = ArgsSeed(self.info.module_def.typespace().with_type(view_def));
14791479
let args = args.into_tuple(view_seed).map_err(InvalidViewArguments)?;
14801480

1481-
match tx.ctx.workload() {
1482-
WorkloadType::Subscribe => {
1483-
// New subscription, update st_view_client table.
1484-
let connection_id = caller_connection_id.ok_or(ViewCallError::MissingClientConnection)?;
1485-
tx.insert_st_view_client(view_name, args.get_bsatn(), caller_identity, connection_id)?;
1486-
}
1487-
_ => {}
1488-
}
1489-
14901481
let res = self
14911482
.call_view_inner(
14921483
tx,

crates/core/src/sql/execute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub async fn run(
204204

205205
for (view_name, args) in stmt.views() {
206206
let (is_memoized, args) = tx
207-
.has_memoized_view(view_name, args, caller_identity)
207+
.is_materialized(view_name, args, caller_identity)
208208
.map_err(|e| DBError::Other(anyhow!("Failed to check memoized view: {e}")))?;
209209

210210
// Skip if already memoized

crates/datastore/src/locking_tx_datastore/committed_state.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 has_memoized_view(&self, view: &UniqueView) -> bool {
101+
fn is_materialized(&self, view: &UniqueView) -> bool {
102102
self.tables.values().any(|views| views.contains(view))
103103
|| self.index_keys.values().any(|col_map| {
104104
col_map
@@ -1061,8 +1061,8 @@ impl CommittedState {
10611061
.set(self.blob_store.bytes_used_by_blobs() as _);
10621062
}
10631063

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

crates/datastore/src/locking_tx_datastore/mut_tx.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -742,12 +742,12 @@ impl MutTxId {
742742

743743
/// Checks whether a memoized view exists for the given view name, arguments, and sender identity.
744744
///
745-
/// If no memoized result is found, [`RelationalDB::evaluate_view`] should be called to compute and store it.
745+
/// If view is not materialized, [`RelationalDB::evaluate_view`] should be called to compute and store it.
746746
///
747747
/// - `view_name`: The name of the view to look up.
748748
/// - `args`: The serialized (bastn-encoded) arguments for the view.
749749
/// - `sender`: The identity of the sender requesting the view.
750-
pub fn has_memoized_view(&self, view_name: &str, args: Bytes, sender: Identity) -> Result<(bool, Bytes)> {
750+
pub fn is_materialized(&self, view_name: &str, args: Bytes, sender: Identity) -> Result<(bool, Bytes)> {
751751
let (view_id, is_anonymous) = self
752752
.view_from_name(view_name)?
753753
.map(|view_row| (view_row.view_id, view_row.is_anonymous))
@@ -760,7 +760,7 @@ impl MutTxId {
760760
};
761761

762762
let has_memoized = self.read_sets.contains_key(&unique_view)
763-
|| self.committed_state_write_lock.has_memoized_view(&unique_view);
763+
|| self.committed_state_write_lock.is_materialized(&unique_view);
764764

765765
Ok((has_memoized, unique_view.into_args()))
766766
}
@@ -1910,8 +1910,8 @@ impl MutTxId {
19101910
let row = &StViewClientRow {
19111911
view_id,
19121912
arg_id,
1913-
identity: IdentityViaU256(sender).into(),
1914-
connection_id: ConnectionIdViaU128(connection_id).into(),
1913+
identity: IdentityViaU256(sender),
1914+
connection_id: ConnectionIdViaU128(connection_id),
19151915
};
19161916
self.insert_via_serialize_bsatn(ST_VIEW_CLIENT_ID, row)?;
19171917

0 commit comments

Comments
 (0)