28 #ifndef TABLES_EXPRGROUP_H
29 #define TABLES_EXPRGROUP_H
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/BasicSL/String.h>
34 #include <casacore/tables/TaQL/ExprAggrNode.h>
163 const vector<TableExprId>&
ids (
uInt group)
const
164 {
return *
itsIds[group]; }
167 vector<CountedPtr<vector<TableExprId> > >
itsIds;
231 virtual Bool getBool (
const vector<TableExprId>& = vector<TableExprId>());
232 virtual Int64 getInt (
const vector<TableExprId>& = vector<TableExprId>());
235 virtual MVTime getDate (
const vector<TableExprId>& = vector<TableExprId>());
398 for (
size_t i=0; i<ids.size(); ++i) {
409 for (
id=0;
id<ids.size(); ++id) {
419 if (
id == ids.size()) {
431 for (;
id<ids.size(); ++id) {
439 miter->array() = values.
mask();
444 if (ndef < ids.size()) {
445 shp[shp.
size() - 1] = ndef;
818 const vector<CountedPtr<TableExprGroupFuncBase> >&
getFuncs()
const
831 vector<CountedPtr<TableExprGroupFuncBase> >
itsFuncs;
Array< T, Alloc > & array()
Return the cursor.
virtual void next() override
Move the cursor to the next position.
void resize()
Make this array a different shape.
Referenced counted pointer for constant data.
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 IPosition & shape() const
Get the shape.
const Array< Bool > & mask() const
Get the mask.
Bool hasMask() const
Is there a mask?
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< DComplex > getArrayDComplex(const vector< TableExprId > &)
MArray< T > getArray(const vector< TableExprId > &ids)
virtual MArray< Bool > getArrayBool(const vector< TableExprId > &)
virtual Bool isLazy() const
Does the aggregate function use lazy semantics? The default implementation returns False.
virtual ~TableExprGroupAggr()
virtual MArray< MVTime > getArrayDate(const vector< TableExprId > &)
virtual MArray< Double > getArrayDouble(const vector< TableExprId > &)
virtual MArray< Int64 > getArrayInt(const vector< TableExprId > &)
TableExprGroupAggr(TableExprNodeRep *node)
virtual MArray< String > getArrayString(const vector< TableExprId > &)
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 CountedPtr< vector< TableExprId > > getIds() const
Get the assembled TableExprIds of a group.
virtual void apply(const TableExprId &id)
Get the operand's value for the given row and apply it to the aggregation.
CountedPtr< vector< TableExprId > > itsIds
virtual Bool isLazy() const
Does the aggregate function use lazy semantics? The default implementation returns False.
TableExprGroupExprId(TableExprNodeRep *node)
virtual ~TableExprGroupExprId()
Class derived from TableExprGroupFuncBase for the first value in a group.
virtual MArray< Int64 > getArrayInt(const vector< TableExprId > &)
virtual MArray< MVTime > getArrayDate(const vector< TableExprId > &)
virtual Bool getBool(const vector< TableExprId > &)
Get the aggregated value.
virtual ~TableExprGroupFirst()
virtual MArray< Bool > getArrayBool(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 DComplex getDComplex(const vector< TableExprId > &)
virtual Int64 getInt(const vector< TableExprId > &)
virtual String getString(const vector< TableExprId > &)
TableExprGroupFirst(TableExprNodeRep *node)
virtual MArray< Double > getArrayDouble(const vector< TableExprId > &)
virtual Double getDouble(const vector< TableExprId > &)
virtual MArray< String > getArrayString(const vector< TableExprId > &)
virtual MArray< DComplex > getArrayDComplex(const vector< TableExprId > &)
Abstract base class for aggregate functions giving a bool array.
virtual ~TableExprGroupFuncArrayBool()
Bool checkShape(const MArrayBase &arr, const String &func)
If not empty, check if the shape matches that of itsValue.
virtual MArray< Bool > getArrayBool(const vector< TableExprId > &)
TableExprGroupFuncArrayBool(TableExprNodeRep *node)
Abstract base class for aggregate functions giving a dcomplex array.
MArray< DComplex > itsValue
virtual MArray< DComplex > getArrayDComplex(const vector< TableExprId > &)
TableExprGroupFuncArrayDComplex(TableExprNodeRep *node)
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
TableExprGroupFuncArrayDouble(TableExprNodeRep *node)
virtual MArray< Double > getArrayDouble(const vector< TableExprId > &)
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.
Bool checkShape(const MArrayBase &arr, const String &func)
If not empty, check if the shape matches that of itsValue.
virtual MArray< Int64 > getArrayInt(const vector< TableExprId > &)
virtual ~TableExprGroupFuncArrayInt()
TableExprGroupFuncArrayInt(TableExprNodeRep *node)
Abstract base class for aggregate functions giving a string array.
Bool checkShape(const MArrayBase &arr, const String &func)
If not empty, check if the shape matches that of itsValue.
virtual MArray< String > getArrayString(const vector< TableExprId > &)
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.
TableExprGroupFuncBase(const TableExprGroupFuncBase &)
Copying is not needed, thus not allowed.
virtual MArray< Int64 > getArrayInt(const vector< TableExprId > &=vector< TableExprId >())
virtual MArray< Double > getArrayDouble(const vector< TableExprId > &=vector< TableExprId >())
virtual Int64 getInt(const vector< TableExprId > &=vector< TableExprId >())
virtual MVTime getDate(const vector< TableExprId > &=vector< TableExprId >())
uInt seqnr() const
Get the function's sequence nr.
TableExprGroupFuncBase & operator=(const TableExprGroupFuncBase &)
virtual Double getDouble(const vector< TableExprId > &=vector< TableExprId >())
virtual MArray< Bool > getArrayBool(const vector< TableExprId > &=vector< TableExprId >())
virtual Bool isLazy() const
Does the aggregate function use lazy semantics? The default implementation returns False.
virtual MArray< String > getArrayString(const vector< TableExprId > &=vector< TableExprId >())
virtual MArray< DComplex > getArrayDComplex(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 CountedPtr< vector< TableExprId > > getIds() const
Get the assembled TableExprIds of a group.
virtual ~TableExprGroupFuncBase()
virtual String getString(const vector< TableExprId > &=vector< TableExprId >())
virtual MArray< MVTime > getArrayDate(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< CountedPtr< TableExprGroupFuncBase > > & getFuncs() const
Get the vector of functions.
TableExprGroupFuncSet(const vector< TableExprNodeRep * > &aggrNodes)
Let the aggregate node objects construct the function set.
TableExprGroupFuncSet & operator=(const TableExprGroupFuncSet &)
void apply(const TableExprId &id)
Apply the functions to the given row.
TableExprGroupFuncSet(const TableExprGroupFuncSet &)
Copying is not needed, thus not allowed.
void add(const CountedPtr< TableExprGroupFuncBase > &func)
Add a function object.
const TableExprId & getId() const
Get the TableExprId.
vector< CountedPtr< 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.
bool operator<(const TableExprGroupKeySet &) const
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
bool operator<(const TableExprGroupKey &) const
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.
vector< CountedPtr< vector< TableExprId > > > itsIds
vector< CountedPtr< TableExprGroupFuncSet > > itsFuncSets
TableExprGroupFuncSet & funcSet(uInt group) const
Get the set of functions (and their results) for the given group.
uInt ngroup() const
Get the nr of groups.
TableExprGroupResult(const vector< CountedPtr< TableExprGroupFuncSet > > &funcSets)
Create from the possible set of immediate aggregate functions.
TableExprGroupResult(const vector< CountedPtr< TableExprGroupFuncSet > > &funcSets, const vector< CountedPtr< vector< TableExprId > > > &ids)
Create from the possible set of immediate aggregate functions and the set of TableExprIds per group f...
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.
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()
virtual MArray< Int64 > getArrayInt(const vector< TableExprId > &)
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.
std::complex< Double > DComplex
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.