presolve_compiler/
computed_projection.rs1use crate::RuntimeComputedRegistry;
3use serde::Serialize;
4pub const COMPUTED_PROJECTION_SCHEMA_VERSION: u32 = 1;
5#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
6pub struct ComputedProjectionRecordV1 {
7 pub computed: String,
8 pub cache_slot: String,
9 pub dirty_flag: String,
10 pub dependencies: Vec<String>,
11 pub memoized_per_instance: bool,
12}
13#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
14pub struct ComputedProjectionV1 {
15 pub schema_version: u32,
16 pub records: Vec<ComputedProjectionRecordV1>,
17}
18#[must_use]
19pub fn build_computed_projection_v1(registry: &RuntimeComputedRegistry) -> ComputedProjectionV1 {
20 let mut records = registry
21 .records
22 .values()
23 .map(|record| ComputedProjectionRecordV1 {
24 computed: record.computed.to_string(),
25 cache_slot: record.cache_slot.as_str().to_owned(),
26 dirty_flag: record.dirty_flag.id.as_str().to_owned(),
27 dependencies: record
28 .dependencies
29 .iter()
30 .map(ToString::to_string)
31 .collect(),
32 memoized_per_instance: true,
33 })
34 .collect::<Vec<_>>();
35 records.sort_by(|a, b| a.computed.cmp(&b.computed));
36 ComputedProjectionV1 {
37 schema_version: COMPUTED_PROJECTION_SCHEMA_VERSION,
38 records,
39 }
40}