Skip to content

Commit 05c3438

Browse files
authored
Fix SimpleAggregationHashTable functions and add TODO (#442)
change SimpleAggregationHashTable functions and add TODO
1 parent 94e02b5 commit 05c3438

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/include/execution/executors/aggregation_executor.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,24 @@ class SimpleAggregationHashTable {
4848
for (const auto &agg_type : agg_types_) {
4949
switch (agg_type) {
5050
case AggregationType::CountStarAggregate:
51-
case AggregationType::CountAggregate:
52-
case AggregationType::SumAggregate:
53-
// Count/Sum starts at zero.
51+
// Count start starts at zero.
5452
values.emplace_back(ValueFactory::GetIntegerValue(0));
5553
break;
54+
case AggregationType::CountAggregate:
55+
case AggregationType::SumAggregate:
5656
case AggregationType::MinAggregate:
57-
// Min starts at INT_MAX.
58-
values.emplace_back(ValueFactory::GetIntegerValue(BUSTUB_INT32_MAX));
59-
break;
6057
case AggregationType::MaxAggregate:
61-
// Max starts at INT_MIN.
62-
values.emplace_back(ValueFactory::GetIntegerValue(BUSTUB_INT32_MIN));
58+
// Others starts at null.
59+
values.emplace_back(ValueFactory::GetNullValueByType(TypeId::INTEGER));
6360
break;
6461
}
6562
}
6663
return {values};
6764
}
6865

6966
/**
67+
* TODO(Student)
68+
*
7069
* Combines the input into the aggregation result.
7170
* @param[out] result The output aggregate value
7271
* @param input The input value
@@ -96,6 +95,11 @@ class SimpleAggregationHashTable {
9695
CombineAggregateValues(&ht_[agg_key], agg_val);
9796
}
9897

98+
/**
99+
* Clear the hash table
100+
*/
101+
void Clear() { ht_.clear(); }
102+
99103
/** An iterator over the aggregation hash table */
100104
class Iterator {
101105
public:

0 commit comments

Comments
 (0)