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>
114 std::vector<std::shared_ptr<TableExprGroupFuncSet>>
multiKey(
115 const std::vector<TableExprNodeRep*>&,
const Vector<rownr_t>& rownrs)
const;
120 template <
typename T>
121 std::vector<std::shared_ptr<TableExprGroupFuncSet>>
singleKey(
122 const std::vector<TableExprNodeRep*>& nodes,
const Vector<rownr_t>& rownrs)
const {
128 std::vector<std::shared_ptr<TableExprGroupFuncSet>> funcSets;
129 std::map<T, int> keyFuncMap;
130 T lastKey = std::numeric_limits<T>::max();
139 if (key != lastKey) {
140 typename std::map<T, int>::iterator iter = keyFuncMap.find(key);
141 if (iter == keyFuncMap.end()) {
142 groupnr = funcSets.size();
143 keyFuncMap[key] = groupnr;
147 groupnr = iter->second;
151 funcSets[groupnr]->apply(rowid);
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.
For temporary backward namespace compatibility, use casa as alias for casacore.
bool Bool
Define the standard types used by Casacore.
uInt64 rownr_t
Define the type of a row number in a table.