int main() {
BuzzDB db; // our custom database
// Import data from “output.txt” file
std::ifstream inputFile("output.txt");
// Variables to store data from the file
int field1, field2;
// Read pairs of integers from the file and insert them into BuzzDB
while (inputFile >> field1 >> field2) {
// insert each pair into the database
db.insert(field1, field2);
}
// Perform aggregation query on the imported data
db.selectGroupBySum();
}
A tuple represents one record (or row) in the database. For example:
class Tuple {
public:
// Identifier field (like a unique ID)
int key;
// Actual data field (value associated with the key)
int value;
};
A field is an individual piece of data in the tuple. For instance, in a tuple {101, 200}, the key (101) and value (200) are fields.
Field Class: Type
Enums: Defines, Constants
enum FieldType {INT, FLOAT}; // Field types supported: ints and floats
class Field {
public:
FieldType type; // type of field (int or float)
union {
int i; // integer value
float f; // float value
} data; // actual data
};