JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
Query.h
Go to the documentation of this file.
1 //
2 // Created by Nico Schäfer on 4/24/17.
3 //
4 
5 #ifndef JODA_QUERY_H
6 #define JODA_QUERY_H
7 
10 #include <joda/join/JoinManager.h>
16 #include <memory>
17 
18 namespace joda::query {
24 class Query {
25  public:
29  Query();
30 
37  bool check(const RapidJsonDocument &json) const;
38 
42  const std::string &getLoad() const;
43 
47  void setLoad(const std::string &load);
48 
54  const std::string &getDelete() const;
55 
61  void setDelete(const std::string &del);
62 
67  void setPredicate(std::unique_ptr<Predicate> &&predicate);
68 
74  std::unique_ptr<Predicate> getPredicate() const;
75 
80  void addProjection(std::unique_ptr<IProjector> &&expr);
85  const std::vector<std::unique_ptr<IProjector>> &getProjectors() const;
86 
91  void addProjection(std::unique_ptr<ISetProjector> &&expr);
92 
97  const std::vector<std::unique_ptr<ISetProjector>> &getSetProjectors() const;
98 
103  void addAggregator(std::unique_ptr<IAggregator> &&agg);
104 
108  bool hasAggregators();
113  const std::vector<std::unique_ptr<IAggregator>> &getAggregators() const;
114  const std::vector<std::unique_ptr<docparsing::IImportSource>>
115  &getImportSources() const;
116  void addImportSource(std::unique_ptr<docparsing::IImportSource> &&source);
117  const std::shared_ptr<JoinManager> &getLoadJoinManager() const;
118  void setLoadJoinManager(const std::shared_ptr<JoinManager> &loadJoinManager);
119  const std::shared_ptr<JoinManager> &getStoreJoinManager() const;
120  void setStoreJoinManager(
121  const std::shared_ptr<JoinManager> &storeJoinManager);
122  std::unique_ptr<IExportDestination> &getExportDestination();
124  std::unique_ptr<IExportDestination> &&exportDestination);
125 
131  bool isDefault() const;
132 
139  bool chooseIsConst(bool &val) const;
140 
145  bool canCreateView() const;
146 
150  std::string toString() const;
151 
152  std::vector<std::string> getAllUsedAttributes() const;
153  std::vector<std::string> getChooseAttributes() const;
154  std::vector<std::string> getASAttributes() const;
155  std::vector<std::string> getAGGAttributes() const;
156 
157  protected:
158  /*
159  * Load command
160  */
161  std::vector<std::unique_ptr<docparsing::IImportSource>> importSources{};
162  std::string load{};
163 
164  std::shared_ptr<JoinManager> loadJoinManager = nullptr;
165 
166  /*
167  * Choose command
168  */
169  std::unique_ptr<Predicate> pred = nullptr;
170 
171  /*
172  * AS command
173  */
174  std::vector<std::unique_ptr<IProjector>> projectors{};
175  std::vector<std::unique_ptr<ISetProjector>> setProjectors{};
176 
177  /*
178  * AGG command
179  */
180 
181  std::vector<std::unique_ptr<IAggregator>> aggregators{};
182 
183  /*
184  * Store command
185  */
186  std::unique_ptr<IExportDestination> exportDestination;
187  std::shared_ptr<JoinManager> storeJoinManager = nullptr;
188  std::string store;
189 
190  /*
191  * Delete command
192  */
193  std::string del;
194 };
195 } // namespace joda::query
196 
197 #endif // JODA_QUERY_H
Definition: RapidJsonDocument.h:22
Definition: Query.h:24
const std::vector< std::unique_ptr< IAggregator > > & getAggregators() const
Definition: Query.cpp:39
Query()
Definition: Query.cpp:34
std::vector< std::string > getChooseAttributes() const
Definition: Query.cpp:209
void setStoreJoinManager(const std::shared_ptr< JoinManager > &storeJoinManager)
Definition: Query.cpp:160
std::vector< std::string > getASAttributes() const
Definition: Query.cpp:218
std::string toString() const
Definition: Query.cpp:92
std::shared_ptr< JoinManager > storeJoinManager
Definition: Query.h:187
std::shared_ptr< JoinManager > loadJoinManager
Definition: Query.h:164
std::string load
Definition: Query.h:162
const std::vector< std::unique_ptr< docparsing::IImportSource > > & getImportSources() const
Definition: Query.cpp:166
void setDelete(const std::string &del)
Definition: Query.cpp:60
const std::string & getLoad() const
Definition: Query.cpp:52
std::string store
Definition: Query.h:188
bool canCreateView() const
Definition: Query.cpp:244
std::string del
Definition: Query.h:193
std::vector< std::string > getAllUsedAttributes() const
Definition: Query.cpp:185
bool chooseIsConst(bool &val) const
Definition: Query.cpp:81
void setLoad(const std::string &load)
Definition: Query.cpp:54
std::vector< std::string > getAGGAttributes() const
Definition: Query.cpp:233
std::unique_ptr< Predicate > pred
Definition: Query.h:169
void addImportSource(std::unique_ptr< docparsing::IImportSource > &&source)
Definition: Query.cpp:170
const std::shared_ptr< JoinManager > & getLoadJoinManager() const
Definition: Query.cpp:145
std::vector< std::unique_ptr< ISetProjector > > setProjectors
Definition: Query.h:175
std::unique_ptr< IExportDestination > exportDestination
Definition: Query.h:186
void setLoadJoinManager(const std::shared_ptr< JoinManager > &loadJoinManager)
Definition: Query.cpp:150
void addAggregator(std::unique_ptr< IAggregator > &&agg)
Definition: Query.cpp:28
void setExportDestination(std::unique_ptr< IExportDestination > &&exportDestination)
Definition: Query.cpp:180
std::vector< std::unique_ptr< IAggregator > > aggregators
Definition: Query.h:181
std::unique_ptr< IExportDestination > & getExportDestination()
Definition: Query.cpp:176
void setPredicate(std::unique_ptr< Predicate > &&predicate)
Definition: Query.cpp:17
std::vector< std::unique_ptr< docparsing::IImportSource > > importSources
Definition: Query.h:161
bool hasAggregators()
Definition: Query.cpp:32
bool isDefault() const
Definition: Query.cpp:64
const std::vector< std::unique_ptr< ISetProjector > > & getSetProjectors() const
Definition: Query.cpp:73
const std::string & getDelete() const
Definition: Query.cpp:58
bool check(const RapidJsonDocument &json) const
Definition: Query.cpp:13
const std::vector< std::unique_ptr< IProjector > > & getProjectors() const
Definition: Query.cpp:48
std::vector< std::unique_ptr< IProjector > > projectors
Definition: Query.h:174
std::unique_ptr< Predicate > getPredicate() const
Definition: Query.cpp:21
void addProjection(std::unique_ptr< IProjector > &&expr)
Definition: Query.cpp:43
const std::shared_ptr< JoinManager > & getStoreJoinManager() const
Definition: Query.cpp:155
Definition: AttributeStatAggregator.h:12