00001 //# ExprAggrNodeArray.h: TaQL node representing an array aggregate function 00002 //# Copyright (C) 2013 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: TaQLNode.h 21051 2011-04-20 11:46:29Z gervandiepen $ 00027 00028 #ifndef TABLES_EXPRAGGRNODEARRAY_H 00029 #define TABLES_EXPRAGGRNODEARRAY_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/tables/TaQL/ExprFuncNodeArray.h> 00034 00035 00036 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00037 00038 //# Forward Declarations. 00039 class TableExprGroupFuncBase; 00040 class TableExprGroupFuncSet; 00041 00042 // <summary> 00043 // TaQL node representing an array aggregate function 00044 // </summary> 00045 00046 // <use visibility=local> 00047 00048 // <reviewed reviewer="" date="" tests="tTaQLNode"> 00049 // </reviewed> 00050 00051 // <synopsis> 00052 // This class is similar to TableExprAggrNode, but its result is an array 00053 // instead of a scalar value. 00054 // There are few aggregate functions resulting in an array. An example 00055 // is <src>gaggr</src>, which aggregates the non-empty arrays in a group 00056 // into a single array. Other functions (like medians, runningmean, etc.) 00057 // can be applied to its result making it quite versatile. 00058 // 00059 // Most array aggregate functions are lazy to avoid using too much memory. 00060 // </synopsis> 00061 00062 class TableExprAggrNodeArray: public TableExprFuncNodeArray 00063 { 00064 public: 00065 // Constructor. 00066 TableExprAggrNodeArray (TableExprFuncNode::FunctionType, 00067 NodeDataType, ValueType, 00068 const TableExprNodeSet& source, 00069 const TaQLStyle& style); 00070 00071 // Get the nodes representing an aggregate function. 00072 virtual void getAggrNodes (vector<TableExprNodeRep*>& aggr); 00073 00074 // Get the operand node. 00075 TableExprNodeRep* operand() 00076 { return (operands().empty() ? 0 : operands()[0]); } 00077 00078 // Create the correct aggregate function object. 00079 virtual CountedPtr<TableExprGroupFuncBase> makeGroupAggrFunc(); 00080 00081 // Is the array aggregate function lazy? 00082 virtual Bool isLazyAggregate() const; 00083 00084 // Functions to get the result of an aggregate function. 00085 // <group> 00086 virtual MArray<Bool> getArrayBool (const TableExprId& id); 00087 virtual MArray<Int64> getArrayInt (const TableExprId& id); 00088 virtual MArray<Double> getArrayDouble (const TableExprId& id); 00089 virtual MArray<DComplex> getArrayDComplex (const TableExprId& id); 00090 virtual MArray<String> getArrayString (const TableExprId& id); 00091 virtual MArray<MVTime> getArrayDate (const TableExprId& id); 00092 // </group> 00093 00094 private: 00095 // Create the correct aggregate function object. 00096 CountedPtr<TableExprGroupFuncBase> doMakeGroupAggrFunc(); 00097 00098 //# Data members. 00099 CountedPtr<TableExprGroupFuncBase> itsFunc; 00100 }; 00101 00102 00103 } //# NAMESPACE CASACORE - END 00104 00105 #endif