-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaggregation_executor.h
More file actions
63 lines (54 loc) · 2.09 KB
/
Copy pathaggregation_executor.h
File metadata and controls
63 lines (54 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include <vector>
#include "abstract_executor.h"
#include "storage.h"
/**
* Enumeration to represent different types of aggregation operations.
*/
enum class AggregationType {
/**
* COUNT: An aggregation operation that counts the number of all tuples.
* It returns a single value representing the total number of tuples.
*/
COUNT,
/**
* SUM: An aggregation operation that calculates the total sum of the "val1" attribute values
* across all tuples. It returns a single value that represents this cumulative sum.
*/
SUM,
/**
* MIN: An aggregation operation that finds the minimum value of the "val1" attribute
* across all tuples. It returns a single value representing the smallest "val1" value.
*/
MIN,
/**
* MAX: An aggregation operation that finds the maximum value of the "val1" attribute
* across all tuples. It returns a single value representing the largest "val1" value.
*/
MAX
};
/**
* The AggregationExecutor class executes an aggregation operation (e.g., COUNT, SUM, MIN, MAX)
* specifically on the "val1" attribute of the tuples from a child executor.
*/
class AggregationExecutor : public AbstractExecutor {
public:
/**
* Constructor for AggregationExecutor.
* @param child_executor A pointer to the child executor on which the aggregation will be performed.
* @param aggr_type The type of aggregation operation to be performed.
*/
AggregationExecutor(AbstractExecutor *child_executor, AggregationType aggr_type);
/** Initialize the aggregation operation. */
void Init() override;
/**
* Yield the next tuple from the aggregation.
* @param tuple The next tuple produced by the aggregation operation, with the result in the "val1" attribute.
* @return `true` if a tuple was produced, `false` if there are no more tuples.
*/
bool Next(Tuple *tuple) override;
private:
AbstractExecutor *child_; ///< Pointer to the child executor.
std::vector<Tuple>::iterator iter_;///< Iterator to iterate over the tuples.
AggregationType aggr_type_; ///< The type of aggregation operation.
};