casacore
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members

Class holding a comparison part of a join condition. More...

#include <TaQLJoin.h>

Public Member Functions

 TaQLJoin (const TENShPtr &mainNode, const TENShPtr &joinNode, const std::vector< std::shared_ptr< TaQLJoinBase > > &children)
 
 ~TaQLJoin () override=default
 
Int64 findRow (const TableExprId &) override
 Find the row number in the join table for the given row in the main table.
 
- Public Member Functions inherited from casacore::TaQLJoinBase
virtual ~TaQLJoinBase ()=default
 

Static Public Member Functions

static std::shared_ptr< TaQLJoinBasecreateRecursive (const std::vector< TableExprNode > &mainNodes, const std::vector< TableExprNode > &joinNodes, const std::vector< rownr_t > &rows, size_t level)
 From the given level on create nested TaQLJoin nodes.
 
template<typename T >
static std::shared_ptr< TaQLJoinBasemakeOptDiscrete (TableExprNodeRep &node, const std::vector< TableExprNode > &mainNodes, const std::vector< TableExprNode > &joinNodes, const std::vector< rownr_t > &rows, size_t level)
 Create nested TaQLJoin nodes for a join expression part at the given level using discrete values.
 
template<typename T >
static std::shared_ptr< TaQLJoinBasemakeOptInterval (const TableExprNodeSet &set, const std::vector< TableExprNode > &mainNodes, const std::vector< TableExprNode > &joinNodes, const std::vector< rownr_t > &rows, size_t level)
 Create nested TaQLJoin nodes for a join expression part at the given level using intervals.
 

Private Attributes

TENShPtr itsMainNode
 
TENShPtr itsJoinNode
 
TableExprNodeSetOptBaseitsOptSet
 
std::vector< std::shared_ptr< TaQLJoinBase > > itsChildren
 

Detailed Description

Class holding a comparison part of a join condition.

Intended use:

Internal

Review Status

Reviewed By:
Tammo Jan Dijkema
Date Reviewed:
2022/12/15
Test programs:
tTableGramJoin

Synopsis

TaQLJoin holds a vector of nested TaQLJoinBase objects, one for each unique value or interval in the join table. It uses TableExprNodeSetOptBase to hold the values and the index in the vector of TaQLJoinBase objects. The data types that can be used in a join condition are the same as those supported by TableExprNodeSetOptBase; that is: integer and string for a discrete value and int, double, datetime and string for an interval. Note that in the interval case int and datetime are handled as double.

Note that at the lowest level the vector of TaQLJoinBase objects contains TaQLJoinRow objects holding the join table row number. The TaQLJoin objects at the higher levels contain the index in the vector at the next level.

The class contains static functions to build the tree given the left and right part of a comparison, where left is an expression using the main table and right using the join table. The right expression gives the values to build the tree as sketched above.

Example

SELECT t1.COL1, t2.NAME FROM maintab t1 JOIN jointab t2 ON
t1.COL1 = t2.IDCOL
AND t1.TIME AROUND t2.TIME IN t2.INTERVAL

In this example the main and join table are joined on 2 condition parts. First the equality match of COL1 and IDCOL, second the interval match on TIME. Note that the NAME column from the join table are selected, thus the join is used to find the name for each row in the main table.
The join table columns may contain something like below. Thus 4 unique IDCOL values, each having 2 time intervals.

IDCOL TIME INTERVAL NAME
0 tm1 d1 name01
1 tm1 d1 name11
2 tm1 d1 name21
3 tm1 d1 name31
0 tm2 d2 name02
1 tm2 d2 name12
2 tm2 d2 name22
3 tm2 d2 name32

The TaQLJoin tree will consist of 3 levels. The first level handles the equality match. It consists of a single TaQLJoin object containing a vector of second level TaQLJoin objects, one for each unique IDCOL value. The second level handles the TIME match. The third level contains the row number for each IDCOL/TIME pair. Schematically:

level 1 TaQLJoin, IDCOL: 0 1 2 3
level 2 TaQLJoin, TIME: tm1 tm2 tm1 tm2 tm1 tm2 tm1 tm2
level 3 TaQLJoinRow: 0 1 2 3 4 5 6 7
Class holding the row number as the final level in the comparison tree.
Definition TaQLJoin.h:73
Class holding a comparison part of a join condition.
Definition TaQLJoin.h:152

To find the matching join table row means that first the matching IDCOL is found at level 1, thereafter at level 2 the matching interval for that IDCOL.Level 3 gives the correct row number in the join table.

Definition at line 151 of file TaQLJoin.h.

Constructor & Destructor Documentation

◆ TaQLJoin()

casacore::TaQLJoin::TaQLJoin ( const TENShPtr mainNode,
const TENShPtr joinNode,
const std::vector< std::shared_ptr< TaQLJoinBase > > &  children 
)

◆ ~TaQLJoin()

casacore::TaQLJoin::~TaQLJoin ( )
overridedefault

Member Function Documentation

◆ createRecursive()

static std::shared_ptr< TaQLJoinBase > casacore::TaQLJoin::createRecursive ( const std::vector< TableExprNode > &  mainNodes,
const std::vector< TableExprNode > &  joinNodes,
const std::vector< rownr_t > &  rows,
size_t  level 
)
static

From the given level on create nested TaQLJoin nodes.

It use makeOptDiscrete or makeOptInterval to create the appropriate TableExprNodeSetOptBase object.

◆ findRow()

Int64 casacore::TaQLJoin::findRow ( const TableExprId )
overridevirtual

Find the row number in the join table for the given row in the main table.

Implements casacore::TaQLJoinBase.

◆ makeOptDiscrete()

template<typename T >
static std::shared_ptr< TaQLJoinBase > casacore::TaQLJoin::makeOptDiscrete ( TableExprNodeRep node,
const std::vector< TableExprNode > &  mainNodes,
const std::vector< TableExprNode > &  joinNodes,
const std::vector< rownr_t > &  rows,
size_t  level 
)
static

Create nested TaQLJoin nodes for a join expression part at the given level using discrete values.

Thereafter createRecursive is called for the next level.

◆ makeOptInterval()

template<typename T >
static std::shared_ptr< TaQLJoinBase > casacore::TaQLJoin::makeOptInterval ( const TableExprNodeSet set,
const std::vector< TableExprNode > &  mainNodes,
const std::vector< TableExprNode > &  joinNodes,
const std::vector< rownr_t > &  rows,
size_t  level 
)
static

Create nested TaQLJoin nodes for a join expression part at the given level using intervals.

Thereafter createRecursive is called for the next level.

Member Data Documentation

◆ itsChildren

std::vector<std::shared_ptr<TaQLJoinBase> > casacore::TaQLJoin::itsChildren
private

Definition at line 197 of file TaQLJoin.h.

◆ itsJoinNode

TENShPtr casacore::TaQLJoin::itsJoinNode
private

Definition at line 195 of file TaQLJoin.h.

◆ itsMainNode

TENShPtr casacore::TaQLJoin::itsMainNode
private

Definition at line 194 of file TaQLJoin.h.

◆ itsOptSet

TableExprNodeSetOptBase* casacore::TaQLJoin::itsOptSet
private

Definition at line 196 of file TaQLJoin.h.


The documentation for this class was generated from the following file: