Column Store
GenericQueryBuilder.h
Go to the documentation of this file.
1 #pragma once
2 #include <memory>
3 #include <string>
4 #include <unordered_map>
5 
10 
18 namespace GenericQuery {
19 
28 using ColumnStore::Query;
30 
31 class GenericDataGenerator;
32 
53  struct Join {
55  std::string foreignKey;
57  std::string primaryKey;
59  std::vector<std::string> columns;
60  };
61 
66  std::unordered_map<std::string, DataSource> data_sources;
67 
73  std::string baseSource;
74 
79  std::vector<std::string> baseColumns;
80 
85  std::vector<std::pair<std::string, Join>> joins;
86 
91  std::unordered_map<std::string, std::string> columnMap;
92 
98 
99  std::vector<ColumnStore::AggregatorQuery> aggregations;
100  std::vector<std::string> groupBys;
101 
102  friend class GenericDataGenerator;
103  friend class GenericDataAggregator;
105 
106  public:
113  void registerDataSource(std::string name, DataSource source);
114 
121  void setBaseSource(std::string name, std::vector<std::string> columns);
122 
131  void join(std::string name, std::vector<std::string> columns,
132  std::string foreignKey, std::string primaryKey);
133 
139  void where(Query query);
140 
153 
160 
161  DataSource build();
162 
164  aggregations.push_back(query);
165  }
166 
167  void groupBy(std::string name) { groupBys.push_back(name); }
168 };
169 }; // namespace GenericQuery
ColumnStore::AggregatorQuery
std::shared_ptr< Aggregator > AggregatorQuery
Shared pointer to Query Structure.
Definition: AggregatorQuery.h:57
GenericQuery::GenericQueryBuilder::build
DataSource build()
Definition: GenericQueryBuilder.cpp:134
ColumnStore::Query
std::shared_ptr< ConditionQuery > Query
Shared pointer to Query Structure.
Definition: ConditionQuery.h:54
ColumnStore::RecordValidator
std::shared_ptr< RecordValidatorInterface > RecordValidator
Shared Pointer for RecordValidator Interface.
Definition: Validators.h:39
GenericQuery::GenericQueryBuilder::setBaseSource
void setBaseSource(std::string name, std::vector< std::string > columns)
Set the Base Source and the columns required in the query result.
Definition: GenericQueryBuilder.cpp:39
ColumnStore::DataType
DataType
Different datatypes supported by this project.
Definition: Column.h:16
ColumnStore::DataRecordMetadata
Stores metadata information of the data record.
Definition: DataRecord.h:88
GenericQuery::GenericQueryBuilder::Join::columns
std::vector< std::string > columns
List of columns required in result from joined source.
Definition: GenericQueryBuilder.h:59
GenericQuery::GenericQueryBuilder::baseSource
std::string baseSource
Base data source.
Definition: GenericQueryBuilder.h:73
GenericQuery::GenericQueryBuilder::GenericDataAggregator
friend class GenericDataAggregator
Definition: GenericQueryBuilder.h:103
GenericQuery::GenericDataGenerator
Definition: GenericGenerator.h:28
GenericQuery::GenericQueryBuilder::generateMetadata
Metadata generateMetadata()
Generates metadata of result records using join and query information.
Definition: GenericQueryBuilder.cpp:95
AggregatorQuery.h
Generic Condition Builder.
GenericQuery
Data Generator for GenericQueryBuilder.
Definition: GenericGenerator.cpp:11
GenericQuery::GenericQueryBuilder::GenericGroupByAggregator
friend class GenericGroupByAggregator
Definition: GenericQueryBuilder.h:104
ColumnStore::Column
Struct which maintains metadata of a single column.
Definition: Column.h:22
GenericQuery::GenericQueryBuilder::data_sources
std::unordered_map< std::string, DataSource > data_sources
map of data source name and data generator
Definition: GenericQueryBuilder.h:66
ColumnStore::Metadata
std::shared_ptr< DataRecordMetadata > Metadata
Shared pointer to DataRecordMetadata.
Definition: DataRecord.h:208
GenericQueryBuilder.h
Generic Query Builder.
ColumnStore::DataSource
std::shared_ptr< DataGeneratorInterface > DataSource
Shared pointer to the DataGeneratorInterface.
Definition: DataGeneratorInterface.h:73
GenericQuery::GenericQueryBuilder::where
void where(Query query)
Sets the query object.
Definition: GenericQueryBuilder.cpp:79
GenericQuery::GenericGroupByAggregator
Definition: GenericGenerator.h:186
GenericQuery::GenericQueryBuilder::generateRecordValidator
RecordValidator generateRecordValidator()
creates record
Definition: GenericQueryBuilder.cpp:130
ColumnStore::DataRecord
Stores a row of data.
Definition: DataRecord.h:64
ColumnStore::ConditionQuery
Base Condition Query Structure.
Definition: ConditionQuery.h:25
GenericGenerator.h
GenericQuery::GenericQueryBuilder::groupBy
void groupBy(std::string name)
Definition: GenericQueryBuilder.h:167
GenericQuery::GenericQueryBuilder::join
void join(std::string name, std::vector< std::string > columns, std::string foreignKey, std::string primaryKey)
Creates a join from base source to a join source.
Definition: GenericQueryBuilder.cpp:59
Validators.h
RecordValidator Interfaces and Implementations for Query Processing.
GenericQuery::GenericQueryBuilder::registerDataSource
void registerDataSource(std::string name, DataSource source)
Registers a new data source and gives is an alias name.
Definition: GenericQueryBuilder.cpp:28
GenericQuery::GenericQueryBuilder::Join::primaryKey
std::string primaryKey
Primary key in join source.
Definition: GenericQueryBuilder.h:57
GenericQuery::GenericQueryBuilder::GenericDataGenerator
friend class GenericDataGenerator
Definition: GenericQueryBuilder.h:102
DataGeneratorInterface.h
Data Generator Interface.
GenericQuery::GenericQueryBuilder::Join::foreignKey
std::string foreignKey
Foreign key from base source.
Definition: GenericQueryBuilder.h:55
GenericQuery::GenericQueryBuilder::query
Query query
Query object.
Definition: GenericQueryBuilder.h:97
GenericQuery::GenericQueryBuilder::groupBys
std::vector< std::string > groupBys
Definition: GenericQueryBuilder.h:100
ConditionQuery.h
Generic Condition Builder.
ColumnStore::DataValue
Implementation of a single data element.
Definition: DataRecord.h:28
GenericQuery::GenericQueryBuilder
Generic Query Builder Class.
Definition: GenericQueryBuilder.h:47
GenericQuery::GenericQueryBuilder::joins
std::vector< std::pair< std::string, Join > > joins
List of joins.
Definition: GenericQueryBuilder.h:85
GenericQuery::GenericQueryBuilder::columnMap
std::unordered_map< std::string, std::string > columnMap
List of columns and their corresponding data source.
Definition: GenericQueryBuilder.h:91
GenericQuery::GenericQueryBuilder::aggregate
void aggregate(ColumnStore::AggregatorQuery query)
Definition: GenericQueryBuilder.h:163
GenericQuery::GenericQueryBuilder::baseColumns
std::vector< std::string > baseColumns
list of columns from the base table required in result
Definition: GenericQueryBuilder.h:79
GenericQuery::GenericQueryBuilder::Join
Helper struct to represent join infromation.
Definition: GenericQueryBuilder.h:53
GenericQuery::GenericDataAggregator
Definition: GenericGenerator.h:120
GenericQuery::GenericQueryBuilder::aggregations
std::vector< ColumnStore::AggregatorQuery > aggregations
Definition: GenericQueryBuilder.h:99