casacore
|
#include <TableParseProject.h>
Public Member Functions | |
TableParseProject (const TableParseTableList &tableList) | |
Constructor fills a reference to the tableList objkect. | |
Record & | dminfo () |
Get access to the datamanager info. | |
const TableDesc & | tableDesc () const |
Get the table description. | |
const Block< String > & | getColumnNames () const |
Get the projected column names. | |
const Block< TableExprNode > & | getColumnExpr () const |
Get the projected column expressions. | |
Bool | hasExpressions () const |
Are expressions used in the column projection? | |
uInt | nColumnsPreCalc () const |
Return the number of projected columns used in other clauses such as HAVING which need to be precalculated. | |
void | setColumnNames (const std::vector< std::shared_ptr< TableParseUpdate > > &) |
Set the column names to the ones to be updated. | |
void | setUpdateNames (std::vector< std::shared_ptr< TableParseUpdate > > &) |
Put the column name and mask name into the update objects. | |
void | setStoredColumns () |
Set the names to the stored columns of the first table. | |
void | handleColumn (Int stringType, const String &name, const TableExprNode &expr, const String &newName, const String &newNameMask, const String &newDtype, TableParseQuery &) |
Add a column to the list of column names. | |
void | handleWildColumn (Int stringType, const String &name) |
Handle the selection of a wildcarded column name. | |
Table | handleColumnFinish (Bool distinct, Bool hasResultSet, TableParseQuery &) |
Finish the additions to the block of column names by removing the deleted empty names and creating Expr objects as needed. | |
void | handleColSpec (const String &columnName, const String &likeColName, const String &dataType, const Record &spec, Bool isCOrder) |
Keep the column specification in a create table command. | |
void | handleAddCol (const Record &dmInfo, Table &) |
Add columns to the table of ALTER TABLE. | |
void | initDescriptions (const TableDesc &desc, const Record &dminfo) |
Initialize the table and data manager descriptions. | |
void | setDMInfo (const Record &dminfo) |
Set the DataManager info for a new table. | |
TableExprNode | handleKeyCol (const String &name, Bool tryProj, TableParseQuery &) |
Find the keyword or column name and create a TableExprNode from it. | |
Table | project (const Table &tab) |
Make the table projection using the selected columns. | |
void | makeUpdate (Bool useSel, TableParseQuery &tpq) |
Create TableParseUpdate objects for the selected column expressions. | |
void | makeProjectExprSel () |
Fill projectExprSelColumn_p telling the columns to be projected at the first stage. | |
void | checkTableProjSizes () const |
Check if the tables used in selection columns have the same size as the first table given in FROM. | |
void | getAggrNodes (std::vector< TableExprNodeRep * > &aggr) const |
Add possible aggregation functions used in projection to the vector. | |
void | checkCountColumns () const |
Check if the COUNT columns are given correctly. | |
Private Member Functions | |
Table | makeProjectExprTable (TableParseQuery &) |
Make the (empty) table for the expression in the SELECT clause. | |
DataType | makeDataType (DataType dtype, const String &dtstr, const String &colName) |
Make a data type from the string. | |
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. | |
std::pair< ColumnDesc, Record > | findColumnInfo (const String &colName, const String &newColName) const |
Find the ColumnDesc and data manager info of another column (a LIKE column). | |
Private Attributes | |
const TableParseTableList & | tableList_p |
std::shared_ptr< TableDesc > | tableDesc_p |
Record | dminfo_p |
Block< String > | columnNames_p |
Block< String > | columnNameMasks_p |
Block< TableExprNode > | columnExpr_p |
Block< String > | columnOldNames_p |
Block< String > | columnDtypes_p |
Block< TableRecord > | columnKeywords_p |
uInt | nrSelExprUsed_p |
Block< uInt > | projectExprSubset_p |
Block< Bool > | projectExprSelColumn_p |
Table | firstColTable_p |
String | firstColName_p |
Class holding the info of a TaQL projection command
Internal
Table projection is the selection of columns in a TaQL command. This class gets the results of the parser of all columns in the projection. Those results are column name, new name, data type and expression. Furthermore, it holds info which projected columns are used in other parts of a TaQL command (HAVING and ORDERBY). Once the TaQL is fully parsed and all parameters are stored, it is executed. This class creates the table description and data manager info and finally creates the resulting table. First projected columns used in other parts are filled. After a possible HAVING clause and ORDERBY clause is executed, the remaining columns are filled.
Definition at line 68 of file TableParseProject.h.
casacore::TableParseProject::TableParseProject | ( | const TableParseTableList & | tableList | ) |
Constructor fills a reference to the tableList objkect.
|
private |
Add the description of a column to the table description.
ndim < 0 means a scalar column.
void casacore::TableParseProject::checkCountColumns | ( | ) | const |
Check if the COUNT columns are given correctly.
void casacore::TableParseProject::checkTableProjSizes | ( | ) | const |
Check if the tables used in selection columns have the same size as the first table given in FROM.
|
inline |
Get access to the datamanager info.
Definition at line 75 of file TableParseProject.h.
References dminfo_p.
Referenced by setDMInfo().
|
private |
Find the ColumnDesc and data manager info of another column (a LIKE column).
The LIKE column name can be qualified to use another table. It sets the new column name in the data manager info. An exception is thrown if colName is invalid or unknown.
void casacore::TableParseProject::getAggrNodes | ( | std::vector< TableExprNodeRep * > & | aggr | ) | const |
Add possible aggregation functions used in projection to the vector.
|
inline |
Get the projected column expressions.
Definition at line 87 of file TableParseProject.h.
References columnExpr_p.
Get the projected column names.
Definition at line 83 of file TableParseProject.h.
References columnNames_p.
Referenced by casacore::TableParseQuery::getColumnNames().
Add columns to the table of ALTER TABLE.
The column descriptions have already been added to tableDesc_p.
void casacore::TableParseProject::handleColSpec | ( | const String & | columnName, |
const String & | likeColName, | ||
const String & | dataType, | ||
const Record & | spec, | ||
Bool | isCOrder | ||
) |
Keep the column specification in a create table command.
void casacore::TableParseProject::handleColumn | ( | Int | stringType, |
const String & | name, | ||
const TableExprNode & | expr, | ||
const String & | newName, | ||
const String & | newNameMask, | ||
const String & | newDtype, | ||
TableParseQuery & | |||
) |
Add a column to the list of column names.
Table casacore::TableParseProject::handleColumnFinish | ( | Bool | distinct, |
Bool | hasResultSet, | ||
TableParseQuery & | |||
) |
Finish the additions to the block of column names by removing the deleted empty names and creating Expr objects as needed.
An exception is thrown if there is a resultset and if columns are selected.
TableExprNode casacore::TableParseProject::handleKeyCol | ( | const String & | name, |
Bool | tryProj, | ||
TableParseQuery & | |||
) |
Find the keyword or column name and create a TableExprNode from it.
If tryProj=True
it is first tried if the column is a coluymn in the projected table (i.e., result from the SELECT part).
Handle the selection of a wildcarded column name.
|
inline |
Are expressions used in the column projection?
Definition at line 91 of file TableParseProject.h.
References nrSelExprUsed_p.
void casacore::TableParseProject::initDescriptions | ( | const TableDesc & | desc, |
const Record & | dminfo | ||
) |
Initialize the table and data manager descriptions.
|
private |
Make a data type from the string.
It checks if it is compatible with the given (expression) data type.
void casacore::TableParseProject::makeProjectExprSel | ( | ) |
Fill projectExprSelColumn_p telling the columns to be projected at the first stage.
|
private |
Make the (empty) table for the expression in the SELECT clause.
void casacore::TableParseProject::makeUpdate | ( | Bool | useSel, |
TableParseQuery & | tpq | ||
) |
Create TableParseUpdate objects for the selected column expressions.
|
inline |
Return the number of projected columns used in other clauses such as HAVING which need to be precalculated.
Definition at line 96 of file TableParseProject.h.
References projectExprSubset_p, and casacore::Block< T >::size().
Make the table projection using the selected columns.
The columns in the resulting table are renamed if a new name was given.
void casacore::TableParseProject::setColumnNames | ( | const std::vector< std::shared_ptr< TableParseUpdate > > & | ) |
Set the column names to the ones to be updated.
|
inline |
Set the DataManager info for a new table.
Definition at line 139 of file TableParseProject.h.
References dminfo(), and dminfo_p.
Referenced by casacore::TableParseQuery::setDMInfo().
void casacore::TableParseProject::setStoredColumns | ( | ) |
Set the names to the stored columns of the first table.
Resize columnNameMasks_p accordingly.
void casacore::TableParseProject::setUpdateNames | ( | std::vector< std::shared_ptr< TableParseUpdate > > & | ) |
Put the column name and mask name into the update objects.
|
inline |
Get the table description.
Definition at line 79 of file TableParseProject.h.
References tableDesc_p.
Definition at line 211 of file TableParseProject.h.
|
private |
Definition at line 207 of file TableParseProject.h.
Referenced by getColumnExpr().
|
private |
Definition at line 213 of file TableParseProject.h.
Definition at line 205 of file TableParseProject.h.
Definition at line 203 of file TableParseProject.h.
Referenced by getColumnNames().
Definition at line 209 of file TableParseProject.h.
|
private |
Definition at line 201 of file TableParseProject.h.
Referenced by dminfo(), and setDMInfo().
|
private |
Definition at line 222 of file TableParseProject.h.
|
private |
Definition at line 221 of file TableParseProject.h.
|
private |
Definition at line 215 of file TableParseProject.h.
Referenced by hasExpressions().
Definition at line 218 of file TableParseProject.h.
Definition at line 217 of file TableParseProject.h.
Referenced by nColumnsPreCalc().
|
private |
Definition at line 200 of file TableParseProject.h.
Referenced by tableDesc().
|
private |
Definition at line 197 of file TableParseProject.h.