Skip to content

Commit 8911b1c

Browse files
committed
WIP
1 parent 0c8c314 commit 8911b1c

File tree

13 files changed

+356
-29
lines changed

13 files changed

+356
-29
lines changed

Cargo.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/developer/design/20241008_expression_cache.md

+6-16
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,7 @@ struct Expressions {
7070
physical_plan: DataflowDescription<mz_compute_types::plan::Plan>,
7171
dataflow_metainfos: DataflowMetainfo<Arc<OptimizerNotice>>,
7272
notices: SmallVec<[Arc<OptimizerNotice>; 4]>,
73-
optimizer_feature_overrides: OptimizerFeatures,
74-
}
75-
76-
struct NewEntry {
77-
/// `GlobalId` of the new expression.
78-
id: GlobalId,
79-
/// New `Expressions` to cache.
80-
expressions: Expressions,
81-
/// `GlobalId`s to invalidate as a result of the new entry.
82-
invalidate_ids: BTreeSet<GlobalId>,
73+
optimizer_feature: OptimizerFeatures,
8374
}
8475

8576
struct ExpressionCache {
@@ -100,13 +91,12 @@ impl ExpressionCache {
10091
/// Returns all cached expressions in the current deploy generation, after reconciliation.
10192
fn open(&mut self, current_ids: &BTreeSet<GlobalId>, optimizer_features: &OptimizerFeatures, remove_prior_gens: bool) -> Vec<(GlobalId, Expressions)>;
10293

103-
/// Durably inserts `expressions` into current deploy generation. This may also invalidate
104-
/// entries giving by `expressions`.
105-
///
106-
/// Returns a [`Future`] that completes once the changes have been made durable.
94+
/// Durably removes all entries given by `invalidate_ids` and inserts `new_entries` into
95+
/// current deploy generation.
10796
///
108-
/// Panics if any `GlobalId` already exists in the cache.
109-
fn insert_expressions(&mut self, expressions: Vec<NewEntry>) -> impl Future<Output=()>;
97+
/// If there is a duplicate ID in both `invalidate_ids` and `new_entries`, then the final value
98+
/// will be taken from `new_entries`.
99+
fn insert_expressions(&mut self, new_entries: Vec<(GlobalId, Expressions)>, invalidate_ids: BTreeSet<GlobalId>);
110100

111101
/// Durably remove and return all entries in current deploy generation that depend on an ID in
112102
/// `dropped_ids` .

src/adapter/BUILD.bazel

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ rust_library(
4040
"//src/compute-types:mz_compute_types",
4141
"//src/controller:mz_controller",
4242
"//src/controller-types:mz_controller_types",
43+
"//src/durable-cache:mz_durable_cache",
4344
"//src/dyncfg:mz_dyncfg",
4445
"//src/expr:mz_expr",
4546
"//src/kafka-util:mz_kafka_util",
@@ -104,6 +105,7 @@ rust_test(
104105
"//src/compute-types:mz_compute_types",
105106
"//src/controller:mz_controller",
106107
"//src/controller-types:mz_controller_types",
108+
"//src/durable-cache:mz_durable_cache",
107109
"//src/dyncfg:mz_dyncfg",
108110
"//src/expr:mz_expr",
109111
"//src/kafka-util:mz_kafka_util",
@@ -153,6 +155,7 @@ rust_doc_test(
153155
"//src/compute-types:mz_compute_types",
154156
"//src/controller:mz_controller",
155157
"//src/controller-types:mz_controller_types",
158+
"//src/durable-cache:mz_durable_cache",
156159
"//src/dyncfg:mz_dyncfg",
157160
"//src/expr:mz_expr",
158161
"//src/kafka-util:mz_kafka_util",
@@ -222,6 +225,7 @@ rust_test(
222225
"//src/compute-types:mz_compute_types",
223226
"//src/controller:mz_controller",
224227
"//src/controller-types:mz_controller_types",
228+
"//src/durable-cache:mz_durable_cache",
225229
"//src/dyncfg:mz_dyncfg",
226230
"//src/expr:mz_expr",
227231
"//src/kafka-util:mz_kafka_util",
@@ -291,6 +295,7 @@ rust_test(
291295
"//src/compute-types:mz_compute_types",
292296
"//src/controller:mz_controller",
293297
"//src/controller-types:mz_controller_types",
298+
"//src/durable-cache:mz_durable_cache",
294299
"//src/dyncfg:mz_dyncfg",
295300
"//src/expr:mz_expr",
296301
"//src/kafka-util:mz_kafka_util",
@@ -360,6 +365,7 @@ rust_test(
360365
"//src/compute-types:mz_compute_types",
361366
"//src/controller:mz_controller",
362367
"//src/controller-types:mz_controller_types",
368+
"//src/durable-cache:mz_durable_cache",
363369
"//src/dyncfg:mz_dyncfg",
364370
"//src/expr:mz_expr",
365371
"//src/kafka-util:mz_kafka_util",

src/adapter/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ mz-compute-client = { path = "../compute-client" }
4343
mz-compute-types = { path = "../compute-types" }
4444
mz-controller = { path = "../controller" }
4545
mz-controller-types = { path = "../controller-types" }
46+
mz-durable-cache = { path = "../durable-cache" }
4647
mz-dyncfg = { path = "../dyncfg" }
4748
mz-expr = { path = "../expr" }
4849
mz-kafka-util = { path = "../kafka-util" }

src/adapter/src/catalog.rs

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ mod migrate;
9696

9797
mod apply;
9898
mod dataflow_expiration;
99+
mod expr_cache;
99100
mod open;
100101
mod state;
101102
mod transact;

0 commit comments

Comments
 (0)