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

flowlight0 / simpledb-rs / #112

20 Jun 2025 10:25AM UTC coverage: 79.857% (+0.2%) from 79.678%
#112

push

web-flow
Implement aggregation functions (#113)

* Add aggregation functions and tests

* Update README.md

76 of 86 new or added lines in 4 files covered. (88.37%)

1 existing line in 1 file now uncovered.

2894 of 3624 relevant lines covered (79.86%)

1.76 hits per line

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

80.95
/src/materialization/min_function.rs
1
use crate::{
2
    errors::TransactionError,
3
    record::field::Value,
4
    scan::{Scan, ScanControl},
5
};
6

7
use super::aggregation_function::AggregationFnControl;
8

9
#[derive(Clone)]
10
pub struct MinFn {
11
    min_value: Option<Value>,
12
    field_name: String,
13
}
14

15
impl MinFn {
16
    pub fn new(field_name: &str) -> Self {
1✔
17
        Self {
18
            min_value: None,
19
            field_name: field_name.to_string(),
1✔
20
        }
21
    }
22
}
23

24
impl AggregationFnControl for MinFn {
25
    fn process_first(&mut self, scan: &mut Scan) -> Result<(), TransactionError> {
1✔
26
        let value = scan.get_value(&self.field_name)?;
2✔
27
        if value == Value::Null {
2✔
NEW
28
            self.min_value = None;
×
29
        } else {
30
            self.min_value = Some(value);
1✔
31
        }
32
        Ok(())
1✔
33
    }
34

35
    fn process_next(&mut self, scan: &mut Scan) -> Result<(), TransactionError> {
1✔
36
        let new_value = scan.get_value(&self.field_name)?;
1✔
37
        if new_value == Value::Null {
2✔
NEW
38
            return Ok(());
×
39
        }
40
        if let Some(min) = &mut self.min_value {
2✔
41
            if new_value < *min {
2✔
NEW
42
                *min = new_value;
×
43
            }
44
        } else {
NEW
45
            self.min_value = Some(new_value);
×
46
        }
47
        Ok(())
1✔
48
    }
49

50
    fn get_field_name(&self) -> &str {
1✔
51
        &self.field_name
1✔
52
    }
53

54
    fn get_value(&self) -> Option<Value> {
1✔
55
        self.min_value.clone()
1✔
56
    }
57
}
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