Skip to content

Commit ce59259

Browse files
Make sum
1 parent 28324ec commit ce59259

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

simple_tester.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@
2626
for rec in recs:
2727
vals = query.select(rec, 0, [0])
2828
print(vals)
29+
30+
for x in range(0, 8):
31+
print(f"query.sum(13, 17, {x})", query.sum(13, 17, x))

src/database.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ impl RTable {
112112

113113
pub fn sum(&mut self, start: u64, end: u64, col_index: u64) -> i64 {
114114
let mut agg = 0i64;
115-
for rid in start..end {
115+
116+
// Make sum range inclusive
117+
// TODO: Validate this assumption if it should actually be inclusive
118+
for rid in start..end + 1 {
116119
if let Some(v) = self.read(rid) {
117120
agg += v[col_index as usize] as i64;
118121
}

0 commit comments

Comments
 (0)