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

getdozer / dozer / 4397225743

pending completion
4397225743

push

github

GitHub
new readme (#1221)

28080 of 37755 relevant lines covered (74.37%)

79035.29 hits per line

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

70.91
/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::storage::lmdb_storage::SharedTransaction;
9
use dozer_core::DEFAULT_PORT_HANDLE;
10
use dozer_types::types::{Operation, Record, Schema};
11

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

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

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

29
        for expr in &self.expressions {
8,860✔
30
            results.push(
31
                expr.evaluate(record, &self.input_schema)
6,610✔
32
                    .map_err(|e| InternalError(Box::new(e)))?,
6,610✔
33
            );
34
        }
35
        Ok(Operation::Delete {
2,250✔
36
            old: Record::new(None, results, None),
2,250✔
37
        })
2,250✔
38
    }
2,250✔
39

40
    fn insert(&mut self, record: &Record) -> Result<Operation, ExecutionError> {
459,378✔
41
        let mut results = vec![];
459,378✔
42

43
        for expr in self.expressions.clone() {
927,388✔
44
            results.push(
45
                expr.evaluate(record, &self.input_schema)
927,388✔
46
                    .map_err(|e| InternalError(Box::new(e)))?,
927,388✔
47
            );
48
        }
49
        Ok(Operation::Insert {
459,460✔
50
            new: Record::new(None, results, None),
459,460✔
51
        })
459,460✔
52
    }
459,460✔
53

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

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

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

76
impl Processor for ProjectionProcessor {
77
    fn process(
461,838✔
78
        &mut self,
461,838✔
79
        _from_port: PortHandle,
461,838✔
80
        op: Operation,
461,838✔
81
        fw: &mut dyn ProcessorChannelForwarder,
461,838✔
82
        _tx: &SharedTransaction,
461,838✔
83
    ) -> Result<(), ExecutionError> {
461,838✔
84
        let _ = match op {
461,838✔
85
            Operation::Delete { ref old } => fw.send(self.delete(old)?, DEFAULT_PORT_HANDLE),
2,260✔
86
            Operation::Insert { ref new } => fw.send(self.insert(new)?, DEFAULT_PORT_HANDLE),
459,578✔
87
            Operation::Update { ref old, ref new } => {
×
88
                fw.send(self.update(old, new)?, DEFAULT_PORT_HANDLE)
×
89
            }
90
        };
91
        Ok(())
461,530✔
92
    }
461,530✔
93

94
    fn commit(&self, _epoch: &Epoch, _tx: &SharedTransaction) -> Result<(), ExecutionError> {
576✔
95
        Ok(())
576✔
96
    }
576✔
97
}
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

© 2025 Coveralls, Inc