TDengine/source/libs/executor/inc/hashjoin.h

117 lines
2.6 KiB
C
Raw Normal View History

2023-06-15 11:34:15 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_HASHJOIN_H
#define TDENGINE_HASHJOIN_H
#ifdef __cplusplus
extern "C" {
#endif
2023-06-21 11:33:27 +00:00
#define HASH_JOIN_DEFAULT_PAGE_SIZE 10485760
2023-06-25 09:31:04 +00:00
#pragma pack(push, 1)
typedef struct SBufRowInfo {
void* next;
uint16_t pageId;
int32_t offset;
} SBufRowInfo;
#pragma pack(pop)
2023-06-20 11:34:16 +00:00
typedef struct SHJoinCtx {
bool rowRemains;
SBufRowInfo* pBuildRow;
SSDataBlock* pProbeData;
int32_t probeIdx;
} SHJoinCtx;
2023-06-15 11:34:15 +00:00
typedef struct SRowLocation {
SSDataBlock* pDataBlock;
int32_t pos;
} SRowLocation;
2023-06-21 11:33:27 +00:00
typedef struct SHJoinColInfo {
2023-06-20 11:34:16 +00:00
int32_t srcSlot;
int32_t dstSlot;
2023-06-21 11:33:27 +00:00
bool keyCol;
2023-06-15 11:34:15 +00:00
bool vardata;
int32_t* offset;
int32_t bytes;
char* data;
2023-06-21 11:33:27 +00:00
char* bitMap;
} SHJoinColInfo;
2023-06-15 11:34:15 +00:00
2023-06-19 11:40:15 +00:00
typedef struct SBufPageInfo {
int32_t pageSize;
int32_t offset;
char* data;
} SBufPageInfo;
2023-06-20 11:34:16 +00:00
typedef struct SGroupData {
2023-06-19 11:40:15 +00:00
SBufRowInfo* rows;
2023-06-20 11:34:16 +00:00
} SGroupData;
2023-06-19 11:40:15 +00:00
2023-06-21 11:33:27 +00:00
typedef struct SHJoinTableInfo {
2023-07-05 03:07:08 +00:00
int32_t downStreamIdx;
2023-06-19 11:40:15 +00:00
SOperatorInfo* downStream;
int32_t blkId;
SQueryStat inputStat;
int32_t keyNum;
2023-06-21 11:33:27 +00:00
SHJoinColInfo* keyCols;
2023-06-19 11:40:15 +00:00
char* keyBuf;
2023-06-21 11:33:27 +00:00
char* keyData;
2023-06-19 11:40:15 +00:00
int32_t valNum;
2023-06-21 11:33:27 +00:00
SHJoinColInfo* valCols;
char* valData;
int32_t valBitMapSize;
2023-06-19 11:40:15 +00:00
int32_t valBufSize;
2023-06-21 11:33:27 +00:00
SArray* valVarCols;
bool valColExist;
} SHJoinTableInfo;
2023-06-15 11:34:15 +00:00
2023-07-25 01:03:52 +00:00
typedef struct SHJoinExecInfo {
int64_t buildBlkNum;
int64_t buildBlkRows;
int64_t probeBlkNum;
int64_t probeBlkRows;
int64_t resRows;
int64_t expectRows;
} SHJoinExecInfo;
2023-06-15 11:34:15 +00:00
typedef struct SHJoinOperatorInfo {
2023-06-21 11:33:27 +00:00
int32_t joinType;
SHJoinTableInfo tbs[2];
SHJoinTableInfo* pBuild;
SHJoinTableInfo* pProbe;
SSDataBlock* pRes;
int32_t pResColNum;
int8_t* pResColMap;
SArray* pRowBufs;
SNode* pCond;
SSHashObj* pKeyHash;
2023-07-06 11:33:31 +00:00
bool keyHashBuilt;
2023-06-21 11:33:27 +00:00
SHJoinCtx ctx;
2023-07-25 01:03:52 +00:00
SHJoinExecInfo execInfo;
2023-06-15 11:34:15 +00:00
} SHJoinOperatorInfo;
2023-06-20 11:34:16 +00:00
2023-06-15 11:34:15 +00:00
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_HASHJOIN_H