28 #ifndef TABLES_TABLEPARSE_H 29 #define TABLES_TABLEPARSE_H 32 #include <casacore/casa/aips.h> 33 #include <casacore/tables/Tables/Table.h> 34 #include <casacore/tables/Tables/TableDesc.h> 35 #include <casacore/tables/TaQL/ExprNode.h> 36 #include <casacore/tables/TaQL/TaQLResult.h> 37 #include <casacore/tables/TaQL/ExprGroup.h> 38 #include <casacore/casa/BasicSL/String.h> 39 #include <casacore/casa/Utilities/Sort.h> 40 #include <casacore/casa/Containers/Record.h> 41 #include <casacore/casa/Containers/Block.h> 49 class TableExprNodeSet;
50 class TableExprNodeSetElem;
51 class TableExprNodeIndex;
54 template<
class T>
class Vector;
153 const Table& tempTable);
155 const std::vector<const Table*>& tempTables);
162 const std::vector<const Table*>& tempTables,
165 const std::vector<const Table*>& tempTables,
221 Bool orderGiven()
const;
226 void checkNode()
const;
271 const String& columnNameMask,
278 const String& columnNameMask,
287 const String& columnNameMask,
299 void setColumnName (
const String& name);
302 void setColumnNameMask (
const String& name);
305 const String& columnName()
const;
308 const String& columnNameMask()
const;
312 {
return maskFirst_p; }
332 void adaptUnit (
const Unit& columnUnit);
408 {
return commandType_p; }
415 void makeTableNoFrom (
const vector<TableParseSelect*>& stack);
424 void execute (
Bool showTimings,
Bool setInGiving,
439 void show (ostream& os)
const;
446 void handleGroupby (
const vector<TableExprNode>&,
Bool rollup);
455 void handleCreTab (
const Record& dmInfo);
458 void handleColSpec (
const String& columnName,
const String& dataType,
466 void handleAddCol (
const Record& dmInfo);
480 static String getTypeString (
const String& typeStr, DataType type);
485 void handleSetKey (
const String& name,
const String& dtype,
489 void handleRenameKey (
const String& oldName,
const String& newName);
492 void handleRemoveKey (
const String& name);
504 { insertExprs_p = exprs; }
522 void handleSort (
const std::vector<TableParseSort>& sortList,
538 void addTable (
Int tabnr,
const String& name,
541 const vector<const Table*> tempTables,
542 const vector<TableParseSelect*>& stack);
551 const vector<const Table*> tempTables,
552 const vector<TableParseSelect*>& stack,
556 void replaceTable (
const Table& table);
588 void handleColumnFinish (
Bool distinct);
592 { dminfo_p = dminfo;}
595 void handleGiving (
const String& name,
const Record& type);
604 const Table& getTable()
const;
628 Int testGroupAggr (vector<TableExprNodeRep*>& aggr)
const;
631 vector<TableExprNodeRep*> getAggrNodes()
const;
651 void doUpdate (
Bool showTimings,
const Table& origTable,
660 void doDelete (
Bool showTimings,
Table& table);
682 void makeProjectExprTable();
686 void makeProjectExprSel();
690 { applySelNodes_p.push_back (node); }
701 (
bool showTimings, vector<TableExprNodeRep*> aggrNodes,
705 void doHaving (
Bool showTimings,
713 (
const vector<TableExprNodeRep*>& aggrNodes);
716 void doSort (
Bool showTimings);
719 void doLimOff (
Bool showTimings);
730 template<
typename TCOL,
typename TNODE>
736 template<
typename TCOL,
typename TNODE>
740 template<
typename TCOL,
typename TNODE>
745 template<
typename TCOL,
typename TNODE>
751 template<
typename TCOL,
typename TNODE>
760 void checkMaskColumn (
Bool hasMask,
767 DataType makeDataType (DataType dtype,
const String& dtstr,
789 void handleWildColumn (
Int stringType,
const String& name);
793 void addColumnDesc (
TableDesc& td, DataType dtype,
810 const vector<TableParseSelect*>& stack);
820 void checkTableProjSizes()
const;
826 vector<CountedPtr<TableExprGroupFuncSet> > doGroupByAggrSingleKey
827 (
const vector<TableExprNodeRep*>& aggrNodes)
834 vector<CountedPtr<TableExprGroupFuncSet> > funcSets;
835 std::map<T, int> keyFuncMap;
842 for (
uInt i=0; i<rownrs_p.size(); ++i) {
844 groupbyNodes_p[0].get (rowid, key);
845 if (key != lastKey) {
846 typename std::map<T, int>::iterator iter = keyFuncMap.find (key);
847 if (iter == keyFuncMap.end()) {
848 groupnr = funcSets.size();
849 keyFuncMap[key] = groupnr;
852 groupnr = iter->second;
856 funcSets[groupnr]->apply (rowid);
863 vector<CountedPtr<TableExprGroupFuncSet> > doGroupByAggrMultipleKeys
864 (
const vector<TableExprNodeRep*>& aggrNodes);
961 { columnName_p = name; }
963 { columnNameMask_p = name; }
965 {
return columnName_p; }
967 {
return columnNameMask_p; }
969 {
return indexPtr_p; }
971 {
return indexNode_p; }
977 { node_p.adaptUnit (columnUnit); }
988 {
return columnNames_p; }
994 { update_p.push_back (upd); }
A Vector of integers, for indexing into Array<T> objects.
CommandType commandType_p
Block< Bool > projectExprSelColumn_p
A 1-D Specialization of the Array class.
vector< TableExprNode > groupbyNodes_p
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
void setColumnName(const String &name)
Set the column name.
TableExprNodeSet * resultSet_p
Bool orderGiven() const
Is the order given?
EndianFormat
Define the possible endian formats in which table data can be stored.
Main interface class to a read/write table.
TableExprNodeIndex * indexPtr_p
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
std::vector< TableExprNode > insertExprs_p
TableExprNode indexNode_p
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Class to hold multiple table expression nodes.
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
Handle class for a table column expression tree.
Order
Enumerate the sort order:
void setRownr(uInt rownr)
Set the row number.
void setColumnNameMask(const String &name)
Set the column name forthe mask.
TableExprNodeIndex * indexPtr() const
Get the pointer to the indices.
Sort::Order getOrder(const TableParseSort &key) const
Get the order for this key.
void adaptUnit(const Unit &columnUnit)
Adapt the possible unit of the expression to the possible unit of the column.
Abstract base class for a node in a table column expression tree.
TableParse & operator=(const TableParse &)
Assignment (copy semantics).
Block< String > columnNameMasks_p
const Table & table() const
Get table object.
Options defining how table files are organized.
vector< TableExprNode > applySelNodes_p
vector< TableParse > fromTables_p
Select-class for flex/bison scanner/parser for TableParse.
Sort::Order order() const
Get the sort order.
Referenced counted pointer for constant data.
Bool maskFirst() const
Tell if the mask is given first (i.e., before slice).
const TableExprNode & node() const
Get the expression node.
Table::EndianFormat endianFormat_p
Class to hold the table expression nodes for an element in a set.
Class to hold the result of a TaQL command.
A holder for a value of any basic Casacore data type.
Class with static members defining the TaQL style.
LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
CommandType commandType() const
Return the command type.
Block< uInt > projectExprSubset_p
Block< String > columnDtypes_p
const TableExprNode & mask() const
Get the mask.
const Block< String > & getColumnNames() const
Get the projected column names.
const String & columnNameMask() const
Get the possible column name for the mask.
Block< TableRecord > columnKeywords_p
A hierarchical collection of named fields of various types.
bool Bool
Define the standard types used by Casacore.
Bool test(const String &shortHand) const
Test if shorthand matches.
Read/write access to a table column.
Class containing the results of aggregated values in a group.
Block< String > columnNames_p
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
A hierarchical collection of named fields of various types.
Block< TableExprNode > columnExpr_p
TableExprNode getNode() const
Return the expression node.
TableParse()
Default constructor for container class.
Helper class for sort keys in TableParse.
Specify which elements to extract from an n-dimensional array.
const TableExprNode & node() const
Get the expression node.
Class to hold values from table grammar parser.
TableExprNode havingNode_p
TableParseSelect * insSel_p
The identification of a TaQL selection subject.
void addUpdate(TableParseUpdate *upd)
Add an update object.
void setInsertExprs(const std::vector< TableExprNode > exprs)
Set the insert expressions for all rows.
Block< String > columnOldNames_p
const TableExprNode & indexNode() const
Get the index expression node.
String: the storage and methods of handling collections of characters.
Define the structure of a Casacore table.
const Table & getTable() const
Get the resulting table.
TaQLResult tableCommand(const String &command)
Abstract base class for Record classes.
StorageOption storageOption_p
const String & shorthand() const
Get the shorthand.
The index of an array element in a table select expression.
void addApplySelNode(const TableExprNode &node)
Add a column node to applySelNodes_p.
const String & columnName() const
Get the column name.
this file contains all the compiler specific defines
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
Helper class for updates in TableParse.
std::vector< TableParseUpdate * > update_p
std::vector< TableParseSort > sort_p
void setDMInfo(const Record &dminfo)
Set the DataManager info for a new table.