Skip to content

Commit 28324ec

Browse files
Get sum fully working
1 parent 8805d83 commit 28324ec

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

python/lstore/query.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ def insert(self, *columns):
4545
# Assume that select will never be called on a key that doesn't exist
4646
"""
4747

48-
def select(
49-
self, search_key: Any, search_key_index: int, projected_columns_index: List[int]
50-
):
48+
def select(self, search_key: Any, search_key_index: int, projected_columns_index: List[int]):
5149
return self.rquery.select(search_key, search_key_index, projected_columns_index)
5250

5351
"""
@@ -88,8 +86,8 @@ def update(self, primary_key: int, *columns):
8886
# Returns False if no record exists in the given range
8987
"""
9088

91-
def sum(self, start_range, end_range, aggregate_column_index) -> int:
92-
return self.table.sum(start_range, end_range, aggregate_column_index)
89+
def sum(self, start_range: int, end_range: int, aggregate_column_index: int) -> int:
90+
return self.rquery.sum(start_range, end_range, aggregate_column_index)
9391

9492
"""
9593
:param start_range: int # Start of the key range to aggregate
@@ -101,9 +99,7 @@ def sum(self, start_range, end_range, aggregate_column_index) -> int:
10199
# Returns False if no record exists in the given range
102100
"""
103101

104-
def sum_version(
105-
self, start_range, end_range, aggregate_column_index, relative_version
106-
):
102+
def sum_version(self, start_range, end_range, aggregate_column_index, relative_version):
107103
pass
108104

109105
"""

src/database.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl RTable {
110110
self.page_directory.remove(&rid);
111111
}
112112

113-
pub fn sum(&self, start: u64, end: u64, col_index: u64) -> i64 {
113+
pub fn sum(&mut self, start: u64, end: u64, col_index: u64) -> i64 {
114114
let mut agg = 0i64;
115115
for rid in start..end {
116116
if let Some(v) = self.read(rid) {

src/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl RQuery {
3434

3535
fn update(&mut self) {}
3636

37-
fn sum(&self, start: u64, end: u64, col_index: u64) -> i64 {
37+
fn sum(&mut self, start: u64, end: u64, col_index: u64) -> i64 {
3838
self.table.sum(start, end, col_index)
3939
}
4040

0 commit comments

Comments
 (0)