28 #ifndef TABLES_TABLEPARSE_H
29 #define TABLES_TABLEPARSE_H
49 class TableExprNodeSet;
50 class TableExprNodeSetElem;
51 class TableExprNodeIndex;
54 template<
class T>
class Vector;
55 template<
class T>
class ArrayColumn;
154 const Table& tempTable);
156 const std::vector<const Table*>& tempTables);
163 const std::vector<const Table*>& tempTables,
166 const std::vector<const Table*>& tempTables,
441 void show (ostream& os)
const;
524 void handleSort (
const std::vector<TableParseSort>& sortList,
544 const vector<const Table*> tempTables,
545 const vector<TableParseSelect*>& stack);
554 const vector<const Table*> tempTables,
555 const vector<TableParseSelect*>& stack,
706 (
bool showTimings,
const std::vector<TableExprNodeRep*> aggrNodes,
718 (
const std::vector<TableExprNodeRep*>& aggrNodes);
735 template<
typename TCOL,
typename TNODE>
741 template<
typename TCOL,
typename TNODE>
745 template<
typename TCOL,
typename TNODE>
750 template<
typename TCOL,
typename TNODE>
756 template<
typename TCOL,
typename TNODE>
806 const Record& attributes);
817 const vector<TableParseSelect*>& stack);
834 (
const vector<TableExprNodeRep*>& aggrNodes)
841 vector<CountedPtr<TableExprGroupFuncSet> > funcSets;
842 std::map<T, int> keyFuncMap;
852 if (key != lastKey) {
853 typename std::map<T, int>::iterator iter = keyFuncMap.find (key);
854 if (iter == keyFuncMap.end()) {
855 groupnr = funcSets.size();
856 keyFuncMap[key] = groupnr;
859 groupnr = iter->second;
863 funcSets[groupnr]->apply (rowid);
871 (
const vector<TableExprNodeRep*>& aggrNodes);
925 std::vector<CountedPtr<TableParseUpdate>>
update_p;
A Vector of integers, for indexing into Array<T> objects.
Bool orderGiven() const
Is the order given?
CommandType commandType_p
Block< Bool > projectExprSelColumn_p
void handleSort(const std::vector< TableParseSort > &sortList, Bool noDuplicates, Sort::Order defaultSortOrder)
Keep the sort expressions.
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.
std::vector< double > Vector
void addColumnDesc(TableDesc &td, DataType dtype, const String &colName, Int options, Int ndim, const IPosition &shape, const String &dmType, const String &dmGroup, const String &comment, const TableRecord &keywordSet, const Vector< String > &unitName, const Record &attributes)
Add the description of a column to the table description.
TableExprNodeSet * resultSet_p
TableExprNode getNode() const
Return the expression node.
TableParseSort()
Construct from a given expression.
EndianFormat
Define the possible endian formats in which table data can be stored.
static String getTypeString(const String &typeStr, DataType type)
Get the type string.
Sort::Order order() const
Get the sort order.
void handleColumn(Int type, const String &name, const TableExprNode &expr, const String &newName, const String &nameMask, const String &newDtype)
Add a column to the list of column names.
Int testGroupAggr(std::vector< TableExprNodeRep * > &aggr) const
Test if groupby or aggregate functions are given.
Table doProject(Bool showTimings, const Table &, const CountedPtr< TableExprGroupResult > &groups=CountedPtr< TableExprGroupResult >())
Do the projection step returning a table containing the projection.
void execute(Bool showTimings, Bool setInGiving, Bool mustSelect, uInt maxRow, Bool doTracing=False)
Execute the select command (select/sort/projection/groupby/having/giving).
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
std::vector< CountedPtr< TableExprGroupFuncSet > > doGroupByAggrSingleKey(const vector< TableExprNodeRep * > &aggrNodes)
Create the set of aggregate functions and groupby keys in case a single groupby key is given...
void updateScalar(uInt row, const TableExprId &rowid, const TableExprNode &node, TableColumn &col)
vector< TableParse > withTables_p
TableExprNode indexNode_p
std::vector< CountedPtr< TableExprGroupFuncSet > > doGroupByAggrMultipleKeys(const vector< TableExprNodeRep * > &aggrNodes)
Create the set of aggregate functions and groupby keys in case multiple keys are given.
ValueHolder getRecFld(const String &name)
Add a keyword or replace a keyword with the value of another keyword.
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
static TableExprFuncNode::FunctionType findFunc(const String &name, uInt narguments, const Vector< Int > &ignoreFuncs)
Find the function code belonging to a function name.
Class to hold multiple table expression nodes.
void handleAddCol(const Record &dmInfo)
Add columns to the table of ALTER TABLE.
Handle class for a table column expression tree.
void handleRenameKey(const String &oldName, const String &newName)
Rename a table or column keyword.
void updateArray(uInt row, const TableExprId &rowid, const TableExprNode &node, const Array< TNODE > &res, ArrayColumn< TCOL > &col)
Order
Enumerate the sort order:
DataType makeDataType(DataType dtype, const String &dtstr, const String &colName)
Make a data type from the string.
void setRownr(uInt rownr)
Set the row number.
Table createTable(const TableDesc &td, Int64 nrow, const Record &dmInfo)
Create a table using the given parameters.
void setColumnNameMask(const String &name)
Set the column name forthe mask.
const String & columnNameMask() const
Get the possible column name for the mask.
void updateSlice(uInt row, const TableExprId &rowid, const TableExprNode &node, const Array< TNODE > &res, const Slicer &slice, ArrayColumn< TCOL > &col)
vector< TableExprNodeRep * > getAggrNodes() const
Get the aggregate functions used in SELECT and HAVING.
static TableExprNode makeFuncNode(TableParseSelect *, const String &name, const TableExprNodeSet &arguments, const Vector< int > &ignoreFuncs, const Table &table, const TaQLStyle &)
Make a function object node for the given function name and arguments.
void checkNode() const
Check if the node results in a scalar and does not contain aggregate functions.
void handleInsert()
Make ready for the insert expression.
void adaptUnit(const Unit &)
Adapt the unit of the expression to the given unit (if not empty).
void checkTableProjSizes() const
Check if the tables used in selection columns have the same size as the first table given in FROM...
virtual casacore::String type() const
Implements RegionShape::type.
TableExprNode handleKeyCol(const String &name, Bool tryProj)
Find the keyword or column name and create a TableExprNode from it.
CommandType commandType() const
Return the command type.
Abstract base class for a node in a table column expression tree.
void adaptUnit(const Unit &columnUnit)
Adapt the possible unit of the expression to the possible unit of the column.
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
TableParse & operator=(const TableParse &)
Assignment (copy semantics).
void handleGroupby(const vector< TableExprNode > &, Bool rollup)
Keep the groupby expressions.
void doHaving(Bool showTimings, const CountedPtr< TableExprGroupResult > &groups)
Do the HAVING step.
Block< String > columnNameMasks_p
void addTable(Int tabnr, const String &name, const Table &table, const String &shorthand, Bool addToFromList, const vector< const Table * > tempTables, const vector< TableParseSelect * > &stack)
Add a table nr, name, or object to the container.
const Table & table() const
Get table object.
Table doFinish(Bool showTimings, Table &table)
Finish the table (rename, copy, and/or flush).
void handleIndices(const TableExprNodeSet &indices, const TaQLStyle &style)
Handle the subscripts or mask.
static TableExprNode handleSlice(const TableExprNode &array, const TableExprNodeSet &indices, const TaQLStyle &)
Handle a slice operator.
Table adjustApplySelNodes(const Table &)
Set the selected rows for the column objects in applySelNodes_p.
void handleLimit(const TableExprNodeSetElem &expr)
Evaluate and keep limit/offset/stride given as start:end:incr.
Options defining how table files are organized.
String getTableInfo(const Vector< String > &parts, const TaQLStyle &style)
Show the structure of fromTables_p[0] using the options given in parts[2:].
Table doInsert(Bool showTimings, Table &table)
Do the insert step and return a selection containing the new rows.
const TableExprNode & node() const
Get the expression node.
vector< TableExprNode > applySelNodes_p
void handleRemoveKey(const String &name)
Remove a table or column keyword.
Table makeTable(Int tabnr, const String &name, const Table &ftab, const String &shorthand, const vector< const Table * > tempTables, const vector< TableParseSelect * > &stack, Bool alwaysOpen=True)
Make a Table object for given name, seqnr or so.
const TableExprNode & indexNode() const
Get the index expression node.
static TableExprNode makeUDFNode(TableParseSelect *, const String &name, const TableExprNodeSet &arguments, const Table &table, const TaQLStyle &)
Try to make a UDF function node for the given function name and arguments.
vector< TableParse > fromTables_p
void handleSetKey(const String &name, const String &dtype, const ValueHolder &value)
Add a keyword or replace a keyword with a value.
Select-class for flex/bison scanner/parser for TableParse.
Block< String > getStoredColumns(const Table &tab) const
Find the names of all stored columns in a table.
Bool test(const String &shortHand) const
Test if shorthand matches.
void doDelete(Bool showTimings, Table &table)
Do the delete step.
static Bool splitName(String &shorthand, String &columnName, Vector< String > &fieldNames, const String &name, Bool checkError, Bool isKeyword, Bool allowNoKey)
Split a name into its parts (shorthand, column and field names).
Int64 evalIntScaExpr(const TableExprNode &expr) const
Evaluate an int scalar expression.
Referenced counted pointer for constant data.
void handleCalcComm(const TableExprNode &)
Keep the expression of a calculate command.
Table::EndianFormat endianFormat_p
Class to hold the table expression nodes for an element in a set.
const String & columnName() const
Get the column name.
Array< Bool > makeMaskSlice(const Array< Bool > &mask, Bool maskFirst, const IPosition &shapeCol, const Slicer *slicerPtr)
const Table & getTable() const
Get the resulting table.
CountedPtr< TableExprGroupResult > doGroupby(bool showTimings, const std::vector< TableExprNodeRep * > aggrNodes, Int groupAggrUsed)
Do the groupby/aggregate step and return its result.
static void setRecFld(RecordInterface &rec, const String &name, const String &dtype, const ValueHolder &vh)
Define a field with the given data type in the Record.
static Table tableKey(const String &fullName, const String &shorthand, const String &columnName, const Vector< String > &fieldNames, const vector< TableParseSelect * > &stack)
Try to find the keyword representing a table in one of the tables in any select block (from inner to ...
TableRecord & findKeyword(const String &name, String &keyName)
Split the given name into optional shorthand, column and fields.
void copyMaskedValue(uInt row, ArrayColumn< TCOL > &acol, const Slicer *slicerPtr, const TNODE *val, uInt incr, const Array< Bool > &mask)
Class to hold the result of a TaQL command.
TableExprNode getColSet()
Make an array from the contents of a column in a subquery.
A holder for a value of any basic Casacore data type.
void makeTableNoFrom(const vector< TableParseSelect * > &stack)
Create a temporary table in no tables are given in FROM.
Class with static members defining the TaQL style.
LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
TableExprNodeIndex * indexPtr() const
Get the pointer to the indices.
Table findTable(const String &shorthand, Bool doWith) const
Find a table for the given shorthand.
void makeProjectExprSel()
Fill projectExprSelColumn_p telling the columns to be projected at the first stage.
void handleGiving(const String &name, const Record &type)
Handle the name and type given in a GIVING clause.
Block< uInt > projectExprSubset_p
Block< String > columnDtypes_p
void handleCreTab(const Record &dmInfo)
Keep the create table command.
void show(ostream &os) const
Show the expression tree.
Block< TableRecord > columnKeywords_p
A hierarchical collection of named fields of various types.
bool Bool
Define the standard types used by Casacore.
void handleColSpec(const String &columnName, const String &dataType, const Record &spec, Bool isCOrder=False)
Keep the column specification in a create table command.
~TableParseSelect()
Destructor.
void updateValue(uInt row, const TableExprId &rowid, Bool isScalarCol, const TableExprNode &node, const Array< Bool > &mask, Bool maskFirst, TableColumn &col, const Slicer *slicerPtr, ArrayColumn< Bool > &maskCol)
Update the values in the columns (helpers of doUpdate).
void makeProjectExprTable()
Make the (empty) table for the epxression in the SELECT clause.
static void checkAggrFuncs(const TableExprNode &node)
An exception is thrown if the node uses an aggregate function.
static Table findTableKey(const Table &table, const String &columnName, const Vector< String > &keyNames)
Try to find the keyword representing a table in the given table.
void handleCount()
Make ready for a COUNT command.
Read/write access to a table column.
void handleUpdate()
Keep the update expressions.
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 doExists(Bool noexists, Bool showTimings)
Test if a subquery has sufficient elements.
void handleColumnFinish(Bool distinct)
Finish the addition of columns to the list of column names.
TableParse()
Default constructor for container class.
Helper class for sort keys in TableParse.
Bool maskFirst() const
Tell if the mask is given first (i.e., before slice).
Specify which elements to extract from an n-dimensional array.
Table doProjectExpr(Bool useSel, const CountedPtr< TableExprGroupResult > &groups)
Do the projection containing column expressions.
TableParseSelect(CommandType type)
Construct.
TableExprNode handleFunc(const String &name, const TableExprNodeSet &arguments, const TaQLStyle &)
Handle a function.
void addUpdate(const CountedPtr< TableParseUpdate > &upd)
Add an update object.
Class to hold values from table grammar parser.
void doUpdate(Bool showTimings, const Table &origTable, Table &updTable, const Vector< uInt > &rownrs, const CountedPtr< TableExprGroupResult > &groups=CountedPtr< TableExprGroupResult >())
Do the update step.
TableExprNode havingNode_p
TableParseSelect * insSel_p
The identification of a TaQL selection subject.
std::vector< CountedPtr< TableParseUpdate > > update_p
const TableExprNode & node() const
Get the expression node.
void doSort(Bool showTimings)
Do the sort step.
void handleHaving(const TableExprNode &)
Keep the having expression.
void setInsertExprs(const std::vector< TableExprNode > exprs)
Set the insert expressions for all rows.
const Block< String > & getColumnNames() const
Get the projected column names.
Block< String > columnOldNames_p
TableExprNode makeSubSet() const
Make a set from the results of the subquery.
TableExprNode doSubQuery(Bool showTimings)
Execute a subquery and create an appropriate node for the result.
Table doDistinct(Bool showTimings, const Table &table)
Do the 'select distinct' step.
void handleAddRow(const TableExprNode &expr)
Evaluate and add the rows.
void handleOffset(const TableExprNode &expr)
Evaluate and keep the offset value.
String: the storage and methods of handling collections of characters.
void replaceTable(const Table &table)
Replace the first table (used by CALC command).
Define the structure of a Casacore table.
void checkMaskColumn(Bool hasMask, const ArrayColumn< Bool > &maskCol, const TableColumn &col)
TaQLResult tableCommand(const String &command)
Abstract base class for Record classes.
void doLimOff(Bool showTimings)
Do the limit/offset step.
StorageOption storageOption_p
void handleAltTab()
Reopen the table (for update) used in the ALTER TABLE command.
void handleWildColumn(Int stringType, const String &name)
Handle the selection of a wildcarded column name.
Table doFromQuery(Bool showTimings)
Execute a query in a from clause resulting in a Table.
The index of an array element in a table select expression.
void addApplySelNode(const TableExprNode &node)
Add a column node to applySelNodes_p.
void handleWhere(const TableExprNode &)
Keep the selection expression.
CountedPtr< TableExprGroupResult > doGroupByAggr(const std::vector< TableExprNodeRep * > &aggrNodes)
Do a full groupby/aggregate step.
Sort::Order getOrder(const TableParseSort &key) const
Get the order for this key.
const String & shorthand() const
Get the shorthand.
Table doCount(Bool showTimings, const Table &)
Do the count step returning a memory table containing the unique column values and the counts of the ...
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
Helper class for updates in TableParse.
const TableExprNode & mask() const
Get the mask.
CountedPtr< TableExprGroupResult > doOnlyCountAll(TableExprNodeRep *aggrNode)
Do a groupby/aggregate step that only does a 'select count(*)'.
std::vector< TableParseSort > sort_p
void setDMInfo(const Record &dminfo)
Set the DataManager info for a new table.
#define casacore
<X11/Intrinsic.h> #defines true, false, casacore::Bool, and String.