Go to the documentation of this file.
6 #include <unordered_map>
56 std::unordered_map<JoinValue, DataRecord, JoinHash>
joinMap;
67 std::vector<DataGeneraterJoin>
joins;
142 std::vector<ColumnStore::Column> columns;
143 for (
auto &aggregate : aggregations)
144 columns.emplace_back(aggregate->getColumnName(),
149 if (!generator.
hasNext())
return;
151 for (
auto &aggregate : aggregations)
152 aggregate->initialize(generatorMetadata);
156 for (
auto &aggregate : aggregations) aggregate->addRecord(
record);
159 std::vector<ColumnStore::DataValue> values;
161 for (
auto &aggregate : aggregations)
162 values.emplace_back(aggregate->getValue());
206 std::vector<std::string> &groupBys = builder.
groupBys;
209 std::vector<ColumnStore::Column> columns;
211 for (
auto &grp : groupBys)
212 columns.push_back(generatorMetadata->getColumn(grp));
214 for (
auto &aggregate : aggregations)
215 columns.emplace_back(aggregate->getColumnName(),
221 std::vector<ColumnStore::AggregatorQuery>,
GroupHash>
224 for (
auto &aggregate : aggregations)
225 aggregate->initialize(generatorMetadata);
227 auto duplicateAggregators = [&]() {
228 std::vector<ColumnStore::AggregatorQuery> temp;
229 for (
auto &agg : aggregations) temp.push_back(agg->clone());
234 auto record = generator.
next();
236 if (!map.count(groupValue))
237 map[groupValue] = duplicateAggregators();
239 auto &aggregations1 = map[groupValue];
241 for (
auto &aggregate : aggregations1) aggregate->addRecord(record);
244 for (
auto &[groupValue, aggregations1] : map) {
245 std::vector<ColumnStore::DataValue> values = groupValue.
values;
246 for (
auto &aggregate : aggregations1)
247 values.emplace_back(aggregate->getValue());
DataRecord record
Definition: GenericGenerator.h:123
std::queue< ColumnStore::DataRecord > records
Definition: GenericGenerator.h:187
bool _hasNext
Definition: GenericGenerator.h:62
std::shared_ptr< RecordValidatorInterface > RecordValidator
Shared Pointer for RecordValidator Interface.
Definition: Validators.h:39
DataType
Different datatypes supported by this project.
Definition: Column.h:16
Definition: CSVparser.cpp:6
JoinValue processValue(DataValue &value)
Definition: GroupByManager.cpp:32
bool _hasNext
Definition: GenericGenerator.h:121
std::string baseSource
Base data source.
Definition: GenericQueryBuilder.h:73
std::vector< int > baseIndices
List of column indices to extract values from base source records.
Definition: GenericGenerator.h:36
Definition: GenericGenerator.h:28
Metadata generateMetadata()
Generates metadata of result records using join and query information.
Definition: GenericQueryBuilder.cpp:95
DataRecord next()
generates a new record
Definition: GenericGenerator.h:180
Data Generator for GenericQueryBuilder.
Definition: GenericGenerator.cpp:11
std::vector< DataGeneraterJoin > joins
List of joins.
Definition: GenericGenerator.h:67
std::unordered_map< std::string, DataSource > data_sources
map of data source name and data generator
Definition: GenericQueryBuilder.h:66
GroupByValue processRecord(DataRecord &record)
Definition: GroupByManager.cpp:67
std::shared_ptr< DataRecordMetadata > Metadata
Shared pointer to DataRecordMetadata.
Definition: DataRecord.h:208
DataSource baseSource
Definition: GenericGenerator.h:32
std::shared_ptr< DataGeneratorInterface > DataSource
Shared pointer to the DataGeneratorInterface.
Definition: DataGeneratorInterface.h:73
JoinValueManager * manager
Definition: GroupByManager.h:58
GenericDataAggregator(GenericQueryBuilder builder)
Construct a new Generic Data Generator object.
Definition: GenericGenerator.h:135
Definition: GenericGenerator.h:186
std::vector< ColumnStore::DataValue > values
Definition: GroupByManager.h:47
RecordValidator generateRecordValidator()
creates record
Definition: GenericQueryBuilder.cpp:130
GenericQueryBuilder builder
builder object from which we are generating data
Definition: GenericGenerator.h:30
Stores a row of data.
Definition: DataRecord.h:64
bool hasNext()
check if a record is available
Definition: GenericGenerator.h:257
DataRecord _getCandidateNext()
Gets the next candidate record.
Definition: GenericGenerator.cpp:50
void _setNext()
internal function to set the next valid record
Definition: GenericGenerator.cpp:31
GenericGroupByAggregator(GenericQueryBuilder builder)
Construct a new Generic Data Generator object.
Definition: GenericGenerator.h:199
bool hasNext()
check if a record is available
Definition: GenericGenerator.h:173
Definition: GroupByManager.h:46
Metadata getMetadata() const
Interface for relational data sources.
Definition: DataGeneratorInterface.cpp:23
Definition: GroupByManager.h:56
RecordValidator Interfaces and Implementations for Query Processing.
GenericDataGenerator(GenericQueryBuilder builder)
Construct a new Generic Data Generator object.
Definition: GenericGenerator.cpp:84
Definition: GroupByManager.h:35
bool hasNext()
check if a record is available
Definition: GenericGenerator.cpp:142
RecordValidator recordValidator
Definition: GenericGenerator.h:31
Definition: GroupByManager.h:18
DataGeneraterJoin(std::string name, Metadata metadata)
Definition: GenericGenerator.h:58
Data Generator Interface.
Metadata metadata
metadata for processing queries
Definition: DataGeneratorInterface.h:27
std::ostream & operator<<(std::ostream &os, const Row &row)
Definition: CSVparser.cpp:250
DataRecord nextRecord
Definition: GenericGenerator.h:64
int FKIndex
FK index in base data source.
Definition: GenericGenerator.h:46
std::vector< std::string > groupBys
Definition: GenericQueryBuilder.h:100
Generic Condition Builder.
std::unordered_map< JoinValue, DataRecord, JoinHash > joinMap
Definition: GenericGenerator.h:56
Implementation of a single data element.
Definition: DataRecord.h:28
Generic Query Builder Class.
Definition: GenericQueryBuilder.h:47
std::vector< std::pair< std::string, Join > > joins
List of joins.
Definition: GenericQueryBuilder.h:85
DataRecord next()
generates a new record
Definition: GenericGenerator.h:264
helper structure to efficiently process joins
Definition: GenericGenerator.h:42
Definition: GroupByManager.h:68
std::vector< int > indices
indices of columns required for joined result
Definition: GenericGenerator.h:44
std::vector< std::string > baseColumns
list of columns from the base table required in result
Definition: GenericQueryBuilder.h:79
DataRecord next()
generates a new record
Definition: GenericGenerator.cpp:149
Definition: GenericGenerator.h:120
Interface for relational data sources.
Definition: DataGeneratorInterface.h:24
std::vector< ColumnStore::AggregatorQuery > aggregations
Definition: GenericQueryBuilder.h:99
DataRecord _getNext()
internal function to process and generate next valid record
Definition: GenericGenerator.cpp:17
JoinValueManager manager
map of PK of join source to join records
Definition: GenericGenerator.h:55