* Copyright (c) 2020 Huawei Technologies Co.,Ltd.
* Portions Copyright (c) 2021, openGauss Contributors
*
* openGauss is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* ---------------------------------------------------------------------------------------
*
* vecnodes.h
* Definition for vector executor state nodes.
*
* IDENTIFICATION
* src/include/vecexecutor/vecnodes.h
*
* ---------------------------------------------------------------------------------------
*/
#ifndef VECNODES_H_
#define VECNODES_H_
#include "executor/exec/execStream.h"
#include "nodes/execnodes.h"
#include "access/cstore_am.h"
#include "pgxc/execRemote.h"
#include "access/cstoreskey.h"
#ifdef ENABLE_MULTIPLE_NODES
#include "tsdb/common/data_row.h"
#endif
typedef ScalarVector* (*vecqual_func)(ExprContext* econtext);
typedef struct BloomFilterRuntime {
List* bf_var_list;
List* bf_filter_index;
filter::BloomFilter** bf_array;
} BloomFilterRuntime;
typedef struct VecHashJoinState : public HashJoinState {
int joinState;
void* hashTbl;
FmgrInfo* eqfunctions;
* function pointer to LLVM machine code if hash join qual
* can be LLVM optimiezed.
*/
vecqual_func jitted_joinqual;
* codegened hash->joinqual expr */
vecqual_func jitted_hashclause;
* codegened hash clause expr */
char* jitted_innerjoin;
char* jitted_matchkey;
char* jitted_buildHashTable;
char* jitted_probeHashTable;
int enable_fast_keyMatch;
* 0 : normal keyMatch
* 1 : one hash clause
* 2 : fast path keyMatch
*/
BloomFilterRuntime bf_runtime;
char* jitted_hashjoin_bfaddLong;
char* jitted_hashjoin_bfincLong;
char* jitted_buildHashTable_NeedCopy;
} VecHashJoinState;
typedef struct VecAsofJoinState {
JoinState js;
List* hashclauses;
List* mergeclauses;
List* hj_OuterHashKeys;
List* hj_InnerHashKeys;
List* hj_OuterSortKeys;
List* hj_InnerSortKeys;
List* hj_HashOperators;
int joinState;
char* cmpName;
void* hashTbl;
FmgrInfo* eqfunctions;
* function pointer to LLVM machine code if hash join qual
* can be LLVM optimiezed.
*/
vecqual_func jitted_joinqual;
* codegened hash->joinqual expr */
vecqual_func jitted_hashclause;
* codegened hash clause expr */
char* jitted_innerjoin;
char* jitted_matchkey;
} VecAsofJoinState;
typedef enum VecAggType {
AGG_COUNT = 0,
AGG_SUM,
AGG_AVG,
AGG_MIN,
AGG_MAX,
} VecAggType;
typedef struct VecAggInfo {
FunctionCallInfoData vec_agg_function;
FunctionCallInfoData vec_final_function;
VectorFunction* vec_agg_cache;
VectorFunction* vec_sonic_agg_cache;
PGFunction* vec_agg_final;
} VecAggInfo;
typedef AggStatePerAggData VecAggStatePerAggData;
typedef VecAggStatePerAggData* VecAggStatePerAgg;
typedef struct VecAggState : public AggState {
void* aggRun;
VecAggStatePerAgg pervecagg;
VecAggInfo* aggInfo;
char* jitted_hashing;
* the codegened hashing function */
char* jitted_sglhashing;
* the codegened hashing function for
* only single hash table case */
char* jitted_batchagg;
* the codegened BatchAggregation
* function */
char* jitted_sonicbatchagg;
* the codegened BatchAggregation
* with sonic format */
char* jitted_SortAggMatchKey;
} VecAggState;
typedef struct VecWindowAggState : public WindowAggState {
void* VecWinAggRuntime;
VecAggInfo* windowAggInfo;
} VecWindowAggState;
struct VecGroupState : public GroupState {
void** container;
void* cap;
uint16 idx;
int cellSize;
bool keySimple;
FmgrInfo* buildFunc;
FmgrInfo* buildScanFunc;
VectorBatch* scanBatch;
VarBuf* currentBuf;
VarBuf* bckBuf;
vecqual_func jitted_vecqual;
* codegened grpstate->ss.ps.qual expr */
};
struct VecUniqueState : public UniqueState {
bool uniqueDone;
void** container;
void* cap;
uint16 idx;
int cellSize;
bool keySimple;
FmgrInfo* buildFunc;
FmgrInfo* buildScanFunc;
VectorBatch* scanBatch;
VarBuf* currentBuf;
VarBuf* bckBuf;
};
typedef struct VecSetOpState : public SetOpState {
void* vecSetOpInfo;
} VecSetOpState;
typedef struct VecSortState : public SortState {
VectorBatch* m_pCurrentBatch;
char* jitted_CompareMultiColumn;
char* jitted_CompareMultiColumn_TOPN;
} VecSortState;
typedef struct VecRemoteQueryState : public RemoteQueryState {
VectorBatch* resultBatch;
} VecRemoteQueryState;
typedef struct VecToRowState VecToRowState;
typedef void (*DevectorizeFun)(VecToRowState* state, ScalarVector* pColumn, int rows, int cols, int i);
typedef struct VecToRowState {
PlanState ps;
VectorBatch* m_pCurrentBatch;
int m_currentRow;
int nattrs;
TupleTableSlot* tts;
Datum* m_ttsvalues;
bool* m_ttsisnull;
int part_id;
List* subpartitions;
List* subPartLengthList;
DevectorizeFun* devectorizeFunRuntime;
} VecToRowState;
typedef struct RowToVecState {
PlanState ps;
bool m_fNoMoreRows;
VectorBatch* m_pCurrentBatch;
bool m_batchMode;
} RowToVecState;
typedef struct VecResultState : public ResultState {
} VecResultState;
struct VecAppendState : public AppendState {
};
struct VecStreamState;
typedef void (*assembleBatchFun)(VecStreamState* vsstate, VectorBatch* batch);
typedef struct VecStreamState : public StreamState {
VectorBatch* m_CurrentBatch;
assembleBatchFun batchForm;
bool redistribute;
int bitNumericLen;
int bitNullLen;
uint32* m_colsType;
} VecStreamState;
typedef struct CStoreScanRunTimeKeyInfo {
CStoreScanKey scan_key;
ExprState* key_expr;
} CStoreScanRunTimeKeyInfo;
typedef struct CStoreScanState : ScanState {
Relation ss_currentDeltaRelation;
Relation ss_partition_parent;
TableScanDesc ss_currentDeltaScanDesc;
bool ss_deltaScan;
bool ss_deltaScanEnd;
VectorBatch* m_pScanBatch;
VectorBatch* m_pCurrentBatch;
CStoreScanRunTimeKeyInfo* m_pScanRunTimeKeys;
int m_ScanRunTimeKeysNum;
bool m_ScanRunTimeKeysReady;
CStore* m_CStore;
CStoreScanKey csss_ScanKeys;
int csss_NumScanKeys;
bool m_fSimpleMap;
bool m_fUseColumnRef;
vecqual_func jitted_vecqual;
bool m_isReplicaTable;
bool m_isImcstore = false;
} CStoreScanState;
class TimeRange;
class TagFilters;
class TsStoreSearch;
typedef struct TsStoreScanState : ScanState {
int top_key_func_arg;
bool is_simple_scan;
bool has_sort;
int limit;
AttrNumber sort_by_time_colidx;
#ifdef ENABLE_MULTIPLE_NODES
TagRows* tag_rows;
#endif
bool only_scan_tag;
VectorBatch* scanBatch;
VectorBatch* currentBatch;
Relation ss_partition_parent;
vecqual_func jitted_vecqual;
TsStoreSearch* ts_store_search;
int tag_id_num;
bool only_const_col;
bool early_stop;
bool tags_scan_done;
TimeRange* time_range;
int scaned_tuples;
bool first_scan;
} TsStoreScanState;
class Batchsortstate;
typedef struct IndexSortState {
VectorBatch* m_tids;
int64 m_sortCount;
Batchsortstate* m_sortState;
TupleDesc m_sortTupleDesc;
bool m_tidEnd;
} IndexSortState;
typedef struct CBTreeScanState : IndexScanState {
IndexSortState* m_sort;
List* m_indexScanTList;
} CBTreeScanState;
typedef struct CBTreeOnlyScanState : IndexOnlyScanState {
IndexSortState* m_sort;
List* m_indexScanTList;
} CBTreeOnlyScanState;
struct CStoreIndexScanState;
typedef VectorBatch* (*cstoreIndexScanFunc)(CStoreIndexScanState* state);
typedef struct CstoreBitmapIndexScanState : BitmapIndexScanState {
IndexSortState* m_sort;
List* m_indexScanTList;
} CstoreBitmapIndexScanState;
* CstoreIndexScanState information
* A column index scan employees two scan: one for index scan to retrieve
* ctids and the other is the base table scan based on ctids.
*/
typedef struct CStoreIndexScanState : CStoreScanState {
CStoreScanState* m_indexScan;
CBTreeScanState* m_btreeIndexScan;
CBTreeOnlyScanState* m_btreeIndexOnlyScan;
List* m_deltaQual;
bool index_only_scan;
int* m_indexOutBaseTabAttr;
int* m_idxInTargetList;
int m_indexOutAttrNo;
cstoreIndexScanFunc m_cstoreIndexScanFunc;
} CStoreIndexScanState;
typedef struct CStoreIndexCtidScanState : CStoreIndexScanState {
CstoreBitmapIndexScanState* m_cstoreBitmapIndexScan;
} CStoreIndexCtidScanState;
typedef struct CStoreIndexHeapScanState : CStoreIndexScanState {
} CStoreIndexHeapScanState;
typedef struct CStoreIndexAndState : public BitmapAndState {
StringInfo resultTids;
uint64 fetchCount;
VectorBatch* m_resultBatch;
} CStoreIndexAndState;
typedef struct CStoreIndexOrState : public BitmapOrState {
StringInfo resultTids;
uint64 fetchCount;
VectorBatch* m_resultBatch;
} CStoreIndexOrState;
typedef void (*AddVarFunc)(ScalarVector* vec, Datum v, int row);
typedef struct VecForeignScanState : public ForeignScanState {
VectorBatch* m_pScanBatch;
VectorBatch* m_pCurrentBatch;
MemoryContext m_scanCxt;
bool m_done;
Datum* m_values;
bool* m_nulls;
} VecForeignScanState;
typedef struct VecModifyTableState : public ModifyTableState {
VectorBatch* m_pScanBatch;
VectorBatch* m_pCurrentBatch;
} VecModifyTableState;
typedef struct VecSubqueryScanState : public SubqueryScanState {
} VecSubqueryScanState;
struct VecNestLoopState : public NestLoopState {
void* vecNestLoopRuntime;
vecqual_func jitted_vecqual;
vecqual_func jitted_joinqual;
};
typedef struct VecPartIteratorState : public PartIteratorState {
} VecPartIteratorState;
class BatchStore;
typedef struct VecMaterialState : public MaterialState {
VectorBatch* m_pCurrentBatch;
BatchStore* batchstorestate;
bool from_memory;
} VecMaterialState;
#endif