• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 4283961027

pending completion
4283961027

push

github

GitHub
feat: Blue green cache (#1061)

645 of 645 new or added lines in 45 files covered. (100.0%)

27779 of 39307 relevant lines covered (70.67%)

52489.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.8
/dozer-sql/src/pipeline/projection/processor.rs
1
use crate::pipeline::expression::execution::{Expression, ExpressionExecutor};
2

3
use dozer_core::channels::ProcessorChannelForwarder;
4
use dozer_core::epoch::Epoch;
5
use dozer_core::errors::ExecutionError;
6
use dozer_core::errors::ExecutionError::InternalError;
7
use dozer_core::node::{PortHandle, Processor};
8
use dozer_core::record_store::RecordReader;
9
use dozer_core::storage::lmdb_storage::SharedTransaction;
10
use dozer_core::DEFAULT_PORT_HANDLE;
11
use dozer_types::types::{Operation, Record, Schema};
12
use std::collections::HashMap;
13

14
#[derive(Debug)]
×
15
pub struct ProjectionProcessor {
16
    expressions: Vec<Expression>,
17
    input_schema: Schema,
18
}
19

20
impl ProjectionProcessor {
21
    pub fn new(input_schema: Schema, expressions: Vec<Expression>) -> Self {
322✔
22
        Self {
322✔
23
            input_schema,
322✔
24
            expressions,
322✔
25
        }
322✔
26
    }
322✔
27

28
    fn delete(&mut self, record: &Record) -> Result<Operation, ExecutionError> {
27,345✔
29
        let mut results = vec![];
27,345✔
30

31
        for expr in &self.expressions {
109,310✔
32
            results.push(
33
                expr.evaluate(record, &self.input_schema)
81,965✔
34
                    .map_err(|e| InternalError(Box::new(e)))?,
81,965✔
35
            );
36
        }
37
        Ok(Operation::Delete {
27,345✔
38
            old: Record::new(None, results, None),
27,345✔
39
        })
27,345✔
40
    }
27,345✔
41

42
    fn insert(&mut self, record: &Record) -> Result<Operation, ExecutionError> {
230,092✔
43
        let mut results = vec![];
230,092✔
44

45
        for expr in self.expressions.clone() {
465,552✔
46
            results.push(
47
                expr.evaluate(record, &self.input_schema)
465,552✔
48
                    .map_err(|e| InternalError(Box::new(e)))?,
465,552✔
49
            );
50
        }
51
        Ok(Operation::Insert {
230,087✔
52
            new: Record::new(None, results, None),
230,087✔
53
        })
230,087✔
54
    }
230,087✔
55

56
    fn update(&self, old: &Record, new: &Record) -> Result<Operation, ExecutionError> {
×
57
        let mut old_results = vec![];
×
58
        let mut new_results = vec![];
×
59

60
        for expr in &self.expressions {
×
61
            old_results.push(
62
                expr.evaluate(old, &self.input_schema)
×
63
                    .map_err(|e| InternalError(Box::new(e)))?,
×
64
            );
65
            new_results.push(
66
                expr.evaluate(new, &self.input_schema)
×
67
                    .map_err(|e| InternalError(Box::new(e)))?,
×
68
            );
69
        }
70

71
        Ok(Operation::Update {
×
72
            old: Record::new(None, old_results, None),
×
73
            new: Record::new(None, new_results, None),
×
74
        })
×
75
    }
×
76
}
77

78
impl Processor for ProjectionProcessor {
79
    fn process(
257,437✔
80
        &mut self,
257,437✔
81
        _from_port: PortHandle,
257,437✔
82
        op: Operation,
257,437✔
83
        fw: &mut dyn ProcessorChannelForwarder,
257,437✔
84
        _tx: &SharedTransaction,
257,437✔
85
        _reader: &HashMap<PortHandle, Box<dyn RecordReader>>,
257,437✔
86
    ) -> Result<(), ExecutionError> {
257,437✔
87
        let _ = match op {
257,437✔
88
            Operation::Delete { ref old } => fw.send(self.delete(old)?, DEFAULT_PORT_HANDLE),
27,345✔
89
            Operation::Insert { ref new } => fw.send(self.insert(new)?, DEFAULT_PORT_HANDLE),
230,092✔
90
            Operation::Update { ref old, ref new } => {
×
91
                fw.send(self.update(old, new)?, DEFAULT_PORT_HANDLE)
×
92
            }
93
            Operation::SnapshottingDone { .. } => fw.send(op, DEFAULT_PORT_HANDLE),
×
94
        };
×
95
        Ok(())
257,427✔
96
    }
257,427✔
97

×
98
    fn commit(&self, _epoch: &Epoch, _tx: &SharedTransaction) -> Result<(), ExecutionError> {
506✔
99
        Ok(())
506✔
100
    }
506✔
101
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc