26#ifndef TABLES_EXPRGROUP_H
27#define TABLES_EXPRGROUP_H
30#include <casacore/casa/aips.h>
31#include <casacore/casa/BasicSL/String.h>
32#include <casacore/tables/TaQL/ExprAggrNode.h>
148 (
const vector<std::shared_ptr<TableExprGroupFuncSet>>& funcSets);
152 (
const vector<std::shared_ptr<TableExprGroupFuncSet>>& funcSets,
153 const vector<std::shared_ptr<vector<TableExprId>>>&
ids);
161 const vector<TableExprId>&
ids (
uInt group)
const
162 {
return *
itsIds[group]; }
165 vector<std::shared_ptr<vector<TableExprId>>>
itsIds;
226 virtual std::shared_ptr<vector<TableExprId>>
getIds()
const;
232 virtual Bool getBool (
const vector<TableExprId>& = vector<TableExprId>());
233 virtual Int64 getInt (
const vector<TableExprId>& = vector<TableExprId>());
235 virtual DComplex
getDComplex (
const vector<TableExprId>& = vector<TableExprId>());
236 virtual MVTime getDate (
const vector<TableExprId>& = vector<TableExprId>());
341 virtual std::shared_ptr<vector<TableExprId>>
getIds()
const;
343 std::shared_ptr<vector<TableExprId>>
itsIds;
395 for (
size_t i=0; i<ids.size(); ++i) {
406 for (
id=0;
id<ids.size(); ++id) {
416 if (
id == ids.size()) {
423 std::shared_ptr<ArrayIterator<Bool>> miter;
428 for (;
id<ids.size(); ++id) {
436 miter->array() = values.
mask();
441 if (ndef < ids.size()) {
442 shp[shp.
size() - 1] = ndef;
553 const DComplex& initValue = DComplex())
813 void add (
const std::shared_ptr<TableExprGroupFuncBase>& func);
819 const vector<std::shared_ptr<TableExprGroupFuncBase>>&
getFuncs()
const
828 vector<std::shared_ptr<TableExprGroupFuncBase>>
itsFuncs;
Array< T > & array()
Return the cursor.
virtual void next() override
Move the cursor to the next position.
void resize()
Make this array a different shape.
void append(const IPosition &other)
Append this IPosition with another one (causing a resize).
Bool isNull() const
Is the array null?
uInt ndim() const
Get the dimensionality.
const Array< Bool > & mask() const
Get the mask.
Bool hasMask() const
Is there a mask?
const IPosition & shape() const
Get the shape.
const Array< T > & array() const
Get access to the array.
String: the storage and methods of handling collections of characters.
Class collecting the arrays in a group.
virtual MArray< String > getArrayString(const vector< TableExprId > &)
virtual Bool isLazy() const
Does the aggregate function use lazy semantics? The default implementation returns False.
virtual MArray< DComplex > getArrayDComplex(const vector< TableExprId > &)
virtual MArray< MVTime > getArrayDate(const vector< TableExprId > &)
virtual MArray< Double > getArrayDouble(const vector< TableExprId > &)
virtual ~TableExprGroupAggr()
virtual MArray< Int64 > getArrayInt(const vector< TableExprId > &)
virtual MArray< Bool > getArrayBool(const vector< TableExprId > &)
MArray< T > getArray(const vector< TableExprId > &ids)
TableExprGroupAggr(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
Class derived from TableExprGroupFuncBase collecting the ids in a group.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
virtual Bool isLazy() const
Does the aggregate function use lazy semantics? The default implementation returns False.
std::shared_ptr< vector< TableExprId > > itsIds
virtual std::shared_ptr< vector< TableExprId > > getIds() const
Get the assembled TableExprIds of a group.
TableExprGroupExprId(TableExprNodeRep *node)
virtual ~TableExprGroupExprId()
Class derived from TableExprGroupFuncBase for the first value in a group.
virtual Bool getBool(const vector< TableExprId > &)
Get the aggregated value.
virtual ~TableExprGroupFirst()
virtual MArray< String > getArrayString(const vector< TableExprId > &)
virtual MVTime getDate(const vector< TableExprId > &)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
virtual MArray< MVTime > getArrayDate(const vector< TableExprId > &)
virtual DComplex getDComplex(const vector< TableExprId > &)
virtual Int64 getInt(const vector< TableExprId > &)
virtual String getString(const vector< TableExprId > &)
virtual MArray< Double > getArrayDouble(const vector< TableExprId > &)
TableExprGroupFirst(TableExprNodeRep *node)
virtual MArray< DComplex > getArrayDComplex(const vector< TableExprId > &)
virtual Double getDouble(const vector< TableExprId > &)
virtual MArray< Int64 > getArrayInt(const vector< TableExprId > &)
virtual MArray< Bool > getArrayBool(const vector< TableExprId > &)
Abstract base class for aggregate functions giving a bool array.
virtual MArray< Bool > getArrayBool(const vector< TableExprId > &)
virtual ~TableExprGroupFuncArrayBool()
Bool checkShape(const MArrayBase &arr, const String &func)
If not empty, check if the shape matches that of itsValue.
TableExprGroupFuncArrayBool(TableExprNodeRep *node)
Abstract base class for aggregate functions giving a dcomplex array.
MArray< DComplex > itsValue
TableExprGroupFuncArrayDComplex(TableExprNodeRep *node)
virtual MArray< DComplex > getArrayDComplex(const vector< TableExprId > &)
virtual ~TableExprGroupFuncArrayDComplex()
Bool checkShape(const MArrayBase &arr, const String &func)
If not empty, check if the shape matches that of itsValue.
Abstract base class for aggregate functions giving a date/time array.
virtual MArray< MVTime > getArrayDate(const vector< TableExprId > &)
Bool checkShape(const MArrayBase &arr, const String &func)
If not empty, check if the shape matches that of itsValue.
TableExprGroupFuncArrayDate(TableExprNodeRep *node)
virtual ~TableExprGroupFuncArrayDate()
MArray< MVTime > itsValue
Abstract base class for aggregate functions giving a double array.
MArray< Double > itsValue
virtual MArray< Double > getArrayDouble(const vector< TableExprId > &)
TableExprGroupFuncArrayDouble(TableExprNodeRep *node)
Bool checkShape(const MArrayBase &arr, const String &func)
If not empty, check if the shape matches that of itsValue.
virtual ~TableExprGroupFuncArrayDouble()
Abstract base class for aggregate functions giving an integer array.
virtual MArray< Int64 > getArrayInt(const vector< TableExprId > &)
Bool checkShape(const MArrayBase &arr, const String &func)
If not empty, check if the shape matches that of itsValue.
virtual ~TableExprGroupFuncArrayInt()
TableExprGroupFuncArrayInt(TableExprNodeRep *node)
Abstract base class for aggregate functions giving a string array.
virtual MArray< String > getArrayString(const vector< TableExprId > &)
Bool checkShape(const MArrayBase &arr, const String &func)
If not empty, check if the shape matches that of itsValue.
MArray< String > itsValue
TableExprGroupFuncArrayString(TableExprNodeRep *node)
virtual ~TableExprGroupFuncArrayString()
Abstract base class for classes calculating an aggregated group result.
virtual void finish()
If needed, finish the aggregation.
TableExprGroupFuncBase(TableExprNodeRep *node)
Construct from the TaQL aggregation node.
virtual void apply(const TableExprId &id)=0
Get the operand's value for the given row and apply it to the aggregation.
virtual std::shared_ptr< vector< TableExprId > > getIds() const
Get the assembled TableExprIds of a group.
virtual MArray< Bool > getArrayBool(const vector< TableExprId > &=vector< TableExprId >())
TableExprGroupFuncBase & operator=(const TableExprGroupFuncBase &)=delete
virtual Int64 getInt(const vector< TableExprId > &=vector< TableExprId >())
virtual MVTime getDate(const vector< TableExprId > &=vector< TableExprId >())
virtual MArray< Int64 > getArrayInt(const vector< TableExprId > &=vector< TableExprId >())
virtual MArray< MVTime > getArrayDate(const vector< TableExprId > &=vector< TableExprId >())
uInt seqnr() const
Get the function's sequence nr.
virtual MArray< String > getArrayString(const vector< TableExprId > &=vector< TableExprId >())
virtual Double getDouble(const vector< TableExprId > &=vector< TableExprId >())
virtual Bool isLazy() const
Does the aggregate function use lazy semantics? The default implementation returns False.
TableExprGroupFuncBase(const TableExprGroupFuncBase &)=delete
Copying is not needed, thus not allowed.
virtual MArray< Double > getArrayDouble(const vector< TableExprId > &=vector< TableExprId >())
TableExprNodeRep * itsNode
virtual DComplex getDComplex(const vector< TableExprId > &=vector< TableExprId >())
void setSeqnr(uInt seqnr)
Set the function's sequence nr.
TableExprNodeRep * itsOperand
virtual Bool getBool(const vector< TableExprId > &=vector< TableExprId >())
Get the aggregated value.
virtual MArray< DComplex > getArrayDComplex(const vector< TableExprId > &=vector< TableExprId >())
virtual ~TableExprGroupFuncBase()
virtual String getString(const vector< TableExprId > &=vector< TableExprId >())
Abstract base class for aggregate functions giving a bool scalar.
virtual Bool getBool(const vector< TableExprId > &)
Get the aggregated value.
TableExprGroupFuncBool(TableExprNodeRep *node, Bool initValue)
virtual ~TableExprGroupFuncBool()
TableExprGroupFuncBool(TableExprNodeRep *node)
Abstract base class for aggregate functions giving a dcomplex scalar.
TableExprGroupFuncDComplex(TableExprNodeRep *node, const DComplex &initValue=DComplex())
virtual DComplex getDComplex(const vector< TableExprId > &)
virtual ~TableExprGroupFuncDComplex()
Abstract base class for aggregate functions giving a date/time scalar.
virtual MVTime getDate(const vector< TableExprId > &)
TableExprGroupFuncDate(TableExprNodeRep *node, const MVTime &initValue=MVTime())
virtual ~TableExprGroupFuncDate()
Abstract base class for aggregate functions giving a double scalar.
virtual ~TableExprGroupFuncDouble()
virtual Double getDouble(const vector< TableExprId > &)
TableExprGroupFuncDouble(TableExprNodeRep *node, Double initValue=0)
Abstract base class for aggregate functions giving an integer scalar.
virtual ~TableExprGroupFuncInt()
virtual Double getDouble(const vector< TableExprId > &)
virtual Int64 getInt(const vector< TableExprId > &)
TableExprGroupFuncInt(TableExprNodeRep *node, Int64 initValue=0)
Class containing the results of aggregated values in a group.
const vector< std::shared_ptr< TableExprGroupFuncBase > > & getFuncs() const
Get the vector of functions.
const TableExprId & getId() const
Get the TableExprId.
TableExprGroupFuncSet(const vector< TableExprNodeRep * > &aggrNodes)
Let the aggregate node objects construct the function set.
void add(const std::shared_ptr< TableExprGroupFuncBase > &func)
Add a function object.
void apply(const TableExprId &id)
Apply the functions to the given row.
TableExprGroupFuncSet & operator=(const TableExprGroupFuncSet &)=delete
TableExprGroupFuncSet(const TableExprGroupFuncSet &)=delete
Copying is not needed, thus not allowed.
vector< std::shared_ptr< TableExprGroupFuncBase > > itsFuncs
Abstract base class for aggregate functions giving a string scalar.
TableExprGroupFuncString(TableExprNodeRep *node, const String &initValue=String())
virtual ~TableExprGroupFuncString()
virtual String getString(const vector< TableExprId > &)
Class representing all keys in the groupby clause.
TableExprGroupKeySet(const vector< TableExprNode > &nodes)
Form the object from the given groupby nodes.
void fill(const vector< TableExprNode > &nodes, const TableExprId &id)
Fill the keys with the values from the nodes for this rowid.
void addKey(TableExprNodeRep::NodeDataType dtype)
Add a key to end the set.
bool operator==(const TableExprGroupKeySet &) const
Compare all keys in the set.
vector< TableExprGroupKey > itsKeys
void set(const String &v)
TableExprGroupKey(TableExprNodeRep::NodeDataType dtype)
Construct for a given data type.
bool operator==(const TableExprGroupKey &) const
Compare this and that key.
TableExprNodeRep::NodeDataType itsDT
TableExprNodeRep::NodeDataType dataType() const
Get the data type.
void set(Bool v)
Set the key's value.
Class derived from TableExprGroupFuncBase for the first value in a group.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
TableExprGroupLast(TableExprNodeRep *node)
virtual ~TableExprGroupLast()
Class derived from TableExprGroupFuncBase representing a no function.
TableExprGroupNull(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
virtual ~TableExprGroupNull()
virtual Bool isLazy() const
Does the aggregate function use lazy semantics? The default implementation returns False.
Class holding the results of groupby and aggregation.
TableExprGroupResult(const vector< std::shared_ptr< TableExprGroupFuncSet > > &funcSets, const vector< std::shared_ptr< vector< TableExprId > > > &ids)
Create from the possible set of immediate aggregate functions and the set of TableExprIds per group f...
vector< std::shared_ptr< TableExprGroupFuncSet > > itsFuncSets
uInt ngroup() const
Get the nr of groups.
vector< std::shared_ptr< vector< TableExprId > > > itsIds
TableExprGroupFuncSet & funcSet(uInt group) const
Get the set of functions (and their results) for the given group.
TableExprGroupResult(const vector< std::shared_ptr< TableExprGroupFuncSet > > &funcSets)
Create from the possible set of immediate aggregate functions.
const vector< TableExprId > & ids(uInt group) const
Get the set of TableExprIds for the given group.
Class collecting the rowids of entries in a group.
virtual Bool isLazy() const
Does the aggregate function use lazy semantics? The default implementation returns False.
virtual MArray< Int64 > getArrayInt(const vector< TableExprId > &)
TableExprGroupRowid(TableExprNodeRep *node)
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
virtual ~TableExprGroupRowid()
Abstract base class for a node in a table column expression tree.
NodeDataType
Define the data types of a node.
void get(const TableExprId &id, Bool &value)
General get functions for template purposes.
ValueType valueType() const
Get the value type.
this file contains all the compiler specific defines
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
bool Bool
Define the standard types used by Casacore.