26#ifndef TABLES_TABLEPARSEGROUPBY_H
27#define TABLES_TABLEPARSEGROUPBY_H
30#include <casacore/casa/aips.h>
31#include <casacore/tables/TaQL/ExprNode.h>
32#include <casacore/tables/TaQL/ExprGroup.h>
38 class TableParseQuery;
109 const std::shared_ptr<TableExprGroupResult>& groups);
125 std::vector<std::shared_ptr<TableExprGroupFuncSet>>
multiKey
126 (
const std::vector<TableExprNodeRep*>&,
const Vector<rownr_t>& rownrs)
const;
132 std::vector<std::shared_ptr<TableExprGroupFuncSet>>
singleKey
133 (
const std::vector<TableExprNodeRep*>& nodes,
141 std::vector<std::shared_ptr<TableExprGroupFuncSet>> funcSets;
142 std::map<T, int> keyFuncMap;
143 T lastKey = std::numeric_limits<T>::max();
152 if (key != lastKey) {
153 typename std::map<T, int>::iterator iter = keyFuncMap.find (key);
154 if (iter == keyFuncMap.end()) {
155 groupnr = funcSets.size();
156 keyFuncMap[key] = groupnr;
157 funcSets.push_back (std::shared_ptr<TableExprGroupFuncSet>
160 groupnr = iter->second;
164 funcSets[groupnr]->apply (rowid);
171 std::vector<TableExprNodeRep*>& aggrNodes)
const;
Class containing the results of aggregated values in a group.
void setRownr(rownr_t rownr)
Set the row number.
std::shared_ptr< TableExprGroupResult > execGroupAggr(Vector< rownr_t > &rownrs) const
Execute the grouping and aggregation and return the results.
std::vector< std::shared_ptr< TableExprGroupFuncSet > > singleKey(const std::vector< TableExprNodeRep * > &nodes, const Vector< rownr_t > &rownrs) const
Create the set of aggregate functions and groupby keys in case a single groupby key is given.
TableExprNode itsHavingNode
The possible HAVING expression.
Bool execHaving(Vector< rownr_t > &rownrs, const std::shared_ptr< TableExprGroupResult > &groups)
Execute the HAVING clause (if present).
Bool isUsed() const
Is GROUPBY and/or aggregation used?
std::shared_ptr< TableExprGroupResult > countAll(Vector< rownr_t > &rownrs) const
Do the grouping and aggregation and return the results.
void getAggrNodes(const TableExprNode &node, std::vector< TableExprNodeRep * > &aggrNodes) const
Get pointers to the aggregate nodes in the node expression.
std::vector< std::shared_ptr< TableExprGroupFuncSet > > multiKey(const std::vector< TableExprNodeRep * > &, const Vector< rownr_t > &rownrs) const
Create the set of aggregate functions and groupby keys.
std::vector< TableExprNode > itsGroupbyNodes
The possible GROUPBY expressions.
void handleHaving(const TableExprNode &)
Keep the having expression.
uInt size() const
Get the number of aggregation ndes.
std::shared_ptr< TableExprGroupResult > aggregate(Vector< rownr_t > &rownrs) const
Do the grouping and aggregation and return the results.
Bool isOnlyAggr() const
Is only aggregation used?
void findGroupAggr(const Block< TableExprNode > &columnNodes, Bool isSelect)
Find if groupby and/or aggregate functions are given.
static void checkAggrFuncs(const TableExprNode &node)
An exception is thrown if the node uses an aggregate function.
void handleGroupby(const std::vector< TableExprNode > &, Bool rollup)
Keep the groupby expressions.
uInt disableApplySelection()
Disable applySelection for the column nodes of aggregate functions.
std::vector< TableExprNodeRep * > itsAggrNodes
Pointers to the aggregate function nodes.
this file contains all the compiler specific defines
bool Bool
Define the standard types used by Casacore.
uInt64 rownr_t
Define the type of a row number in a table.