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

getdozer / dozer / 4384029966

pending completion
4384029966

push

github

GitHub
Prepare v0.1.11 (#1203)

28488 of 40876 relevant lines covered (69.69%)

39271.28 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 {
360✔
20
        Self {
360✔
21
            input_schema,
360✔
22
            expressions,
360✔
23
        }
360✔
24
    }
360✔
25

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

29
        for expr in &self.expressions {
4,430✔
30
            results.push(
31
                expr.evaluate(record, &self.input_schema)
3,305✔
32
                    .map_err(|e| InternalError(Box::new(e)))?,
3,305✔
33
            );
34
        }
35
        Ok(Operation::Delete {
1,125✔
36
            old: Record::new(None, results, None),
1,125✔
37
        })
1,125✔
38
    }
1,125✔
39

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

43
        for expr in self.expressions.clone() {
464,005✔
44
            results.push(
45
                expr.evaluate(record, &self.input_schema)
464,005✔
46
                    .map_err(|e| InternalError(Box::new(e)))?,
464,005✔
47
            );
48
        }
49
        Ok(Operation::Insert {
229,795✔
50
            new: Record::new(None, results, None),
229,795✔
51
        })
229,795✔
52
    }
229,795✔
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(
230,890✔
78
        &mut self,
230,890✔
79
        _from_port: PortHandle,
230,890✔
80
        op: Operation,
230,890✔
81
        fw: &mut dyn ProcessorChannelForwarder,
230,890✔
82
        _tx: &SharedTransaction,
230,890✔
83
    ) -> Result<(), ExecutionError> {
230,890✔
84
        let _ = match op {
230,890✔
85
            Operation::Delete { ref old } => fw.send(self.delete(old)?, DEFAULT_PORT_HANDLE),
1,070✔
86
            Operation::Insert { ref new } => fw.send(self.insert(new)?, DEFAULT_PORT_HANDLE),
229,820✔
87
            Operation::Update { ref old, ref new } => {
×
88
                fw.send(self.update(old, new)?, DEFAULT_PORT_HANDLE)
×
89
            }
90
        };
91
        Ok(())
230,650✔
92
    }
230,650✔
93

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