Column Store
GroupByManager.h
Go to the documentation of this file.
1 #pragma once
2 #include <memory>
3 #include <queue>
4 #include <string>
5 #include <unordered_map>
6 
7 #include "GenericQueryBuilder.h"
10 #include "interfaces/Validators.h"
11 
12 namespace GenericQuery {
13 
14 struct GroupByValue;
15 
16 struct JoinValue;
17 
19  std::vector<int> indices;
20  std::vector<DataType> types;
21  GroupByManager(std::vector<std::string> &columns, Metadata metadata) {
22  indices.reserve(columns.size());
23  types.reserve(columns.size());
24  for (auto &c : columns) {
25  indices.push_back(metadata->getColumn(c).index);
26  types.push_back(metadata->getColumn(c));
27  }
28  }
29 
30  bool compare(const GroupByValue &value1, const GroupByValue &value2) const;
31  size_t hash(const GroupByValue &value) const;
33 };
34 
37  JoinValueManager(std::string name, Metadata metadata) {
38  type = metadata->getColumn(name);
39  }
40 
41  bool compare(const JoinValue &value1, const JoinValue &value2) const;
42  size_t hash(const JoinValue &value) const;
44 };
45 
46 struct GroupByValue {
47  std::vector<ColumnStore::DataValue> values;
49  bool operator==(const GroupByValue &value) const {
50  return manager->compare(*this, value);
51  }
52 
53  const DataValue &operator[](int index) const { return values[index]; }
54 };
55 
56 struct JoinValue {
60  : value(value), manager(manager) {}
61  bool operator==(const JoinValue &value) const {
62  return manager->compare(*this, value);
63  }
64 
65  operator const ColumnStore::DataValue() const { return value; }
66 };
67 
68 struct GroupHash {
69  public:
70  size_t operator()(const GroupByValue &value) const {
71  return value.manager->hash(value);
72  }
73 };
74 
75 struct JoinHash {
76  size_t operator()(const JoinValue &value) const {
77  return value.manager->hash(value);
78  }
79 };
80 } // namespace GenericQuery
GenericQuery::GroupByManager::GroupByManager
GroupByManager(std::vector< std::string > &columns, Metadata metadata)
Definition: GroupByManager.h:21
GenericQuery::GroupByValue::operator[]
const DataValue & operator[](int index) const
Definition: GroupByManager.h:53
ColumnStore::DataType
DataType
Different datatypes supported by this project.
Definition: Column.h:16
GenericQuery::JoinValueManager::type
DataType type
Definition: GroupByManager.h:36
GenericQuery::GroupByValue::operator==
bool operator==(const GroupByValue &value) const
Definition: GroupByManager.h:49
GenericQuery::JoinValueManager::processValue
JoinValue processValue(DataValue &value)
Definition: GroupByManager.cpp:32
GenericQuery::JoinValue::value
ColumnStore::DataValue value
Definition: GroupByManager.h:57
ColumnStore::DataValue::as
const T as() const
Extracts value by type.
Definition: DataRecord.h:40
GenericQuery
Data Generator for GenericQueryBuilder.
Definition: GenericGenerator.cpp:11
ColumnStore::DataType::STRING
@ STRING
GenericQuery::GroupByManager::processRecord
GroupByValue processRecord(DataRecord &record)
Definition: GroupByManager.cpp:67
ColumnStore::Metadata
std::shared_ptr< DataRecordMetadata > Metadata
Shared pointer to DataRecordMetadata.
Definition: DataRecord.h:208
GenericQueryBuilder.h
Generic Query Builder.
GenericQuery::GroupByManager::indices
std::vector< int > indices
Definition: GroupByManager.h:19
GenericQuery::JoinValue::manager
JoinValueManager * manager
Definition: GroupByManager.h:58
GenericQuery::GroupByValue::values
std::vector< ColumnStore::DataValue > values
Definition: GroupByManager.h:47
ColumnStore::DataRecord
Stores a row of data.
Definition: DataRecord.h:64
GroupByManager.h
GenericQuery::GroupHash::operator()
size_t operator()(const GroupByValue &value) const
Definition: GroupByManager.h:70
GenericQuery::GroupByValue::manager
GroupByManager * manager
Definition: GroupByManager.h:48
GenericQuery::GroupByValue
Definition: GroupByManager.h:46
GenericQuery::GroupByManager::types
std::vector< DataType > types
Definition: GroupByManager.h:20
GenericQuery::JoinValue
Definition: GroupByManager.h:56
Validators.h
RecordValidator Interfaces and Implementations for Query Processing.
GenericQuery::JoinValueManager
Definition: GroupByManager.h:35
ColumnStore::DataType::INT
@ INT
GenericQuery::GroupByManager
Definition: GroupByManager.h:18
GenericQuery::JoinHash
Definition: GroupByManager.h:75
GenericQuery::JoinHash::operator()
size_t operator()(const JoinValue &value) const
Definition: GroupByManager.h:76
DataGeneratorInterface.h
Data Generator Interface.
GenericQuery::JoinValueManager::hash
size_t hash(const JoinValue &value) const
Definition: GroupByManager.cpp:19
ConditionQuery.h
Generic Condition Builder.
ColumnStore::DataValue
Implementation of a single data element.
Definition: DataRecord.h:28
GenericQuery::JoinValueManager::JoinValueManager
JoinValueManager(std::string name, Metadata metadata)
Definition: GroupByManager.h:37
ColumnStore::DataType::FLOAT
@ FLOAT
GenericQuery::GroupHash
Definition: GroupByManager.h:68
GenericQuery::JoinValue::operator==
bool operator==(const JoinValue &value) const
Definition: GroupByManager.h:61
GenericQuery::GroupByManager::compare
bool compare(const GroupByValue &value1, const GroupByValue &value2) const
Definition: GroupByManager.cpp:36
GenericQuery::GroupByManager::hash
size_t hash(const GroupByValue &value) const
Definition: GroupByManager.cpp:52
GenericQuery::JoinValue::JoinValue
JoinValue(ColumnStore::DataValue value, JoinValueManager *manager)
Definition: GroupByManager.h:59
GenericQuery::JoinValueManager::compare
bool compare(const JoinValue &value1, const JoinValue &value2) const
Definition: GroupByManager.cpp:5