test: add develop=test/5-taos-tools/taosbenchmark/telnet_tcp.py
This commit is contained in:
commit
4a0a805b50
|
@ -430,8 +430,6 @@ pipeline {
|
||||||
rm -rf ${WKC}/debug
|
rm -rf ${WKC}/debug
|
||||||
cd ${WKC}/tests/parallel_test
|
cd ${WKC}/tests/parallel_test
|
||||||
time ./container_build.sh -w ${WKDIR} -t 10 -e
|
time ./container_build.sh -w ${WKDIR} -t 10 -e
|
||||||
rm -f /tmp/cases.task
|
|
||||||
./collect_cases.sh -e
|
|
||||||
'''
|
'''
|
||||||
def extra_param = ""
|
def extra_param = ""
|
||||||
def log_server_file = "/home/log_server.json"
|
def log_server_file = "/home/log_server.json"
|
||||||
|
@ -462,7 +460,7 @@ pipeline {
|
||||||
cd ${WKC}/tests/parallel_test
|
cd ${WKC}/tests/parallel_test
|
||||||
export DEFAULT_RETRY_TIME=2
|
export DEFAULT_RETRY_TIME=2
|
||||||
date
|
date
|
||||||
''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t /tmp/cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 480 ''' + extra_param + '''
|
''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 480 ''' + extra_param + '''
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,12 @@ IF ("${CPUTYPE}" STREQUAL "")
|
||||||
SET(TD_ARM_64 TRUE)
|
SET(TD_ARM_64 TRUE)
|
||||||
ADD_DEFINITIONS("-D_TD_ARM_")
|
ADD_DEFINITIONS("-D_TD_ARM_")
|
||||||
ADD_DEFINITIONS("-D_TD_ARM_64")
|
ADD_DEFINITIONS("-D_TD_ARM_64")
|
||||||
|
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "loongarch64")
|
||||||
|
MESSAGE(STATUS "The current platform is loongarch64")
|
||||||
|
SET(PLATFORM_ARCH_STR "loongarch64")
|
||||||
|
SET(TD_LOONGARCH_64 TRUE)
|
||||||
|
ADD_DEFINITIONS("-D_TD_LOONGARCH_")
|
||||||
|
ADD_DEFINITIONS("-D_TD_LOONGARCH_64")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
ELSE ()
|
ELSE ()
|
||||||
# if generate ARM version:
|
# if generate ARM version:
|
||||||
|
@ -118,6 +124,12 @@ ELSE ()
|
||||||
ADD_DEFINITIONS("-D_TD_ARM_")
|
ADD_DEFINITIONS("-D_TD_ARM_")
|
||||||
ADD_DEFINITIONS("-D_TD_ARM_64")
|
ADD_DEFINITIONS("-D_TD_ARM_64")
|
||||||
SET(TD_ARM_64 TRUE)
|
SET(TD_ARM_64 TRUE)
|
||||||
|
ELSEIF (${CPUTYPE} MATCHES "loongarch64")
|
||||||
|
SET(PLATFORM_ARCH_STR "loongarch64")
|
||||||
|
MESSAGE(STATUS "input cpuType: loongarch64")
|
||||||
|
SET(TD_LOONGARCH_64 TRUE)
|
||||||
|
ADD_DEFINITIONS("-D_TD_LOONGARCH_")
|
||||||
|
ADD_DEFINITIONS("-D_TD_LOONGARCH_64")
|
||||||
ELSEIF (${CPUTYPE} MATCHES "mips64")
|
ELSEIF (${CPUTYPE} MATCHES "mips64")
|
||||||
SET(PLATFORM_ARCH_STR "mips")
|
SET(PLATFORM_ARCH_STR "mips")
|
||||||
MESSAGE(STATUS "input cpuType: mips64")
|
MESSAGE(STATUS "input cpuType: mips64")
|
||||||
|
|
|
@ -65,13 +65,14 @@ ELSE ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
MESSAGE(STATUS "============= compile version parameter information start ============= ")
|
MESSAGE(STATUS "============= compile version parameter information start ============= ")
|
||||||
MESSAGE(STATUS "ver number:" ${TD_VER_NUMBER})
|
MESSAGE(STATUS "version: " ${TD_VER_NUMBER})
|
||||||
MESSAGE(STATUS "compatible ver number:" ${TD_VER_COMPATIBLE})
|
MESSAGE(STATUS "compatible: " ${TD_VER_COMPATIBLE})
|
||||||
MESSAGE(STATUS "communit commit id:" ${TD_VER_GIT})
|
MESSAGE(STATUS "commit id: " ${TD_VER_GIT})
|
||||||
MESSAGE(STATUS "build date:" ${TD_VER_DATE})
|
MESSAGE(STATUS "build date: " ${TD_VER_DATE})
|
||||||
MESSAGE(STATUS "ver type:" ${TD_VER_VERTYPE})
|
MESSAGE(STATUS "build type: " ${CMAKE_BUILD_TYPE})
|
||||||
MESSAGE(STATUS "ver cpu:" ${TD_VER_CPUTYPE})
|
MESSAGE(STATUS "type: " ${TD_VER_VERTYPE})
|
||||||
MESSAGE(STATUS "os type:" ${TD_VER_OSTYPE})
|
MESSAGE(STATUS "cpu: " ${TD_VER_CPUTYPE})
|
||||||
|
MESSAGE(STATUS "os: " ${TD_VER_OSTYPE})
|
||||||
MESSAGE(STATUS "============= compile version parameter information end ============= ")
|
MESSAGE(STATUS "============= compile version parameter information end ============= ")
|
||||||
|
|
||||||
STRING(REPLACE "." "_" TD_LIB_VER_NUMBER ${TD_VER_NUMBER})
|
STRING(REPLACE "." "_" TD_LIB_VER_NUMBER ${TD_VER_NUMBER})
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# taos-tools
|
# taos-tools
|
||||||
ExternalProject_Add(taos-tools
|
ExternalProject_Add(taos-tools
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||||
GIT_TAG a921bd4
|
GIT_TAG 23e2b73
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -14,7 +14,7 @@ Note: ● means officially tested and verified, ○ means unofficially tested an
|
||||||
|
|
||||||
## List of supported platforms for TDengine clients and connectors
|
## List of supported platforms for TDengine clients and connectors
|
||||||
|
|
||||||
TDengine's connector can support a wide range of platforms, including X64/X86/ARM64/ARM32/MIPS/Alpha hardware platforms and Linux/Win64/Win32/macOS development environments.
|
TDengine's connector can support a wide range of platforms, including X64/X86/ARM64/ARM32/MIPS/Alpha/LoongArch64 hardware platforms and Linux/Win64/Win32/macOS development environments.
|
||||||
|
|
||||||
The comparison matrix is as follows.
|
The comparison matrix is as follows.
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ title: 立即开始
|
||||||
description: '快速设置 TDengine 环境并体验其高效写入和查询'
|
description: '快速设置 TDengine 环境并体验其高效写入和查询'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import xiaot from './tdengine.webp'
|
||||||
|
|
||||||
TDengine 完整的软件包包括服务端(taosd)、用于与第三方系统对接并提供 RESTful 接口的 taosAdapter、应用驱动(taosc)、命令行程序 (CLI,taos) 和一些工具软件。TDengine 除了提供多种语言的连接器之外,还通过 [taosAdapter](../reference/taosadapter) 提供 [RESTful 接口](../connector/rest-api)。
|
TDengine 完整的软件包包括服务端(taosd)、用于与第三方系统对接并提供 RESTful 接口的 taosAdapter、应用驱动(taosc)、命令行程序 (CLI,taos) 和一些工具软件。TDengine 除了提供多种语言的连接器之外,还通过 [taosAdapter](../reference/taosadapter) 提供 [RESTful 接口](../connector/rest-api)。
|
||||||
|
|
||||||
本章主要介绍如何利用 Docker 或者安装包快速设置 TDengine 环境并体验其高效写入和查询。
|
本章主要介绍如何利用 Docker 或者安装包快速设置 TDengine 环境并体验其高效写入和查询。
|
||||||
|
@ -12,4 +14,10 @@ import DocCardList from '@theme/DocCardList';
|
||||||
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
||||||
|
|
||||||
<DocCardList items={useCurrentSidebarCategory().items}/>
|
<DocCardList items={useCurrentSidebarCategory().items}/>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 开发者技术交流群
|
||||||
|
|
||||||
|
微信扫描下面二维码,加“小 T”为好友,即可加入“物联网大数据技术前沿群”,与大家共同交流物联网大数据技术应用、TDengine 使用问题和技巧等话题。
|
||||||
|
|
||||||
|
<img src={xiaot} alt="小 T 的二维码" width="200" />
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
|
@ -115,6 +115,7 @@ TDengine 客户端驱动的安装请参考 [安装指南](../#安装步骤)
|
||||||
<summary>订阅和消费</summary>
|
<summary>订阅和消费</summary>
|
||||||
|
|
||||||
```c
|
```c
|
||||||
|
{{#include examples/c/tmq.c}}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
|
@ -16,7 +16,7 @@ description: "TDengine 服务端、客户端和连接器支持的平台列表"
|
||||||
|
|
||||||
## TDengine 客户端和连接器支持的平台列表
|
## TDengine 客户端和连接器支持的平台列表
|
||||||
|
|
||||||
目前 TDengine 的连接器可支持的平台广泛,目前包括:X64/X86/ARM64/ARM32/MIPS/Alpha 等硬件平台,以及 Linux/Win64/Win32/macOS 等开发环境。
|
目前 TDengine 的连接器可支持的平台广泛,目前包括:X64/X86/ARM64/ARM32/MIPS/LoongArch64 等硬件平台,以及 Linux/Win64/Win32/macOS 等开发环境。
|
||||||
|
|
||||||
对照矩阵如下:
|
对照矩阵如下:
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ taos -h tdengine -P 6030
|
||||||
FROM ubuntu:20.04
|
FROM ubuntu:20.04
|
||||||
RUN apt-get update && apt-get install -y wget
|
RUN apt-get update && apt-get install -y wget
|
||||||
ENV TDENGINE_VERSION=3.0.0.0
|
ENV TDENGINE_VERSION=3.0.0.0
|
||||||
RUN wget -c https://www.tdengine.com/assets-download/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
RUN wget -c https://www.tdengine.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||||
&& tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
&& tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||||
&& cd TDengine-client-${TDENGINE_VERSION} \
|
&& cd TDengine-client-${TDENGINE_VERSION} \
|
||||||
&& ./install_client.sh \
|
&& ./install_client.sh \
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
---
|
---
|
||||||
sidebar_label: TDengine 发布历史
|
sidebar_label: TDengine 发布历史
|
||||||
title: TDengine 发布历史
|
title: TDengine 发布历史及下载链接
|
||||||
description: TDengine 发布历史、Release Notes 及下载链接
|
description: TDengine 发布历史、Release Notes 及下载链接
|
||||||
---
|
---
|
||||||
|
|
||||||
|
各版本 TDengine 安装包下载链接如下:
|
||||||
|
|
||||||
import Release from "/components/ReleaseV3";
|
import Release from "/components/ReleaseV3";
|
||||||
|
|
||||||
## 3.0.1.6
|
## 3.0.1.6
|
||||||
|
@ -33,4 +35,3 @@ import Release from "/components/ReleaseV3";
|
||||||
## 3.0.1.0
|
## 3.0.1.0
|
||||||
|
|
||||||
<Release type="tdengine" version="3.0.1.0" />
|
<Release type="tdengine" version="3.0.1.0" />
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
---
|
---
|
||||||
sidebar_label: taosTools 发布历史
|
sidebar_label: taosTools 发布历史
|
||||||
title: taosTools 发布历史
|
title: taosTools 发布历史及下载链接
|
||||||
description: taosTools 的发布历史、Release Notes 和下载链接
|
description: taosTools 的发布历史、Release Notes 和下载链接
|
||||||
---
|
---
|
||||||
|
|
||||||
|
各版本 taosTools 安装包下载链接如下:
|
||||||
|
|
||||||
import Release from "/components/ReleaseV3";
|
import Release from "/components/ReleaseV3";
|
||||||
|
|
||||||
## 2.2.7
|
## 2.2.7
|
||||||
|
|
|
@ -244,7 +244,7 @@ int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColIn
|
||||||
SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId);
|
SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId);
|
||||||
SColumnInfoData* bdGetColumnInfoData(const SSDataBlock* pBlock, int32_t index);
|
SColumnInfoData* bdGetColumnInfoData(const SSDataBlock* pBlock, int32_t index);
|
||||||
|
|
||||||
void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress);
|
int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols);
|
||||||
const char* blockDecode(SSDataBlock* pBlock, const char* pData);
|
const char* blockDecode(SSDataBlock* pBlock, const char* pData);
|
||||||
|
|
||||||
void blockDebugShowDataBlock(SSDataBlock* pBlock, const char* flag);
|
void blockDebugShowDataBlock(SSDataBlock* pBlock, const char* flag);
|
||||||
|
|
|
@ -130,7 +130,7 @@ void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn)
|
||||||
void tColDataClear(SColData *pColData);
|
void tColDataClear(SColData *pColData);
|
||||||
int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal);
|
int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal);
|
||||||
void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal);
|
void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal);
|
||||||
uint8_t tColDataGetBitValue(SColData *pColData, int32_t iVal);
|
uint8_t tColDataGetBitValue(const SColData *pColData, int32_t iVal);
|
||||||
int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest);
|
int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest);
|
||||||
extern void (*tColDataCalcSMA[])(SColData *pColData, int64_t *sum, int64_t *max, int64_t *min, int16_t *numOfNull);
|
extern void (*tColDataCalcSMA[])(SColData *pColData, int64_t *sum, int64_t *max, int64_t *min, int16_t *numOfNull);
|
||||||
|
|
||||||
|
|
|
@ -135,6 +135,9 @@ extern int32_t tsTtlPushInterval;
|
||||||
extern int32_t tsGrantHBInterval;
|
extern int32_t tsGrantHBInterval;
|
||||||
extern int32_t tsUptimeInterval;
|
extern int32_t tsUptimeInterval;
|
||||||
|
|
||||||
|
extern int32_t tsRpcRetryLimit;
|
||||||
|
extern int32_t tsRpcRetryInterval;
|
||||||
|
|
||||||
//#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
//#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
||||||
|
|
||||||
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
||||||
|
|
|
@ -190,6 +190,7 @@ typedef struct {
|
||||||
int64_t dbId;
|
int64_t dbId;
|
||||||
int32_t vgVersion;
|
int32_t vgVersion;
|
||||||
int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT
|
int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT
|
||||||
|
int64_t stateTs;
|
||||||
} SBuildUseDBInput;
|
} SBuildUseDBInput;
|
||||||
|
|
||||||
typedef struct SField {
|
typedef struct SField {
|
||||||
|
@ -417,13 +418,17 @@ static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWr
|
||||||
static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapper* pSW) {
|
static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapper* pSW) {
|
||||||
buf = taosDecodeVariantI32(buf, &pSW->nCols);
|
buf = taosDecodeVariantI32(buf, &pSW->nCols);
|
||||||
buf = taosDecodeVariantI32(buf, &pSW->version);
|
buf = taosDecodeVariantI32(buf, &pSW->version);
|
||||||
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
if (pSW->nCols > 0) {
|
||||||
if (pSW->pSchema == NULL) {
|
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||||
return NULL;
|
if (pSW->pSchema == NULL) {
|
||||||
}
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||||
buf = taosDecodeSSchema(buf, &pSW->pSchema[i]);
|
buf = taosDecodeSSchema(buf, &pSW->pSchema[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pSW->pSchema = NULL;
|
||||||
}
|
}
|
||||||
return (void*)buf;
|
return (void*)buf;
|
||||||
}
|
}
|
||||||
|
@ -838,7 +843,7 @@ typedef struct {
|
||||||
int64_t dbId;
|
int64_t dbId;
|
||||||
int32_t vgVersion;
|
int32_t vgVersion;
|
||||||
int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT
|
int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT
|
||||||
int64_t stateTs; // ms
|
int64_t stateTs; // ms
|
||||||
} SUseDbReq;
|
} SUseDbReq;
|
||||||
|
|
||||||
int32_t tSerializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq);
|
int32_t tSerializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq);
|
||||||
|
@ -1805,7 +1810,7 @@ int32_t tDeserializeSCMCreateTopicRsp(void* buf, int32_t bufLen, SCMCreateTopicR
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t consumerId;
|
int64_t consumerId;
|
||||||
} SMqConsumerLostMsg, SMqConsumerRecoverMsg;
|
} SMqConsumerLostMsg, SMqConsumerRecoverMsg, SMqConsumerClearMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t consumerId;
|
int64_t consumerId;
|
||||||
|
@ -2989,7 +2994,8 @@ static FORCE_INLINE void* tDecodeSMqSubTopicEp(void* buf, SMqSubTopicEp* pTopicE
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) {
|
static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) {
|
||||||
if (pSubTopicEp->schema.nCols) taosMemoryFreeClear(pSubTopicEp->schema.pSchema);
|
taosMemoryFreeClear(pSubTopicEp->schema.pSchema);
|
||||||
|
pSubTopicEp->schema.nCols = 0;
|
||||||
taosArrayDestroy(pSubTopicEp->vgs);
|
taosArrayDestroy(pSubTopicEp->vgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_DO_REBALANCE, "do-rebalance", SMqDoRebalanceMsg, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_DO_REBALANCE, "do-rebalance", SMqDoRebalanceMsg, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_DROP_CGROUP, "drop-cgroup", SMqDropCGroupReq, SMqDropCGroupRsp)
|
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_DROP_CGROUP, "drop-cgroup", SMqDropCGroupReq, SMqDropCGroupRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_UNUSED2, "unused2", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_UNUSED2, "unused2", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_TIMER, "mq-tmr", SMTimerReq, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_TIMER, "tmq-tmr", SMTimerReq, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TELEM_TIMER, "telem-tmr", SMTimerReq, SMTimerReq)
|
TD_DEF_MSG_TYPE(TDMT_MND_TELEM_TIMER, "telem-tmr", SMTimerReq, SMTimerReq)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TRANS_TIMER, "trans-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_TRANS_TIMER, "trans-tmr", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TTL_TIMER, "ttl-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_TTL_TIMER, "ttl-tmr", NULL, NULL)
|
||||||
|
@ -171,6 +171,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_SHOW_VARIABLES, "show-variables", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_SHOW_VARIABLES, "show-variables", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_SERVER_VERSION, "server-version", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_SERVER_VERSION, "server-version", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_UPTIME_TIMER, "uptime-timer", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_UPTIME_TIMER, "uptime-timer", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_LOST_CONSUMER_CLEAR, "lost-consumer-clear", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
||||||
|
@ -249,8 +250,8 @@ enum {
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_SYNC_MSG)
|
TD_NEW_MSG_SEG(TDMT_SYNC_MSG)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_TIMEOUT, "sync-timer", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_TIMEOUT, "sync-timer", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PING, "sync-ping", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_PING, "sync-ping", NULL, NULL) // no longer used
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PING_REPLY, "sync-ping-reply", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_PING_REPLY, "sync-ping-reply", NULL, NULL) // no longer used
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST, "sync-client-request", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST, "sync-client-request", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST_BATCH, "sync-client-request-batch", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST_BATCH, "sync-client-request-batch", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST_REPLY, "sync-client-request-reply", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST_REPLY, "sync-client-request-reply", NULL, NULL)
|
||||||
|
|
|
@ -174,61 +174,61 @@
|
||||||
#define TK_SUBSCRIPTIONS 156
|
#define TK_SUBSCRIPTIONS 156
|
||||||
#define TK_VNODES 157
|
#define TK_VNODES 157
|
||||||
#define TK_LIKE 158
|
#define TK_LIKE 158
|
||||||
#define TK_INDEX 159
|
#define TK_TBNAME 159
|
||||||
#define TK_FUNCTION 160
|
#define TK_QTAGS 160
|
||||||
#define TK_INTERVAL 161
|
#define TK_AS 161
|
||||||
#define TK_TOPIC 162
|
#define TK_INDEX 162
|
||||||
#define TK_AS 163
|
#define TK_FUNCTION 163
|
||||||
#define TK_WITH 164
|
#define TK_INTERVAL 164
|
||||||
#define TK_META 165
|
#define TK_TOPIC 165
|
||||||
#define TK_CONSUMER 166
|
#define TK_WITH 166
|
||||||
#define TK_GROUP 167
|
#define TK_META 167
|
||||||
#define TK_DESC 168
|
#define TK_CONSUMER 168
|
||||||
#define TK_DESCRIBE 169
|
#define TK_GROUP 169
|
||||||
#define TK_RESET 170
|
#define TK_DESC 170
|
||||||
#define TK_QUERY 171
|
#define TK_DESCRIBE 171
|
||||||
#define TK_CACHE 172
|
#define TK_RESET 172
|
||||||
#define TK_EXPLAIN 173
|
#define TK_QUERY 173
|
||||||
#define TK_ANALYZE 174
|
#define TK_CACHE 174
|
||||||
#define TK_VERBOSE 175
|
#define TK_EXPLAIN 175
|
||||||
#define TK_NK_BOOL 176
|
#define TK_ANALYZE 176
|
||||||
#define TK_RATIO 177
|
#define TK_VERBOSE 177
|
||||||
#define TK_NK_FLOAT 178
|
#define TK_NK_BOOL 178
|
||||||
#define TK_OUTPUTTYPE 179
|
#define TK_RATIO 179
|
||||||
#define TK_AGGREGATE 180
|
#define TK_NK_FLOAT 180
|
||||||
#define TK_BUFSIZE 181
|
#define TK_OUTPUTTYPE 181
|
||||||
#define TK_STREAM 182
|
#define TK_AGGREGATE 182
|
||||||
#define TK_INTO 183
|
#define TK_BUFSIZE 183
|
||||||
#define TK_TRIGGER 184
|
#define TK_STREAM 184
|
||||||
#define TK_AT_ONCE 185
|
#define TK_INTO 185
|
||||||
#define TK_WINDOW_CLOSE 186
|
#define TK_TRIGGER 186
|
||||||
#define TK_IGNORE 187
|
#define TK_AT_ONCE 187
|
||||||
#define TK_EXPIRED 188
|
#define TK_WINDOW_CLOSE 188
|
||||||
#define TK_FILL_HISTORY 189
|
#define TK_IGNORE 189
|
||||||
#define TK_SUBTABLE 190
|
#define TK_EXPIRED 190
|
||||||
#define TK_KILL 191
|
#define TK_FILL_HISTORY 191
|
||||||
#define TK_CONNECTION 192
|
#define TK_SUBTABLE 192
|
||||||
#define TK_TRANSACTION 193
|
#define TK_KILL 193
|
||||||
#define TK_BALANCE 194
|
#define TK_CONNECTION 194
|
||||||
#define TK_VGROUP 195
|
#define TK_TRANSACTION 195
|
||||||
#define TK_MERGE 196
|
#define TK_BALANCE 196
|
||||||
#define TK_REDISTRIBUTE 197
|
#define TK_VGROUP 197
|
||||||
#define TK_SPLIT 198
|
#define TK_MERGE 198
|
||||||
#define TK_DELETE 199
|
#define TK_REDISTRIBUTE 199
|
||||||
#define TK_INSERT 200
|
#define TK_SPLIT 200
|
||||||
#define TK_NULL 201
|
#define TK_DELETE 201
|
||||||
#define TK_NK_QUESTION 202
|
#define TK_INSERT 202
|
||||||
#define TK_NK_ARROW 203
|
#define TK_NULL 203
|
||||||
#define TK_ROWTS 204
|
#define TK_NK_QUESTION 204
|
||||||
#define TK_TBNAME 205
|
#define TK_NK_ARROW 205
|
||||||
#define TK_QSTART 206
|
#define TK_ROWTS 206
|
||||||
#define TK_QEND 207
|
#define TK_QSTART 207
|
||||||
#define TK_QDURATION 208
|
#define TK_QEND 208
|
||||||
#define TK_WSTART 209
|
#define TK_QDURATION 209
|
||||||
#define TK_WEND 210
|
#define TK_WSTART 210
|
||||||
#define TK_WDURATION 211
|
#define TK_WEND 211
|
||||||
#define TK_IROWTS 212
|
#define TK_WDURATION 212
|
||||||
#define TK_QTAGS 213
|
#define TK_IROWTS 213
|
||||||
#define TK_CAST 214
|
#define TK_CAST 214
|
||||||
#define TK_NOW 215
|
#define TK_NOW 215
|
||||||
#define TK_TODAY 216
|
#define TK_TODAY 216
|
||||||
|
|
|
@ -56,6 +56,7 @@ typedef struct SDbInfo {
|
||||||
int32_t vgVer;
|
int32_t vgVer;
|
||||||
int32_t tbNum;
|
int32_t tbNum;
|
||||||
int64_t dbId;
|
int64_t dbId;
|
||||||
|
int64_t stateTs;
|
||||||
} SDbInfo;
|
} SDbInfo;
|
||||||
|
|
||||||
typedef struct STablesReq {
|
typedef struct STablesReq {
|
||||||
|
@ -153,7 +154,7 @@ int32_t catalogInit(SCatalogCfg* cfg);
|
||||||
*/
|
*/
|
||||||
int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle);
|
int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle);
|
||||||
|
|
||||||
int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId, int32_t* tableNum);
|
int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId, int32_t* tableNum, int64_t* stateTs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a DB's all vgroup info.
|
* Get a DB's all vgroup info.
|
||||||
|
|
|
@ -284,6 +284,13 @@ typedef struct SShowVnodesStmt {
|
||||||
SNode* pDnodeEndpoint;
|
SNode* pDnodeEndpoint;
|
||||||
} SShowVnodesStmt;
|
} SShowVnodesStmt;
|
||||||
|
|
||||||
|
typedef struct SShowTableTagsStmt {
|
||||||
|
ENodeType type;
|
||||||
|
SNode* pDbName; // SValueNode
|
||||||
|
SNode* pTbName; // SValueNode
|
||||||
|
SNodeList* pTags;
|
||||||
|
} SShowTableTagsStmt;
|
||||||
|
|
||||||
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType;
|
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType;
|
||||||
|
|
||||||
typedef struct SIndexOptions {
|
typedef struct SIndexOptions {
|
||||||
|
|
|
@ -297,6 +297,7 @@ typedef struct SSelectStmt {
|
||||||
bool hasStateKey;
|
bool hasStateKey;
|
||||||
bool onlyHasKeepOrderFunc;
|
bool onlyHasKeepOrderFunc;
|
||||||
bool groupSort;
|
bool groupSort;
|
||||||
|
bool tagScan;
|
||||||
} SSelectStmt;
|
} SSelectStmt;
|
||||||
|
|
||||||
typedef enum ESetOperatorType { SET_OP_TYPE_UNION_ALL = 1, SET_OP_TYPE_UNION } ESetOperatorType;
|
typedef enum ESetOperatorType { SET_OP_TYPE_UNION_ALL = 1, SET_OP_TYPE_UNION } ESetOperatorType;
|
||||||
|
|
|
@ -127,6 +127,7 @@ typedef struct SDBVgInfo {
|
||||||
int16_t hashSuffix;
|
int16_t hashSuffix;
|
||||||
int8_t hashMethod;
|
int8_t hashMethod;
|
||||||
int32_t numOfTable; // DB's table num, unit is TSDB_TABLE_NUM_UNIT
|
int32_t numOfTable; // DB's table num, unit is TSDB_TABLE_NUM_UNIT
|
||||||
|
int64_t stateTs;
|
||||||
SHashObj* vgHash; // key:vgId, value:SVgroupInfo
|
SHashObj* vgHash; // key:vgId, value:SVgroupInfo
|
||||||
} SDBVgInfo;
|
} SDBVgInfo;
|
||||||
|
|
||||||
|
@ -203,6 +204,8 @@ int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code);
|
||||||
|
|
||||||
void destroySendMsgInfo(SMsgSendInfo* pMsgBody);
|
void destroySendMsgInfo(SMsgSendInfo* pMsgBody);
|
||||||
|
|
||||||
|
void destroyAhandle(void* ahandle);
|
||||||
|
|
||||||
int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, SMsgSendInfo* pInfo,
|
int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, SMsgSendInfo* pInfo,
|
||||||
bool persistHandle, void* ctx);
|
bool persistHandle, void* ctx);
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ typedef int64_t SyncIndex;
|
||||||
typedef uint64_t SyncTerm;
|
typedef uint64_t SyncTerm;
|
||||||
|
|
||||||
typedef struct SSyncNode SSyncNode;
|
typedef struct SSyncNode SSyncNode;
|
||||||
typedef struct SSyncBuffer SSyncBuffer;
|
|
||||||
typedef struct SWal SWal;
|
typedef struct SWal SWal;
|
||||||
typedef struct SSyncRaftEntry SSyncRaftEntry;
|
typedef struct SSyncRaftEntry SSyncRaftEntry;
|
||||||
|
|
||||||
|
@ -139,6 +138,7 @@ typedef struct SSyncFSM {
|
||||||
void (*FpReConfigCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SReConfigCbMeta* pMeta);
|
void (*FpReConfigCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SReConfigCbMeta* pMeta);
|
||||||
void (*FpLeaderTransferCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
void (*FpLeaderTransferCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||||
bool (*FpApplyQueueEmptyCb)(const struct SSyncFSM* pFsm);
|
bool (*FpApplyQueueEmptyCb)(const struct SSyncFSM* pFsm);
|
||||||
|
int32_t (*FpApplyQueueItems)(const struct SSyncFSM* pFsm);
|
||||||
|
|
||||||
void (*FpBecomeLeaderCb)(const struct SSyncFSM* pFsm);
|
void (*FpBecomeLeaderCb)(const struct SSyncFSM* pFsm);
|
||||||
void (*FpBecomeFollowerCb)(const struct SSyncFSM* pFsm);
|
void (*FpBecomeFollowerCb)(const struct SSyncFSM* pFsm);
|
||||||
|
|
|
@ -72,15 +72,18 @@ typedef struct SRpcMsg {
|
||||||
typedef void (*RpcCfp)(void *parent, SRpcMsg *, SEpSet *epset);
|
typedef void (*RpcCfp)(void *parent, SRpcMsg *, SEpSet *epset);
|
||||||
typedef bool (*RpcRfp)(int32_t code, tmsg_t msgType);
|
typedef bool (*RpcRfp)(int32_t code, tmsg_t msgType);
|
||||||
typedef bool (*RpcTfp)(int32_t code, tmsg_t msgType);
|
typedef bool (*RpcTfp)(int32_t code, tmsg_t msgType);
|
||||||
|
typedef void (*RpcDfp)(void *ahandle);
|
||||||
|
|
||||||
typedef struct SRpcInit {
|
typedef struct SRpcInit {
|
||||||
char localFqdn[TSDB_FQDN_LEN];
|
char localFqdn[TSDB_FQDN_LEN];
|
||||||
uint16_t localPort; // local port
|
uint16_t localPort; // local port
|
||||||
char *label; // for debug purpose
|
char *label; // for debug purpose
|
||||||
int32_t numOfThreads; // number of threads to handle connections
|
int32_t numOfThreads; // number of threads to handle connections
|
||||||
int32_t sessions; // number of sessions allowed
|
int32_t sessions; // number of sessions allowed
|
||||||
int8_t connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
|
int8_t connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
|
||||||
int32_t idleTime; // milliseconds, 0 means idle timer is disabled
|
int32_t idleTime; // milliseconds, 0 means idle timer is disabled
|
||||||
|
int32_t retryLimit; // retry limit
|
||||||
|
int32_t retryInterval; // retry interval ms
|
||||||
|
|
||||||
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
||||||
int8_t encryption; // encrypt or not
|
int8_t encryption; // encrypt or not
|
||||||
|
@ -97,6 +100,9 @@ typedef struct SRpcInit {
|
||||||
// set up timeout for particular msg
|
// set up timeout for particular msg
|
||||||
RpcTfp tfp;
|
RpcTfp tfp;
|
||||||
|
|
||||||
|
// destroy client ahandle;
|
||||||
|
RpcDfp dfp;
|
||||||
|
|
||||||
void *parent;
|
void *parent;
|
||||||
} SRpcInit;
|
} SRpcInit;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ extern "C" {
|
||||||
|
|
||||||
#define TSKEY int64_t
|
#define TSKEY int64_t
|
||||||
#define TSKEY_MIN INT64_MIN
|
#define TSKEY_MIN INT64_MIN
|
||||||
#define TSKEY_MAX (INT64_MAX - 1)
|
#define TSKEY_MAX INT64_MAX
|
||||||
#define TSKEY_INITIAL_VAL TSKEY_MIN
|
#define TSKEY_INITIAL_VAL TSKEY_MIN
|
||||||
|
|
||||||
#define TD_VER_MAX UINT64_MAX // TODO: use the real max version from query handle
|
#define TD_VER_MAX UINT64_MAX // TODO: use the real max version from query handle
|
||||||
|
@ -290,7 +290,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_DEFAULT_VN_PER_DB 2
|
#define TSDB_DEFAULT_VN_PER_DB 2
|
||||||
#define TSDB_MIN_BUFFER_PER_VNODE 3 // unit MB
|
#define TSDB_MIN_BUFFER_PER_VNODE 3 // unit MB
|
||||||
#define TSDB_MAX_BUFFER_PER_VNODE 16384 // unit MB
|
#define TSDB_MAX_BUFFER_PER_VNODE 16384 // unit MB
|
||||||
#define TSDB_DEFAULT_BUFFER_PER_VNODE 96
|
#define TSDB_DEFAULT_BUFFER_PER_VNODE 256
|
||||||
#define TSDB_MIN_PAGES_PER_VNODE 64
|
#define TSDB_MIN_PAGES_PER_VNODE 64
|
||||||
#define TSDB_MAX_PAGES_PER_VNODE (INT32_MAX - 1)
|
#define TSDB_MAX_PAGES_PER_VNODE (INT32_MAX - 1)
|
||||||
#define TSDB_DEFAULT_PAGES_PER_VNODE 256
|
#define TSDB_DEFAULT_PAGES_PER_VNODE 256
|
||||||
|
|
|
@ -5,7 +5,7 @@ set -e
|
||||||
#set -x
|
#set -x
|
||||||
|
|
||||||
# dockerbuild.sh
|
# dockerbuild.sh
|
||||||
# -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...]
|
# -c [aarch32 | aarch64 | amd64 | x86 | mips64 | loongarch64...]
|
||||||
# -n [version number]
|
# -n [version number]
|
||||||
# -p [password for docker hub]
|
# -p [password for docker hub]
|
||||||
# -V [stable | beta]
|
# -V [stable | beta]
|
||||||
|
@ -57,7 +57,7 @@ do
|
||||||
dockerLatest=$(echo $OPTARG)
|
dockerLatest=$(echo $OPTARG)
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] "
|
echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 | loongarch64...] "
|
||||||
echo " -n [version number] "
|
echo " -n [version number] "
|
||||||
echo " -p [password for docker hub] "
|
echo " -p [password for docker hub] "
|
||||||
echo " -V [stable | beta] "
|
echo " -V [stable | beta] "
|
||||||
|
@ -136,4 +136,4 @@ if [ "$cloudBuild" != "y" ] && [ ${dockerLatest} == 'y' ] ;then
|
||||||
docker push tdengine/tdengine-${dockername}:latest
|
docker push tdengine/tdengine-${dockername}:latest
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f ${pkgFile}
|
rm -f ${pkgFile}
|
||||||
|
|
|
@ -5,7 +5,7 @@ set -e
|
||||||
#set -x
|
#set -x
|
||||||
|
|
||||||
# dockerbuild.sh
|
# dockerbuild.sh
|
||||||
# -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...]
|
# -c [aarch32 | aarch64 | amd64 | x86 | mips64 | loongarch64...]
|
||||||
# -n [version number]
|
# -n [version number]
|
||||||
# -p [password for docker hub]
|
# -p [password for docker hub]
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ do
|
||||||
passWord=$(echo $OPTARG)
|
passWord=$(echo $OPTARG)
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] "
|
echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 | loongarch64...] "
|
||||||
echo " -n [version number] "
|
echo " -n [version number] "
|
||||||
echo " -p [password for docker hub] "
|
echo " -p [password for docker hub] "
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -6,7 +6,7 @@ set -e
|
||||||
#set -x
|
#set -x
|
||||||
|
|
||||||
# release.sh -v [cluster | edge]
|
# release.sh -v [cluster | edge]
|
||||||
# -c [aarch32 | aarch64 | x64 | x86 | mips64 ...]
|
# -c [aarch32 | aarch64 | x64 | x86 | mips64 | loongarch64...]
|
||||||
# -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
|
# -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
|
||||||
# -V [stable | beta]
|
# -V [stable | beta]
|
||||||
# -l [full | lite]
|
# -l [full | lite]
|
||||||
|
@ -19,7 +19,7 @@ set -e
|
||||||
# set parameters by default value
|
# set parameters by default value
|
||||||
verMode=edge # [cluster, edge, cloud]
|
verMode=edge # [cluster, edge, cloud]
|
||||||
verType=stable # [stable, beta]
|
verType=stable # [stable, beta]
|
||||||
cpuType=x64 # [aarch32 | aarch64 | x64 | x86 | mips64 ...]
|
cpuType=x64 # [aarch32 | aarch64 | x64 | x86 | mips64 loongarch64...]
|
||||||
osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
|
osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
|
||||||
pagMode=full # [full | lite]
|
pagMode=full # [full | lite]
|
||||||
soMode=dynamic # [static | dynamic]
|
soMode=dynamic # [static | dynamic]
|
||||||
|
@ -77,7 +77,7 @@ while getopts "hv:V:c:o:l:s:d:a:n:m:H:" arg; do
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
echo "Usage: $(basename $0) -v [cluster | edge] "
|
echo "Usage: $(basename $0) -v [cluster | edge] "
|
||||||
echo " -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] "
|
echo " -c [aarch32 | aarch64 | x64 | x86 | mips64 | loongarch64 ...] "
|
||||||
echo " -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] "
|
echo " -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] "
|
||||||
echo " -V [stable | beta] "
|
echo " -V [stable | beta] "
|
||||||
echo " -l [full | lite] "
|
echo " -l [full | lite] "
|
||||||
|
@ -216,7 +216,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check support cpu type
|
# check support cpu type
|
||||||
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "arm64" ]] || [[ "$cpuType" == "arm32" ]] || [[ "$cpuType" == "mips64" ]]; then
|
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "arm64" ]] || [[ "$cpuType" == "arm32" ]] || [[ "$cpuType" == "mips64" ]] || [[ "$cpuType" == "loongarch64" ]] ; then
|
||||||
if [ "$verMode" == "edge" ]; then
|
if [ "$verMode" == "edge" ]; then
|
||||||
# community-version compile
|
# community-version compile
|
||||||
cmake ../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
|
cmake ../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
|
||||||
|
|
|
@ -140,12 +140,15 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
||||||
rpcInit.numOfThreads = numOfThread;
|
rpcInit.numOfThreads = numOfThread;
|
||||||
rpcInit.cfp = processMsgFromServer;
|
rpcInit.cfp = processMsgFromServer;
|
||||||
rpcInit.rfp = clientRpcRfp;
|
rpcInit.rfp = clientRpcRfp;
|
||||||
// rpcInit.tfp = clientRpcTfp;
|
|
||||||
rpcInit.sessions = 1024;
|
rpcInit.sessions = 1024;
|
||||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||||
rpcInit.user = (char *)user;
|
rpcInit.user = (char *)user;
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.compressSize = tsCompressMsgSize;
|
rpcInit.compressSize = tsCompressMsgSize;
|
||||||
|
rpcInit.dfp = destroyAhandle;
|
||||||
|
rpcInit.retryLimit = tsRpcRetryLimit;
|
||||||
|
rpcInit.retryInterval = tsRpcRetryInterval;
|
||||||
|
|
||||||
void *pDnodeConn = rpcOpen(&rpcInit);
|
void *pDnodeConn = rpcOpen(&rpcInit);
|
||||||
if (pDnodeConn == NULL) {
|
if (pDnodeConn == NULL) {
|
||||||
tscError("failed to init connection to server");
|
tscError("failed to init connection to server");
|
||||||
|
|
|
@ -61,7 +61,8 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
||||||
int32_t numOfBatchs = taosArrayGetSize(batchUseRsp.pArray);
|
int32_t numOfBatchs = taosArrayGetSize(batchUseRsp.pArray);
|
||||||
for (int32_t i = 0; i < numOfBatchs; ++i) {
|
for (int32_t i = 0; i < numOfBatchs; ++i) {
|
||||||
SUseDbRsp *rsp = taosArrayGet(batchUseRsp.pArray, i);
|
SUseDbRsp *rsp = taosArrayGet(batchUseRsp.pArray, i);
|
||||||
tscDebug("hb db rsp, db:%s, vgVersion:%d, uid:%" PRIx64, rsp->db, rsp->vgVersion, rsp->uid);
|
tscDebug("hb db rsp, db:%s, vgVersion:%d, stateTs:%" PRId64 ", uid:%" PRIx64, rsp->db, rsp->vgVersion, rsp->stateTs,
|
||||||
|
rsp->uid);
|
||||||
|
|
||||||
if (rsp->vgVersion < 0) {
|
if (rsp->vgVersion < 0) {
|
||||||
code = catalogRemoveDB(pCatalog, rsp->db, rsp->uid);
|
code = catalogRemoveDB(pCatalog, rsp->db, rsp->uid);
|
||||||
|
@ -72,6 +73,7 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
||||||
}
|
}
|
||||||
|
|
||||||
vgInfo->vgVersion = rsp->vgVersion;
|
vgInfo->vgVersion = rsp->vgVersion;
|
||||||
|
vgInfo->stateTs = rsp->stateTs;
|
||||||
vgInfo->hashMethod = rsp->hashMethod;
|
vgInfo->hashMethod = rsp->hashMethod;
|
||||||
vgInfo->hashPrefix = rsp->hashPrefix;
|
vgInfo->hashPrefix = rsp->hashPrefix;
|
||||||
vgInfo->hashSuffix = rsp->hashSuffix;
|
vgInfo->hashSuffix = rsp->hashSuffix;
|
||||||
|
@ -292,6 +294,7 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
taosThreadMutexUnlock(&appInfo.mutex);
|
taosThreadMutexUnlock(&appInfo.mutex);
|
||||||
tscError("cluster not exist, key:%s", key);
|
tscError("cluster not exist, key:%s", key);
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
|
taosMemoryFree(pMsg->pEpSet);
|
||||||
tFreeClientHbBatchRsp(&pRsp);
|
tFreeClientHbBatchRsp(&pRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -321,6 +324,7 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
|
|
||||||
tFreeClientHbBatchRsp(&pRsp);
|
tFreeClientHbBatchRsp(&pRsp);
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
|
taosMemoryFree(pMsg->pEpSet);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,6 +490,7 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl
|
||||||
db->dbId = htobe64(db->dbId);
|
db->dbId = htobe64(db->dbId);
|
||||||
db->vgVersion = htonl(db->vgVersion);
|
db->vgVersion = htonl(db->vgVersion);
|
||||||
db->numOfTable = htonl(db->numOfTable);
|
db->numOfTable = htonl(db->numOfTable);
|
||||||
|
db->stateTs = htobe64(db->stateTs);
|
||||||
}
|
}
|
||||||
|
|
||||||
SKv kv = {
|
SKv kv = {
|
||||||
|
|
|
@ -1971,6 +1971,8 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.compressSize = tsCompressMsgSize;
|
rpcInit.compressSize = tsCompressMsgSize;
|
||||||
rpcInit.user = "_dnd";
|
rpcInit.user = "_dnd";
|
||||||
|
rpcInit.retryLimit = tsRpcRetryLimit;
|
||||||
|
rpcInit.retryInterval = tsRpcRetryInterval;
|
||||||
|
|
||||||
clientRpc = rpcOpen(&rpcInit);
|
clientRpc = rpcOpen(&rpcInit);
|
||||||
if (clientRpc == NULL) {
|
if (clientRpc == NULL) {
|
||||||
|
|
|
@ -990,7 +990,7 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
// all data has returned to App already, no need to try again
|
// all data has returned to App already, no need to try again
|
||||||
if (pResultInfo->completed) {
|
if (pResultInfo->completed) {
|
||||||
// it is a local executed query, no need to do async fetch
|
// it is a local executed query, no need to do async fetch
|
||||||
if (QUERY_EXEC_MODE_LOCAL == pRequest->body.execMode) {
|
if (QUERY_EXEC_MODE_SCHEDULE != pRequest->body.execMode) {
|
||||||
if (pResultInfo->localResultFetched) {
|
if (pResultInfo->localResultFetched) {
|
||||||
pResultInfo->numOfRows = 0;
|
pResultInfo->numOfRows = 0;
|
||||||
pResultInfo->current = 0;
|
pResultInfo->current = 0;
|
||||||
|
|
|
@ -181,7 +181,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp);
|
tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp);
|
||||||
struct SCatalog* pCatalog = NULL;
|
struct SCatalog* pCatalog = NULL;
|
||||||
|
|
||||||
if (usedbRsp.vgVersion >= 0) {
|
if (usedbRsp.vgVersion >= 0) { // cached in local
|
||||||
uint64_t clusterId = pRequest->pTscObj->pAppInfo->clusterId;
|
uint64_t clusterId = pRequest->pTscObj->pAppInfo->clusterId;
|
||||||
int32_t code1 = catalogGetHandle(clusterId, &pCatalog);
|
int32_t code1 = catalogGetHandle(clusterId, &pCatalog);
|
||||||
if (code1 != TSDB_CODE_SUCCESS) {
|
if (code1 != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -442,8 +442,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
|
||||||
(*pRsp)->numOfRows = htonl(pBlock->info.rows);
|
(*pRsp)->numOfRows = htonl(pBlock->info.rows);
|
||||||
(*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS);
|
(*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS);
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = blockEncode(pBlock, (*pRsp)->data, SHOW_VARIABLES_RESULT_COLS);
|
||||||
blockEncode(pBlock, (*pRsp)->data, &len, SHOW_VARIABLES_RESULT_COLS, false);
|
|
||||||
ASSERT(len == rspSize - sizeof(SRetrieveTableRsp));
|
ASSERT(len == rspSize - sizeof(SRetrieveTableRsp));
|
||||||
|
|
||||||
blockDataDestroy(pBlock);
|
blockDataDestroy(pBlock);
|
||||||
|
|
|
@ -2082,7 +2082,7 @@ static int32_t smlParseJSONString(SSmlHandle *info, cJSON *root, SSmlTableInfo *
|
||||||
|
|
||||||
static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql, const int len) {
|
static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql, const int len) {
|
||||||
SSmlLineInfo elements = {0};
|
SSmlLineInfo elements = {0};
|
||||||
uDebug("SML:0x%" PRIx64 " smlParseInfluxLine sql:%s, hello", info->id, sql);
|
uDebug("SML:0x%" PRIx64 " smlParseInfluxLine sql", info->id);
|
||||||
|
|
||||||
int ret = smlParseInfluxString(sql, sql + len, &elements, &info->msgBuf);
|
int ret = smlParseInfluxString(sql, sql + len, &elements, &info->msgBuf);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -334,10 +334,12 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p
|
||||||
}
|
}
|
||||||
|
|
||||||
pColumnInfoData->varmeta.length = pSource->varmeta.length;
|
pColumnInfoData->varmeta.length = pSource->varmeta.length;
|
||||||
memcpy(pColumnInfoData->pData, pSource->pData, pSource->varmeta.length);
|
if (pColumnInfoData->pData != NULL && pSource->pData != NULL) {
|
||||||
|
memcpy(pColumnInfoData->pData, pSource->pData, pSource->varmeta.length);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
memcpy(pColumnInfoData->nullbitmap, pSource->nullbitmap, BitmapLen(numOfRows));
|
memcpy(pColumnInfoData->nullbitmap, pSource->nullbitmap, BitmapLen(numOfRows));
|
||||||
if (pSource->pData) {
|
if (pSource->pData != NULL) {
|
||||||
memcpy(pColumnInfoData->pData, pSource->pData, pSource->info.bytes * numOfRows);
|
memcpy(pColumnInfoData->pData, pSource->pData, pSource->info.bytes * numOfRows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2197,7 +2199,9 @@ char* buildCtbNameByGroupId(const char* stbFullName, uint64_t groupId) {
|
||||||
return rname.ctbShortName;
|
return rname.ctbShortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress) {
|
int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols) {
|
||||||
|
int32_t dataLen = 0;
|
||||||
|
|
||||||
// todo extract method
|
// todo extract method
|
||||||
int32_t* version = (int32_t*)data;
|
int32_t* version = (int32_t*)data;
|
||||||
*version = 1;
|
*version = 1;
|
||||||
|
@ -2238,7 +2242,7 @@ void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_
|
||||||
int32_t* colSizes = (int32_t*)data;
|
int32_t* colSizes = (int32_t*)data;
|
||||||
data += numOfCols * sizeof(int32_t);
|
data += numOfCols * sizeof(int32_t);
|
||||||
|
|
||||||
*dataLen = blockDataGetSerialMetaSize(numOfCols);
|
dataLen = blockDataGetSerialMetaSize(numOfCols);
|
||||||
|
|
||||||
int32_t numOfRows = pBlock->info.rows;
|
int32_t numOfRows = pBlock->info.rows;
|
||||||
for (int32_t col = 0; col < numOfCols; ++col) {
|
for (int32_t col = 0; col < numOfCols; ++col) {
|
||||||
|
@ -2255,26 +2259,25 @@ void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
data += metaSize;
|
data += metaSize;
|
||||||
(*dataLen) += metaSize;
|
dataLen += metaSize;
|
||||||
|
|
||||||
if (needCompress) {
|
colSizes[col] = colDataGetLength(pColRes, numOfRows);
|
||||||
colSizes[col] = blockCompressColData(pColRes, numOfRows, data, needCompress);
|
dataLen += colSizes[col];
|
||||||
data += colSizes[col];
|
if (pColRes->pData != NULL) {
|
||||||
(*dataLen) += colSizes[col];
|
|
||||||
} else {
|
|
||||||
colSizes[col] = colDataGetLength(pColRes, numOfRows);
|
|
||||||
(*dataLen) += colSizes[col];
|
|
||||||
memmove(data, pColRes->pData, colSizes[col]);
|
memmove(data, pColRes->pData, colSizes[col]);
|
||||||
data += colSizes[col];
|
|
||||||
}
|
}
|
||||||
|
data += colSizes[col];
|
||||||
|
|
||||||
colSizes[col] = htonl(colSizes[col]);
|
colSizes[col] = htonl(colSizes[col]);
|
||||||
}
|
}
|
||||||
|
|
||||||
*actualLen = *dataLen;
|
*actualLen = dataLen;
|
||||||
*groupId = pBlock->info.groupId;
|
*groupId = pBlock->info.groupId;
|
||||||
ASSERT(*dataLen > 0);
|
ASSERT(dataLen > 0);
|
||||||
uDebug("build data block, actualLen:%d, rows:%d, cols:%d", *dataLen, *rows, *cols);
|
|
||||||
|
uDebug("build data block, actualLen:%d, rows:%d, cols:%d", dataLen, *rows, *cols);
|
||||||
|
|
||||||
|
return dataLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
|
const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
|
||||||
|
|
|
@ -1557,7 +1557,7 @@ void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal) {
|
||||||
tColDataGetValueImpl[pColData->flag](pColData, iVal, pColVal);
|
tColDataGetValueImpl[pColData->flag](pColData, iVal, pColVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t tColDataGetBitValue(SColData *pColData, int32_t iVal) {
|
uint8_t tColDataGetBitValue(const SColData *pColData, int32_t iVal) {
|
||||||
uint8_t v;
|
uint8_t v;
|
||||||
switch (pColData->flag) {
|
switch (pColData->flag) {
|
||||||
case HAS_NONE:
|
case HAS_NONE:
|
||||||
|
|
|
@ -163,10 +163,12 @@ int32_t tsMqRebalanceInterval = 2;
|
||||||
int32_t tsTtlUnit = 86400;
|
int32_t tsTtlUnit = 86400;
|
||||||
int32_t tsTtlPushInterval = 86400;
|
int32_t tsTtlPushInterval = 86400;
|
||||||
int32_t tsGrantHBInterval = 60;
|
int32_t tsGrantHBInterval = 60;
|
||||||
int32_t tsUptimeInterval = 300; // seconds
|
int32_t tsUptimeInterval = 300; // seconds
|
||||||
char tsUdfdResFuncs[512] = ""; // udfd resident funcs that teardown when udfd exits
|
char tsUdfdResFuncs[512] = ""; // udfd resident funcs that teardown when udfd exits
|
||||||
char tsUdfdLdLibPath[512] = "";
|
char tsUdfdLdLibPath[512] = "";
|
||||||
|
|
||||||
|
int32_t tsRpcRetryLimit = 100;
|
||||||
|
int32_t tsRpcRetryInterval = 15;
|
||||||
#ifndef _STORAGE
|
#ifndef _STORAGE
|
||||||
int32_t taosSetTfsCfg(SConfig *pCfg) {
|
int32_t taosSetTfsCfg(SConfig *pCfg) {
|
||||||
SConfigItem *pItem = cfgGetItem(pCfg, "dataDir");
|
SConfigItem *pItem = cfgGetItem(pCfg, "dataDir");
|
||||||
|
@ -297,6 +299,8 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
||||||
if (cfgAddString(pCfg, "smlTagName", tsSmlTagName, 1) != 0) return -1;
|
if (cfgAddString(pCfg, "smlTagName", tsSmlTagName, 1) != 0) return -1;
|
||||||
if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1;
|
if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "maxMemUsedByInsert", tsMaxMemUsedByInsert, 1, INT32_MAX, true) != 0) return -1;
|
if (cfgAddInt32(pCfg, "maxMemUsedByInsert", tsMaxMemUsedByInsert, 1, INT32_MAX, true) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "rpcRetryLimit", tsRpcRetryLimit, 1, 100000, 0) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "rpcRetryInterval", tsRpcRetryInterval, 1, 100000, 0) != 0) return -1;
|
||||||
|
|
||||||
tsNumOfTaskQueueThreads = tsNumOfCores / 2;
|
tsNumOfTaskQueueThreads = tsNumOfCores / 2;
|
||||||
tsNumOfTaskQueueThreads = TMAX(tsNumOfTaskQueueThreads, 4);
|
tsNumOfTaskQueueThreads = TMAX(tsNumOfTaskQueueThreads, 4);
|
||||||
|
@ -422,6 +426,10 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
if (cfgAddBool(pCfg, "udf", tsStartUdfd, 0) != 0) return -1;
|
if (cfgAddBool(pCfg, "udf", tsStartUdfd, 0) != 0) return -1;
|
||||||
if (cfgAddString(pCfg, "udfdResFuncs", tsUdfdResFuncs, 0) != 0) return -1;
|
if (cfgAddString(pCfg, "udfdResFuncs", tsUdfdResFuncs, 0) != 0) return -1;
|
||||||
if (cfgAddString(pCfg, "udfdLdLibPath", tsUdfdLdLibPath, 0) != 0) return -1;
|
if (cfgAddString(pCfg, "udfdLdLibPath", tsUdfdLdLibPath, 0) != 0) return -1;
|
||||||
|
|
||||||
|
if (cfgAddInt32(pCfg, "rpcRetryLimit", tsRpcRetryLimit, 1, 100000, 0) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "rpcRetryInterval", tsRpcRetryInterval, 1, 100000, 0) != 0) return -1;
|
||||||
|
|
||||||
GRANT_CFG_ADD;
|
GRANT_CFG_ADD;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -634,6 +642,9 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
||||||
tsQueryNodeChunkSize = cfgGetItem(pCfg, "queryNodeChunkSize")->i32;
|
tsQueryNodeChunkSize = cfgGetItem(pCfg, "queryNodeChunkSize")->i32;
|
||||||
tsQueryUseNodeAllocator = cfgGetItem(pCfg, "queryUseNodeAllocator")->bval;
|
tsQueryUseNodeAllocator = cfgGetItem(pCfg, "queryUseNodeAllocator")->bval;
|
||||||
tsKeepColumnName = cfgGetItem(pCfg, "keepColumnName")->bval;
|
tsKeepColumnName = cfgGetItem(pCfg, "keepColumnName")->bval;
|
||||||
|
|
||||||
|
tsRpcRetryLimit = cfgGetItem(pCfg, "rpcRetryLimit")->i32;
|
||||||
|
tsRpcRetryInterval = cfgGetItem(pCfg, "rpcRetryInterval")->i32;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,6 +719,9 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
if (tsQueryBufferSize >= 0) {
|
if (tsQueryBufferSize >= 0) {
|
||||||
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tsRpcRetryLimit = cfgGetItem(pCfg, "rpcRetryLimit")->i32;
|
||||||
|
tsRpcRetryInterval = cfgGetItem(pCfg, "rpcRetryInterval")->i32;
|
||||||
GRANT_CFG_GET;
|
GRANT_CFG_GET;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,8 +307,7 @@ int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
pStart += sizeof(SSysTableSchema);
|
pStart += sizeof(SSysTableSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = blockEncode(pBlock, pStart, numOfCols);
|
||||||
blockEncode(pBlock, pStart, &len, numOfCols, false);
|
|
||||||
|
|
||||||
pRsp->numOfRows = htonl(pBlock->info.rows);
|
pRsp->numOfRows = htonl(pBlock->info.rows);
|
||||||
pRsp->precision = TSDB_TIME_PRECISION_MILLI; // millisecond time precision
|
pRsp->precision = TSDB_TIME_PRECISION_MILLI; // millisecond time precision
|
||||||
|
|
|
@ -183,8 +183,6 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_BATCH, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_BATCH, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
|
|
|
@ -450,8 +450,6 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_BATCH, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_BATCH, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -258,6 +258,8 @@ int32_t dmInitClient(SDnode *pDnode) {
|
||||||
rpcInit.parent = pDnode;
|
rpcInit.parent = pDnode;
|
||||||
rpcInit.rfp = rpcRfp;
|
rpcInit.rfp = rpcRfp;
|
||||||
rpcInit.compressSize = tsCompressMsgSize;
|
rpcInit.compressSize = tsCompressMsgSize;
|
||||||
|
rpcInit.retryLimit = tsRpcRetryLimit;
|
||||||
|
rpcInit.retryInterval = tsRpcRetryInterval;
|
||||||
|
|
||||||
pTrans->clientRpc = rpcOpen(&rpcInit);
|
pTrans->clientRpc = rpcOpen(&rpcInit);
|
||||||
if (pTrans->clientRpc == NULL) {
|
if (pTrans->clientRpc == NULL) {
|
||||||
|
|
|
@ -44,6 +44,7 @@ SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer);
|
||||||
SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw);
|
SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw);
|
||||||
|
|
||||||
int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer);
|
int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer);
|
||||||
|
int32_t mndSetConsumerDropLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer);
|
||||||
|
|
||||||
bool mndRebTryStart();
|
bool mndRebTryStart();
|
||||||
void mndRebEnd();
|
void mndRebEnd();
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
#define MND_CONSUMER_VER_NUMBER 1
|
#define MND_CONSUMER_VER_NUMBER 1
|
||||||
#define MND_CONSUMER_RESERVE_SIZE 64
|
#define MND_CONSUMER_RESERVE_SIZE 64
|
||||||
|
|
||||||
#define MND_CONSUMER_LOST_HB_CNT 3
|
#define MND_CONSUMER_LOST_HB_CNT 3
|
||||||
|
#define MND_CONSUMER_LOST_CLEAR_THRESHOLD 43200
|
||||||
|
|
||||||
static int8_t mqRebInExecCnt = 0;
|
static int8_t mqRebInExecCnt = 0;
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg);
|
||||||
static int32_t mndProcessMqHbReq(SRpcMsg *pMsg);
|
static int32_t mndProcessMqHbReq(SRpcMsg *pMsg);
|
||||||
static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg);
|
static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg);
|
||||||
static int32_t mndProcessConsumerLostMsg(SRpcMsg *pMsg);
|
static int32_t mndProcessConsumerLostMsg(SRpcMsg *pMsg);
|
||||||
|
static int32_t mndProcessConsumerClearMsg(SRpcMsg *pMsg);
|
||||||
static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg);
|
static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg);
|
||||||
|
|
||||||
int32_t mndInitConsumer(SMnode *pMnode) {
|
int32_t mndInitConsumer(SMnode *pMnode) {
|
||||||
|
@ -69,6 +71,7 @@ int32_t mndInitConsumer(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_TIMER, mndProcessMqTimerMsg);
|
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_TIMER, mndProcessMqTimerMsg);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_CONSUMER_LOST, mndProcessConsumerLostMsg);
|
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_CONSUMER_LOST, mndProcessConsumerLostMsg);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_CONSUMER_RECOVER, mndProcessConsumerRecoverMsg);
|
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_CONSUMER_RECOVER, mndProcessConsumerRecoverMsg);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_LOST_CONSUMER_CLEAR, mndProcessConsumerClearMsg);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONSUMERS, mndRetrieveConsumer);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONSUMERS, mndRetrieveConsumer);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONSUMERS, mndCancelGetNextConsumer);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONSUMERS, mndCancelGetNextConsumer);
|
||||||
|
@ -162,6 +165,43 @@ FAIL:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessConsumerClearMsg(SRpcMsg *pMsg) {
|
||||||
|
SMnode *pMnode = pMsg->info.node;
|
||||||
|
SMqConsumerClearMsg *pClearMsg = pMsg->pCont;
|
||||||
|
SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, pClearMsg->consumerId);
|
||||||
|
if (pConsumer == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
mInfo("receive consumer clear msg, consumer id %" PRId64 ", status %s", pClearMsg->consumerId,
|
||||||
|
mndConsumerStatusName(pConsumer->status));
|
||||||
|
|
||||||
|
if (pConsumer->status != MQ_CONSUMER_STATUS__LOST_REBD) {
|
||||||
|
mndReleaseConsumer(pMnode, pConsumer);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(pConsumer->consumerId, pConsumer->cgroup);
|
||||||
|
pConsumerNew->updateType = CONSUMER_UPDATE__LOST;
|
||||||
|
|
||||||
|
mndReleaseConsumer(pMnode, pConsumer);
|
||||||
|
|
||||||
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg, "clear-csm");
|
||||||
|
if (pTrans == NULL) goto FAIL;
|
||||||
|
if (mndSetConsumerDropLogs(pMnode, pTrans, pConsumerNew) != 0) goto FAIL;
|
||||||
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto FAIL;
|
||||||
|
|
||||||
|
tDeleteSMqConsumerObj(pConsumerNew);
|
||||||
|
taosMemoryFree(pConsumerNew);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return 0;
|
||||||
|
FAIL:
|
||||||
|
tDeleteSMqConsumerObj(pConsumerNew);
|
||||||
|
taosMemoryFree(pConsumerNew);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) {
|
static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) {
|
||||||
SMqRebInfo *pRebInfo = taosHashGet(pHash, key, strlen(key) + 1);
|
SMqRebInfo *pRebInfo = taosHashGet(pHash, key, strlen(key) + 1);
|
||||||
if (pRebInfo == NULL) {
|
if (pRebInfo == NULL) {
|
||||||
|
@ -206,15 +246,28 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
|
||||||
SMqConsumerLostMsg *pLostMsg = rpcMallocCont(sizeof(SMqConsumerLostMsg));
|
SMqConsumerLostMsg *pLostMsg = rpcMallocCont(sizeof(SMqConsumerLostMsg));
|
||||||
|
|
||||||
pLostMsg->consumerId = pConsumer->consumerId;
|
pLostMsg->consumerId = pConsumer->consumerId;
|
||||||
SRpcMsg pRpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
.msgType = TDMT_MND_TMQ_CONSUMER_LOST,
|
.msgType = TDMT_MND_TMQ_CONSUMER_LOST,
|
||||||
.pCont = pLostMsg,
|
.pCont = pLostMsg,
|
||||||
.contLen = sizeof(SMqConsumerLostMsg),
|
.contLen = sizeof(SMqConsumerLostMsg),
|
||||||
};
|
};
|
||||||
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &pRpcMsg);
|
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||||
}
|
}
|
||||||
if (status == MQ_CONSUMER_STATUS__LOST_REBD || status == MQ_CONSUMER_STATUS__READY) {
|
|
||||||
|
if (status == MQ_CONSUMER_STATUS__READY) {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
} else if (status == MQ_CONSUMER_STATUS__LOST_REBD) {
|
||||||
|
if (hbStatus > MND_CONSUMER_LOST_CLEAR_THRESHOLD) {
|
||||||
|
SMqConsumerClearMsg *pClearMsg = rpcMallocCont(sizeof(SMqConsumerClearMsg));
|
||||||
|
|
||||||
|
pClearMsg->consumerId = pConsumer->consumerId;
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.msgType = TDMT_MND_TMQ_LOST_CONSUMER_CLEAR,
|
||||||
|
.pCont = pClearMsg,
|
||||||
|
.contLen = sizeof(SMqConsumerClearMsg),
|
||||||
|
};
|
||||||
|
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||||
|
}
|
||||||
} else if (status == MQ_CONSUMER_STATUS__LOST) {
|
} else if (status == MQ_CONSUMER_STATUS__LOST) {
|
||||||
taosRLockLatch(&pConsumer->lock);
|
taosRLockLatch(&pConsumer->lock);
|
||||||
int32_t topicNum = taosArrayGetSize(pConsumer->currentTopics);
|
int32_t topicNum = taosArrayGetSize(pConsumer->currentTopics);
|
||||||
|
@ -444,6 +497,14 @@ FAIL:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t mndSetConsumerDropLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer) {
|
||||||
|
SSdbRaw *pCommitRaw = mndConsumerActionEncode(pConsumer);
|
||||||
|
if (pCommitRaw == NULL) return -1;
|
||||||
|
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1;
|
||||||
|
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED) != 0) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer) {
|
int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer) {
|
||||||
SSdbRaw *pCommitRaw = mndConsumerActionEncode(pConsumer);
|
SSdbRaw *pCommitRaw = mndConsumerActionEncode(pConsumer);
|
||||||
if (pCommitRaw == NULL) return -1;
|
if (pCommitRaw == NULL) return -1;
|
||||||
|
|
|
@ -606,7 +606,7 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
||||||
} else {
|
} else {
|
||||||
if (terrno == TSDB_CODE_MND_DB_IN_CREATING) {
|
if (terrno == TSDB_CODE_MND_DB_IN_CREATING) {
|
||||||
if (mndSetRpcInfoForDbTrans(pMnode, pReq, MND_OPER_CREATE_DB, createReq.db) == 0) {
|
if (mndSetRpcInfoForDbTrans(pMnode, pReq, MND_OPER_CREATE_DB, createReq.db) == 0) {
|
||||||
mInfo("db:%s, is creating and response after trans finished", createReq.db);
|
mInfo("db:%s, is creating and createdb response after trans finished", createReq.db);
|
||||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1175,7 +1175,7 @@ int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUs
|
||||||
|
|
||||||
int32_t numOfTable = mndGetDBTableNum(pDb, pMnode);
|
int32_t numOfTable = mndGetDBTableNum(pDb, pMnode);
|
||||||
|
|
||||||
if (pReq == NULL || pReq->vgVersion < pDb->vgVersion || pReq->dbId != pDb->uid || numOfTable != pReq->numOfTable) {
|
if (pReq == NULL || pReq->vgVersion < pDb->vgVersion || pReq->dbId != pDb->uid || numOfTable != pReq->numOfTable || pReq->stateTs < pDb->stateTs) {
|
||||||
mndBuildDBVgroupInfo(pDb, pMnode, pRsp->pVgroupInfos);
|
mndBuildDBVgroupInfo(pDb, pMnode, pRsp->pVgroupInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1225,6 +1225,14 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
|
||||||
usedbRsp.vgVersion = usedbReq.vgVersion;
|
usedbRsp.vgVersion = usedbReq.vgVersion;
|
||||||
usedbRsp.errCode = terrno;
|
usedbRsp.errCode = terrno;
|
||||||
|
|
||||||
|
if (terrno == TSDB_CODE_MND_DB_IN_CREATING) {
|
||||||
|
if (mndSetRpcInfoForDbTrans(pMnode, pReq, MND_OPER_CREATE_DB, usedbReq.db) == 0) {
|
||||||
|
mInfo("db:%s, is creating and usedb response after trans finished", usedbReq.db);
|
||||||
|
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mError("db:%s, failed to process use db req since %s", usedbReq.db, terrstr());
|
mError("db:%s, failed to process use db req since %s", usedbReq.db, terrstr());
|
||||||
} else {
|
} else {
|
||||||
if (mndCheckDbPrivilege(pMnode, pReq->info.conn.user, MND_OPER_USE_DB, pDb) != 0) {
|
if (mndCheckDbPrivilege(pMnode, pReq->info.conn.user, MND_OPER_USE_DB, pDb) != 0) {
|
||||||
|
@ -1255,7 +1263,7 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
|
||||||
pReq->info.rspLen = contLen;
|
pReq->info.rspLen = contLen;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != 0) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("db:%s, failed to process use db req since %s", usedbReq.db, terrstr());
|
mError("db:%s, failed to process use db req since %s", usedbReq.db, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1275,12 +1283,31 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfDbs; ++i) {
|
for (int32_t i = 0; i < numOfDbs; ++i) {
|
||||||
SDbVgVersion *pDbVgVersion = &pDbs[i];
|
SDbVgVersion *pDbVgVersion = &pDbs[i];
|
||||||
pDbVgVersion->dbId = htobe64(pDbVgVersion->dbId);
|
pDbVgVersion->dbId = be64toh(pDbVgVersion->dbId);
|
||||||
pDbVgVersion->vgVersion = htonl(pDbVgVersion->vgVersion);
|
pDbVgVersion->vgVersion = htonl(pDbVgVersion->vgVersion);
|
||||||
pDbVgVersion->numOfTable = htonl(pDbVgVersion->numOfTable);
|
pDbVgVersion->numOfTable = htonl(pDbVgVersion->numOfTable);
|
||||||
|
pDbVgVersion->stateTs = be64toh(pDbVgVersion->stateTs);
|
||||||
|
|
||||||
SUseDbRsp usedbRsp = {0};
|
SUseDbRsp usedbRsp = {0};
|
||||||
|
|
||||||
|
if ((0 == strcasecmp(pDbVgVersion->dbFName, TSDB_INFORMATION_SCHEMA_DB) || (0 == strcasecmp(pDbVgVersion->dbFName, TSDB_PERFORMANCE_SCHEMA_DB)))) {
|
||||||
|
memcpy(usedbRsp.db, pDbVgVersion->dbFName, TSDB_DB_FNAME_LEN);
|
||||||
|
int32_t vgVersion = mndGetGlobalVgroupVersion(pMnode);
|
||||||
|
if (pDbVgVersion->vgVersion < vgVersion) {
|
||||||
|
usedbRsp.pVgroupInfos = taosArrayInit(10, sizeof(SVgroupInfo));
|
||||||
|
|
||||||
|
mndBuildDBVgroupInfo(NULL, pMnode, usedbRsp.pVgroupInfos);
|
||||||
|
usedbRsp.vgVersion = vgVersion++;
|
||||||
|
} else {
|
||||||
|
usedbRsp.vgVersion = pDbVgVersion->vgVersion;
|
||||||
|
}
|
||||||
|
usedbRsp.vgNum = taosArrayGetSize(usedbRsp.pVgroupInfos);
|
||||||
|
|
||||||
|
taosArrayPush(batchUseRsp.pArray, &usedbRsp);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
SDbObj *pDb = mndAcquireDb(pMnode, pDbVgVersion->dbFName);
|
SDbObj *pDb = mndAcquireDb(pMnode, pDbVgVersion->dbFName);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
mTrace("db:%s, no exist", pDbVgVersion->dbFName);
|
mTrace("db:%s, no exist", pDbVgVersion->dbFName);
|
||||||
|
@ -1293,8 +1320,8 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
|
||||||
|
|
||||||
int32_t numOfTable = mndGetDBTableNum(pDb, pMnode);
|
int32_t numOfTable = mndGetDBTableNum(pDb, pMnode);
|
||||||
|
|
||||||
if (pDbVgVersion->vgVersion >= pDb->vgVersion && numOfTable == pDbVgVersion->numOfTable /* &&
|
if (pDbVgVersion->vgVersion >= pDb->vgVersion && numOfTable == pDbVgVersion->numOfTable &&
|
||||||
pDbVgVersion->stateTs == pDb->stateTs */) {
|
pDbVgVersion->stateTs == pDb->stateTs) {
|
||||||
mTrace("db:%s, valid dbinfo, vgVersion:%d stateTs:%" PRId64
|
mTrace("db:%s, valid dbinfo, vgVersion:%d stateTs:%" PRId64
|
||||||
" numOfTables:%d, not changed vgVersion:%d stateTs:%" PRId64 " numOfTables:%d",
|
" numOfTables:%d, not changed vgVersion:%d stateTs:%" PRId64 " numOfTables:%d",
|
||||||
pDbVgVersion->dbFName, pDbVgVersion->vgVersion, pDbVgVersion->stateTs, pDbVgVersion->numOfTable,
|
pDbVgVersion->dbFName, pDbVgVersion->vgVersion, pDbVgVersion->stateTs, pDbVgVersion->numOfTable,
|
||||||
|
|
|
@ -303,8 +303,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
|
||||||
pStart += sizeof(SSysTableSchema);
|
pStart += sizeof(SSysTableSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = blockEncode(pBlock, pStart, pShow->pMeta->numOfColumns);
|
||||||
blockEncode(pBlock, pStart, &len, pShow->pMeta->numOfColumns, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pRsp->numOfRows = htonl(rowsRead);
|
pRsp->numOfRows = htonl(rowsRead);
|
||||||
|
|
|
@ -532,6 +532,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
streamObj.sql = strdup(pCreate->sql);
|
streamObj.sql = strdup(pCreate->sql);
|
||||||
streamObj.smaId = smaObj.uid;
|
streamObj.smaId = smaObj.uid;
|
||||||
streamObj.watermark = pCreate->watermark;
|
streamObj.watermark = pCreate->watermark;
|
||||||
|
streamObj.fillHistory = STREAM_FILL_HISTORY_ON;
|
||||||
streamObj.trigger = STREAM_TRIGGER_WINDOW_CLOSE;
|
streamObj.trigger = STREAM_TRIGGER_WINDOW_CLOSE;
|
||||||
streamObj.triggerParam = pCreate->maxDelay;
|
streamObj.triggerParam = pCreate->maxDelay;
|
||||||
streamObj.ast = strdup(smaObj.ast);
|
streamObj.ast = strdup(smaObj.ast);
|
||||||
|
|
|
@ -205,8 +205,23 @@ static void mndBecomeLeader(const SSyncFSM *pFsm) {
|
||||||
static bool mndApplyQueueEmpty(const SSyncFSM *pFsm) {
|
static bool mndApplyQueueEmpty(const SSyncFSM *pFsm) {
|
||||||
SMnode *pMnode = pFsm->data;
|
SMnode *pMnode = pFsm->data;
|
||||||
|
|
||||||
int32_t itemSize = tmsgGetQueueSize(&pMnode->msgCb, 1, APPLY_QUEUE);
|
if (pMnode != NULL && pMnode->msgCb.qsizeFp != NULL) {
|
||||||
return (itemSize == 0);
|
int32_t itemSize = tmsgGetQueueSize(&pMnode->msgCb, 1, APPLY_QUEUE);
|
||||||
|
return (itemSize == 0);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndApplyQueueItems(const SSyncFSM *pFsm) {
|
||||||
|
SMnode *pMnode = pFsm->data;
|
||||||
|
|
||||||
|
if (pMnode != NULL && pMnode->msgCb.qsizeFp != NULL) {
|
||||||
|
int32_t itemSize = tmsgGetQueueSize(&pMnode->msgCb, 1, APPLY_QUEUE);
|
||||||
|
return itemSize;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
|
SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
|
||||||
|
@ -218,6 +233,7 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
|
||||||
pFsm->FpRestoreFinishCb = mndRestoreFinish;
|
pFsm->FpRestoreFinishCb = mndRestoreFinish;
|
||||||
pFsm->FpLeaderTransferCb = NULL;
|
pFsm->FpLeaderTransferCb = NULL;
|
||||||
pFsm->FpApplyQueueEmptyCb = mndApplyQueueEmpty;
|
pFsm->FpApplyQueueEmptyCb = mndApplyQueueEmpty;
|
||||||
|
pFsm->FpApplyQueueItems = mndApplyQueueItems;
|
||||||
pFsm->FpReConfigCb = NULL;
|
pFsm->FpReConfigCb = NULL;
|
||||||
pFsm->FpBecomeLeaderCb = mndBecomeLeader;
|
pFsm->FpBecomeLeaderCb = mndBecomeLeader;
|
||||||
pFsm->FpBecomeFollowerCb = mndBecomeFollower;
|
pFsm->FpBecomeFollowerCb = mndBecomeFollower;
|
||||||
|
@ -291,7 +307,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
||||||
|
|
||||||
SRpcMsg req = {.msgType = TDMT_MND_APPLY_MSG, .contLen = sdbGetRawTotalSize(pRaw)};
|
SRpcMsg req = {.msgType = TDMT_MND_APPLY_MSG, .contLen = sdbGetRawTotalSize(pRaw)};
|
||||||
if (req.contLen <= 0) return -1;
|
if (req.contLen <= 0) return -1;
|
||||||
|
|
||||||
req.pCont = rpcMallocCont(req.contLen);
|
req.pCont = rpcMallocCont(req.contLen);
|
||||||
if (req.pCont == NULL) return -1;
|
if (req.pCont == NULL) return -1;
|
||||||
memcpy(req.pCont, pRaw, req.contLen);
|
memcpy(req.pCont, pRaw, req.contLen);
|
||||||
|
|
|
@ -637,6 +637,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
if (pConsumer->status == MQ_CONSUMER_STATUS__LOST_REBD) continue;
|
if (pConsumer->status == MQ_CONSUMER_STATUS__LOST_REBD) continue;
|
||||||
|
|
||||||
int32_t sz = taosArrayGetSize(pConsumer->assignedTopics);
|
int32_t sz = taosArrayGetSize(pConsumer->assignedTopics);
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
char *name = taosArrayGetP(pConsumer->assignedTopics, i);
|
char *name = taosArrayGetP(pConsumer->assignedTopics, i);
|
||||||
|
@ -649,6 +650,33 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sz = taosArrayGetSize(pConsumer->rebNewTopics);
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
char *name = taosArrayGetP(pConsumer->rebNewTopics, i);
|
||||||
|
if (strcmp(name, pTopic->name) == 0) {
|
||||||
|
mndReleaseConsumer(pMnode, pConsumer);
|
||||||
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
|
terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED;
|
||||||
|
mError("topic:%s, failed to drop since subscribed by consumer:%" PRId64 ", in consumer group %s (reb new)",
|
||||||
|
dropReq.name, pConsumer->consumerId, pConsumer->cgroup);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sz = taosArrayGetSize(pConsumer->rebRemovedTopics);
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
char *name = taosArrayGetP(pConsumer->rebRemovedTopics, i);
|
||||||
|
if (strcmp(name, pTopic->name) == 0) {
|
||||||
|
mndReleaseConsumer(pMnode, pConsumer);
|
||||||
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
|
terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED;
|
||||||
|
mError("topic:%s, failed to drop since subscribed by consumer:%" PRId64 ", in consumer group %s (reb remove)",
|
||||||
|
dropReq.name, pConsumer->consumerId, pConsumer->cgroup);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sdbRelease(pSdb, pConsumer);
|
sdbRelease(pSdb, pConsumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,15 +703,6 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
mInfo("trans:%d, used to drop topic:%s", pTrans->id, pTopic->name);
|
mInfo("trans:%d, used to drop topic:%s", pTrans->id, pTopic->name);
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (mndDropOffsetByTopic(pMnode, pTrans, dropReq.name) < 0) {
|
|
||||||
ASSERT(0);
|
|
||||||
mndTransDrop(pTrans);
|
|
||||||
mndReleaseTopic(pMnode, pTopic);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO check if rebalancing
|
// TODO check if rebalancing
|
||||||
if (mndDropSubByTopic(pMnode, pTrans, dropReq.name) < 0) {
|
if (mndDropSubByTopic(pMnode, pTrans, dropReq.name) < 0) {
|
||||||
/*ASSERT(0);*/
|
/*ASSERT(0);*/
|
||||||
|
|
|
@ -938,11 +938,15 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
SRpcHandleInfo *pInfo = taosArrayGet(pTrans->pRpcArray, i);
|
SRpcHandleInfo *pInfo = taosArrayGet(pTrans->pRpcArray, i);
|
||||||
if (pInfo->handle != NULL) {
|
if (pInfo->handle != NULL) {
|
||||||
mInfo("trans:%d, send rsp, code:0x%x stage:%s app:%p", pTrans->id, code, mndTransStr(pTrans->stage),
|
|
||||||
pInfo->ahandle);
|
|
||||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
|
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
|
||||||
code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL;
|
code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL;
|
||||||
}
|
}
|
||||||
|
if (i != 0 && code == 0) {
|
||||||
|
code = TSDB_CODE_RPC_REDIRECT;
|
||||||
|
}
|
||||||
|
mInfo("trans:%d, client:%d send rsp, code:0x%x stage:%s app:%p", pTrans->id, i, code, mndTransStr(pTrans->stage),
|
||||||
|
pInfo->ahandle);
|
||||||
|
|
||||||
SRpcMsg rspMsg = {.code = code, .info = *pInfo};
|
SRpcMsg rspMsg = {.code = code, .info = *pInfo};
|
||||||
|
|
||||||
if (pTrans->originRpcType == TDMT_MND_CREATE_DB) {
|
if (pTrans->originRpcType == TDMT_MND_CREATE_DB) {
|
||||||
|
|
|
@ -70,6 +70,7 @@ int32_t metaCacheDrop(SMeta* pMeta, int64_t uid);
|
||||||
int32_t metaStatsCacheUpsert(SMeta* pMeta, SMetaStbStats* pInfo);
|
int32_t metaStatsCacheUpsert(SMeta* pMeta, SMetaStbStats* pInfo);
|
||||||
int32_t metaStatsCacheDrop(SMeta* pMeta, int64_t uid);
|
int32_t metaStatsCacheDrop(SMeta* pMeta, int64_t uid);
|
||||||
int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo);
|
int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo);
|
||||||
|
void metaUpdateStbStats(SMeta *pMeta, int64_t uid, int64_t delta);
|
||||||
|
|
||||||
struct SMeta {
|
struct SMeta {
|
||||||
TdThreadRwlock lock;
|
TdThreadRwlock lock;
|
||||||
|
|
|
@ -110,7 +110,6 @@ static FORCE_INLINE int64_t tsdbLogicToFileSize(int64_t lSize, int32_t szPage) {
|
||||||
#define tsdbRowFromBlockData(BLOCKDATA, IROW) ((TSDBROW){.type = 1, .pBlockData = (BLOCKDATA), .iRow = (IROW)})
|
#define tsdbRowFromBlockData(BLOCKDATA, IROW) ((TSDBROW){.type = 1, .pBlockData = (BLOCKDATA), .iRow = (IROW)})
|
||||||
void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal);
|
void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal);
|
||||||
int32_t tPutTSDBRow(uint8_t *p, TSDBROW *pRow);
|
int32_t tPutTSDBRow(uint8_t *p, TSDBROW *pRow);
|
||||||
int32_t tGetTSDBRow(uint8_t *p, TSDBROW *pRow);
|
|
||||||
int32_t tsdbRowCmprFn(const void *p1, const void *p2);
|
int32_t tsdbRowCmprFn(const void *p1, const void *p2);
|
||||||
// SRowIter
|
// SRowIter
|
||||||
void tRowIterInit(SRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema);
|
void tRowIterInit(SRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema);
|
||||||
|
@ -210,11 +209,10 @@ void tsdbRefMemTable(SMemTable *pMemTable);
|
||||||
void tsdbUnrefMemTable(SMemTable *pMemTable);
|
void tsdbUnrefMemTable(SMemTable *pMemTable);
|
||||||
SArray *tsdbMemTableGetTbDataArray(SMemTable *pMemTable);
|
SArray *tsdbMemTableGetTbDataArray(SMemTable *pMemTable);
|
||||||
// STbDataIter
|
// STbDataIter
|
||||||
int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter **ppIter);
|
int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter **ppIter);
|
||||||
void *tsdbTbDataIterDestroy(STbDataIter *pIter);
|
void *tsdbTbDataIterDestroy(STbDataIter *pIter);
|
||||||
void tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter *pIter);
|
void tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter *pIter);
|
||||||
TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter);
|
bool tsdbTbDataIterNext(STbDataIter *pIter);
|
||||||
bool tsdbTbDataIterNext(STbDataIter *pIter);
|
|
||||||
// STbData
|
// STbData
|
||||||
int32_t tsdbGetNRowsInTbData(STbData *pTbData);
|
int32_t tsdbGetNRowsInTbData(STbData *pTbData);
|
||||||
// tsdbFile.c ==============================================================================================
|
// tsdbFile.c ==============================================================================================
|
||||||
|
@ -772,6 +770,40 @@ static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SL_NODE_FORWARD(n, l) ((n)->forwards[l])
|
||||||
|
#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)])
|
||||||
|
#define SL_NODE_DATA(n) (&SL_NODE_BACKWARD(n, (n)->level))
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tGetTSDBRow(uint8_t *p, TSDBROW *pRow) {
|
||||||
|
int32_t n = tGetI64(p, &pRow->version);
|
||||||
|
pRow->pTSRow = (STSRow *)(p + n);
|
||||||
|
n += pRow->pTSRow->len;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter) {
|
||||||
|
if (pIter == NULL) return NULL;
|
||||||
|
|
||||||
|
if (pIter->pRow) {
|
||||||
|
return pIter->pRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pIter->backward) {
|
||||||
|
if (pIter->pNode == pIter->pTbData->sl.pHead) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (pIter->pNode == pIter->pTbData->sl.pTail) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tGetTSDBRow((uint8_t *)SL_NODE_DATA(pIter->pNode), &pIter->row);
|
||||||
|
pIter->pRow = &pIter->row;
|
||||||
|
|
||||||
|
return pIter->pRow;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -61,14 +61,14 @@ struct SVBufPoolNode {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SVBufPool {
|
struct SVBufPool {
|
||||||
SVBufPool* next;
|
SVBufPool* next;
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
volatile int32_t nRef;
|
TdThreadSpinlock* lock;
|
||||||
TdThreadSpinlock lock;
|
volatile int32_t nRef;
|
||||||
int64_t size;
|
int64_t size;
|
||||||
uint8_t* ptr;
|
uint8_t* ptr;
|
||||||
SVBufPoolNode* pTail;
|
SVBufPoolNode* pTail;
|
||||||
SVBufPoolNode node;
|
SVBufPoolNode node;
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t vnodeOpenBufPool(SVnode* pVnode);
|
int32_t vnodeOpenBufPool(SVnode* pVnode);
|
||||||
|
|
|
@ -1445,3 +1445,13 @@ int32_t metaGetStbStats(SMeta *pMeta, int64_t uid, SMetaStbStats *pInfo) {
|
||||||
_exit:
|
_exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void metaUpdateStbStats(SMeta *pMeta, int64_t uid, int64_t delta) {
|
||||||
|
SMetaStbStats stats = {0};
|
||||||
|
|
||||||
|
if (metaStatsCacheGet(pMeta, uid, &stats) == TSDB_CODE_SUCCESS) {
|
||||||
|
stats.ctbNum += delta;
|
||||||
|
|
||||||
|
metaStatsCacheUpsert(pMeta, &stats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -371,7 +371,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
// update uid index
|
// update uid index
|
||||||
metaUpdateUidIdx(pMeta, &nStbEntry);
|
metaUpdateUidIdx(pMeta, &nStbEntry);
|
||||||
|
|
||||||
metaStatsCacheDrop(pMeta, nStbEntry.uid);
|
// metaStatsCacheDrop(pMeta, nStbEntry.uid);
|
||||||
|
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
|
||||||
|
@ -450,6 +450,10 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq, STableMe
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
++pMeta->pVnode->config.vndStats.numOfCTables;
|
++pMeta->pVnode->config.vndStats.numOfCTables;
|
||||||
|
|
||||||
|
metaWLock(pMeta);
|
||||||
|
metaUpdateStbStats(pMeta, me.ctbEntry.suid, 1);
|
||||||
|
metaULock(pMeta);
|
||||||
} else {
|
} else {
|
||||||
me.ntbEntry.ctime = pReq->ctime;
|
me.ntbEntry.ctime = pReq->ctime;
|
||||||
me.ntbEntry.ttlDays = pReq->ttl;
|
me.ntbEntry.ttlDays = pReq->ttl;
|
||||||
|
@ -670,6 +674,8 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||||
tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), &pMeta->txn);
|
tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), &pMeta->txn);
|
||||||
|
|
||||||
--pMeta->pVnode->config.vndStats.numOfCTables;
|
--pMeta->pVnode->config.vndStats.numOfCTables;
|
||||||
|
|
||||||
|
metaUpdateStbStats(pMeta, e.ctbEntry.suid, -1);
|
||||||
} else if (e.type == TSDB_NORMAL_TABLE) {
|
} else if (e.type == TSDB_NORMAL_TABLE) {
|
||||||
// drop schema.db (todo)
|
// drop schema.db (todo)
|
||||||
|
|
||||||
|
|
|
@ -582,10 +582,10 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
code = -1;
|
code = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tqDebug("tmq poll: consumer %" PRId64 ", subkey %s, vg %d, send data blockNum:%d, offset type:%d, uid:%" PRId64
|
tqDebug("tmq poll: consumer %" PRId64
|
||||||
", version:%" PRId64 "",
|
", subkey %s, vg %d, send data blockNum:%d, offset type:%d, uid/version:%" PRId64 ", ts:%" PRId64 "",
|
||||||
consumerId, pHandle->subKey, TD_VID(pTq->pVnode), dataRsp.blockNum, dataRsp.rspOffset.type,
|
consumerId, pHandle->subKey, TD_VID(pTq->pVnode), dataRsp.blockNum, dataRsp.rspOffset.type,
|
||||||
dataRsp.rspOffset.uid, dataRsp.rspOffset.version);
|
dataRsp.rspOffset.uid, dataRsp.rspOffset.ts);
|
||||||
|
|
||||||
tDeleteSMqDataRsp(&dataRsp);
|
tDeleteSMqDataRsp(&dataRsp);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -27,9 +27,7 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t
|
||||||
pRetrieve->completed = 1;
|
pRetrieve->completed = 1;
|
||||||
pRetrieve->numOfRows = htonl(pBlock->info.rows);
|
pRetrieve->numOfRows = htonl(pBlock->info.rows);
|
||||||
|
|
||||||
// TODO enable compress
|
int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols);
|
||||||
int32_t actualLen = 0;
|
|
||||||
blockEncode(pBlock, pRetrieve->data, &actualLen, numOfCols, false);
|
|
||||||
actualLen += sizeof(SRetrieveTableRsp);
|
actualLen += sizeof(SRetrieveTableRsp);
|
||||||
ASSERT(actualLen <= dataStrLen);
|
ASSERT(actualLen <= dataStrLen);
|
||||||
taosArrayPush(pRsp->blockDataLen, &actualLen);
|
taosArrayPush(pRsp->blockDataLen, &actualLen);
|
||||||
|
|
|
@ -244,7 +244,7 @@ SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchem
|
||||||
|
|
||||||
int32_t rows = pDataBlock->info.rows;
|
int32_t rows = pDataBlock->info.rows;
|
||||||
|
|
||||||
tqDebug("tq sink, convert block %d, rows: %d", i, rows);
|
tqDebug("tq sink, convert block1 %d, rows: %d", i, rows);
|
||||||
|
|
||||||
int32_t dataLen = 0;
|
int32_t dataLen = 0;
|
||||||
int32_t schemaLen = 0;
|
int32_t schemaLen = 0;
|
||||||
|
@ -486,7 +486,7 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
|
||||||
blkHead->uid = 0;
|
blkHead->uid = 0;
|
||||||
blkHead->schemaLen = 0;
|
blkHead->schemaLen = 0;
|
||||||
|
|
||||||
tqDebug("tq sink, convert block %d, rows: %d", i, rows);
|
tqDebug("tq sink, convert block2 %d, rows: %d", i, rows);
|
||||||
|
|
||||||
int32_t dataLen = 0;
|
int32_t dataLen = 0;
|
||||||
void* blkSchema = POINTER_SHIFT(blkHead, sizeof(SSubmitBlk));
|
void* blkSchema = POINTER_SHIFT(blkHead, sizeof(SSubmitBlk));
|
||||||
|
@ -514,6 +514,9 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
|
||||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, pColumn->offset, k);
|
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, pColumn->offset, k);
|
||||||
} else {
|
} else {
|
||||||
void* colData = colDataGetData(pColData, j);
|
void* colData = colDataGetData(pColData, j);
|
||||||
|
if (k == 0) {
|
||||||
|
tqDebug("tq sink, row %d ts %" PRId64, j, *(int64_t*)colData);
|
||||||
|
}
|
||||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, colData, true, pColumn->offset, k);
|
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, colData, true, pColumn->offset, k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,7 +475,7 @@ _err:
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
static int32_t getTableDelIdx(SDelFReader *pDelFReader, tb_uid_t suid, tb_uid_t uid, SDelIdx *pDelIdx) {
|
static int32_t getTableDelIdx(SDelFReader *pDelFReader, tb_uid_t suid, tb_uid_t uid, SDelIdx *pDelIdx) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SArray *pDelIdxArray = NULL;
|
SArray *pDelIdxArray = NULL;
|
||||||
|
@ -499,7 +499,7 @@ _err:
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SFSLASTNEXTROW_FS,
|
SFSLASTNEXTROW_FS,
|
||||||
SFSLASTNEXTROW_FILESET,
|
SFSLASTNEXTROW_FILESET,
|
||||||
|
@ -997,8 +997,6 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
|
||||||
|
|
||||||
pIter->pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
|
pIter->pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
|
||||||
|
|
||||||
SDelIdx delIdx;
|
|
||||||
|
|
||||||
SDelFile *pDelFile = pReadSnap->fs.pDelFile;
|
SDelFile *pDelFile = pReadSnap->fs.pDelFile;
|
||||||
if (pDelFile) {
|
if (pDelFile) {
|
||||||
SDelFReader *pDelFReader;
|
SDelFReader *pDelFReader;
|
||||||
|
@ -1006,18 +1004,20 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
|
||||||
code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb);
|
code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = getTableDelIdx(pDelFReader, suid, uid, &delIdx);
|
SArray *pDelIdxArray = taosArrayInit(32, sizeof(SDelIdx));
|
||||||
if (code) {
|
|
||||||
tsdbDelFReaderClose(&pDelFReader);
|
code = tsdbReadDelIdx(pDelFReader, pDelIdxArray);
|
||||||
goto _err;
|
if (code) goto _err;
|
||||||
}
|
|
||||||
|
SDelIdx *delIdx = taosArraySearch(pDelIdxArray, &(SDelIdx){.suid = suid, .uid = uid}, tCmprDelIdx, TD_EQ);
|
||||||
code = getTableDelSkyline(pMem, pIMem, pDelFReader, &delIdx, pIter->pSkyline);
|
|
||||||
|
code = getTableDelSkyline(pMem, pIMem, pDelFReader, delIdx, pIter->pSkyline);
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbDelFReaderClose(&pDelFReader);
|
tsdbDelFReaderClose(&pDelFReader);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pDelIdxArray);
|
||||||
tsdbDelFReaderClose(&pDelFReader);
|
tsdbDelFReaderClose(&pDelFReader);
|
||||||
} else {
|
} else {
|
||||||
code = getTableDelSkyline(pMem, pIMem, NULL, NULL, pIter->pSkyline);
|
code = getTableDelSkyline(pMem, pIMem, NULL, NULL, pIter->pSkyline);
|
||||||
|
|
|
@ -495,6 +495,10 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
pCommitter->commitFid = tsdbKeyFid(pCommitter->nextKey, pCommitter->minutes, pCommitter->precision);
|
pCommitter->commitFid = tsdbKeyFid(pCommitter->nextKey, pCommitter->minutes, pCommitter->precision);
|
||||||
tsdbFidKeyRange(pCommitter->commitFid, pCommitter->minutes, pCommitter->precision, &pCommitter->minKey,
|
tsdbFidKeyRange(pCommitter->commitFid, pCommitter->minutes, pCommitter->precision, &pCommitter->minKey,
|
||||||
&pCommitter->maxKey);
|
&pCommitter->maxKey);
|
||||||
|
#if 0
|
||||||
|
ASSERT(pCommitter->minKey <= pCommitter->nextKey && pCommitter->maxKey >= pCommitter->nextKey);
|
||||||
|
#endif
|
||||||
|
|
||||||
pCommitter->nextKey = TSKEY_MAX;
|
pCommitter->nextKey = TSKEY_MAX;
|
||||||
|
|
||||||
// Reader
|
// Reader
|
||||||
|
|
|
@ -294,31 +294,6 @@ bool tsdbTbDataIterNext(STbDataIter *pIter) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter) {
|
|
||||||
// we add here for commit usage
|
|
||||||
if (pIter == NULL) return NULL;
|
|
||||||
|
|
||||||
if (pIter->pRow) {
|
|
||||||
goto _exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pIter->backward) {
|
|
||||||
if (pIter->pNode == pIter->pTbData->sl.pHead) {
|
|
||||||
goto _exit;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (pIter->pNode == pIter->pTbData->sl.pTail) {
|
|
||||||
goto _exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tGetTSDBRow((uint8_t *)SL_NODE_DATA(pIter->pNode), &pIter->row);
|
|
||||||
pIter->pRow = &pIter->row;
|
|
||||||
|
|
||||||
_exit:
|
|
||||||
return pIter->pRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t tsdbMemTableRehash(SMemTable *pMemTable) {
|
static int32_t tsdbMemTableRehash(SMemTable *pMemTable) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -483,11 +458,10 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int8_t tsdbMemSkipListRandLevel(SMemSkipList *pSl) {
|
static FORCE_INLINE int8_t tsdbMemSkipListRandLevel(SMemSkipList *pSl) {
|
||||||
int8_t level = 1;
|
int8_t level = 1;
|
||||||
int8_t tlevel = TMIN(pSl->maxLevel, pSl->level + 1);
|
int8_t tlevel = TMIN(pSl->maxLevel, pSl->level + 1);
|
||||||
const uint32_t factor = 4;
|
|
||||||
|
|
||||||
while ((taosRandR(&pSl->seed) % factor) == 0 && level < tlevel) {
|
while ((taosRandR(&pSl->seed) & 0x3) == 0 && level < tlevel) {
|
||||||
level++;
|
level++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,7 +567,9 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i
|
||||||
do {
|
do {
|
||||||
key.ts = row.pTSRow->ts;
|
key.ts = row.pTSRow->ts;
|
||||||
nRow++;
|
nRow++;
|
||||||
tbDataMovePosTo(pTbData, pos, &key, SL_MOVE_FROM_POS);
|
if (SL_NODE_FORWARD(pos[0], 0) != pTbData->sl.pTail) {
|
||||||
|
tbDataMovePosTo(pTbData, pos, &key, SL_MOVE_FROM_POS);
|
||||||
|
}
|
||||||
code = tbDataDoPut(pMemTable, pTbData, pos, &row, 1);
|
code = tbDataDoPut(pMemTable, pTbData, pos, &row, 1);
|
||||||
if (code) {
|
if (code) {
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
|
@ -893,7 +893,7 @@ static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int or
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getEndPosInDataBlock(STsdbReader* pReader, SBlockData* pBlockData, SDataBlk* pBlock, int32_t pos) {
|
static int32_t getEndPosInDataBlock(STsdbReader* pReader, SBlockData* pBlockData, SDataBlk* pBlock, int32_t pos) {
|
||||||
// NOTE: reverse the order to find the end position in data block
|
// NOTE: reverse the order to find the end position in data block
|
||||||
int32_t endPos = -1;
|
int32_t endPos = -1;
|
||||||
bool asc = ASCENDING_TRAVERSE(pReader->order);
|
bool asc = ASCENDING_TRAVERSE(pReader->order);
|
||||||
|
@ -910,6 +910,117 @@ int32_t getEndPosInDataBlock(STsdbReader* pReader, SBlockData* pBlockData, SData
|
||||||
return endPos;
|
return endPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void copyPrimaryTsCol(const SBlockData* pBlockData, SFileBlockDumpInfo* pDumpInfo, SColumnInfoData* pColData,
|
||||||
|
int32_t dumpedRows, bool asc) {
|
||||||
|
if (asc) {
|
||||||
|
memcpy(pColData->pData, &pBlockData->aTSKEY[pDumpInfo->rowIndex], dumpedRows * sizeof(int64_t));
|
||||||
|
} else {
|
||||||
|
int32_t startIndex = pDumpInfo->rowIndex - dumpedRows + 1;
|
||||||
|
memcpy(pColData->pData, &pBlockData->aTSKEY[startIndex], dumpedRows * sizeof(int64_t));
|
||||||
|
|
||||||
|
// todo: opt perf by extract the loop
|
||||||
|
// reverse the array list
|
||||||
|
int32_t mid = dumpedRows >> 1u;
|
||||||
|
int64_t* pts = (int64_t*)pColData->pData;
|
||||||
|
for (int32_t j = 0; j < mid; ++j) {
|
||||||
|
int64_t t = pts[j];
|
||||||
|
pts[j] = pts[dumpedRows - j - 1];
|
||||||
|
pts[dumpedRows - j - 1] = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// a faster version of copy procedure.
|
||||||
|
static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo, SColumnInfoData* pColData,
|
||||||
|
int32_t dumpedRows, bool asc) {
|
||||||
|
uint8_t* p = NULL;
|
||||||
|
if (asc) {
|
||||||
|
p = pData->pData + tDataTypes[pData->type].bytes * pDumpInfo->rowIndex;
|
||||||
|
} else {
|
||||||
|
int32_t startIndex = pDumpInfo->rowIndex - dumpedRows + 1;
|
||||||
|
p = pData->pData + tDataTypes[pData->type].bytes * startIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t step = asc? 1:-1;
|
||||||
|
|
||||||
|
// make sure it is aligned to 8bit
|
||||||
|
ASSERT((((uint64_t)pColData->pData) & (0x8 - 1)) == 0);
|
||||||
|
|
||||||
|
// 1. copy data in a batch model
|
||||||
|
memcpy(pColData->pData, p, dumpedRows * tDataTypes[pData->type].bytes);
|
||||||
|
|
||||||
|
// 2. reverse the array list in case of descending order scan data block
|
||||||
|
if (!asc) {
|
||||||
|
switch(pColData->info.type) {
|
||||||
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
|
{
|
||||||
|
int32_t mid = dumpedRows >> 1u;
|
||||||
|
int64_t* pts = (int64_t*)pColData->pData;
|
||||||
|
for (int32_t j = 0; j < mid; ++j) {
|
||||||
|
int64_t t = pts[j];
|
||||||
|
pts[j] = pts[dumpedRows - j - 1];
|
||||||
|
pts[dumpedRows - j - 1] = t;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
|
case TSDB_DATA_TYPE_UTINYINT: {
|
||||||
|
int32_t mid = dumpedRows >> 1u;
|
||||||
|
int8_t* pts = (int8_t*)pColData->pData;
|
||||||
|
for (int32_t j = 0; j < mid; ++j) {
|
||||||
|
int8_t t = pts[j];
|
||||||
|
pts[j] = pts[dumpedRows - j - 1];
|
||||||
|
pts[dumpedRows - j - 1] = t;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
|
case TSDB_DATA_TYPE_USMALLINT: {
|
||||||
|
int32_t mid = dumpedRows >> 1u;
|
||||||
|
int16_t* pts = (int16_t*)pColData->pData;
|
||||||
|
for (int32_t j = 0; j < mid; ++j) {
|
||||||
|
int64_t t = pts[j];
|
||||||
|
pts[j] = pts[dumpedRows - j - 1];
|
||||||
|
pts[dumpedRows - j - 1] = t;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
|
case TSDB_DATA_TYPE_INT:
|
||||||
|
case TSDB_DATA_TYPE_UINT: {
|
||||||
|
int32_t mid = dumpedRows >> 1u;
|
||||||
|
int32_t* pts = (int32_t*)pColData->pData;
|
||||||
|
for (int32_t j = 0; j < mid; ++j) {
|
||||||
|
int32_t t = pts[j];
|
||||||
|
pts[j] = pts[dumpedRows - j - 1];
|
||||||
|
pts[dumpedRows - j - 1] = t;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. if the null value exists, check items one-by-one
|
||||||
|
if (pData->flag != HAS_VALUE) {
|
||||||
|
int32_t rowIndex = 0;
|
||||||
|
|
||||||
|
for (int32_t j = pDumpInfo->rowIndex; rowIndex < dumpedRows; j += step, rowIndex++) {
|
||||||
|
uint8_t v = tColDataGetBitValue(pData, j);
|
||||||
|
if (v == 0 || v == 1) {
|
||||||
|
colDataSetNull_f(pColData->nullbitmap, rowIndex);
|
||||||
|
pColData->hasNull = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo) {
|
static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo) {
|
||||||
SReaderStatus* pStatus = &pReader->status;
|
SReaderStatus* pStatus = &pReader->status;
|
||||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||||
|
@ -949,24 +1060,17 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
}
|
}
|
||||||
|
|
||||||
endIndex += step;
|
endIndex += step;
|
||||||
int32_t remain = asc ? (endIndex - pDumpInfo->rowIndex) : (pDumpInfo->rowIndex - endIndex);
|
int32_t dumpedRows = asc ? (endIndex - pDumpInfo->rowIndex) : (pDumpInfo->rowIndex - endIndex);
|
||||||
if (remain > pReader->capacity) { // output buffer check
|
if (dumpedRows > pReader->capacity) { // output buffer check
|
||||||
remain = pReader->capacity;
|
dumpedRows = pReader->capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t i = 0;
|
||||||
int32_t rowIndex = 0;
|
int32_t rowIndex = 0;
|
||||||
|
|
||||||
int32_t i = 0;
|
|
||||||
SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, i);
|
SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, i);
|
||||||
if (pColData->info.colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
if (pColData->info.colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
if (asc) {
|
copyPrimaryTsCol(pBlockData, pDumpInfo, pColData, dumpedRows, asc);
|
||||||
memcpy(pColData->pData, &pBlockData->aTSKEY[pDumpInfo->rowIndex], remain * sizeof(int64_t));
|
|
||||||
} else {
|
|
||||||
for (int32_t j = pDumpInfo->rowIndex; rowIndex < remain; j += step) {
|
|
||||||
colDataAppendInt64(pColData, rowIndex++, &pBlockData->aTSKEY[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -981,23 +1085,12 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
colIndex += 1;
|
colIndex += 1;
|
||||||
} else if (pData->cid == pColData->info.colId) {
|
} else if (pData->cid == pColData->info.colId) {
|
||||||
if (pData->flag == HAS_NONE || pData->flag == HAS_NULL || pData->flag == (HAS_NULL | HAS_NONE)) {
|
if (pData->flag == HAS_NONE || pData->flag == HAS_NULL || pData->flag == (HAS_NULL | HAS_NONE)) {
|
||||||
colDataAppendNNULL(pColData, 0, remain);
|
colDataAppendNNULL(pColData, 0, dumpedRows);
|
||||||
} else {
|
} else {
|
||||||
if (IS_NUMERIC_TYPE(pColData->info.type) && asc) {
|
if (IS_MATHABLE_TYPE(pColData->info.type)) {
|
||||||
uint8_t* p = pData->pData + tDataTypes[pData->type].bytes * pDumpInfo->rowIndex;
|
copyNumericCols(pData, pDumpInfo, pColData, dumpedRows, asc);
|
||||||
memcpy(pColData->pData, p, remain * tDataTypes[pData->type].bytes);
|
} else { // varchar/nchar type
|
||||||
|
for (int32_t j = pDumpInfo->rowIndex; rowIndex < dumpedRows; j += step) {
|
||||||
// null value exists, check one-by-one
|
|
||||||
if (pData->flag != HAS_VALUE) {
|
|
||||||
for (int32_t j = pDumpInfo->rowIndex; rowIndex < remain; j += step, rowIndex++) {
|
|
||||||
uint8_t v = tColDataGetBitValue(pData, j);
|
|
||||||
if (v == 0 || v == 1) {
|
|
||||||
colDataSetNull_f(pColData->nullbitmap, rowIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int32_t j = pDumpInfo->rowIndex; rowIndex < remain; j += step) {
|
|
||||||
tColDataGetValue(pData, j, &cv);
|
tColDataGetValue(pData, j, &cv);
|
||||||
doCopyColVal(pColData, rowIndex++, i, &cv, pSupInfo);
|
doCopyColVal(pColData, rowIndex++, i, &cv, pSupInfo);
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1100,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
colIndex += 1;
|
colIndex += 1;
|
||||||
i += 1;
|
i += 1;
|
||||||
} else { // the specified column does not exist in file block, fill with null data
|
} else { // the specified column does not exist in file block, fill with null data
|
||||||
colDataAppendNNULL(pColData, 0, remain);
|
colDataAppendNNULL(pColData, 0, dumpedRows);
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1015,12 +1108,12 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
// fill the mis-matched columns with null value
|
// fill the mis-matched columns with null value
|
||||||
while (i < numOfOutputCols) {
|
while (i < numOfOutputCols) {
|
||||||
pColData = taosArrayGet(pResBlock->pDataBlock, i);
|
pColData = taosArrayGet(pResBlock->pDataBlock, i);
|
||||||
colDataAppendNNULL(pColData, 0, remain);
|
colDataAppendNNULL(pColData, 0, dumpedRows);
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pResBlock->info.rows = remain;
|
pResBlock->info.rows = dumpedRows;
|
||||||
pDumpInfo->rowIndex += step * remain;
|
pDumpInfo->rowIndex += step * dumpedRows;
|
||||||
|
|
||||||
// check if current block are all handled
|
// check if current block are all handled
|
||||||
if (pDumpInfo->rowIndex >= 0 && pDumpInfo->rowIndex < pBlock->nRow) {
|
if (pDumpInfo->rowIndex >= 0 && pDumpInfo->rowIndex < pBlock->nRow) {
|
||||||
|
@ -1039,7 +1132,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
int32_t unDumpedRows = asc ? pBlock->nRow - pDumpInfo->rowIndex : pDumpInfo->rowIndex + 1;
|
int32_t unDumpedRows = asc ? pBlock->nRow - pDumpInfo->rowIndex : pDumpInfo->rowIndex + 1;
|
||||||
tsdbDebug("%p copy file block to sdatablock, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64
|
tsdbDebug("%p copy file block to sdatablock, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64
|
||||||
", rows:%d, remain:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", elapsed time:%.2f ms, %s",
|
", rows:%d, remain:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", elapsed time:%.2f ms, %s",
|
||||||
pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, remain,
|
pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, dumpedRows,
|
||||||
unDumpedRows, pBlock->minVer, pBlock->maxVer, elapsedTime, pReader->idStr);
|
unDumpedRows, pBlock->minVer, pBlock->maxVer, elapsedTime, pReader->idStr);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -505,8 +505,8 @@ int32_t tsdbKeyFid(TSKEY key, int32_t minutes, int8_t precision) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsdbFidKeyRange(int32_t fid, int32_t minutes, int8_t precision, TSKEY *minKey, TSKEY *maxKey) {
|
void tsdbFidKeyRange(int32_t fid, int32_t minutes, int8_t precision, TSKEY *minKey, TSKEY *maxKey) {
|
||||||
*minKey = fid * minutes * tsTickPerMin[precision];
|
*minKey = tsTickPerMin[precision] * fid * minutes;
|
||||||
*maxKey = *minKey + minutes * tsTickPerMin[precision] - 1;
|
*maxKey = *minKey + tsTickPerMin[precision] * minutes - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFidLevel(int32_t fid, STsdbKeepCfg *pKeepCfg, int64_t now) {
|
int32_t tsdbFidLevel(int32_t fid, STsdbKeepCfg *pKeepCfg, int64_t now) {
|
||||||
|
@ -575,16 +575,6 @@ int32_t tPutTSDBRow(uint8_t *p, TSDBROW *pRow) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tGetTSDBRow(uint8_t *p, TSDBROW *pRow) {
|
|
||||||
int32_t n = 0;
|
|
||||||
|
|
||||||
n += tGetI64(p, &pRow->version);
|
|
||||||
pRow->pTSRow = (STSRow *)(p + n);
|
|
||||||
n += pRow->pTSRow->len;
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tsdbRowCmprFn(const void *p1, const void *p2) {
|
int32_t tsdbRowCmprFn(const void *p1, const void *p2) {
|
||||||
return tsdbKeyCmprFn(&TSDBROW_KEY((TSDBROW *)p1), &TSDBROW_KEY((TSDBROW *)p2));
|
return tsdbKeyCmprFn(&TSDBROW_KEY((TSDBROW *)p1), &TSDBROW_KEY((TSDBROW *)p2));
|
||||||
}
|
}
|
||||||
|
@ -1025,6 +1015,191 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t tBlockDataAppendBlockRow(SBlockData *pBlockData, SBlockData *pBlockDataFrom, int32_t iRow) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
SColVal cv = {0};
|
||||||
|
int32_t iColDataFrom = 0;
|
||||||
|
SColData *pColDataFrom =
|
||||||
|
(iColDataFrom < pBlockDataFrom->nColData) ? &((SColData *)pBlockDataFrom->aColData->pData)[iColDataFrom] : NULL;
|
||||||
|
|
||||||
|
for (int32_t iColDataTo = 0; iColDataTo < pBlockData->nColData; iColDataTo++) {
|
||||||
|
SColData *pColDataTo = &((SColData *)pBlockData->aColData->pData)[iColDataTo];
|
||||||
|
|
||||||
|
while (pColDataFrom && pColDataFrom->cid < pColDataTo->cid) {
|
||||||
|
iColDataFrom++;
|
||||||
|
pColDataFrom = (iColDataFrom < pBlockDataFrom->nColData)
|
||||||
|
? &((SColData *)pBlockDataFrom->aColData->pData)[iColDataFrom]
|
||||||
|
: NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pColDataFrom == NULL || pColDataFrom->cid > pColDataTo->cid) {
|
||||||
|
code = tColDataAppendValue(pColDataTo, &COL_VAL_NONE(pColDataTo->cid, pColDataTo->type));
|
||||||
|
if (code) goto _exit;
|
||||||
|
} else {
|
||||||
|
tColDataGetValue(pColDataFrom, iRow, &cv);
|
||||||
|
|
||||||
|
code = tColDataAppendValue(pColDataTo, &cv);
|
||||||
|
if (code) goto _exit;
|
||||||
|
|
||||||
|
iColDataFrom++;
|
||||||
|
pColDataFrom = (iColDataFrom < pBlockDataFrom->nColData)
|
||||||
|
? &((SColData *)pBlockDataFrom->aColData->pData)[iColDataFrom]
|
||||||
|
: NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tBlockDataAppendTPRow(SBlockData *pBlockData, STSRow *pRow, STSchema *pTSchema) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
int32_t iTColumn = 1;
|
||||||
|
STColumn *pTColumn = (iTColumn < pTSchema->numOfCols) ? &pTSchema->columns[iTColumn] : NULL;
|
||||||
|
void *pBitmap = pRow->statis ? tdGetBitmapAddrTp(pRow, pTSchema->flen) : NULL;
|
||||||
|
|
||||||
|
for (int32_t iColData = 0; iColData < pBlockData->nColData; iColData++) {
|
||||||
|
SColData *pColData = &((SColData *)pBlockData->aColData->pData)[iColData];
|
||||||
|
|
||||||
|
while (pTColumn && pTColumn->colId < pColData->cid) {
|
||||||
|
iTColumn++;
|
||||||
|
pTColumn = (iTColumn < pTSchema->numOfCols) ? &pTSchema->columns[iTColumn] : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTColumn == NULL || pTColumn->colId > pColData->cid) {
|
||||||
|
code = tColDataAppendValue(pColData, &COL_VAL_NONE(pColData->cid, pColData->type));
|
||||||
|
if (code) goto _exit;
|
||||||
|
} else {
|
||||||
|
ASSERT(pTColumn->type == pColData->type);
|
||||||
|
|
||||||
|
SColVal cv = {.cid = pTColumn->colId, .type = pTColumn->type};
|
||||||
|
|
||||||
|
if (pRow->statis) {
|
||||||
|
TDRowValT vt = TD_VTYPE_MAX;
|
||||||
|
tdGetBitmapValTypeII(pBitmap, iTColumn - 1, &vt);
|
||||||
|
|
||||||
|
if (vt == TD_VTYPE_NORM) {
|
||||||
|
cv.flag = CV_FLAG_VALUE;
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||||
|
void *pData = (char*)pRow + *(int32_t *)(pRow->data + pTColumn->offset - sizeof(TSKEY));
|
||||||
|
cv.value.nData = varDataLen(pData);
|
||||||
|
cv.value.pData = varDataVal(pData);
|
||||||
|
} else {
|
||||||
|
memcpy(&cv.value.val, pRow->data + pTColumn->offset - sizeof(TSKEY), pTColumn->bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tColDataAppendValue(pColData, &cv);
|
||||||
|
if (code) goto _exit;
|
||||||
|
} else if (vt == TD_VTYPE_NONE) {
|
||||||
|
code = tColDataAppendValue(pColData, &COL_VAL_NONE(pColData->cid, pColData->type));
|
||||||
|
if (code) goto _exit;
|
||||||
|
} else if (vt == TD_VTYPE_NULL) {
|
||||||
|
code = tColDataAppendValue(pColData, &COL_VAL_NULL(pColData->cid, pColData->type));
|
||||||
|
if (code) goto _exit;
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cv.flag = CV_FLAG_VALUE;
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||||
|
void *pData = (char*)pRow + *(int32_t *)(pRow->data + pTColumn->offset - sizeof(TSKEY));
|
||||||
|
cv.value.nData = varDataLen(pData);
|
||||||
|
cv.value.pData = varDataVal(pData);
|
||||||
|
} else {
|
||||||
|
memcpy(&cv.value.val, pRow->data + pTColumn->offset - sizeof(TSKEY), pTColumn->bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tColDataAppendValue(pColData, &cv);
|
||||||
|
if (code) goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
iTColumn++;
|
||||||
|
pTColumn = (iTColumn < pTSchema->numOfCols) ? &pTSchema->columns[iTColumn] : NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tBlockDataAppendKVRow(SBlockData *pBlockData, STSRow *pRow, STSchema *pTSchema) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
col_id_t kvIter = 0;
|
||||||
|
col_id_t nKvCols = tdRowGetNCols(pRow) - 1;
|
||||||
|
void *pColIdx = TD_ROW_COL_IDX(pRow);
|
||||||
|
void *pBitmap = tdGetBitmapAddrKv(pRow, tdRowGetNCols(pRow));
|
||||||
|
int32_t iTColumn = 1;
|
||||||
|
STColumn *pTColumn = (iTColumn < pTSchema->numOfCols) ? &pTSchema->columns[iTColumn] : NULL;
|
||||||
|
|
||||||
|
for (int32_t iColData = 0; iColData < pBlockData->nColData; iColData++) {
|
||||||
|
SColData *pColData = &((SColData *)pBlockData->aColData->pData)[iColData];
|
||||||
|
|
||||||
|
while (pTColumn && pTColumn->colId < pColData->cid) {
|
||||||
|
iTColumn++;
|
||||||
|
pTColumn = (iTColumn < pTSchema->numOfCols) ? &pTSchema->columns[iTColumn] : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTColumn == NULL || pTColumn->colId > pColData->cid) {
|
||||||
|
code = tColDataAppendValue(pColData, &COL_VAL_NONE(pColData->cid, pColData->type));
|
||||||
|
if (code) goto _exit;
|
||||||
|
} else {
|
||||||
|
ASSERT(pTColumn->type == pColData->type);
|
||||||
|
|
||||||
|
SColVal cv = {.cid = pTColumn->colId, .type = pTColumn->type};
|
||||||
|
TDRowValT vt = TD_VTYPE_NONE; // default is NONE
|
||||||
|
SKvRowIdx *pKvIdx = NULL;
|
||||||
|
|
||||||
|
while (kvIter < nKvCols) {
|
||||||
|
pKvIdx = (SKvRowIdx *)POINTER_SHIFT(pColIdx, kvIter * sizeof(SKvRowIdx));
|
||||||
|
if (pKvIdx->colId == pTColumn->colId) {
|
||||||
|
tdGetBitmapValTypeII(pBitmap, kvIter, &vt);
|
||||||
|
++kvIter;
|
||||||
|
break;
|
||||||
|
} else if (pKvIdx->colId > pTColumn->colId) {
|
||||||
|
vt = TD_VTYPE_NONE;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
++kvIter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vt == TD_VTYPE_NORM) {
|
||||||
|
cv.flag = CV_FLAG_VALUE;
|
||||||
|
|
||||||
|
void *pData = POINTER_SHIFT(pRow, pKvIdx->offset);
|
||||||
|
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||||
|
cv.value.nData = varDataLen(pData);
|
||||||
|
cv.value.pData = varDataVal(pData);
|
||||||
|
} else {
|
||||||
|
memcpy(&cv.value.val, pData, pTColumn->bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tColDataAppendValue(pColData, &cv);
|
||||||
|
if (code) goto _exit;
|
||||||
|
} else if (vt == TD_VTYPE_NONE) {
|
||||||
|
code = tColDataAppendValue(pColData, &COL_VAL_NONE(pColData->cid, pColData->type));
|
||||||
|
if (code) goto _exit;
|
||||||
|
} else if (vt == TD_VTYPE_NULL) {
|
||||||
|
code = tColDataAppendValue(pColData, &COL_VAL_NULL(pColData->cid, pColData->type));
|
||||||
|
if (code) goto _exit;
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
iTColumn++;
|
||||||
|
pTColumn = (iTColumn < pTSchema->numOfCols) ? &pTSchema->columns[iTColumn] : NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema, int64_t uid) {
|
int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema, int64_t uid) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -1046,27 +1221,20 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
pBlockData->aTSKEY[pBlockData->nRow] = TSDBROW_TS(pRow);
|
pBlockData->aTSKEY[pBlockData->nRow] = TSDBROW_TS(pRow);
|
||||||
|
|
||||||
// OTHER
|
SColVal cv = {0};
|
||||||
SRowIter rIter = {0};
|
if (pRow->type == 0) {
|
||||||
SColVal *pColVal;
|
if (TD_IS_TP_ROW(pRow->pTSRow)) {
|
||||||
|
code = tBlockDataAppendTPRow(pBlockData, pRow->pTSRow, pTSchema);
|
||||||
tRowIterInit(&rIter, pRow, pTSchema);
|
if (code) goto _err;
|
||||||
pColVal = tRowIterNext(&rIter);
|
} else if (TD_IS_KV_ROW(pRow->pTSRow)) {
|
||||||
for (int32_t iColData = 0; iColData < pBlockData->nColData; iColData++) {
|
code = tBlockDataAppendKVRow(pBlockData, pRow->pTSRow, pTSchema);
|
||||||
SColData *pColData = tBlockDataGetColDataByIdx(pBlockData, iColData);
|
|
||||||
|
|
||||||
while (pColVal && pColVal->cid < pColData->cid) {
|
|
||||||
pColVal = tRowIterNext(&rIter);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pColVal == NULL || pColVal->cid > pColData->cid) {
|
|
||||||
code = tColDataAppendValue(pColData, &COL_VAL_NONE(pColData->cid, pColData->type));
|
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
} else {
|
} else {
|
||||||
code = tColDataAppendValue(pColData, pColVal);
|
ASSERT(0);
|
||||||
if (code) goto _err;
|
|
||||||
pColVal = tRowIterNext(&rIter);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
code = tBlockDataAppendBlockRow(pBlockData, pRow->pBlockData, pRow->iRow);
|
||||||
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
pBlockData->nRow++;
|
pBlockData->nRow++;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,15 @@
|
||||||
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief max key by precision
|
||||||
|
* approximately calculation:
|
||||||
|
* ms: 3600*1000*8765*1000 // 1970 + 1000 years
|
||||||
|
* us: 3600*1000000*8765*1000 // 1970 + 1000 years
|
||||||
|
* ns: 3600*1000000000*8765*292 // 1970 + 292 years
|
||||||
|
*/
|
||||||
|
static int64_t tsMaxKeyByPrecision[] = {31556995200000L, 31556995200000000L, 9214646400000000000L};
|
||||||
|
|
||||||
// static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg);
|
// static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg);
|
||||||
|
|
||||||
int tsdbInsertData(STsdb *pTsdb, int64_t version, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
|
int tsdbInsertData(STsdb *pTsdb, int64_t version, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
|
||||||
|
@ -97,7 +106,7 @@ int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) {
|
||||||
STsdbKeepCfg *pCfg = &pTsdb->keepCfg;
|
STsdbKeepCfg *pCfg = &pTsdb->keepCfg;
|
||||||
TSKEY now = taosGetTimestamp(pCfg->precision);
|
TSKEY now = taosGetTimestamp(pCfg->precision);
|
||||||
TSKEY minKey = now - tsTickPerMin[pCfg->precision] * pCfg->keep2;
|
TSKEY minKey = now - tsTickPerMin[pCfg->precision] * pCfg->keep2;
|
||||||
TSKEY maxKey = now + tsTickPerMin[pCfg->precision] * pCfg->days;
|
TSKEY maxKey = tsMaxKeyByPrecision[pCfg->precision];
|
||||||
|
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
// pMsg->length = htonl(pMsg->length);
|
// pMsg->length = htonl(pMsg->length);
|
||||||
|
|
|
@ -27,10 +27,21 @@ static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosThreadSpinInit(&pPool->lock, 0) != 0) {
|
if (VND_IS_RSMA(pVnode)) {
|
||||||
taosMemoryFree(pPool);
|
pPool->lock = taosMemoryMalloc(sizeof(TdThreadSpinlock));
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
if (!pPool->lock) {
|
||||||
return -1;
|
taosMemoryFree(pPool);
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (taosThreadSpinInit(pPool->lock, 0) != 0) {
|
||||||
|
taosMemoryFree((void*)pPool->lock);
|
||||||
|
taosMemoryFree(pPool);
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pPool->lock = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pPool->next = NULL;
|
pPool->next = NULL;
|
||||||
|
@ -49,7 +60,10 @@ static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool)
|
||||||
|
|
||||||
static int vnodeBufPoolDestroy(SVBufPool *pPool) {
|
static int vnodeBufPoolDestroy(SVBufPool *pPool) {
|
||||||
vnodeBufPoolReset(pPool);
|
vnodeBufPoolReset(pPool);
|
||||||
taosThreadSpinDestroy(&pPool->lock);
|
if (pPool->lock) {
|
||||||
|
taosThreadSpinDestroy(pPool->lock);
|
||||||
|
taosMemoryFree((void*)pPool->lock);
|
||||||
|
}
|
||||||
taosMemoryFree(pPool);
|
taosMemoryFree(pPool);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +128,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
|
||||||
void *p = NULL;
|
void *p = NULL;
|
||||||
ASSERT(pPool != NULL);
|
ASSERT(pPool != NULL);
|
||||||
|
|
||||||
taosThreadSpinLock(&pPool->lock);
|
if (pPool->lock) taosThreadSpinLock(pPool->lock);
|
||||||
if (pPool->node.size >= pPool->ptr - pPool->node.data + size) {
|
if (pPool->node.size >= pPool->ptr - pPool->node.data + size) {
|
||||||
// allocate from the anchor node
|
// allocate from the anchor node
|
||||||
p = pPool->ptr;
|
p = pPool->ptr;
|
||||||
|
@ -125,7 +139,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
|
||||||
pNode = taosMemoryMalloc(sizeof(*pNode) + size);
|
pNode = taosMemoryMalloc(sizeof(*pNode) + size);
|
||||||
if (pNode == NULL) {
|
if (pNode == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
taosThreadSpinUnlock(&pPool->lock);
|
if (pPool->lock) taosThreadSpinUnlock(pPool->lock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +152,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
|
||||||
|
|
||||||
pPool->size = pPool->size + sizeof(*pNode) + size;
|
pPool->size = pPool->size + sizeof(*pNode) + size;
|
||||||
}
|
}
|
||||||
taosThreadSpinUnlock(&pPool->lock);
|
if (pPool->lock) taosThreadSpinUnlock(pPool->lock);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,12 @@ struct SVnodeGlobal vnodeGlobal;
|
||||||
|
|
||||||
static void* loop(void* arg);
|
static void* loop(void* arg);
|
||||||
|
|
||||||
|
static tsem_t canCommit = {0};
|
||||||
|
|
||||||
|
static void vnodeInitCommit() { tsem_init(&canCommit, 0, 4); };
|
||||||
|
void vnode_wait_commit() { tsem_wait(&canCommit); }
|
||||||
|
void vnode_done_commit() { tsem_wait(&canCommit); }
|
||||||
|
|
||||||
int vnodeInit(int nthreads) {
|
int vnodeInit(int nthreads) {
|
||||||
int8_t init;
|
int8_t init;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
|
@ -438,8 +438,24 @@ static void vnodeBecomeLeader(const SSyncFSM *pFsm) {
|
||||||
|
|
||||||
static bool vnodeApplyQueueEmpty(const SSyncFSM *pFsm) {
|
static bool vnodeApplyQueueEmpty(const SSyncFSM *pFsm) {
|
||||||
SVnode *pVnode = pFsm->data;
|
SVnode *pVnode = pFsm->data;
|
||||||
int32_t itemSize = tmsgGetQueueSize(&pVnode->msgCb, pVnode->config.vgId, APPLY_QUEUE);
|
|
||||||
return (itemSize == 0);
|
if (pVnode != NULL && pVnode->msgCb.qsizeFp != NULL) {
|
||||||
|
int32_t itemSize = tmsgGetQueueSize(&pVnode->msgCb, pVnode->config.vgId, APPLY_QUEUE);
|
||||||
|
return (itemSize == 0);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t vnodeApplyQueueItems(const SSyncFSM *pFsm) {
|
||||||
|
SVnode *pVnode = pFsm->data;
|
||||||
|
|
||||||
|
if (pVnode != NULL && pVnode->msgCb.qsizeFp != NULL) {
|
||||||
|
int32_t itemSize = tmsgGetQueueSize(&pVnode->msgCb, pVnode->config.vgId, APPLY_QUEUE);
|
||||||
|
return itemSize;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
||||||
|
@ -452,6 +468,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
||||||
pFsm->FpRestoreFinishCb = vnodeRestoreFinish;
|
pFsm->FpRestoreFinishCb = vnodeRestoreFinish;
|
||||||
pFsm->FpLeaderTransferCb = NULL;
|
pFsm->FpLeaderTransferCb = NULL;
|
||||||
pFsm->FpApplyQueueEmptyCb = vnodeApplyQueueEmpty;
|
pFsm->FpApplyQueueEmptyCb = vnodeApplyQueueEmpty;
|
||||||
|
pFsm->FpApplyQueueItems = vnodeApplyQueueItems;
|
||||||
pFsm->FpBecomeLeaderCb = vnodeBecomeLeader;
|
pFsm->FpBecomeLeaderCb = vnodeBecomeLeader;
|
||||||
pFsm->FpBecomeFollowerCb = vnodeBecomeFollower;
|
pFsm->FpBecomeFollowerCb = vnodeBecomeFollower;
|
||||||
pFsm->FpReConfigCb = NULL;
|
pFsm->FpReConfigCb = NULL;
|
||||||
|
|
|
@ -715,10 +715,10 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId, int32_t* tableNum) {
|
int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId, int32_t* tableNum, int64_t* pStateTs) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
if (NULL == pCtg || NULL == dbFName || NULL == version || NULL == dbId) {
|
if (NULL == pCtg || NULL == dbFName || NULL == version || NULL == dbId || NULL == tableNum || NULL == pStateTs) {
|
||||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1204,11 +1204,12 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
stbCtx.flag = flag;
|
stbCtx.flag = flag;
|
||||||
stbCtx.pName = &stbName;
|
stbCtx.pName = &stbName;
|
||||||
|
|
||||||
STableMeta *stbMeta = NULL;
|
STableMeta* stbMeta = NULL;
|
||||||
ctgReadTbMetaFromCache(pCtg, &stbCtx, &stbMeta);
|
ctgReadTbMetaFromCache(pCtg, &stbCtx, &stbMeta);
|
||||||
if (stbMeta && stbMeta->sversion >= pOut->tbMeta->sversion) {
|
if (stbMeta && stbMeta->sversion >= pOut->tbMeta->sversion) {
|
||||||
ctgDebug("use cached stb meta, tbName:%s", tNameGetTableName(pName));
|
ctgDebug("use cached stb meta, tbName:%s", tNameGetTableName(pName));
|
||||||
exist = 1;
|
exist = 1;
|
||||||
|
taosMemoryFreeClear(stbMeta);
|
||||||
} else {
|
} else {
|
||||||
ctgDebug("need to get/update stb meta, tbName:%s", tNameGetTableName(pName));
|
ctgDebug("need to get/update stb meta, tbName:%s", tNameGetTableName(pName));
|
||||||
taosMemoryFreeClear(pOut->tbMeta);
|
taosMemoryFreeClear(pOut->tbMeta);
|
||||||
|
@ -1998,6 +1999,7 @@ int32_t ctgLaunchGetDbInfoTask(SCtgTask* pTask) {
|
||||||
pInfo->vgVer = dbCache->vgCache.vgInfo->vgVersion;
|
pInfo->vgVer = dbCache->vgCache.vgInfo->vgVersion;
|
||||||
pInfo->dbId = dbCache->dbId;
|
pInfo->dbId = dbCache->dbId;
|
||||||
pInfo->tbNum = dbCache->vgCache.vgInfo->numOfTable;
|
pInfo->tbNum = dbCache->vgCache.vgInfo->numOfTable;
|
||||||
|
pInfo->stateTs = dbCache->vgCache.vgInfo->stateTs;
|
||||||
|
|
||||||
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
dbCache = NULL;
|
dbCache = NULL;
|
||||||
|
|
|
@ -72,8 +72,8 @@ void ctgRUnlockVgInfo(SCtgDBCache *dbCache) { CTG_UNLOCK(CTG_READ, &dbCache->vgC
|
||||||
|
|
||||||
void ctgWUnlockVgInfo(SCtgDBCache *dbCache) { CTG_UNLOCK(CTG_WRITE, &dbCache->vgCache.vgLock); }
|
void ctgWUnlockVgInfo(SCtgDBCache *dbCache) { CTG_UNLOCK(CTG_WRITE, &dbCache->vgCache.vgLock); }
|
||||||
|
|
||||||
void ctgReleaseDBCache(SCatalog *pCtg, SCtgDBCache *dbCache) {
|
void ctgReleaseDBCache(SCatalog *pCtg, SCtgDBCache *dbCache) {
|
||||||
CTG_UNLOCK(CTG_READ, &dbCache->dbLock);
|
CTG_UNLOCK(CTG_READ, &dbCache->dbLock);
|
||||||
taosHashRelease(pCtg->dbCache, dbCache);
|
taosHashRelease(pCtg->dbCache, dbCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ int32_t ctgAcquireDBCacheImpl(SCatalog *pCtg, const char *dbFName, SCtgDBCache *
|
||||||
} else {
|
} else {
|
||||||
dbCache = (SCtgDBCache *)taosHashGet(pCtg->dbCache, dbFName, strlen(dbFName));
|
dbCache = (SCtgDBCache *)taosHashGet(pCtg->dbCache, dbFName, strlen(dbFName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == dbCache) {
|
if (NULL == dbCache) {
|
||||||
*pCache = NULL;
|
*pCache = NULL;
|
||||||
ctgDebug("db not in cache, dbFName:%s", dbFName);
|
ctgDebug("db not in cache, dbFName:%s", dbFName);
|
||||||
|
@ -422,6 +422,7 @@ _return:
|
||||||
|
|
||||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||||
taosMemoryFreeClear(*pTableMeta);
|
taosMemoryFreeClear(*pTableMeta);
|
||||||
|
*pTableMeta = NULL;
|
||||||
|
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
@ -1231,14 +1232,16 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) {
|
||||||
|
|
||||||
CTG_CACHE_STAT_INC(numOfDb, 1);
|
CTG_CACHE_STAT_INC(numOfDb, 1);
|
||||||
|
|
||||||
SDbVgVersion vgVersion = {.dbId = newDBCache.dbId, .vgVersion = -1};
|
SDbVgVersion vgVersion = {.dbId = newDBCache.dbId, .vgVersion = -1, .stateTs = 0};
|
||||||
tstrncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName));
|
tstrncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName));
|
||||||
|
|
||||||
ctgDebug("db added to cache, dbFName:%s, dbId:0x%" PRIx64, dbFName, dbId);
|
ctgDebug("db added to cache, dbFName:%s, dbId:0x%" PRIx64, dbFName, dbId);
|
||||||
|
|
||||||
CTG_ERR_RET(ctgMetaRentAdd(&pCtg->dbRent, &vgVersion, dbId, sizeof(SDbVgVersion)));
|
if (!IS_SYS_DBNAME(dbFName)) {
|
||||||
|
CTG_ERR_RET(ctgMetaRentAdd(&pCtg->dbRent, &vgVersion, dbId, sizeof(SDbVgVersion)));
|
||||||
|
|
||||||
ctgDebug("db added to rent, dbFName:%s, vgVersion:%d, dbId:0x%" PRIx64, dbFName, vgVersion.vgVersion, dbId);
|
ctgDebug("db added to rent, dbFName:%s, vgVersion:%d, dbId:0x%" PRIx64, dbFName, vgVersion.vgVersion, dbId);
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -1434,7 +1437,7 @@ int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNam
|
||||||
if (pCache) {
|
if (pCache) {
|
||||||
CTG_ERR_RET(ctgUpdateRentStbVersion(pCtg, dbFName, tbName, dbId, meta->suid, pCache));
|
CTG_ERR_RET(ctgUpdateRentStbVersion(pCtg, dbFName, tbName, dbId, meta->suid, pCache));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1563,7 +1566,8 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool newAdded = false;
|
bool newAdded = false;
|
||||||
SDbVgVersion vgVersion = {.dbId = msg->dbId, .vgVersion = dbInfo->vgVersion, .numOfTable = dbInfo->numOfTable};
|
SDbVgVersion vgVersion = {
|
||||||
|
.dbId = msg->dbId, .vgVersion = dbInfo->vgVersion, .numOfTable = dbInfo->numOfTable, .stateTs = dbInfo->stateTs};
|
||||||
|
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
CTG_ERR_JRET(ctgGetAddDBCache(msg->pCtg, dbFName, msg->dbId, &dbCache));
|
CTG_ERR_JRET(ctgGetAddDBCache(msg->pCtg, dbFName, msg->dbId, &dbCache));
|
||||||
|
@ -1579,15 +1583,17 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
||||||
SDBVgInfo *vgInfo = vgCache->vgInfo;
|
SDBVgInfo *vgInfo = vgCache->vgInfo;
|
||||||
|
|
||||||
if (dbInfo->vgVersion < vgInfo->vgVersion) {
|
if (dbInfo->vgVersion < vgInfo->vgVersion) {
|
||||||
ctgDebug("db vgVer is old, dbFName:%s, vgVer:%d, curVer:%d", dbFName, dbInfo->vgVersion, vgInfo->vgVersion);
|
ctgDebug("db updateVgroup is ignored, dbFName:%s, vgVer:%d, curVer:%d", dbFName, dbInfo->vgVersion,
|
||||||
|
vgInfo->vgVersion);
|
||||||
ctgWUnlockVgInfo(dbCache);
|
ctgWUnlockVgInfo(dbCache);
|
||||||
|
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbInfo->vgVersion == vgInfo->vgVersion && dbInfo->numOfTable == vgInfo->numOfTable) {
|
if (dbInfo->vgVersion == vgInfo->vgVersion && dbInfo->numOfTable == vgInfo->numOfTable &&
|
||||||
ctgDebug("no new db vgVer or numOfTable, dbFName:%s, vgVer:%d, numOfTable:%d", dbFName, dbInfo->vgVersion,
|
dbInfo->stateTs == vgInfo->stateTs) {
|
||||||
dbInfo->numOfTable);
|
ctgDebug("no new db vgroup update info, dbFName:%s, vgVer:%d, numOfTable:%d, stateTs:%" PRId64, dbFName,
|
||||||
|
dbInfo->vgVersion, dbInfo->numOfTable, dbInfo->stateTs);
|
||||||
ctgWUnlockVgInfo(dbCache);
|
ctgWUnlockVgInfo(dbCache);
|
||||||
|
|
||||||
goto _return;
|
goto _return;
|
||||||
|
@ -1599,15 +1605,18 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
||||||
vgCache->vgInfo = dbInfo;
|
vgCache->vgInfo = dbInfo;
|
||||||
msg->dbInfo = NULL;
|
msg->dbInfo = NULL;
|
||||||
|
|
||||||
ctgDebug("db vgInfo updated, dbFName:%s, vgVer:%d, dbId:0x%" PRIx64, dbFName, vgVersion.vgVersion, vgVersion.dbId);
|
ctgDebug("db vgInfo updated, dbFName:%s, vgVer:%d, stateTs:%" PRId64 ", dbId:0x%" PRIx64, dbFName,
|
||||||
|
vgVersion.vgVersion, vgVersion.stateTs, vgVersion.dbId);
|
||||||
|
|
||||||
ctgWUnlockVgInfo(dbCache);
|
ctgWUnlockVgInfo(dbCache);
|
||||||
|
|
||||||
dbCache = NULL;
|
dbCache = NULL;
|
||||||
|
|
||||||
tstrncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName));
|
if (!IS_SYS_DBNAME(dbFName)) {
|
||||||
CTG_ERR_JRET(ctgMetaRentUpdate(&msg->pCtg->dbRent, &vgVersion, vgVersion.dbId, sizeof(SDbVgVersion),
|
tstrncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName));
|
||||||
ctgDbVgVersionSortCompare, ctgDbVgVersionSearchCompare));
|
CTG_ERR_JRET(ctgMetaRentUpdate(&msg->pCtg->dbRent, &vgVersion, vgVersion.dbId, sizeof(SDbVgVersion),
|
||||||
|
ctgDbVgVersionSortCompare, ctgDbVgVersionSearchCompare));
|
||||||
|
}
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
|
@ -1688,7 +1697,7 @@ int32_t ctgOpUpdateTbMeta(SCtgCacheOperation *operation) {
|
||||||
if (pCtg->stopUpdate) {
|
if (pCtg->stopUpdate) {
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!CTG_IS_META_CTABLE(pMeta->metaType)) && NULL == pMeta->tbMeta) {
|
if ((!CTG_IS_META_CTABLE(pMeta->metaType)) && NULL == pMeta->tbMeta) {
|
||||||
ctgError("no valid tbmeta got from meta rsp, dbFName:%s, tbName:%s", pMeta->dbFName, pMeta->tbName);
|
ctgError("no valid tbmeta got from meta rsp, dbFName:%s, tbName:%s", pMeta->dbFName, pMeta->tbName);
|
||||||
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||||
|
@ -1898,7 +1907,7 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgUpdateEpsetMsg *msg = operation->data;
|
SCtgUpdateEpsetMsg *msg = operation->data;
|
||||||
SCatalog *pCtg = msg->pCtg;
|
SCatalog *pCtg = msg->pCtg;
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
|
||||||
if (pCtg->stopUpdate) {
|
if (pCtg->stopUpdate) {
|
||||||
goto _return;
|
goto _return;
|
||||||
|
@ -2170,7 +2179,6 @@ void *ctgUpdateThreadFunc(void *param) {
|
||||||
CTG_RT_STAT_INC(numOfOpDequeue, 1);
|
CTG_RT_STAT_INC(numOfOpDequeue, 1);
|
||||||
|
|
||||||
ctgdShowCacheInfo();
|
ctgdShowCacheInfo();
|
||||||
ctgdShowClusterCache(pCtg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qInfo("catalog update thread stopped");
|
qInfo("catalog update thread stopped");
|
||||||
|
@ -2206,6 +2214,7 @@ int32_t ctgGetTbMetaFromCache(SCatalog *pCtg, SCtgTbMetaCtx *ctx, STableMeta **p
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(*pTableMeta);
|
taosMemoryFreeClear(*pTableMeta);
|
||||||
|
*pTableMeta = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CTG_FLAG_IS_UNKNOWN_STB(ctx->flag)) {
|
if (CTG_FLAG_IS_UNKNOWN_STB(ctx->flag)) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ void ctgdUserCallback(SMetaData *pResult, void *param, int32_t code) {
|
||||||
num = taosArrayGetSize(pResult->pDbInfo);
|
num = taosArrayGetSize(pResult->pDbInfo);
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
SDbInfo *pDb = taosArrayGet(pResult->pDbInfo, i);
|
SDbInfo *pDb = taosArrayGet(pResult->pDbInfo, i);
|
||||||
qDebug("db %d dbInfo: vgVer:%d, tbNum:%d, dbId:0x%" PRIx64, i, pDb->vgVer, pDb->tbNum, pDb->dbId);
|
qDebug("db %d dbInfo: vgVer:%d, tbNum:%d, stateTs:%" PRId64 " dbId:0x%" PRIx64, i, pDb->vgVer, pDb->tbNum, pDb->stateTs, pDb->dbId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug("empty db info");
|
qDebug("empty db info");
|
||||||
|
@ -462,6 +462,7 @@ void ctgdShowDBCache(SCatalog *pCtg, SHashObj *dbHash) {
|
||||||
int32_t hashMethod = -1;
|
int32_t hashMethod = -1;
|
||||||
int16_t hashPrefix = 0;
|
int16_t hashPrefix = 0;
|
||||||
int16_t hashSuffix = 0;
|
int16_t hashSuffix = 0;
|
||||||
|
int64_t stateTs = 0;
|
||||||
int32_t vgNum = 0;
|
int32_t vgNum = 0;
|
||||||
|
|
||||||
if (dbCache->vgCache.vgInfo) {
|
if (dbCache->vgCache.vgInfo) {
|
||||||
|
@ -469,16 +470,35 @@ void ctgdShowDBCache(SCatalog *pCtg, SHashObj *dbHash) {
|
||||||
hashMethod = dbCache->vgCache.vgInfo->hashMethod;
|
hashMethod = dbCache->vgCache.vgInfo->hashMethod;
|
||||||
hashPrefix = dbCache->vgCache.vgInfo->hashPrefix;
|
hashPrefix = dbCache->vgCache.vgInfo->hashPrefix;
|
||||||
hashSuffix = dbCache->vgCache.vgInfo->hashSuffix;
|
hashSuffix = dbCache->vgCache.vgInfo->hashSuffix;
|
||||||
|
stateTs = dbCache->vgCache.vgInfo->stateTs;
|
||||||
if (dbCache->vgCache.vgInfo->vgHash) {
|
if (dbCache->vgCache.vgInfo->vgHash) {
|
||||||
vgNum = taosHashGetSize(dbCache->vgCache.vgInfo->vgHash);
|
vgNum = taosHashGetSize(dbCache->vgCache.vgInfo->vgHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctgDebug("[%d] db [%.*s][0x%" PRIx64
|
ctgDebug("[%d] db [%.*s][0x%" PRIx64
|
||||||
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, prefix:%d, suffix:%d, vgNum:%d",
|
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, stateTs:%" PRId64 ", hashMethod:%d, prefix:%d, suffix:%d, vgNum:%d",
|
||||||
i, (int32_t)len, dbFName, dbCache->dbId, dbCache->deleted ? "deleted" : "", metaNum, stbNum, vgVersion,
|
i, (int32_t)len, dbFName, dbCache->dbId, dbCache->deleted ? "deleted" : "", metaNum, stbNum, vgVersion, stateTs,
|
||||||
hashMethod, hashPrefix, hashSuffix, vgNum);
|
hashMethod, hashPrefix, hashSuffix, vgNum);
|
||||||
|
|
||||||
|
if (dbCache->vgCache.vgInfo) {
|
||||||
|
int32_t i = 0;
|
||||||
|
void *pVgIter = taosHashIterate(dbCache->vgCache.vgInfo->vgHash, NULL);
|
||||||
|
while (pVgIter) {
|
||||||
|
SVgroupInfo * pVg = (SVgroupInfo *)pVgIter;
|
||||||
|
|
||||||
|
ctgDebug("The %04dth VG [id:%d, hashBegin:%u, hashEnd:%u, numOfTable:%d, epNum:%d, inUse:%d]",
|
||||||
|
i++, pVg->vgId, pVg->hashBegin, pVg->hashEnd, pVg->numOfTable, pVg->epSet.numOfEps, pVg->epSet.inUse);
|
||||||
|
|
||||||
|
for (int32_t n = 0; n < pVg->epSet.numOfEps; ++n) {
|
||||||
|
SEp *pEp = &pVg->epSet.eps[n];
|
||||||
|
ctgDebug("\tEp %d [fqdn:%s, port:%d]", n, pEp->fqdn, pEp->port);
|
||||||
|
}
|
||||||
|
|
||||||
|
pVgIter = taosHashIterate(dbCache->vgCache.vgInfo->vgHash, pVgIter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pIter = taosHashIterate(dbHash, pIter);
|
pIter = taosHashIterate(dbHash, pIter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2486,7 +2486,8 @@ TEST(dbVgroup, getSetDbVgroupCase) {
|
||||||
int32_t dbVer = 0;
|
int32_t dbVer = 0;
|
||||||
int64_t dbId = 0;
|
int64_t dbId = 0;
|
||||||
int32_t tbNum = 0;
|
int32_t tbNum = 0;
|
||||||
code = catalogGetDBVgVersion(pCtg, ctgTestDbname, &dbVer, &dbId, &tbNum);
|
int64_t stateTs = 0;
|
||||||
|
code = catalogGetDBVgVersion(pCtg, ctgTestDbname, &dbVer, &dbId, &tbNum, &stateTs);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(dbVer, ctgTestVgVersion);
|
ASSERT_EQ(dbVer, ctgTestVgVersion);
|
||||||
ASSERT_EQ(dbId, ctgTestDbId);
|
ASSERT_EQ(dbId, ctgTestDbId);
|
||||||
|
|
|
@ -39,8 +39,7 @@ static int32_t buildRetrieveTableRsp(SSDataBlock* pBlock, int32_t numOfCols, SRe
|
||||||
(*pRsp)->numOfRows = htonl(pBlock->info.rows);
|
(*pRsp)->numOfRows = htonl(pBlock->info.rows);
|
||||||
(*pRsp)->numOfCols = htonl(numOfCols);
|
(*pRsp)->numOfCols = htonl(numOfCols);
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = blockEncode(pBlock, (*pRsp)->data, numOfCols);
|
||||||
blockEncode(pBlock, (*pRsp)->data, &len, numOfCols, false);
|
|
||||||
ASSERT(len == rspSize - sizeof(SRetrieveTableRsp));
|
ASSERT(len == rspSize - sizeof(SRetrieveTableRsp));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -1610,8 +1610,7 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
|
||||||
rsp->completed = 1;
|
rsp->completed = 1;
|
||||||
rsp->numOfRows = htonl(rowNum);
|
rsp->numOfRows = htonl(rowNum);
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = blockEncode(pBlock, rsp->data, taosArrayGetSize(pBlock->pDataBlock));
|
||||||
blockEncode(pBlock, rsp->data, &len, taosArrayGetSize(pBlock->pDataBlock), 0);
|
|
||||||
ASSERT(len == rspSize - sizeof(SRetrieveTableRsp));
|
ASSERT(len == rspSize - sizeof(SRetrieveTableRsp));
|
||||||
|
|
||||||
rsp->compLen = htonl(len);
|
rsp->compLen = htonl(len);
|
||||||
|
|
|
@ -264,6 +264,7 @@ typedef struct SExchangeInfo {
|
||||||
SLoadRemoteDataInfo loadInfo;
|
SLoadRemoteDataInfo loadInfo;
|
||||||
uint64_t self;
|
uint64_t self;
|
||||||
SLimitInfo limitInfo;
|
SLimitInfo limitInfo;
|
||||||
|
int64_t openedTs; // start exec time stamp
|
||||||
} SExchangeInfo;
|
} SExchangeInfo;
|
||||||
|
|
||||||
typedef struct SScanInfo {
|
typedef struct SScanInfo {
|
||||||
|
@ -841,10 +842,8 @@ typedef struct SJoinOperatorInfo {
|
||||||
#define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED)
|
#define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED)
|
||||||
#define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED)
|
#define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED)
|
||||||
|
|
||||||
void doDestroyExchangeOperatorInfo(void* param);
|
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t cleanup,
|
||||||
|
__optr_close_fn_t closeFn, __optr_explain_fn_t explain);
|
||||||
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn,
|
|
||||||
__optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_explain_fn_t explain);
|
|
||||||
|
|
||||||
int32_t operatorDummyOpenFn(SOperatorInfo* pOperator);
|
int32_t operatorDummyOpenFn(SOperatorInfo* pOperator);
|
||||||
int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num);
|
int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num);
|
||||||
|
@ -880,7 +879,11 @@ STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInter
|
||||||
int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scanFlag);
|
int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scanFlag);
|
||||||
int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz);
|
int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz);
|
||||||
|
|
||||||
void doSetOperatorCompleted(SOperatorInfo* pOperator);
|
void doDestroyExchangeOperatorInfo(void* param);
|
||||||
|
|
||||||
|
void setOperatorCompleted(SOperatorInfo* pOperator);
|
||||||
|
void setOperatorInfo(SOperatorInfo* pOperator, const char* name, int32_t type, bool blocking, int32_t status, void* pInfo,
|
||||||
|
SExecTaskInfo* pTaskInfo);
|
||||||
void doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo);
|
void doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo);
|
||||||
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr,
|
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr,
|
||||||
SSDataBlock* pBlock, int32_t rows, const char* idStr, STableMetaCacheInfo * pCache);
|
SSDataBlock* pBlock, int32_t rows, const char* idStr, STableMetaCacheInfo * pCache);
|
||||||
|
@ -978,6 +981,7 @@ void setTaskKilled(SExecTaskInfo* pTaskInfo);
|
||||||
void queryCostStatis(SExecTaskInfo* pTaskInfo);
|
void queryCostStatis(SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
void doDestroyTask(SExecTaskInfo* pTaskInfo);
|
void doDestroyTask(SExecTaskInfo* pTaskInfo);
|
||||||
|
void destroyOperatorInfo(SOperatorInfo* pOperator);
|
||||||
int32_t getMaximumIdleDurationSec();
|
int32_t getMaximumIdleDurationSec();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -93,16 +93,11 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
||||||
p->pCtx = createSqlFunctionCtx(p->pExprInfo, p->numOfExprs, &p->rowEntryInfoOffset);
|
p->pCtx = createSqlFunctionCtx(p->pExprInfo, p->numOfExprs, &p->rowEntryInfoOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperator->name = "LastrowScanOperator";
|
setOperatorInfo(pOperator, "CachedRowScanOperator", QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN;
|
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(operatorDummyOpenFn, doScanCache, NULL, NULL, destroyLastrowScanOperator, NULL);
|
createOperatorFpSet(operatorDummyOpenFn, doScanCache, NULL, destroyLastrowScanOperator, NULL);
|
||||||
|
|
||||||
pOperator->cost.openCost = 0;
|
pOperator->cost.openCost = 0;
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
@ -126,7 +121,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
uint64_t suid = tableListGetSuid(pTableList);
|
uint64_t suid = tableListGetSuid(pTableList);
|
||||||
int32_t size = tableListGetSize(pTableList);
|
int32_t size = tableListGetSize(pTableList);
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +177,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
pInfo->indexOfBufferedRes += 1;
|
pInfo->indexOfBufferedRes += 1;
|
||||||
return pRes;
|
return pRes;
|
||||||
} else {
|
} else {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -234,7 +229,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
|
||||||
pEntry->dataLen = 0;
|
pEntry->dataLen = 0;
|
||||||
|
|
||||||
pBuf->useSize = sizeof(SDataCacheEntry);
|
pBuf->useSize = sizeof(SDataCacheEntry);
|
||||||
blockEncode(pInput->pData, pEntry->data, &pEntry->dataLen, numOfCols, pEntry->compressed);
|
pEntry->dataLen = blockEncode(pInput->pData, pEntry->data, numOfCols);
|
||||||
ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
|
ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
|
||||||
ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
|
ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,638 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "filter.h"
|
||||||
|
#include "function.h"
|
||||||
|
#include "functionMgt.h"
|
||||||
|
#include "os.h"
|
||||||
|
#include "querynodes.h"
|
||||||
|
#include "tfill.h"
|
||||||
|
#include "tname.h"
|
||||||
|
#include "tref.h"
|
||||||
|
|
||||||
|
#include "tdatablock.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "tmsg.h"
|
||||||
|
#include "tsort.h"
|
||||||
|
#include "ttime.h"
|
||||||
|
|
||||||
|
#include "executorimpl.h"
|
||||||
|
#include "index.h"
|
||||||
|
#include "query.h"
|
||||||
|
#include "tcompare.h"
|
||||||
|
#include "thash.h"
|
||||||
|
#include "ttypes.h"
|
||||||
|
#include "vnode.h"
|
||||||
|
|
||||||
|
typedef struct SFetchRspHandleWrapper {
|
||||||
|
uint32_t exchangeId;
|
||||||
|
int32_t sourceIndex;
|
||||||
|
} SFetchRspHandleWrapper;
|
||||||
|
|
||||||
|
static void destroyExchangeOperatorInfo(void* param);
|
||||||
|
static void freeBlock(void* pParam);
|
||||||
|
static void freeSourceDataInfo(void* param);
|
||||||
|
static void* setAllSourcesCompleted(SOperatorInfo* pOperator, int64_t startTs);
|
||||||
|
|
||||||
|
static int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code);
|
||||||
|
static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTaskInfo, int32_t sourceIndex);
|
||||||
|
static int32_t getCompletedSources(const SArray* pArray);
|
||||||
|
static int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator);
|
||||||
|
static int32_t seqLoadRemoteData(SOperatorInfo* pOperator);
|
||||||
|
static int32_t prepareLoadRemoteData(SOperatorInfo* pOperator);
|
||||||
|
|
||||||
|
static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeInfo* pExchangeInfo,
|
||||||
|
SExecTaskInfo* pTaskInfo) {
|
||||||
|
int32_t code = 0;
|
||||||
|
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSourceDataInfo);
|
||||||
|
int32_t completed = getCompletedSources(pExchangeInfo->pSourceDataInfo);
|
||||||
|
if (completed == totalSources) {
|
||||||
|
setAllSourcesCompleted(pOperator, pExchangeInfo->openedTs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
tsem_wait(&pExchangeInfo->ready);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < totalSources; ++i) {
|
||||||
|
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, i);
|
||||||
|
if (pDataInfo->status == EX_SOURCE_DATA_EXHAUSTED) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pDataInfo->status != EX_SOURCE_DATA_READY) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pDataInfo->code != TSDB_CODE_SUCCESS) {
|
||||||
|
code = pDataInfo->code;
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRetrieveTableRsp* pRsp = pDataInfo->pRsp;
|
||||||
|
SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, i);
|
||||||
|
|
||||||
|
// todo
|
||||||
|
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
||||||
|
if (pRsp->numOfRows == 0) {
|
||||||
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
|
qDebug("%s vgId:%d, taskId:0x%" PRIx64 " execId:%d index:%d completed, rowsOfSource:%" PRIu64
|
||||||
|
", totalRows:%" PRIu64 ", try next %d/%" PRIzu,
|
||||||
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, i, pDataInfo->totalRows,
|
||||||
|
pExchangeInfo->loadInfo.totalRows, i + 1, totalSources);
|
||||||
|
taosMemoryFreeClear(pDataInfo->pRsp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRetrieveTableRsp* pRetrieveRsp = pDataInfo->pRsp;
|
||||||
|
int32_t index = 0;
|
||||||
|
char* pStart = pRetrieveRsp->data;
|
||||||
|
while (index++ < pRetrieveRsp->numOfBlocks) {
|
||||||
|
SSDataBlock* pb = createOneDataBlock(pExchangeInfo->pDummyBlock, false);
|
||||||
|
code = extractDataBlockFromFetchRsp(pb, pStart, NULL, &pStart);
|
||||||
|
if (code != 0) {
|
||||||
|
taosMemoryFreeClear(pDataInfo->pRsp);
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayPush(pExchangeInfo->pResultBlockList, &pb);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLoadRemoteInfo(pLoadInfo, pRetrieveRsp->numOfRows, pRetrieveRsp->compLen, pExchangeInfo->openedTs, pOperator);
|
||||||
|
|
||||||
|
if (pRsp->completed == 1) {
|
||||||
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64
|
||||||
|
" execId:%d index:%d completed, blocks:%d, numOfRows:%d, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64
|
||||||
|
", total:%.2f Kb, try next %d/%" PRIzu,
|
||||||
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, i, pRsp->numOfBlocks,
|
||||||
|
pRsp->numOfRows, pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize / 1024.0,
|
||||||
|
i + 1, totalSources);
|
||||||
|
} else {
|
||||||
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64
|
||||||
|
" execId:%d blocks:%d, numOfRows:%d, totalRows:%" PRIu64 ", total:%.2f Kb",
|
||||||
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRsp->numOfBlocks,
|
||||||
|
pRsp->numOfRows, pLoadInfo->totalRows, pLoadInfo->totalSize / 1024.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(pDataInfo->pRsp);
|
||||||
|
|
||||||
|
if (pDataInfo->status != EX_SOURCE_DATA_EXHAUSTED) {
|
||||||
|
pDataInfo->status = EX_SOURCE_DATA_NOT_READY;
|
||||||
|
code = doSendFetchDataRequest(pExchangeInfo, pTaskInfo, i);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
taosMemoryFreeClear(pDataInfo->pRsp);
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} // end loop
|
||||||
|
|
||||||
|
int32_t complete1 = getCompletedSources(pExchangeInfo->pSourceDataInfo);
|
||||||
|
if (complete1 == totalSources) {
|
||||||
|
qDebug("all sources are completed, %s", GET_TASKID(pTaskInfo));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_error:
|
||||||
|
pTaskInfo->code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* doLoadRemoteDataImpl(SOperatorInfo* pOperator) {
|
||||||
|
SExchangeInfo* pExchangeInfo = pOperator->info;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
pTaskInfo->code = pOperator->fpSet._openFn(pOperator);
|
||||||
|
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
||||||
|
|
||||||
|
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
||||||
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
|
qDebug("%s all %" PRIzu " source(s) are exhausted, total rows:%" PRIu64 " bytes:%" PRIu64 ", elapsed:%.2f ms",
|
||||||
|
GET_TASKID(pTaskInfo), totalSources, pLoadInfo->totalRows, pLoadInfo->totalSize,
|
||||||
|
pLoadInfo->totalElapsed / 1000.0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t size = taosArrayGetSize(pExchangeInfo->pResultBlockList);
|
||||||
|
if (size == 0 || pExchangeInfo->rspBlockIndex >= size) {
|
||||||
|
pExchangeInfo->rspBlockIndex = 0;
|
||||||
|
taosArrayClearEx(pExchangeInfo->pResultBlockList, freeBlock);
|
||||||
|
if (pExchangeInfo->seqLoadData) {
|
||||||
|
seqLoadRemoteData(pOperator);
|
||||||
|
} else {
|
||||||
|
concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosArrayGetSize(pExchangeInfo->pResultBlockList) == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we have buffered retrieved datablock, return it directly
|
||||||
|
return taosArrayGetP(pExchangeInfo->pResultBlockList, pExchangeInfo->rspBlockIndex++);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* doLoadRemoteData(SOperatorInfo* pOperator) {
|
||||||
|
SExchangeInfo* pExchangeInfo = pOperator->info;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
SSDataBlock* pBlock = doLoadRemoteDataImpl(pOperator);
|
||||||
|
if (pBlock == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SLimitInfo* pLimitInfo = &pExchangeInfo->limitInfo;
|
||||||
|
if (hasLimitOffsetInfo(pLimitInfo)) {
|
||||||
|
int32_t status = handleLimitOffset(pOperator, pLimitInfo, pBlock, false);
|
||||||
|
if (status == PROJECT_RETRIEVE_CONTINUE) {
|
||||||
|
continue;
|
||||||
|
} else if (status == PROJECT_RETRIEVE_DONE) {
|
||||||
|
size_t rows = pBlock->info.rows;
|
||||||
|
pExchangeInfo->limitInfo.numOfOutputRows += rows;
|
||||||
|
|
||||||
|
if (rows == 0) {
|
||||||
|
setOperatorCompleted(pOperator);
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
return pBlock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return pBlock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo, const char* id) {
|
||||||
|
pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo));
|
||||||
|
if (pInfo->pSourceDataInfo == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfSources; ++i) {
|
||||||
|
SSourceDataInfo dataInfo = {0};
|
||||||
|
dataInfo.status = EX_SOURCE_DATA_NOT_READY;
|
||||||
|
dataInfo.taskId = id;
|
||||||
|
dataInfo.index = i;
|
||||||
|
SSourceDataInfo* pDs = taosArrayPush(pInfo->pSourceDataInfo, &dataInfo);
|
||||||
|
if (pDs == NULL) {
|
||||||
|
taosArrayDestroy(pInfo->pSourceDataInfo);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo* pInfo, const char* id) {
|
||||||
|
size_t numOfSources = LIST_LENGTH(pExNode->pSrcEndPoints);
|
||||||
|
|
||||||
|
if (numOfSources == 0) {
|
||||||
|
qError("%s invalid number: %d of sources in exchange operator", id, (int32_t)numOfSources);
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
|
||||||
|
pInfo->pSources = taosArrayInit(numOfSources, sizeof(SDownstreamSourceNode));
|
||||||
|
if (pInfo->pSources == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfSources; ++i) {
|
||||||
|
SDownstreamSourceNode* pNode = (SDownstreamSourceNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i);
|
||||||
|
taosArrayPush(pInfo->pSources, pNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
initLimitInfo(pExNode->node.pLimit, pExNode->node.pSlimit, &pInfo->limitInfo);
|
||||||
|
pInfo->self = taosAddRef(exchangeObjRefPool, pInfo);
|
||||||
|
|
||||||
|
return initDataSource(numOfSources, pInfo, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo) {
|
||||||
|
SExchangeInfo* pInfo = taosMemoryCalloc(1, sizeof(SExchangeInfo));
|
||||||
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code = initExchangeOperator(pExNode, pInfo, GET_TASKID(pTaskInfo));
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsem_init(&pInfo->ready, 0, 0);
|
||||||
|
pInfo->pDummyBlock = createResDataBlock(pExNode->node.pOutputDataBlockDesc);
|
||||||
|
pInfo->pResultBlockList = taosArrayInit(1, POINTER_BYTES);
|
||||||
|
|
||||||
|
pInfo->seqLoadData = false;
|
||||||
|
pInfo->pTransporter = pTransporter;
|
||||||
|
|
||||||
|
setOperatorInfo(pOperator, "ExchangeOperator", QUERY_NODE_PHYSICAL_PLAN_EXCHANGE, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
|
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pDummyBlock->pDataBlock);
|
||||||
|
|
||||||
|
pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, destroyExchangeOperatorInfo, NULL);
|
||||||
|
return pOperator;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
if (pInfo != NULL) {
|
||||||
|
doDestroyExchangeOperatorInfo(pInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(pOperator);
|
||||||
|
pTaskInfo->code = code;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroyExchangeOperatorInfo(void* param) {
|
||||||
|
SExchangeInfo* pExInfo = (SExchangeInfo*)param;
|
||||||
|
taosRemoveRef(exchangeObjRefPool, pExInfo->self);
|
||||||
|
}
|
||||||
|
|
||||||
|
void freeBlock(void* pParam) {
|
||||||
|
SSDataBlock* pBlock = *(SSDataBlock**)pParam;
|
||||||
|
blockDataDestroy(pBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void freeSourceDataInfo(void* p) {
|
||||||
|
SSourceDataInfo* pInfo = (SSourceDataInfo*)p;
|
||||||
|
taosMemoryFreeClear(pInfo->pRsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void doDestroyExchangeOperatorInfo(void* param) {
|
||||||
|
SExchangeInfo* pExInfo = (SExchangeInfo*)param;
|
||||||
|
|
||||||
|
taosArrayDestroy(pExInfo->pSources);
|
||||||
|
taosArrayDestroyEx(pExInfo->pSourceDataInfo, freeSourceDataInfo);
|
||||||
|
|
||||||
|
if (pExInfo->pResultBlockList != NULL) {
|
||||||
|
taosArrayDestroyEx(pExInfo->pResultBlockList, freeBlock);
|
||||||
|
pExInfo->pResultBlockList = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockDataDestroy(pExInfo->pDummyBlock);
|
||||||
|
|
||||||
|
tsem_destroy(&pExInfo->ready);
|
||||||
|
taosMemoryFreeClear(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
|
SFetchRspHandleWrapper* pWrapper = (SFetchRspHandleWrapper*)param;
|
||||||
|
|
||||||
|
SExchangeInfo* pExchangeInfo = taosAcquireRef(exchangeObjRefPool, pWrapper->exchangeId);
|
||||||
|
if (pExchangeInfo == NULL) {
|
||||||
|
qWarn("failed to acquire exchange operator, since it may have been released");
|
||||||
|
taosMemoryFree(pMsg->pData);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t index = pWrapper->sourceIndex;
|
||||||
|
SSourceDataInfo* pSourceDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, index);
|
||||||
|
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
pSourceDataInfo->pRsp = pMsg->pData;
|
||||||
|
|
||||||
|
SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp;
|
||||||
|
pRsp->numOfRows = htonl(pRsp->numOfRows);
|
||||||
|
pRsp->compLen = htonl(pRsp->compLen);
|
||||||
|
pRsp->numOfCols = htonl(pRsp->numOfCols);
|
||||||
|
pRsp->useconds = htobe64(pRsp->useconds);
|
||||||
|
pRsp->numOfBlocks = htonl(pRsp->numOfBlocks);
|
||||||
|
|
||||||
|
ASSERT(pRsp != NULL);
|
||||||
|
qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%d", pSourceDataInfo->taskId, index, pRsp->numOfBlocks,
|
||||||
|
pRsp->numOfRows);
|
||||||
|
} else {
|
||||||
|
taosMemoryFree(pMsg->pData);
|
||||||
|
pSourceDataInfo->code = code;
|
||||||
|
qDebug("%s fetch rsp received, index:%d, error:%s", pSourceDataInfo->taskId, index, tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
pSourceDataInfo->status = EX_SOURCE_DATA_READY;
|
||||||
|
|
||||||
|
tsem_post(&pExchangeInfo->ready);
|
||||||
|
taosReleaseRef(exchangeObjRefPool, pWrapper->exchangeId);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTaskInfo, int32_t sourceIndex) {
|
||||||
|
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
||||||
|
|
||||||
|
SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, sourceIndex);
|
||||||
|
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, sourceIndex);
|
||||||
|
|
||||||
|
ASSERT(pDataInfo->status == EX_SOURCE_DATA_NOT_READY);
|
||||||
|
|
||||||
|
SFetchRspHandleWrapper* pWrapper = taosMemoryCalloc(1, sizeof(SFetchRspHandleWrapper));
|
||||||
|
pWrapper->exchangeId = pExchangeInfo->self;
|
||||||
|
pWrapper->sourceIndex = sourceIndex;
|
||||||
|
|
||||||
|
if (pSource->localExec) {
|
||||||
|
SDataBuf pBuf = {0};
|
||||||
|
int32_t code =
|
||||||
|
(*pTaskInfo->localFetch.fp)(pTaskInfo->localFetch.handle, pSource->schedId, pTaskInfo->id.queryId,
|
||||||
|
pSource->taskId, 0, pSource->execId, &pBuf.pData, pTaskInfo->localFetch.explainRes);
|
||||||
|
loadRemoteDataCallback(pWrapper, &pBuf, code);
|
||||||
|
taosMemoryFree(pWrapper);
|
||||||
|
} else {
|
||||||
|
SResFetchReq* pMsg = taosMemoryCalloc(1, sizeof(SResFetchReq));
|
||||||
|
if (NULL == pMsg) {
|
||||||
|
pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
taosMemoryFree(pWrapper);
|
||||||
|
return pTaskInfo->code;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%" PRIx64 ", execId:%d, %d/%" PRIzu,
|
||||||
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId,
|
||||||
|
pSource->execId, sourceIndex, totalSources);
|
||||||
|
|
||||||
|
pMsg->header.vgId = htonl(pSource->addr.nodeId);
|
||||||
|
pMsg->sId = htobe64(pSource->schedId);
|
||||||
|
pMsg->taskId = htobe64(pSource->taskId);
|
||||||
|
pMsg->queryId = htobe64(pTaskInfo->id.queryId);
|
||||||
|
pMsg->execId = htonl(pSource->execId);
|
||||||
|
|
||||||
|
// send the fetch remote task result reques
|
||||||
|
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||||
|
if (NULL == pMsgSendInfo) {
|
||||||
|
taosMemoryFreeClear(pMsg);
|
||||||
|
taosMemoryFree(pWrapper);
|
||||||
|
qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo));
|
||||||
|
pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
return pTaskInfo->code;
|
||||||
|
}
|
||||||
|
|
||||||
|
pMsgSendInfo->param = pWrapper;
|
||||||
|
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
|
pMsgSendInfo->msgInfo.pData = pMsg;
|
||||||
|
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
||||||
|
pMsgSendInfo->msgType = pSource->fetchMsgType;
|
||||||
|
pMsgSendInfo->fp = loadRemoteDataCallback;
|
||||||
|
|
||||||
|
int64_t transporterId = 0;
|
||||||
|
int32_t code =
|
||||||
|
asyncSendMsgToServer(pExchangeInfo->pTransporter, &pSource->addr.epSet, &transporterId, pMsgSendInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int32_t numOfRows, int32_t dataLen, int64_t startTs,
|
||||||
|
SOperatorInfo* pOperator) {
|
||||||
|
pInfo->totalRows += numOfRows;
|
||||||
|
pInfo->totalSize += dataLen;
|
||||||
|
pInfo->totalElapsed += (taosGetTimestampUs() - startTs);
|
||||||
|
pOperator->resultInfo.totalRows += numOfRows;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, SArray* pColList, char** pNextStart) {
|
||||||
|
if (pColList == NULL) { // data from other sources
|
||||||
|
blockDataCleanup(pRes);
|
||||||
|
*pNextStart = (char*)blockDecode(pRes, pData);
|
||||||
|
} else { // extract data according to pColList
|
||||||
|
char* pStart = pData;
|
||||||
|
|
||||||
|
int32_t numOfCols = htonl(*(int32_t*)pStart);
|
||||||
|
pStart += sizeof(int32_t);
|
||||||
|
|
||||||
|
// todo refactor:extract method
|
||||||
|
SSysTableSchema* pSchema = (SSysTableSchema*)pStart;
|
||||||
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SSysTableSchema* p = (SSysTableSchema*)pStart;
|
||||||
|
|
||||||
|
p->colId = htons(p->colId);
|
||||||
|
p->bytes = htonl(p->bytes);
|
||||||
|
pStart += sizeof(SSysTableSchema);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSDataBlock* pBlock = createDataBlock();
|
||||||
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SColumnInfoData idata = createColumnInfoData(pSchema[i].type, pSchema[i].bytes, pSchema[i].colId);
|
||||||
|
blockDataAppendColInfo(pBlock, &idata);
|
||||||
|
}
|
||||||
|
|
||||||
|
blockDecode(pBlock, pStart);
|
||||||
|
blockDataEnsureCapacity(pRes, pBlock->info.rows);
|
||||||
|
|
||||||
|
// data from mnode
|
||||||
|
pRes->info.rows = pBlock->info.rows;
|
||||||
|
relocateColumnData(pRes, pColList, pBlock->pDataBlock, false);
|
||||||
|
blockDataDestroy(pBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo move this to time window aggregator, since the primary timestamp may not be known by exchange operator.
|
||||||
|
blockDataUpdateTsWindow(pRes, 0);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* setAllSourcesCompleted(SOperatorInfo* pOperator, int64_t startTs) {
|
||||||
|
SExchangeInfo* pExchangeInfo = pOperator->info;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
int64_t el = taosGetTimestampUs() - startTs;
|
||||||
|
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
||||||
|
|
||||||
|
pLoadInfo->totalElapsed += el;
|
||||||
|
|
||||||
|
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
||||||
|
qDebug("%s all %" PRIzu " sources are exhausted, total rows: %" PRIu64 " bytes:%" PRIu64 ", elapsed:%.2f ms",
|
||||||
|
GET_TASKID(pTaskInfo), totalSources, pLoadInfo->totalRows, pLoadInfo->totalSize,
|
||||||
|
pLoadInfo->totalElapsed / 1000.0);
|
||||||
|
|
||||||
|
setOperatorCompleted(pOperator);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t getCompletedSources(const SArray* pArray) {
|
||||||
|
size_t total = taosArrayGetSize(pArray);
|
||||||
|
|
||||||
|
int32_t completed = 0;
|
||||||
|
for (int32_t k = 0; k < total; ++k) {
|
||||||
|
SSourceDataInfo* p = taosArrayGet(pArray, k);
|
||||||
|
if (p->status == EX_SOURCE_DATA_EXHAUSTED) {
|
||||||
|
completed += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) {
|
||||||
|
SExchangeInfo* pExchangeInfo = pOperator->info;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
||||||
|
int64_t startTs = taosGetTimestampUs();
|
||||||
|
|
||||||
|
// Asynchronously send all fetch requests to all sources.
|
||||||
|
for (int32_t i = 0; i < totalSources; ++i) {
|
||||||
|
int32_t code = doSendFetchDataRequest(pExchangeInfo, pTaskInfo, i);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
pTaskInfo->code = code;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t endTs = taosGetTimestampUs();
|
||||||
|
qDebug("%s send all fetch requests to %" PRIzu " sources completed, elapsed:%.2fms", GET_TASKID(pTaskInfo),
|
||||||
|
totalSources, (endTs - startTs) / 1000.0);
|
||||||
|
|
||||||
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
|
pOperator->cost.openCost = taosGetTimestampUs() - startTs;
|
||||||
|
|
||||||
|
tsem_wait(&pExchangeInfo->ready);
|
||||||
|
tsem_post(&pExchangeInfo->ready);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t seqLoadRemoteData(SOperatorInfo* pOperator) {
|
||||||
|
SExchangeInfo* pExchangeInfo = pOperator->info;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
||||||
|
int64_t startTs = taosGetTimestampUs();
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
if (pExchangeInfo->current >= totalSources) {
|
||||||
|
setAllSourcesCompleted(pOperator, startTs);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
doSendFetchDataRequest(pExchangeInfo, pTaskInfo, pExchangeInfo->current);
|
||||||
|
tsem_wait(&pExchangeInfo->ready);
|
||||||
|
|
||||||
|
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, pExchangeInfo->current);
|
||||||
|
SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, pExchangeInfo->current);
|
||||||
|
|
||||||
|
if (pDataInfo->code != TSDB_CODE_SUCCESS) {
|
||||||
|
qError("%s vgId:%d, taskID:0x%" PRIx64 " execId:%d error happens, code:%s", GET_TASKID(pTaskInfo),
|
||||||
|
pSource->addr.nodeId, pSource->taskId, pSource->execId, tstrerror(pDataInfo->code));
|
||||||
|
pOperator->pTaskInfo->code = pDataInfo->code;
|
||||||
|
return pOperator->pTaskInfo->code;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRetrieveTableRsp* pRsp = pDataInfo->pRsp;
|
||||||
|
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
||||||
|
if (pRsp->numOfRows == 0) {
|
||||||
|
qDebug("%s vgId:%d, taskID:0x%" PRIx64 " execId:%d %d of total completed, rowsOfSource:%" PRIu64
|
||||||
|
", totalRows:%" PRIu64 " try next",
|
||||||
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pExchangeInfo->current + 1,
|
||||||
|
pDataInfo->totalRows, pLoadInfo->totalRows);
|
||||||
|
|
||||||
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
|
pExchangeInfo->current += 1;
|
||||||
|
taosMemoryFreeClear(pDataInfo->pRsp);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRetrieveTableRsp* pRetrieveRsp = pDataInfo->pRsp;
|
||||||
|
|
||||||
|
char* pStart = pRetrieveRsp->data;
|
||||||
|
int32_t code = extractDataBlockFromFetchRsp(NULL, pStart, NULL, &pStart);
|
||||||
|
|
||||||
|
if (pRsp->completed == 1) {
|
||||||
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, rowsOfSource:%" PRIu64
|
||||||
|
", totalRows:%" PRIu64 ", totalBytes:%" PRIu64 " try next %d/%" PRIzu,
|
||||||
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRetrieveRsp->numOfRows,
|
||||||
|
pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize, pExchangeInfo->current + 1,
|
||||||
|
totalSources);
|
||||||
|
|
||||||
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
|
pExchangeInfo->current += 1;
|
||||||
|
} else {
|
||||||
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, totalRows:%" PRIu64
|
||||||
|
", totalBytes:%" PRIu64,
|
||||||
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRetrieveRsp->numOfRows,
|
||||||
|
pLoadInfo->totalRows, pLoadInfo->totalSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLoadRemoteInfo(pLoadInfo, pRetrieveRsp->numOfRows, pRetrieveRsp->compLen, startTs, pOperator);
|
||||||
|
pDataInfo->totalRows += pRetrieveRsp->numOfRows;
|
||||||
|
|
||||||
|
taosMemoryFreeClear(pDataInfo->pRsp);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t prepareLoadRemoteData(SOperatorInfo* pOperator) {
|
||||||
|
if (OPTR_IS_OPENED(pOperator)) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t st = taosGetTimestampUs();
|
||||||
|
|
||||||
|
SExchangeInfo* pExchangeInfo = pOperator->info;
|
||||||
|
if (!pExchangeInfo->seqLoadData) {
|
||||||
|
int32_t code = prepareConcurrentlyLoad(pOperator);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
pExchangeInfo->openedTs = taosGetTimestampUs();
|
||||||
|
}
|
||||||
|
|
||||||
|
OPTR_SET_OPENED(pOperator);
|
||||||
|
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
|
@ -1106,3 +1106,24 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qProcessRspMsg(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||||
|
SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle;
|
||||||
|
assert(pMsg->info.ahandle != NULL);
|
||||||
|
|
||||||
|
SDataBuf buf = {.len = pMsg->contLen, .pData = NULL};
|
||||||
|
|
||||||
|
if (pMsg->contLen > 0) {
|
||||||
|
buf.pData = taosMemoryCalloc(1, pMsg->contLen);
|
||||||
|
if (buf.pData == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
} else {
|
||||||
|
memcpy(buf.pData, pMsg->pCont, pMsg->contLen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pSendInfo->fp(pSendInfo->param, &buf, pMsg->code);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
destroySendMsgInfo(pSendInfo);
|
||||||
|
}
|
|
@ -32,7 +32,6 @@
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
||||||
#include "tcompression.h"
|
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
#include "ttypes.h"
|
#include "ttypes.h"
|
||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
|
@ -91,11 +90,8 @@ static void destroySortOperatorInfo(void* param);
|
||||||
static void destroyAggOperatorInfo(void* param);
|
static void destroyAggOperatorInfo(void* param);
|
||||||
|
|
||||||
static void destroyIntervalOperatorInfo(void* param);
|
static void destroyIntervalOperatorInfo(void* param);
|
||||||
static void destroyExchangeOperatorInfo(void* param);
|
|
||||||
|
|
||||||
static void destroyOperatorInfo(SOperatorInfo* pOperator);
|
void setOperatorCompleted(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
void doSetOperatorCompleted(SOperatorInfo* pOperator) {
|
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
ASSERT(pOperator->pTaskInfo != NULL);
|
ASSERT(pOperator->pTaskInfo != NULL);
|
||||||
|
|
||||||
|
@ -103,14 +99,24 @@ void doSetOperatorCompleted(SOperatorInfo* pOperator) {
|
||||||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setOperatorInfo(SOperatorInfo* pOperator, const char* name, int32_t type, bool blocking, int32_t status,
|
||||||
|
void* pInfo, SExecTaskInfo* pTaskInfo) {
|
||||||
|
pOperator->name = (char*)name;
|
||||||
|
pOperator->operatorType = type;
|
||||||
|
pOperator->blocking = blocking;
|
||||||
|
pOperator->status = status;
|
||||||
|
pOperator->info = pInfo;
|
||||||
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t operatorDummyOpenFn(SOperatorInfo* pOperator) {
|
int32_t operatorDummyOpenFn(SOperatorInfo* pOperator) {
|
||||||
OPTR_SET_OPENED(pOperator);
|
OPTR_SET_OPENED(pOperator);
|
||||||
pOperator->cost.openCost = 0;
|
pOperator->cost.openCost = 0;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn,
|
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t cleanup,
|
||||||
__optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_explain_fn_t explain) {
|
__optr_close_fn_t closeFn, __optr_explain_fn_t explain) {
|
||||||
SOperatorFpSet fpSet = {
|
SOperatorFpSet fpSet = {
|
||||||
._openFn = openFn,
|
._openFn = openFn,
|
||||||
.getNextFn = nextFn,
|
.getNextFn = nextFn,
|
||||||
|
@ -1652,623 +1658,6 @@ int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct SFetchRspHandleWrapper {
|
|
||||||
uint32_t exchangeId;
|
|
||||||
int32_t sourceIndex;
|
|
||||||
} SFetchRspHandleWrapper;
|
|
||||||
|
|
||||||
int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
|
||||||
SFetchRspHandleWrapper* pWrapper = (SFetchRspHandleWrapper*)param;
|
|
||||||
|
|
||||||
SExchangeInfo* pExchangeInfo = taosAcquireRef(exchangeObjRefPool, pWrapper->exchangeId);
|
|
||||||
if (pExchangeInfo == NULL) {
|
|
||||||
qWarn("failed to acquire exchange operator, since it may have been released");
|
|
||||||
taosMemoryFree(pMsg->pData);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t index = pWrapper->sourceIndex;
|
|
||||||
SSourceDataInfo* pSourceDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, index);
|
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
|
||||||
pSourceDataInfo->pRsp = pMsg->pData;
|
|
||||||
|
|
||||||
SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp;
|
|
||||||
pRsp->numOfRows = htonl(pRsp->numOfRows);
|
|
||||||
pRsp->compLen = htonl(pRsp->compLen);
|
|
||||||
pRsp->numOfCols = htonl(pRsp->numOfCols);
|
|
||||||
pRsp->useconds = htobe64(pRsp->useconds);
|
|
||||||
pRsp->numOfBlocks = htonl(pRsp->numOfBlocks);
|
|
||||||
|
|
||||||
ASSERT(pRsp != NULL);
|
|
||||||
qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%d", pSourceDataInfo->taskId, index, pRsp->numOfBlocks,
|
|
||||||
pRsp->numOfRows);
|
|
||||||
} else {
|
|
||||||
taosMemoryFree(pMsg->pData);
|
|
||||||
pSourceDataInfo->code = code;
|
|
||||||
qDebug("%s fetch rsp received, index:%d, error:%s", pSourceDataInfo->taskId, index, tstrerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
pSourceDataInfo->status = EX_SOURCE_DATA_READY;
|
|
||||||
|
|
||||||
tsem_post(&pExchangeInfo->ready);
|
|
||||||
taosReleaseRef(exchangeObjRefPool, pWrapper->exchangeId);
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void qProcessRspMsg(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
|
||||||
SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle;
|
|
||||||
assert(pMsg->info.ahandle != NULL);
|
|
||||||
|
|
||||||
SDataBuf buf = {.len = pMsg->contLen, .pData = NULL};
|
|
||||||
|
|
||||||
if (pMsg->contLen > 0) {
|
|
||||||
buf.pData = taosMemoryCalloc(1, pMsg->contLen);
|
|
||||||
if (buf.pData == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
} else {
|
|
||||||
memcpy(buf.pData, pMsg->pCont, pMsg->contLen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pSendInfo->fp(pSendInfo->param, &buf, pMsg->code);
|
|
||||||
rpcFreeCont(pMsg->pCont);
|
|
||||||
destroySendMsgInfo(pSendInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTaskInfo, int32_t sourceIndex) {
|
|
||||||
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
|
||||||
|
|
||||||
SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, sourceIndex);
|
|
||||||
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, sourceIndex);
|
|
||||||
|
|
||||||
ASSERT(pDataInfo->status == EX_SOURCE_DATA_NOT_READY);
|
|
||||||
|
|
||||||
SFetchRspHandleWrapper* pWrapper = taosMemoryCalloc(1, sizeof(SFetchRspHandleWrapper));
|
|
||||||
pWrapper->exchangeId = pExchangeInfo->self;
|
|
||||||
pWrapper->sourceIndex = sourceIndex;
|
|
||||||
|
|
||||||
if (pSource->localExec) {
|
|
||||||
SDataBuf pBuf = {0};
|
|
||||||
int32_t code =
|
|
||||||
(*pTaskInfo->localFetch.fp)(pTaskInfo->localFetch.handle, pSource->schedId, pTaskInfo->id.queryId,
|
|
||||||
pSource->taskId, 0, pSource->execId, &pBuf.pData, pTaskInfo->localFetch.explainRes);
|
|
||||||
loadRemoteDataCallback(pWrapper, &pBuf, code);
|
|
||||||
taosMemoryFree(pWrapper);
|
|
||||||
} else {
|
|
||||||
SResFetchReq* pMsg = taosMemoryCalloc(1, sizeof(SResFetchReq));
|
|
||||||
if (NULL == pMsg) {
|
|
||||||
pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
|
||||||
taosMemoryFree(pWrapper);
|
|
||||||
return pTaskInfo->code;
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug("%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%" PRIx64 ", execId:%d, %d/%" PRIzu,
|
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId,
|
|
||||||
pSource->execId, sourceIndex, totalSources);
|
|
||||||
|
|
||||||
pMsg->header.vgId = htonl(pSource->addr.nodeId);
|
|
||||||
pMsg->sId = htobe64(pSource->schedId);
|
|
||||||
pMsg->taskId = htobe64(pSource->taskId);
|
|
||||||
pMsg->queryId = htobe64(pTaskInfo->id.queryId);
|
|
||||||
pMsg->execId = htonl(pSource->execId);
|
|
||||||
|
|
||||||
// send the fetch remote task result reques
|
|
||||||
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
|
||||||
if (NULL == pMsgSendInfo) {
|
|
||||||
taosMemoryFreeClear(pMsg);
|
|
||||||
taosMemoryFree(pWrapper);
|
|
||||||
qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo));
|
|
||||||
pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
|
||||||
return pTaskInfo->code;
|
|
||||||
}
|
|
||||||
|
|
||||||
pMsgSendInfo->param = pWrapper;
|
|
||||||
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
|
||||||
pMsgSendInfo->msgInfo.pData = pMsg;
|
|
||||||
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
|
||||||
pMsgSendInfo->msgType = pSource->fetchMsgType;
|
|
||||||
pMsgSendInfo->fp = loadRemoteDataCallback;
|
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
|
||||||
int32_t code =
|
|
||||||
asyncSendMsgToServer(pExchangeInfo->pTransporter, &pSource->addr.epSet, &transporterId, pMsgSendInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int32_t numOfRows, int32_t dataLen, int64_t startTs,
|
|
||||||
SOperatorInfo* pOperator) {
|
|
||||||
pInfo->totalRows += numOfRows;
|
|
||||||
pInfo->totalSize += dataLen;
|
|
||||||
pInfo->totalElapsed += (taosGetTimestampUs() - startTs);
|
|
||||||
pOperator->resultInfo.totalRows += numOfRows;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, SArray* pColList, char** pNextStart) {
|
|
||||||
if (pColList == NULL) { // data from other sources
|
|
||||||
blockDataCleanup(pRes);
|
|
||||||
*pNextStart = (char*)blockDecode(pRes, pData);
|
|
||||||
} else { // extract data according to pColList
|
|
||||||
char* pStart = pData;
|
|
||||||
|
|
||||||
int32_t numOfCols = htonl(*(int32_t*)pStart);
|
|
||||||
pStart += sizeof(int32_t);
|
|
||||||
|
|
||||||
// todo refactor:extract method
|
|
||||||
SSysTableSchema* pSchema = (SSysTableSchema*)pStart;
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
|
||||||
SSysTableSchema* p = (SSysTableSchema*)pStart;
|
|
||||||
|
|
||||||
p->colId = htons(p->colId);
|
|
||||||
p->bytes = htonl(p->bytes);
|
|
||||||
pStart += sizeof(SSysTableSchema);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSDataBlock* pBlock = createDataBlock();
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
|
||||||
SColumnInfoData idata = createColumnInfoData(pSchema[i].type, pSchema[i].bytes, pSchema[i].colId);
|
|
||||||
blockDataAppendColInfo(pBlock, &idata);
|
|
||||||
}
|
|
||||||
|
|
||||||
blockDecode(pBlock, pStart);
|
|
||||||
blockDataEnsureCapacity(pRes, pBlock->info.rows);
|
|
||||||
|
|
||||||
// data from mnode
|
|
||||||
pRes->info.rows = pBlock->info.rows;
|
|
||||||
relocateColumnData(pRes, pColList, pBlock->pDataBlock, false);
|
|
||||||
blockDataDestroy(pBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo move this to time window aggregator, since the primary timestamp may not be known by exchange operator.
|
|
||||||
blockDataUpdateTsWindow(pRes, 0);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void* setAllSourcesCompleted(SOperatorInfo* pOperator, int64_t startTs) {
|
|
||||||
SExchangeInfo* pExchangeInfo = pOperator->info;
|
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
|
||||||
|
|
||||||
int64_t el = taosGetTimestampUs() - startTs;
|
|
||||||
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
|
||||||
|
|
||||||
pLoadInfo->totalElapsed += el;
|
|
||||||
|
|
||||||
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
|
||||||
qDebug("%s all %" PRIzu " sources are exhausted, total rows: %" PRIu64 " bytes:%" PRIu64 ", elapsed:%.2f ms",
|
|
||||||
GET_TASKID(pTaskInfo), totalSources, pLoadInfo->totalRows, pLoadInfo->totalSize,
|
|
||||||
pLoadInfo->totalElapsed / 1000.0);
|
|
||||||
|
|
||||||
doSetOperatorCompleted(pOperator);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeInfo* pExchangeInfo,
|
|
||||||
SExecTaskInfo* pTaskInfo) {
|
|
||||||
int32_t code = 0;
|
|
||||||
int64_t startTs = taosGetTimestampUs();
|
|
||||||
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
|
||||||
|
|
||||||
int32_t completed = 0;
|
|
||||||
for (int32_t k = 0; k < totalSources; ++k) {
|
|
||||||
SSourceDataInfo* p = taosArrayGet(pExchangeInfo->pSourceDataInfo, k);
|
|
||||||
if (p->status == EX_SOURCE_DATA_EXHAUSTED) {
|
|
||||||
completed += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (completed == totalSources) {
|
|
||||||
setAllSourcesCompleted(pOperator, startTs);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
// printf("1\n");
|
|
||||||
tsem_wait(&pExchangeInfo->ready);
|
|
||||||
// printf("2\n");
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < totalSources; ++i) {
|
|
||||||
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, i);
|
|
||||||
if (pDataInfo->status == EX_SOURCE_DATA_EXHAUSTED) {
|
|
||||||
// printf("========:%d is completed\n", i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// printf("index:%d - status:%d\n", i, pDataInfo->status);
|
|
||||||
if (pDataInfo->status != EX_SOURCE_DATA_READY) {
|
|
||||||
// printf("-----------%d, status:%d, continue\n", i, pDataInfo->status);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pDataInfo->code != TSDB_CODE_SUCCESS) {
|
|
||||||
code = pDataInfo->code;
|
|
||||||
goto _error;
|
|
||||||
}
|
|
||||||
|
|
||||||
SRetrieveTableRsp* pRsp = pDataInfo->pRsp;
|
|
||||||
SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, i);
|
|
||||||
|
|
||||||
// todo
|
|
||||||
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
|
||||||
if (pRsp->numOfRows == 0) {
|
|
||||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
|
||||||
// printf("%d completed, try next\n", i);
|
|
||||||
|
|
||||||
qDebug("%s vgId:%d, taskId:0x%" PRIx64 " execId:%d index:%d completed, rowsOfSource:%" PRIu64
|
|
||||||
", totalRows:%" PRIu64 ", completed:%d try next %d/%" PRIzu,
|
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, i, pDataInfo->totalRows,
|
|
||||||
pExchangeInfo->loadInfo.totalRows, completed, i + 1, totalSources);
|
|
||||||
taosMemoryFreeClear(pDataInfo->pRsp);
|
|
||||||
|
|
||||||
// if (completed == totalSources) {
|
|
||||||
// return;
|
|
||||||
// } else {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SRetrieveTableRsp* pRetrieveRsp = pDataInfo->pRsp;
|
|
||||||
int32_t index = 0;
|
|
||||||
char* pStart = pRetrieveRsp->data;
|
|
||||||
while (index++ < pRetrieveRsp->numOfBlocks) {
|
|
||||||
printf("results, numOfBLock: %d\n", pRetrieveRsp->numOfBlocks);
|
|
||||||
SSDataBlock* pb = createOneDataBlock(pExchangeInfo->pDummyBlock, false);
|
|
||||||
code = extractDataBlockFromFetchRsp(pb, pStart, NULL, &pStart);
|
|
||||||
if (code != 0) {
|
|
||||||
taosMemoryFreeClear(pDataInfo->pRsp);
|
|
||||||
goto _error;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayPush(pExchangeInfo->pResultBlockList, &pb);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLoadRemoteInfo(pLoadInfo, pRetrieveRsp->numOfRows, pRetrieveRsp->compLen, startTs, pOperator);
|
|
||||||
|
|
||||||
// int32_t completed = 0;
|
|
||||||
if (pRsp->completed == 1) {
|
|
||||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
|
||||||
|
|
||||||
// for (int32_t k = 0; k < totalSources; ++k) {
|
|
||||||
// SSourceDataInfo* p = taosArrayGet(pExchangeInfo->pSourceDataInfo, k);
|
|
||||||
// if (p->status == EX_SOURCE_DATA_EXHAUSTED) {
|
|
||||||
// completed += 1;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64
|
|
||||||
" execId:%d index:%d completed, blocks:%d, numOfRows:%d, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64
|
|
||||||
", total:%.2f Kb, completed:%d try next %d/%" PRIzu,
|
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, i, pRsp->numOfBlocks,
|
|
||||||
pRsp->numOfRows, pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize / 1024.0,
|
|
||||||
completed, i + 1, totalSources);
|
|
||||||
} else {
|
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64
|
|
||||||
" execId:%d blocks:%d, numOfRows:%d, totalRows:%" PRIu64 ", total:%.2f Kb",
|
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRsp->numOfBlocks,
|
|
||||||
pRsp->numOfRows, pLoadInfo->totalRows, pLoadInfo->totalSize / 1024.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFreeClear(pDataInfo->pRsp);
|
|
||||||
|
|
||||||
if (pDataInfo->status != EX_SOURCE_DATA_EXHAUSTED) {
|
|
||||||
pDataInfo->status = EX_SOURCE_DATA_NOT_READY;
|
|
||||||
code = doSendFetchDataRequest(pExchangeInfo, pTaskInfo, i);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
taosMemoryFreeClear(pDataInfo->pRsp);
|
|
||||||
goto _error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (completed == totalSources) {
|
|
||||||
// setAllSourcesCompleted(pOperator, startTs);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t completed = 0;
|
|
||||||
for (int32_t k = 0; k < totalSources; ++k) {
|
|
||||||
SSourceDataInfo* p = taosArrayGet(pExchangeInfo->pSourceDataInfo, k);
|
|
||||||
if (p->status == EX_SOURCE_DATA_EXHAUSTED) {
|
|
||||||
completed += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (completed == totalSources) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_error:
|
|
||||||
pTaskInfo->code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) {
|
|
||||||
SExchangeInfo* pExchangeInfo = pOperator->info;
|
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
|
||||||
|
|
||||||
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
|
||||||
int64_t startTs = taosGetTimestampUs();
|
|
||||||
|
|
||||||
// Asynchronously send all fetch requests to all sources.
|
|
||||||
for (int32_t i = 0; i < totalSources; ++i) {
|
|
||||||
int32_t code = doSendFetchDataRequest(pExchangeInfo, pTaskInfo, i);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
pTaskInfo->code = code;
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t endTs = taosGetTimestampUs();
|
|
||||||
qDebug("%s send all fetch requests to %" PRIzu " sources completed, elapsed:%.2fms", GET_TASKID(pTaskInfo),
|
|
||||||
totalSources, (endTs - startTs) / 1000.0);
|
|
||||||
|
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
|
||||||
pOperator->cost.openCost = taosGetTimestampUs() - startTs;
|
|
||||||
|
|
||||||
tsem_wait(&pExchangeInfo->ready);
|
|
||||||
tsem_post(&pExchangeInfo->ready);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t seqLoadRemoteData(SOperatorInfo* pOperator) {
|
|
||||||
SExchangeInfo* pExchangeInfo = pOperator->info;
|
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
|
||||||
|
|
||||||
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
|
||||||
int64_t startTs = taosGetTimestampUs();
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
if (pExchangeInfo->current >= totalSources) {
|
|
||||||
setAllSourcesCompleted(pOperator, startTs);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
doSendFetchDataRequest(pExchangeInfo, pTaskInfo, pExchangeInfo->current);
|
|
||||||
tsem_wait(&pExchangeInfo->ready);
|
|
||||||
|
|
||||||
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, pExchangeInfo->current);
|
|
||||||
SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, pExchangeInfo->current);
|
|
||||||
|
|
||||||
if (pDataInfo->code != TSDB_CODE_SUCCESS) {
|
|
||||||
qError("%s vgId:%d, taskID:0x%" PRIx64 " execId:%d error happens, code:%s", GET_TASKID(pTaskInfo),
|
|
||||||
pSource->addr.nodeId, pSource->taskId, pSource->execId, tstrerror(pDataInfo->code));
|
|
||||||
pOperator->pTaskInfo->code = pDataInfo->code;
|
|
||||||
return pOperator->pTaskInfo->code;
|
|
||||||
}
|
|
||||||
|
|
||||||
SRetrieveTableRsp* pRsp = pDataInfo->pRsp;
|
|
||||||
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
|
||||||
if (pRsp->numOfRows == 0) {
|
|
||||||
qDebug("%s vgId:%d, taskID:0x%" PRIx64 " execId:%d %d of total completed, rowsOfSource:%" PRIu64
|
|
||||||
", totalRows:%" PRIu64 " try next",
|
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pExchangeInfo->current + 1,
|
|
||||||
pDataInfo->totalRows, pLoadInfo->totalRows);
|
|
||||||
|
|
||||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
|
||||||
pExchangeInfo->current += 1;
|
|
||||||
taosMemoryFreeClear(pDataInfo->pRsp);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
SRetrieveTableRsp* pRetrieveRsp = pDataInfo->pRsp;
|
|
||||||
|
|
||||||
char* pStart = pRetrieveRsp->data;
|
|
||||||
int32_t code = extractDataBlockFromFetchRsp(NULL, pStart, NULL, &pStart);
|
|
||||||
|
|
||||||
if (pRsp->completed == 1) {
|
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, rowsOfSource:%" PRIu64
|
|
||||||
", totalRows:%" PRIu64 ", totalBytes:%" PRIu64 " try next %d/%" PRIzu,
|
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRetrieveRsp->numOfRows,
|
|
||||||
pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize, pExchangeInfo->current + 1,
|
|
||||||
totalSources);
|
|
||||||
|
|
||||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
|
||||||
pExchangeInfo->current += 1;
|
|
||||||
} else {
|
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, totalRows:%" PRIu64
|
|
||||||
", totalBytes:%" PRIu64,
|
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRetrieveRsp->numOfRows,
|
|
||||||
pLoadInfo->totalRows, pLoadInfo->totalSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLoadRemoteInfo(pLoadInfo, pRetrieveRsp->numOfRows, pRetrieveRsp->compLen, startTs, pOperator);
|
|
||||||
pDataInfo->totalRows += pRetrieveRsp->numOfRows;
|
|
||||||
|
|
||||||
taosMemoryFreeClear(pDataInfo->pRsp);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t prepareLoadRemoteData(SOperatorInfo* pOperator) {
|
|
||||||
if (OPTR_IS_OPENED(pOperator)) {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t st = taosGetTimestampUs();
|
|
||||||
|
|
||||||
SExchangeInfo* pExchangeInfo = pOperator->info;
|
|
||||||
if (!pExchangeInfo->seqLoadData) {
|
|
||||||
int32_t code = prepareConcurrentlyLoad(pOperator);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OPTR_SET_OPENED(pOperator);
|
|
||||||
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void freeBlock(void* pParam) {
|
|
||||||
SSDataBlock* pBlock = *(SSDataBlock**)pParam;
|
|
||||||
blockDataDestroy(pBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SSDataBlock* doLoadRemoteDataImpl(SOperatorInfo* pOperator) {
|
|
||||||
SExchangeInfo* pExchangeInfo = pOperator->info;
|
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
|
||||||
|
|
||||||
pTaskInfo->code = pOperator->fpSet._openFn(pOperator);
|
|
||||||
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
|
||||||
|
|
||||||
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
|
||||||
qDebug("%s all %" PRIzu " source(s) are exhausted, total rows:%" PRIu64 " bytes:%" PRIu64 ", elapsed:%.2f ms",
|
|
||||||
GET_TASKID(pTaskInfo), totalSources, pLoadInfo->totalRows, pLoadInfo->totalSize,
|
|
||||||
pLoadInfo->totalElapsed / 1000.0);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size = taosArrayGetSize(pExchangeInfo->pResultBlockList);
|
|
||||||
if (size == 0 || pExchangeInfo->rspBlockIndex >= size) {
|
|
||||||
pExchangeInfo->rspBlockIndex = 0;
|
|
||||||
taosArrayClearEx(pExchangeInfo->pResultBlockList, freeBlock);
|
|
||||||
if (pExchangeInfo->seqLoadData) {
|
|
||||||
seqLoadRemoteData(pOperator);
|
|
||||||
} else {
|
|
||||||
concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosArrayGetSize(pExchangeInfo->pResultBlockList) == 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// we have buffered retrieved datablock, return it directly
|
|
||||||
return taosArrayGetP(pExchangeInfo->pResultBlockList, pExchangeInfo->rspBlockIndex++);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SSDataBlock* doLoadRemoteData(SOperatorInfo* pOperator) {
|
|
||||||
SExchangeInfo* pExchangeInfo = pOperator->info;
|
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
|
||||||
|
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
SSDataBlock* pBlock = doLoadRemoteDataImpl(pOperator);
|
|
||||||
if (pBlock == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SLimitInfo* pLimitInfo = &pExchangeInfo->limitInfo;
|
|
||||||
if (hasLimitOffsetInfo(pLimitInfo)) {
|
|
||||||
int32_t status = handleLimitOffset(pOperator, pLimitInfo, pBlock, false);
|
|
||||||
if (status == PROJECT_RETRIEVE_CONTINUE) {
|
|
||||||
continue;
|
|
||||||
} else if (status == PROJECT_RETRIEVE_DONE) {
|
|
||||||
size_t rows = pBlock->info.rows;
|
|
||||||
pExchangeInfo->limitInfo.numOfOutputRows += rows;
|
|
||||||
|
|
||||||
if (rows == 0) {
|
|
||||||
doSetOperatorCompleted(pOperator);
|
|
||||||
return NULL;
|
|
||||||
} else {
|
|
||||||
return pBlock;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return pBlock;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo, const char* id) {
|
|
||||||
pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo));
|
|
||||||
if (pInfo->pSourceDataInfo == NULL) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfSources; ++i) {
|
|
||||||
SSourceDataInfo dataInfo = {0};
|
|
||||||
dataInfo.status = EX_SOURCE_DATA_NOT_READY;
|
|
||||||
dataInfo.taskId = id;
|
|
||||||
dataInfo.index = i;
|
|
||||||
SSourceDataInfo* pDs = taosArrayPush(pInfo->pSourceDataInfo, &dataInfo);
|
|
||||||
if (pDs == NULL) {
|
|
||||||
taosArrayDestroy(pInfo->pSourceDataInfo);
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo* pInfo, const char* id) {
|
|
||||||
size_t numOfSources = LIST_LENGTH(pExNode->pSrcEndPoints);
|
|
||||||
|
|
||||||
if (numOfSources == 0) {
|
|
||||||
qError("%s invalid number: %d of sources in exchange operator", id, (int32_t)numOfSources);
|
|
||||||
return TSDB_CODE_INVALID_PARA;
|
|
||||||
}
|
|
||||||
|
|
||||||
pInfo->pSources = taosArrayInit(numOfSources, sizeof(SDownstreamSourceNode));
|
|
||||||
if (pInfo->pSources == NULL) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfSources; ++i) {
|
|
||||||
SDownstreamSourceNode* pNode = (SDownstreamSourceNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i);
|
|
||||||
taosArrayPush(pInfo->pSources, pNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
initLimitInfo(pExNode->node.pLimit, pExNode->node.pSlimit, &pInfo->limitInfo);
|
|
||||||
pInfo->self = taosAddRef(exchangeObjRefPool, pInfo);
|
|
||||||
|
|
||||||
return initDataSource(numOfSources, pInfo, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo) {
|
|
||||||
SExchangeInfo* pInfo = taosMemoryCalloc(1, sizeof(SExchangeInfo));
|
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
|
||||||
goto _error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t code = initExchangeOperator(pExNode, pInfo, GET_TASKID(pTaskInfo));
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
goto _error;
|
|
||||||
}
|
|
||||||
|
|
||||||
tsem_init(&pInfo->ready, 0, 0);
|
|
||||||
pInfo->pDummyBlock = createResDataBlock(pExNode->node.pOutputDataBlockDesc);
|
|
||||||
pInfo->pResultBlockList = taosArrayInit(1, POINTER_BYTES);
|
|
||||||
|
|
||||||
pInfo->seqLoadData = false;
|
|
||||||
pInfo->pTransporter = pTransporter;
|
|
||||||
|
|
||||||
pOperator->name = "ExchangeOperator";
|
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_EXCHANGE;
|
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pDummyBlock->pDataBlock);
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet =
|
|
||||||
createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL, destroyExchangeOperatorInfo, NULL);
|
|
||||||
return pOperator;
|
|
||||||
|
|
||||||
_error:
|
|
||||||
if (pInfo != NULL) {
|
|
||||||
doDestroyExchangeOperatorInfo(pInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFreeClear(pOperator);
|
|
||||||
pTaskInfo->code = code;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize,
|
static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize,
|
||||||
const char* pKey);
|
const char* pKey);
|
||||||
|
|
||||||
|
@ -2413,7 +1802,7 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) {
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
pTaskInfo->code = pOperator->fpSet._openFn(pOperator);
|
pTaskInfo->code = pOperator->fpSet._openFn(pOperator);
|
||||||
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
|
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2423,7 +1812,7 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) {
|
||||||
doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
|
doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
|
||||||
|
|
||||||
if (!hasRemainResults(&pAggInfo->groupResInfo)) {
|
if (!hasRemainResults(&pAggInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2672,7 +2061,7 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
|
||||||
SSDataBlock* pBlock = pDownstream->fpSet.getNextFn(pDownstream);
|
SSDataBlock* pBlock = pDownstream->fpSet.getNextFn(pDownstream);
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
if (pInfo->totalInputRows == 0) {
|
if (pInfo->totalInputRows == 0) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2749,7 +2138,7 @@ static SSDataBlock* doFill(SOperatorInfo* pOperator) {
|
||||||
while (true) {
|
while (true) {
|
||||||
fillResult = doFillImpl(pOperator);
|
fillResult = doFillImpl(pOperator);
|
||||||
if (fillResult == NULL) {
|
if (fillResult == NULL) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2780,7 +2169,7 @@ void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyOperatorInfo(SOperatorInfo* pOperator) {
|
void destroyOperatorInfo(SOperatorInfo* pOperator) {
|
||||||
if (pOperator == NULL) {
|
if (pOperator == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2979,15 +2368,10 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN
|
||||||
|
|
||||||
pInfo->binfo.mergeResultBlock = pAggNode->mergeDataBlock;
|
pInfo->binfo.mergeResultBlock = pAggNode->mergeDataBlock;
|
||||||
pInfo->groupId = UINT64_MAX;
|
pInfo->groupId = UINT64_MAX;
|
||||||
pOperator->name = "TableAggregate";
|
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_HASH_AGG;
|
|
||||||
pOperator->blocking = true;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
|
setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, true, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, NULL, destroyAggOperatorInfo, NULL);
|
createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, NULL);
|
||||||
|
|
||||||
if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) {
|
if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) {
|
||||||
STableScanInfo* pTableScanInfo = downstream->info;
|
STableScanInfo* pTableScanInfo = downstream->info;
|
||||||
|
@ -3051,33 +2435,6 @@ void destroyFillOperatorInfo(void* param) {
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyExchangeOperatorInfo(void* param) {
|
|
||||||
SExchangeInfo* pExInfo = (SExchangeInfo*)param;
|
|
||||||
taosRemoveRef(exchangeObjRefPool, pExInfo->self);
|
|
||||||
}
|
|
||||||
|
|
||||||
void freeSourceDataInfo(void* p) {
|
|
||||||
SSourceDataInfo* pInfo = (SSourceDataInfo*)p;
|
|
||||||
taosMemoryFreeClear(pInfo->pRsp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void doDestroyExchangeOperatorInfo(void* param) {
|
|
||||||
SExchangeInfo* pExInfo = (SExchangeInfo*)param;
|
|
||||||
|
|
||||||
taosArrayDestroy(pExInfo->pSources);
|
|
||||||
taosArrayDestroyEx(pExInfo->pSourceDataInfo, freeSourceDataInfo);
|
|
||||||
|
|
||||||
if (pExInfo->pResultBlockList != NULL) {
|
|
||||||
taosArrayDestroyEx(pExInfo->pResultBlockList, freeBlock);
|
|
||||||
pExInfo->pResultBlockList = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
blockDataDestroy(pExInfo->pDummyBlock);
|
|
||||||
|
|
||||||
tsem_destroy(&pExInfo->ready);
|
|
||||||
taosMemoryFreeClear(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t numOfCols, SExprInfo* pNotFillExpr,
|
static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t numOfCols, SExprInfo* pNotFillExpr,
|
||||||
int32_t numOfNotFillCols, SNodeListNode* pValNode, STimeWindow win, int32_t capacity,
|
int32_t numOfNotFillCols, SNodeListNode* pValNode, STimeWindow win, int32_t capacity,
|
||||||
const char* id, SInterval* pInterval, int32_t fillType, int32_t order) {
|
const char* id, SInterval* pInterval, int32_t fillType, int32_t order) {
|
||||||
|
@ -3209,15 +2566,9 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperator->name = "FillOperator";
|
setOperatorInfo(pOperator, "FillOperator", QUERY_NODE_PHYSICAL_PLAN_FILL, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_FILL;
|
|
||||||
pOperator->exprSupp.numOfExprs = pInfo->numOfExpr;
|
pOperator->exprSupp.numOfExprs = pInfo->numOfExpr;
|
||||||
pOperator->info = pInfo;
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, destroyFillOperatorInfo, NULL);
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, NULL, destroyFillOperatorInfo, NULL);
|
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
@ -4072,6 +3423,7 @@ int32_t buildSessionResultDataBlock(SOperatorInfo* pOperator, SStreamState* pSta
|
||||||
ASSERT(code == 0);
|
ASSERT(code == 0);
|
||||||
if (code == -1) {
|
if (code == -1) {
|
||||||
// coverity scan
|
// coverity scan
|
||||||
|
pGroupResInfo->index += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SResultRow* pRow = (SResultRow*)pVal;
|
SResultRow* pRow = (SResultRow*)pVal;
|
||||||
|
|
|
@ -316,7 +316,7 @@ static SSDataBlock* buildGroupResultDataBlock(SOperatorInfo* pOperator) {
|
||||||
doFilter(pRes, pOperator->exprSupp.pFilterInfo, NULL);
|
doFilter(pRes, pOperator->exprSupp.pFilterInfo, NULL);
|
||||||
|
|
||||||
if (!hasRemainResults(&pInfo->groupResInfo)) {
|
if (!hasRemainResults(&pInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,15 +438,10 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode*
|
||||||
}
|
}
|
||||||
|
|
||||||
initResultRowInfo(&pInfo->binfo.resultRowInfo);
|
initResultRowInfo(&pInfo->binfo.resultRowInfo);
|
||||||
|
setOperatorInfo(pOperator, "GroupbyAggOperator", 0, true, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->name = "GroupbyAggOperator";
|
|
||||||
pOperator->blocking = true;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(operatorDummyOpenFn, hashGroupbyAggregate, NULL, NULL, destroyGroupOperatorInfo, NULL);
|
createOperatorFpSet(operatorDummyOpenFn, hashGroupbyAggregate, NULL, destroyGroupOperatorInfo, NULL);
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
|
@ -654,7 +649,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
|
||||||
// try next group data
|
// try next group data
|
||||||
++pInfo->groupIndex;
|
++pInfo->groupIndex;
|
||||||
if (pInfo->groupIndex >= taosArrayGetSize(pInfo->sortedGroupArray)) {
|
if (pInfo->groupIndex >= taosArrayGetSize(pInfo->sortedGroupArray)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
clearPartitionOperator(pInfo);
|
clearPartitionOperator(pInfo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -821,17 +816,12 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperator->name = "PartitionOperator";
|
setOperatorInfo(pOperator, "PartitionOperator", QUERY_NODE_PHYSICAL_PLAN_PARTITION, false, OP_NOT_OPENED, pInfo,
|
||||||
pOperator->blocking = true;
|
pTaskInfo);
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_PARTITION;
|
|
||||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, hashPartition, NULL, destroyPartitionOperatorInfo, NULL);
|
||||||
createOperatorFpSet(operatorDummyOpenFn, hashPartition, NULL, NULL, destroyPartitionOperatorInfo, NULL);
|
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
@ -909,7 +899,10 @@ static SSDataBlock* buildStreamPartitionResult(SOperatorInfo* pOperator) {
|
||||||
void* pData = colDataGetVarData(pCol, 0);
|
void* pData = colDataGetVarData(pCol, 0);
|
||||||
// TODO check tbname validity
|
// TODO check tbname validity
|
||||||
if (pData != (void*)-1) {
|
if (pData != (void*)-1) {
|
||||||
memcpy(pDest->info.parTbName, varDataVal(pData), varDataLen(pData));
|
memset(pDest->info.parTbName, 0, TSDB_TABLE_NAME_LEN);
|
||||||
|
int32_t len = TMIN(varDataLen(pData), TSDB_TABLE_NAME_LEN - 1);
|
||||||
|
memcpy(pDest->info.parTbName, varDataVal(pData), len);
|
||||||
|
/*pDest->info.parTbName[len + 1] = 0;*/
|
||||||
} else {
|
} else {
|
||||||
pDest->info.parTbName[0] = 0;
|
pDest->info.parTbName[0] = 0;
|
||||||
}
|
}
|
||||||
|
@ -918,6 +911,8 @@ static SSDataBlock* buildStreamPartitionResult(SOperatorInfo* pOperator) {
|
||||||
blockDataDestroy(pResBlock);
|
blockDataDestroy(pResBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
taosArrayDestroy(pParInfo->rowIds);
|
||||||
|
pParInfo->rowIds = NULL;
|
||||||
blockDataUpdateTsWindow(pDest, pInfo->tsColIndex);
|
blockDataUpdateTsWindow(pDest, pInfo->tsColIndex);
|
||||||
pDest->info.groupId = pParInfo->groupId;
|
pDest->info.groupId = pParInfo->groupId;
|
||||||
pOperator->resultInfo.totalRows += pDest->info.rows;
|
pOperator->resultInfo.totalRows += pDest->info.rows;
|
||||||
|
@ -963,7 +958,7 @@ static SSDataBlock* doStreamHashPartition(SOperatorInfo* pOperator) {
|
||||||
pInfo->pInputDataBlock = NULL;
|
pInfo->pInputDataBlock = NULL;
|
||||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
printDataBlock(pBlock, "stream partitionby recv");
|
printDataBlock(pBlock, "stream partitionby recv");
|
||||||
|
@ -1016,6 +1011,7 @@ static void destroyStreamPartitionOperatorInfo(void* param) {
|
||||||
cleanupExprSupp(&pInfo->tbnameCalSup);
|
cleanupExprSupp(&pInfo->tbnameCalSup);
|
||||||
cleanupExprSupp(&pInfo->tagCalSup);
|
cleanupExprSupp(&pInfo->tagCalSup);
|
||||||
blockDataDestroy(pInfo->pDelRes);
|
blockDataDestroy(pInfo->pDelRes);
|
||||||
|
taosHashCleanup(pInfo->pPartitions);
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1103,16 +1099,12 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
SExprInfo* pExprInfo = createExprInfo(pPartNode->part.pTargets, NULL, &numOfCols);
|
SExprInfo* pExprInfo = createExprInfo(pPartNode->part.pTargets, NULL, &numOfCols);
|
||||||
|
|
||||||
pOperator->name = "StreamPartitionOperator";
|
setOperatorInfo(pOperator, "StreamPartitionOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION, false, OP_NOT_OPENED,
|
||||||
pOperator->blocking = false;
|
pInfo, pTaskInfo);
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION;
|
|
||||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||||
pOperator->info = pInfo;
|
pOperator->fpSet =
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
createOperatorFpSet(operatorDummyOpenFn, doStreamHashPartition, NULL, destroyStreamPartitionOperatorInfo, NULL);
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamHashPartition, NULL, NULL,
|
|
||||||
destroyStreamPartitionOperatorInfo, NULL);
|
|
||||||
|
|
||||||
initParDownStream(downstream, &pInfo->partitionSup, &pInfo->scalarSup);
|
initParDownStream(downstream, &pInfo->partitionSup, &pInfo->scalarSup);
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
|
|
@ -73,14 +73,10 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||||
|
|
||||||
pInfo->pRes = pResBlock;
|
pInfo->pRes = pResBlock;
|
||||||
pOperator->name = "MergeJoinOperator";
|
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN;
|
setOperatorInfo(pOperator, "MergeJoinOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
extractTimeCondition(pInfo, pDownstream, numOfDownstream, pJoinNode);
|
extractTimeCondition(pInfo, pDownstream, numOfDownstream, pJoinNode);
|
||||||
|
|
||||||
|
@ -121,8 +117,7 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
|
||||||
pInfo->inputOrder = TSDB_ORDER_DESC;
|
pInfo->inputOrder = TSDB_ORDER_DESC;
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, destroyMergeJoinOperator, NULL);
|
||||||
createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, NULL, destroyMergeJoinOperator, NULL);
|
|
||||||
code = appendDownstream(pOperator, pDownstream, numOfDownstream);
|
code = appendDownstream(pOperator, pDownstream, numOfDownstream);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
|
@ -372,13 +367,13 @@ static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes)
|
||||||
|
|
||||||
if (leftTs == rightTs) {
|
if (leftTs == rightTs) {
|
||||||
mergeJoinJoinDownstreamTsRanges(pOperator, leftTs, pRes, &nrows);
|
mergeJoinJoinDownstreamTsRanges(pOperator, leftTs, pRes, &nrows);
|
||||||
} else if (asc && leftTs < rightTs || !asc && leftTs > rightTs) {
|
} else if ((asc && leftTs < rightTs) || (!asc && leftTs > rightTs)) {
|
||||||
pJoinInfo->leftPos += 1;
|
pJoinInfo->leftPos += 1;
|
||||||
|
|
||||||
if (pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) {
|
if (pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (asc && leftTs > rightTs || !asc && leftTs < rightTs) {
|
} else if ((asc && leftTs > rightTs) || (!asc && leftTs < rightTs)) {
|
||||||
pJoinInfo->rightPos += 1;
|
pJoinInfo->rightPos += 1;
|
||||||
if (pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) {
|
if (pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -98,13 +98,9 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pOperator->exprSupp.pCtx, numOfCols);
|
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pOperator->exprSupp.pCtx, numOfCols);
|
||||||
pOperator->name = "ProjectOperator";
|
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_PROJECT;
|
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doProjectOperation, NULL, NULL,
|
setOperatorInfo(pOperator, "ProjectOperator", QUERY_NODE_PHYSICAL_PLAN_PROJECT, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doProjectOperation, NULL,
|
||||||
destroyProjectOperatorInfo, NULL);
|
destroyProjectOperatorInfo, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -153,7 +149,7 @@ static int32_t setInfoForNewGroup(SSDataBlock* pBlock, SLimitInfo* pLimitInfo, S
|
||||||
if (pLimitInfo->currentGroupId != 0 && pLimitInfo->currentGroupId != pBlock->info.groupId) {
|
if (pLimitInfo->currentGroupId != 0 && pLimitInfo->currentGroupId != pBlock->info.groupId) {
|
||||||
pLimitInfo->numOfOutputGroups += 1;
|
pLimitInfo->numOfOutputGroups += 1;
|
||||||
if ((pLimitInfo->slimit.limit > 0) && (pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) {
|
if ((pLimitInfo->slimit.limit > 0) && (pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return PROJECT_RETRIEVE_DONE;
|
return PROJECT_RETRIEVE_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +183,7 @@ static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SS
|
||||||
// TODO: optimize it later when partition by + limit
|
// TODO: optimize it later when partition by + limit
|
||||||
if ((pLimitInfo->slimit.limit == -1 && pLimitInfo->currentGroupId == 0) ||
|
if ((pLimitInfo->slimit.limit == -1 && pLimitInfo->currentGroupId == 0) ||
|
||||||
(pLimitInfo->slimit.limit > 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) {
|
(pLimitInfo->slimit.limit > 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +248,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
qDebug("set op close, exec %d, status %d rows %d", pTaskInfo->execModel, pOperator->status,
|
qDebug("set op close, exec %d, status %d rows %d", pTaskInfo->execModel, pOperator->status,
|
||||||
pFinalRes->info.rows);
|
pFinalRes->info.rows);
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE) {
|
if (pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE) {
|
||||||
|
@ -400,14 +396,8 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
|
||||||
pInfo->binfo.pRes = pResBlock;
|
pInfo->binfo.pRes = pResBlock;
|
||||||
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pSup->pCtx, numOfExpr);
|
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pSup->pCtx, numOfExpr);
|
||||||
|
|
||||||
pOperator->name = "IndefinitOperator";
|
setOperatorInfo(pOperator, "IndefinitOperator", QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC;
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doApplyIndefinitFunction, NULL, destroyIndefinitOperatorInfo, NULL);
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doApplyIndefinitFunction, NULL, NULL,
|
|
||||||
destroyIndefinitOperatorInfo, NULL);
|
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -499,7 +489,7 @@ SSDataBlock* doApplyIndefinitFunction(SOperatorInfo* pOperator) {
|
||||||
// The downstream exec may change the value of the newgroup, so use a local variable instead.
|
// The downstream exec may change the value of the newgroup, so use a local variable instead.
|
||||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,7 +618,7 @@ SSDataBlock* doGenerateSourceData(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
pOperator->resultInfo.totalRows += pRes->info.rows;
|
pOperator->resultInfo.totalRows += pRes->info.rows;
|
||||||
|
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
if (pOperator->cost.openCost == 0) {
|
if (pOperator->cost.openCost == 0) {
|
||||||
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
|
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ static int32_t doDynamicPruneDataBlock(SOperatorInfo* pOperator, SDataBlockInfo*
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool doFilterByBlockSMA(SFilterInfo* pFilterInfo, SColumnDataAgg** pColsAgg, int32_t numOfCols,
|
static bool doFilterByBlockSMA(SFilterInfo* pFilterInfo, SColumnDataAgg** pColsAgg, int32_t numOfCols,
|
||||||
int32_t numOfRows) {
|
int32_t numOfRows) {
|
||||||
if (pColsAgg == NULL || pFilterInfo == NULL) {
|
if (pColsAgg == NULL || pFilterInfo == NULL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ static void doSetTagColumnData(STableScanInfo* pTableScanInfo, SSDataBlock* pBlo
|
||||||
|
|
||||||
// todo handle the slimit info
|
// todo handle the slimit info
|
||||||
void applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo, SOperatorInfo* pOperator) {
|
void applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo, SOperatorInfo* pOperator) {
|
||||||
SLimit* pLimit = &pLimitInfo->limit;
|
SLimit* pLimit = &pLimitInfo->limit;
|
||||||
const char* id = GET_TASKID(pTaskInfo);
|
const char* id = GET_TASKID(pTaskInfo);
|
||||||
|
|
||||||
if (pLimit->offset > 0 && pLimitInfo->remainOffset > 0) {
|
if (pLimit->offset > 0 && pLimitInfo->remainOffset > 0) {
|
||||||
|
@ -499,7 +499,7 @@ static void prepareForDescendingScan(STableScanInfo* pTableScanInfo, SqlFunction
|
||||||
|
|
||||||
typedef struct STableCachedVal {
|
typedef struct STableCachedVal {
|
||||||
const char* pName;
|
const char* pName;
|
||||||
STag* pTags;
|
STag* pTags;
|
||||||
} STableCachedVal;
|
} STableCachedVal;
|
||||||
|
|
||||||
static void freeTableCachedVal(void* param) {
|
static void freeTableCachedVal(void* param) {
|
||||||
|
@ -513,13 +513,11 @@ static void freeTableCachedVal(void* param) {
|
||||||
taosMemoryFree(pVal);
|
taosMemoryFree(pVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
//const void *key, size_t keyLen, void *value
|
// const void *key, size_t keyLen, void *value
|
||||||
static void freeCachedMetaItem(const void *key, size_t keyLen, void *value) {
|
static void freeCachedMetaItem(const void* key, size_t keyLen, void* value) { freeTableCachedVal(value); }
|
||||||
freeTableCachedVal(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr,
|
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr, SSDataBlock* pBlock,
|
||||||
SSDataBlock* pBlock, int32_t rows, const char* idStr, STableMetaCacheInfo* pCache) {
|
int32_t rows, const char* idStr, STableMetaCacheInfo* pCache) {
|
||||||
// currently only the tbname pseudo column
|
// currently only the tbname pseudo column
|
||||||
if (numOfExpr <= 0) {
|
if (numOfExpr <= 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -531,11 +529,11 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int
|
||||||
int32_t backupRows = pBlock->info.rows;
|
int32_t backupRows = pBlock->info.rows;
|
||||||
pBlock->info.rows = rows;
|
pBlock->info.rows = rows;
|
||||||
|
|
||||||
bool freeReader = false;
|
bool freeReader = false;
|
||||||
STableCachedVal val = {0};
|
STableCachedVal val = {0};
|
||||||
|
|
||||||
SMetaReader mr = {0};
|
SMetaReader mr = {0};
|
||||||
LRUHandle* h = NULL;
|
LRUHandle* h = NULL;
|
||||||
|
|
||||||
// 1. check if it is existed in meta cache
|
// 1. check if it is existed in meta cache
|
||||||
if (pCache == NULL) {
|
if (pCache == NULL) {
|
||||||
|
@ -582,7 +580,8 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int
|
||||||
val = *pVal;
|
val = *pVal;
|
||||||
freeReader = true;
|
freeReader = true;
|
||||||
|
|
||||||
int32_t ret = taosLRUCacheInsert(pCache->pTableMetaEntryCache, &pBlock->info.uid, sizeof(uint64_t), pVal, sizeof(STableCachedVal), freeCachedMetaItem, NULL, TAOS_LRU_PRIORITY_LOW);
|
int32_t ret = taosLRUCacheInsert(pCache->pTableMetaEntryCache, &pBlock->info.uid, sizeof(uint64_t), pVal,
|
||||||
|
sizeof(STableCachedVal), freeCachedMetaItem, NULL, TAOS_LRU_PRIORITY_LOW);
|
||||||
if (ret != TAOS_LRU_STATUS_OK) {
|
if (ret != TAOS_LRU_STATUS_OK) {
|
||||||
qError("failed to put meta into lru cache, code:%d, %s", ret, idStr);
|
qError("failed to put meta into lru cache, code:%d, %s", ret, idStr);
|
||||||
freeTableCachedVal(pVal);
|
freeTableCachedVal(pVal);
|
||||||
|
@ -594,13 +593,13 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int
|
||||||
taosLRUCacheRelease(pCache->pTableMetaEntryCache, h, false);
|
taosLRUCacheRelease(pCache->pTableMetaEntryCache, h, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("retrieve table meta from cache:%"PRIu64", hit:%"PRIu64 " miss:%"PRIu64", %s", pCache->metaFetch, pCache->cacheHit,
|
qDebug("retrieve table meta from cache:%" PRIu64 ", hit:%" PRIu64 " miss:%" PRIu64 ", %s", pCache->metaFetch,
|
||||||
(pCache->metaFetch - pCache->cacheHit), idStr);
|
pCache->cacheHit, (pCache->metaFetch - pCache->cacheHit), idStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t j = 0; j < numOfExpr; ++j) {
|
for (int32_t j = 0; j < numOfExpr; ++j) {
|
||||||
const SExprInfo* pExpr1 = &pExpr[j];
|
const SExprInfo* pExpr1 = &pExpr[j];
|
||||||
int32_t dstSlotId = pExpr1->base.resSchema.slotId;
|
int32_t dstSlotId = pExpr1->base.resSchema.slotId;
|
||||||
|
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, dstSlotId);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, dstSlotId);
|
||||||
colInfoDataCleanup(pColInfoData, pBlock->info.rows);
|
colInfoDataCleanup(pColInfoData, pBlock->info.rows);
|
||||||
|
@ -652,7 +651,7 @@ void setTbNameColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData,
|
||||||
fmGetScalarFuncExecFuncs(functionId, &fpSet);
|
fmGetScalarFuncExecFuncs(functionId, &fpSet);
|
||||||
|
|
||||||
size_t len = TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE;
|
size_t len = TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE;
|
||||||
char buf[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char buf[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
STR_TO_VARSTR(buf, name)
|
STR_TO_VARSTR(buf, name)
|
||||||
|
|
||||||
SColumnInfoData infoData = createColumnInfoData(TSDB_DATA_TYPE_VARCHAR, len, 1);
|
SColumnInfoData infoData = createColumnInfoData(TSDB_DATA_TYPE_VARCHAR, len, 1);
|
||||||
|
@ -820,7 +819,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
||||||
} else { // scan table group by group sequentially
|
} else { // scan table group by group sequentially
|
||||||
if (pInfo->currentGroupId == -1) {
|
if (pInfo->currentGroupId == -1) {
|
||||||
if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pTaskInfo->pTableInfoList)) {
|
if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pTaskInfo->pTableInfoList)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -843,7 +842,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pTaskInfo->pTableInfoList)) {
|
if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pTaskInfo->pTableInfoList)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,7 +864,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -904,12 +903,12 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
SScanPhysiNode* pScanNode = &pTableScanNode->scan;
|
SScanPhysiNode* pScanNode = &pTableScanNode->scan;
|
||||||
SDataBlockDescNode* pDescNode = pScanNode->node.pOutputDataBlockDesc;
|
SDataBlockDescNode* pDescNode = pScanNode->node.pOutputDataBlockDesc;
|
||||||
|
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
int32_t code = extractColMatchInfo(pScanNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID,
|
int32_t code =
|
||||||
&pInfo->matchInfo);
|
extractColMatchInfo(pScanNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -947,22 +946,18 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
||||||
pInfo->currentGroupId = -1;
|
pInfo->currentGroupId = -1;
|
||||||
pInfo->assignBlockUid = pTableScanNode->assignBlockUid;
|
pInfo->assignBlockUid = pTableScanNode->assignBlockUid;
|
||||||
|
|
||||||
pOperator->name = "TableScanOperator"; // for debug purpose
|
setOperatorInfo(pOperator, "TableScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, false, OP_NOT_OPENED, pInfo,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
|
pTaskInfo);
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pInfo->metaCache.pTableMetaEntryCache = taosLRUCacheInit(1024*128, -1, .5);
|
pInfo->metaCache.pTableMetaEntryCache = taosLRUCacheInit(1024 * 128, -1, .5);
|
||||||
if (pInfo->metaCache.pTableMetaEntryCache == NULL) {
|
if (pInfo->metaCache.pTableMetaEntryCache == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosLRUCacheSetStrictCapacity(pInfo->metaCache.pTableMetaEntryCache, false);
|
taosLRUCacheSetStrictCapacity(pInfo->metaCache.pTableMetaEntryCache, false);
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScan, NULL, NULL, destroyTableScanOperatorInfo,
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScan, NULL, destroyTableScanOperatorInfo,
|
||||||
getTableScannerExecInfo);
|
getTableScannerExecInfo);
|
||||||
|
|
||||||
// for non-blocking operator, the open cost is always 0
|
// for non-blocking operator, the open cost is always 0
|
||||||
|
@ -986,14 +981,9 @@ SOperatorInfo* createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo*
|
||||||
pInfo->dataReader = pReadHandle;
|
pInfo->dataReader = pReadHandle;
|
||||||
// pInfo->prevGroupId = -1;
|
// pInfo->prevGroupId = -1;
|
||||||
|
|
||||||
pOperator->name = "TableSeqScanOperator";
|
setOperatorInfo(pOperator, "TableSeqScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN, false, OP_NOT_OPENED,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN;
|
pInfo, pTaskInfo);
|
||||||
pOperator->blocking = false;
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScanImpl, NULL, NULL, NULL);
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScanImpl, NULL, NULL, NULL, NULL);
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1049,8 +1039,8 @@ static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator) {
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
STableBlockDistInfo blockDistInfo = {.minRows = INT_MAX, .maxRows = INT_MIN};
|
STableBlockDistInfo blockDistInfo = {.minRows = INT_MAX, .maxRows = INT_MIN};
|
||||||
int32_t code = doGetTableRowSize(pBlockScanInfo->readHandle.meta, pBlockScanInfo->uid, (int32_t*)&blockDistInfo.rowSize,
|
int32_t code = doGetTableRowSize(pBlockScanInfo->readHandle.meta, pBlockScanInfo->uid,
|
||||||
GET_TASKID(pTaskInfo));
|
(int32_t*)&blockDistInfo.rowSize, GET_TASKID(pTaskInfo));
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
@ -1148,15 +1138,10 @@ SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDi
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperator->name = "DataBlockDistScanOperator";
|
setOperatorInfo(pOperator, "DataBlockDistScanOperator", QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN, false,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN;
|
OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(operatorDummyOpenFn, doBlockInfoScan, NULL, NULL, destroyBlockDistScanOperatorInfo, NULL);
|
createOperatorFpSet(operatorDummyOpenFn, doBlockInfoScan, NULL, destroyBlockDistScanOperatorInfo, NULL);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
|
@ -1599,8 +1584,10 @@ static void calBlockTbName(SExprSupp* pTbNameCalSup, SSDataBlock* pBlock) {
|
||||||
void* pData = colDataGetData(pCol, 0);
|
void* pData = colDataGetData(pCol, 0);
|
||||||
// TODO check tbname validation
|
// TODO check tbname validation
|
||||||
if (pData != (void*)-1 && pData != NULL) {
|
if (pData != (void*)-1 && pData != NULL) {
|
||||||
memcpy(pBlock->info.parTbName, varDataVal(pData), TMIN(varDataLen(pData), TSDB_TABLE_NAME_LEN));
|
memset(pBlock->info.parTbName, 0, TSDB_TABLE_NAME_LEN);
|
||||||
pBlock->info.parTbName[TSDB_TABLE_NAME_LEN - 1] = 0;
|
int32_t len = TMIN(varDataLen(pData), TSDB_TABLE_NAME_LEN - 1);
|
||||||
|
memcpy(pBlock->info.parTbName, varDataVal(pData), len);
|
||||||
|
/*pBlock->info.parTbName[len + 1] = 0;*/
|
||||||
} else {
|
} else {
|
||||||
pBlock->info.parTbName[0] = 0;
|
pBlock->info.parTbName[0] = 0;
|
||||||
}
|
}
|
||||||
|
@ -1786,6 +1773,7 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) {
|
||||||
tqOffsetResetToLog(&pTaskInfo->streamInfo.prepareStatus, pTaskInfo->streamInfo.snapshotVer);
|
tqOffsetResetToLog(&pTaskInfo->streamInfo.prepareStatus, pTaskInfo->streamInfo.snapshotVer);
|
||||||
qDebug("queue scan tsdb over, switch to wal ver %" PRId64 "", pTaskInfo->streamInfo.snapshotVer + 1);
|
qDebug("queue scan tsdb over, switch to wal ver %" PRId64 "", pTaskInfo->streamInfo.snapshotVer + 1);
|
||||||
if (tqSeekVer(pInfo->tqReader, pTaskInfo->streamInfo.snapshotVer + 1) < 0) {
|
if (tqSeekVer(pInfo->tqReader, pTaskInfo->streamInfo.snapshotVer + 1) < 0) {
|
||||||
|
tqOffsetResetToLog(&pTaskInfo->streamInfo.lastStatus, pTaskInfo->streamInfo.snapshotVer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ASSERT(pInfo->tqReader->pWalReader->curVersion == pTaskInfo->streamInfo.snapshotVer + 1);
|
ASSERT(pInfo->tqReader->pWalReader->curVersion == pTaskInfo->streamInfo.snapshotVer + 1);
|
||||||
|
@ -2368,11 +2356,10 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pT
|
||||||
pInfo->vnode = pHandle->vnode;
|
pInfo->vnode = pHandle->vnode;
|
||||||
|
|
||||||
pInfo->sContext = pHandle->sContext;
|
pInfo->sContext = pHandle->sContext;
|
||||||
pOperator->name = "RawScanOperator";
|
setOperatorInfo(pOperator, "RawScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, false, OP_NOT_OPENED, pInfo,
|
||||||
pOperator->info = pInfo;
|
pTaskInfo);
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, NULL, destroyRawScanOperatorInfo, NULL);
|
pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, destroyRawScanOperatorInfo, NULL);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
|
@ -2385,9 +2372,7 @@ _end:
|
||||||
static void destroyStreamScanOperatorInfo(void* param) {
|
static void destroyStreamScanOperatorInfo(void* param) {
|
||||||
SStreamScanInfo* pStreamScan = (SStreamScanInfo*)param;
|
SStreamScanInfo* pStreamScan = (SStreamScanInfo*)param;
|
||||||
if (pStreamScan->pTableScanOp && pStreamScan->pTableScanOp->info) {
|
if (pStreamScan->pTableScanOp && pStreamScan->pTableScanOp->info) {
|
||||||
STableScanInfo* pTableScanInfo = pStreamScan->pTableScanOp->info;
|
destroyOperatorInfo(pStreamScan->pTableScanOp);
|
||||||
destroyTableScanOperatorInfo(pTableScanInfo);
|
|
||||||
taosMemoryFreeClear(pStreamScan->pTableScanOp);
|
|
||||||
}
|
}
|
||||||
if (pStreamScan->tqReader) {
|
if (pStreamScan->tqReader) {
|
||||||
tqCloseReader(pStreamScan->tqReader);
|
tqCloseReader(pStreamScan->tqReader);
|
||||||
|
@ -2556,16 +2541,12 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
pInfo->assignBlockUid = pTableScanNode->assignBlockUid;
|
pInfo->assignBlockUid = pTableScanNode->assignBlockUid;
|
||||||
pInfo->partitionSup.needCalc = false;
|
pInfo->partitionSup.needCalc = false;
|
||||||
|
|
||||||
pOperator->name = "StreamScanOperator";
|
setOperatorInfo(pOperator, "StreamScanOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, false, OP_NOT_OPENED, pInfo,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
|
pTaskInfo);
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
__optr_fn_t nextFn = pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM ? doStreamScan : doQueueScan;
|
__optr_fn_t nextFn = pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM ? doStreamScan : doQueueScan;
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, nextFn, NULL, NULL, destroyStreamScanOperatorInfo, NULL);
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, nextFn, NULL, destroyStreamScanOperatorInfo, NULL);
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
|
@ -2900,7 +2881,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
blockDataDestroy(dataBlock);
|
blockDataDestroy(dataBlock);
|
||||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2953,7 +2934,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
metaCloseTbCursor(pInfo->pCur);
|
metaCloseTbCursor(pInfo->pCur);
|
||||||
pInfo->pCur = NULL;
|
pInfo->pCur = NULL;
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||||
|
@ -3743,7 +3724,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= taosArrayGetSize(pIdx->uids)) {
|
if (i >= taosArrayGetSize(pIdx->uids)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
} else {
|
} else {
|
||||||
pIdx->lastIdx = i + 1;
|
pIdx->lastIdx = i + 1;
|
||||||
}
|
}
|
||||||
|
@ -3925,7 +3906,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
metaCloseTbCursor(pInfo->pCur);
|
metaCloseTbCursor(pInfo->pCur);
|
||||||
pInfo->pCur = NULL;
|
pInfo->pCur = NULL;
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||||
|
@ -3947,7 +3928,7 @@ static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) {
|
||||||
doFilterResult(pInfo->pRes, pOperator->exprSupp.pFilterInfo);
|
doFilterResult(pInfo->pRes, pOperator->exprSupp.pFilterInfo);
|
||||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||||
|
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||||
} else {
|
} else {
|
||||||
if (pInfo->showRewrite == false) {
|
if (pInfo->showRewrite == false) {
|
||||||
|
@ -4199,15 +4180,10 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
|
||||||
pInfo->readHandle = *(SReadHandle*)readHandle;
|
pInfo->readHandle = *(SReadHandle*)readHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperator->name = "SysTableScanOperator";
|
setOperatorInfo(pOperator, "SysTableScanOperator", QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN, false, OP_NOT_OPENED,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN;
|
pInfo, pTaskInfo);
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doSysTableScan, NULL, destroySysScanOperator, NULL);
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doSysTableScan, NULL, NULL, destroySysScanOperator, NULL);
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
|
@ -4283,7 +4259,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
count += 1;
|
count += 1;
|
||||||
if (++pInfo->curPos >= size) {
|
if (++pInfo->curPos >= size) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4319,7 +4295,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
|
||||||
|
|
||||||
int32_t numOfExprs = 0;
|
int32_t numOfExprs = 0;
|
||||||
SExprInfo* pExprInfo = createExprInfo(pPhyNode->pScanPseudoCols, NULL, &numOfExprs);
|
SExprInfo* pExprInfo = createExprInfo(pPhyNode->pScanPseudoCols, NULL, &numOfExprs);
|
||||||
int32_t code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfExprs);
|
int32_t code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfExprs);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -4335,18 +4311,12 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
|
||||||
pInfo->readHandle = *pReadHandle;
|
pInfo->readHandle = *pReadHandle;
|
||||||
pInfo->curPos = 0;
|
pInfo->curPos = 0;
|
||||||
|
|
||||||
pOperator->name = "TagScanOperator";
|
setOperatorInfo(pOperator, "TagScanOperator", QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN, false, OP_NOT_OPENED, pInfo,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN;
|
pTaskInfo);
|
||||||
|
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTagScan, NULL, NULL, destroyTagScanOperatorInfo, NULL);
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTagScan, NULL, destroyTagScanOperatorInfo, NULL);
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
|
@ -4455,7 +4425,7 @@ static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeSc
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pOperator->exprSupp.pFilterInfo!= NULL) {
|
if (pOperator->exprSupp.pFilterInfo != NULL) {
|
||||||
int64_t st = taosGetTimestampMs();
|
int64_t st = taosGetTimestampMs();
|
||||||
doFilter(pBlock, pOperator->exprSupp.pFilterInfo, &pTableScanInfo->matchInfo);
|
doFilter(pBlock, pOperator->exprSupp.pFilterInfo, &pTableScanInfo->matchInfo);
|
||||||
|
|
||||||
|
@ -4713,7 +4683,7 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) {
|
||||||
pInfo->hasGroupId = true;
|
pInfo->hasGroupId = true;
|
||||||
|
|
||||||
if (tableListSize == 0) {
|
if (tableListSize == 0) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pInfo->tableStartIndex = 0;
|
pInfo->tableStartIndex = 0;
|
||||||
|
@ -4732,7 +4702,7 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) {
|
||||||
} else {
|
} else {
|
||||||
stopGroupTableMergeScan(pOperator);
|
stopGroupTableMergeScan(pOperator);
|
||||||
if (pInfo->tableEndIndex >= tableListSize - 1) {
|
if (pInfo->tableEndIndex >= tableListSize - 1) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pInfo->tableStartIndex = pInfo->tableEndIndex + 1;
|
pInfo->tableStartIndex = pInfo->tableEndIndex + 1;
|
||||||
|
@ -4831,7 +4801,6 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
||||||
pInfo->sample.seed = taosGetTimestampSec();
|
pInfo->sample.seed = taosGetTimestampSec();
|
||||||
pInfo->dataBlockLoadFlag = pTableScanNode->dataRequired;
|
pInfo->dataBlockLoadFlag = pTableScanNode->dataRequired;
|
||||||
|
|
||||||
|
|
||||||
code = filterInitFromNode((SNode*)pTableScanNode->scan.node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
|
code = filterInitFromNode((SNode*)pTableScanNode->scan.node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
|
@ -4853,16 +4822,12 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
||||||
int32_t rowSize = pInfo->pResBlock->info.rowSize;
|
int32_t rowSize = pInfo->pResBlock->info.rowSize;
|
||||||
pInfo->bufPageSize = getProperSortPageSize(rowSize);
|
pInfo->bufPageSize = getProperSortPageSize(rowSize);
|
||||||
|
|
||||||
pOperator->name = "TableMergeScanOperator";
|
setOperatorInfo(pOperator, "TableMergeScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN, false, OP_NOT_OPENED,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN;
|
pInfo, pTaskInfo);
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableMergeScan, NULL, NULL,
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableMergeScan, NULL, destroyTableMergeScanOperatorInfo,
|
||||||
destroyTableMergeScanOperatorInfo, getTableMergeScanExplainExecInfo);
|
getTableMergeScanExplainExecInfo);
|
||||||
pOperator->cost.openCost = 0;
|
pOperator->cost.openCost = 0;
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
|
|
|
@ -53,11 +53,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
|
||||||
pInfo->pSortInfo = createSortInfo(pSortNode->pSortKeys);
|
pInfo->pSortInfo = createSortInfo(pSortNode->pSortKeys);
|
||||||
initLimitInfo(pSortNode->node.pLimit, pSortNode->node.pSlimit, &pInfo->limitInfo);
|
initLimitInfo(pSortNode->node.pLimit, pSortNode->node.pSlimit, &pInfo->limitInfo);
|
||||||
|
|
||||||
pOperator->name = "SortOperator";
|
setOperatorInfo(pOperator, "SortOperator", QUERY_NODE_PHYSICAL_PLAN_SORT, true, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SORT;
|
|
||||||
pOperator->blocking = true;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||||
|
|
||||||
|
@ -67,7 +63,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
|
||||||
// TODO dynamic set the available sort buffer
|
// TODO dynamic set the available sort buffer
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(doOpenSortOperator, doSort, NULL, NULL, destroySortOperatorInfo, getExplainExecInfo);
|
createOperatorFpSet(doOpenSortOperator, doSort, NULL, destroySortOperatorInfo, getExplainExecInfo);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -214,7 +210,7 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) {
|
||||||
pBlock = getSortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity,
|
pBlock = getSortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity,
|
||||||
pInfo->matchInfo.pList, pInfo);
|
pInfo->matchInfo.pList, pInfo);
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +424,7 @@ SSDataBlock* doGroupSort(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
pInfo->prefetchedSortInput = pOperator->pDownstream[0]->fpSet.getNextFn(pOperator->pDownstream[0]);
|
pInfo->prefetchedSortInput = pOperator->pDownstream[0]->fpSet.getNextFn(pOperator->pDownstream[0]);
|
||||||
if (pInfo->prefetchedSortInput == NULL) {
|
if (pInfo->prefetchedSortInput == NULL) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pInfo->currGroupId = pInfo->prefetchedSortInput->info.groupId;
|
pInfo->currGroupId = pInfo->prefetchedSortInput->info.groupId;
|
||||||
|
@ -453,7 +449,7 @@ SSDataBlock* doGroupSort(SOperatorInfo* pOperator) {
|
||||||
beginSortGroup(pOperator);
|
beginSortGroup(pOperator);
|
||||||
} else if (pInfo->childOpStatus == CHILD_OP_FINISHED) {
|
} else if (pInfo->childOpStatus == CHILD_OP_FINISHED) {
|
||||||
finishSortGroup(pOperator);
|
finishSortGroup(pOperator);
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -509,15 +505,8 @@ SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSort
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys);
|
pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys);
|
||||||
|
setOperatorInfo(pOperator, "GroupSortOperator", QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->name = "GroupSortOperator";
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doGroupSort, NULL, destroyGroupSortOperatorInfo,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT;
|
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doGroupSort, NULL, NULL, destroyGroupSortOperatorInfo,
|
|
||||||
getGroupSortExplainExecInfo);
|
getGroupSortExplainExecInfo);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -705,7 +694,7 @@ SSDataBlock* doMultiwayMerge(SOperatorInfo* pOperator) {
|
||||||
if (pBlock != NULL) {
|
if (pBlock != NULL) {
|
||||||
pOperator->resultInfo.totalRows += pBlock->info.rows;
|
pOperator->resultInfo.totalRows += pBlock->info.rows;
|
||||||
} else {
|
} else {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pBlock;
|
return pBlock;
|
||||||
|
@ -774,14 +763,8 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size
|
||||||
pInfo->bufPageSize = getProperSortPageSize(rowSize);
|
pInfo->bufPageSize = getProperSortPageSize(rowSize);
|
||||||
pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); // one additional is reserved for merged result.
|
pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); // one additional is reserved for merged result.
|
||||||
|
|
||||||
pOperator->name = "MultiwayMerge";
|
setOperatorInfo(pOperator, "MultiwayMergeOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE;
|
pOperator->fpSet = createOperatorFpSet(doOpenMultiwayMergeOperator, doMultiwayMerge, NULL,
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(doOpenMultiwayMergeOperator, doMultiwayMerge, NULL, NULL,
|
|
||||||
destroyMultiwayMergeOperatorInfo, getMultiwayMergeExplainExecInfo);
|
destroyMultiwayMergeOperatorInfo, getMultiwayMergeExplainExecInfo);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, downStreams, numStreams);
|
code = appendDownstream(pOperator, downStreams, numStreams);
|
||||||
|
|
|
@ -680,9 +680,9 @@ SResultCellData* getResultCell(SResultRowData* pRaw, int32_t index) {
|
||||||
void* destroyFillColumnInfo(SFillColInfo* pFillCol, int32_t start, int32_t end) {
|
void* destroyFillColumnInfo(SFillColInfo* pFillCol, int32_t start, int32_t end) {
|
||||||
for (int32_t i = start; i < end; i++) {
|
for (int32_t i = start; i < end; i++) {
|
||||||
destroyExprInfo(pFillCol[i].pExpr, 1);
|
destroyExprInfo(pFillCol[i].pExpr, 1);
|
||||||
taosMemoryFreeClear(pFillCol[i].pExpr);
|
|
||||||
taosVariantDestroy(&pFillCol[i].fillVal);
|
taosVariantDestroy(&pFillCol[i].fillVal);
|
||||||
}
|
}
|
||||||
|
taosMemoryFreeClear(pFillCol[start].pExpr);
|
||||||
taosMemoryFree(pFillCol);
|
taosMemoryFree(pFillCol);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1443,7 +1443,7 @@ static SSDataBlock* doStreamFill(SOperatorInfo* pOperator) {
|
||||||
printDataBlock(pInfo->pRes, "stream fill");
|
printDataBlock(pInfo->pRes, "stream fill");
|
||||||
return pInfo->pRes;
|
return pInfo->pRes;
|
||||||
}
|
}
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
resetStreamFillInfo(pInfo);
|
resetStreamFillInfo(pInfo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1512,7 +1512,7 @@ static SSDataBlock* doStreamFill(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->pRes->info.rows == 0) {
|
if (pInfo->pRes->info.rows == 0) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
resetStreamFillInfo(pInfo);
|
resetStreamFillInfo(pInfo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1690,15 +1690,9 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->srcRowIndex = 0;
|
pInfo->srcRowIndex = 0;
|
||||||
|
setOperatorInfo(pOperator, "StreamFillOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->name = "StreamFillOperator";
|
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(operatorDummyOpenFn, doStreamFill, NULL, NULL, destroyStreamFillOperatorInfo, NULL);
|
createOperatorFpSet(operatorDummyOpenFn, doStreamFill, NULL, destroyStreamFillOperatorInfo, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -1221,7 +1221,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
pTaskInfo->code = pOperator->fpSet._openFn(pOperator);
|
pTaskInfo->code = pOperator->fpSet._openFn(pOperator);
|
||||||
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
|
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1232,7 +1232,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
bool hasRemain = hasRemainResults(&pInfo->groupResInfo);
|
bool hasRemain = hasRemainResults(&pInfo->groupResInfo);
|
||||||
if (!hasRemain) {
|
if (!hasRemain) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1269,7 +1269,7 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
bool hasRemain = hasRemainResults(&pInfo->groupResInfo);
|
bool hasRemain = hasRemainResults(&pInfo->groupResInfo);
|
||||||
if (!hasRemain) {
|
if (!hasRemain) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1739,7 +1739,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
|
||||||
|
|
||||||
ASSERT(as.calTrigger != STREAM_TRIGGER_MAX_DELAY);
|
ASSERT(as.calTrigger != STREAM_TRIGGER_MAX_DELAY);
|
||||||
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
pInfo->win = pTaskInfo->window;
|
pInfo->win = pTaskInfo->window;
|
||||||
pInfo->inputOrder = (pPhyNode->window.inputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
pInfo->inputOrder = (pPhyNode->window.inputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||||
pInfo->resultTsOrder = (pPhyNode->window.outputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
pInfo->resultTsOrder = (pPhyNode->window.outputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||||
|
@ -1777,15 +1776,11 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
|
||||||
}
|
}
|
||||||
|
|
||||||
initResultRowInfo(&pInfo->binfo.resultRowInfo);
|
initResultRowInfo(&pInfo->binfo.resultRowInfo);
|
||||||
|
setOperatorInfo(pOperator, "TimeIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL, true, OP_NOT_OPENED,
|
||||||
pOperator->name = "TimeIntervalAggOperator";
|
pInfo, pTaskInfo);
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL;
|
|
||||||
pOperator->blocking = true;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, NULL, destroyIntervalOperatorInfo, NULL);
|
createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, destroyIntervalOperatorInfo, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -1890,7 +1885,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
bool hasRemain = hasRemainResults(&pInfo->groupResInfo);
|
bool hasRemain = hasRemainResults(&pInfo->groupResInfo);
|
||||||
if (!hasRemain) {
|
if (!hasRemain) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1933,7 +1928,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
bool hasRemain = hasRemainResults(&pInfo->groupResInfo);
|
bool hasRemain = hasRemainResults(&pInfo->groupResInfo);
|
||||||
if (!hasRemain) {
|
if (!hasRemain) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2281,7 +2276,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2330,7 +2325,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2342,7 +2337,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
||||||
pSliceInfo->current =
|
pSliceInfo->current =
|
||||||
taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
|
taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
|
||||||
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2365,7 +2360,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2386,7 +2381,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2448,7 +2443,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2463,7 +2458,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2557,15 +2552,9 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode
|
||||||
pScanInfo->cond.twindows = pInfo->win;
|
pScanInfo->cond.twindows = pInfo->win;
|
||||||
pScanInfo->cond.type = TIMEWINDOW_RANGE_EXTERNAL;
|
pScanInfo->cond.type = TIMEWINDOW_RANGE_EXTERNAL;
|
||||||
|
|
||||||
pOperator->name = "TimeSliceOperator";
|
setOperatorInfo(pOperator, "TimeSliceOperator", QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC, false, OP_NOT_OPENED, pInfo,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC;
|
pTaskInfo);
|
||||||
pOperator->blocking = false;
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTimeslice, NULL, destroyTimeSliceOperatorInfo, NULL);
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet =
|
|
||||||
createOperatorFpSet(operatorDummyOpenFn, doTimeslice, NULL, NULL, destroyTimeSliceOperatorInfo, NULL);
|
|
||||||
|
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
|
|
||||||
|
@ -2633,15 +2622,11 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi
|
||||||
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
|
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
|
||||||
|
|
||||||
pInfo->tsSlotId = tsSlotId;
|
pInfo->tsSlotId = tsSlotId;
|
||||||
pOperator->name = "StateWindowOperator";
|
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE;
|
|
||||||
pOperator->blocking = true;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
|
|
||||||
|
setOperatorInfo(pOperator, "StateWindowOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE, true, OP_NOT_OPENED, pInfo,
|
||||||
|
pTaskInfo);
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(openStateWindowAggOptr, doStateWindowAgg, NULL, NULL, destroyStateWindowOperatorInfo, NULL);
|
createOperatorFpSet(openStateWindowAggOptr, doStateWindowAgg, NULL, destroyStateWindowOperatorInfo, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -2711,14 +2696,10 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperator->name = "SessionWindowAggOperator";
|
setOperatorInfo(pOperator, "SessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION, true, OP_NOT_OPENED,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION;
|
pInfo, pTaskInfo);
|
||||||
pOperator->blocking = true;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(operatorDummyOpenFn, doSessionWindowAgg, NULL, NULL, destroySWindowOperatorInfo, NULL);
|
createOperatorFpSet(operatorDummyOpenFn, doSessionWindowAgg, NULL, destroySWindowOperatorInfo, NULL);
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -3134,7 +3115,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
return pInfo->binfo.pRes;
|
return pInfo->binfo.pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
if (!IS_FINAL_OP(pInfo)) {
|
if (!IS_FINAL_OP(pInfo)) {
|
||||||
clearFunctionContext(&pOperator->exprSupp);
|
clearFunctionContext(&pOperator->exprSupp);
|
||||||
// semi interval operator clear disk buffer
|
// semi interval operator clear disk buffer
|
||||||
|
@ -3403,7 +3384,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, NULL, destroyStreamFinalIntervalOperatorInfo, NULL);
|
createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, NULL);
|
||||||
if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL) {
|
if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL) {
|
||||||
initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup);
|
initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup);
|
||||||
}
|
}
|
||||||
|
@ -3599,6 +3580,11 @@ static void removeSessionResult(SSHashObj* pHashMap, SSHashObj* pResMap, SSessio
|
||||||
tSimpleHashRemove(pResMap, &key, sizeof(SSessionKey));
|
tSimpleHashRemove(pResMap, &key, sizeof(SSessionKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void getSessionHashKey(const SSessionKey* pKey, SSessionKey* pHashKey) {
|
||||||
|
*pHashKey = *pKey;
|
||||||
|
pHashKey->win.ekey = pKey->win.skey;
|
||||||
|
}
|
||||||
|
|
||||||
static void removeSessionResults(SSHashObj* pHashMap, SArray* pWins) {
|
static void removeSessionResults(SSHashObj* pHashMap, SArray* pWins) {
|
||||||
if (tSimpleHashGetSize(pHashMap) == 0) {
|
if (tSimpleHashGetSize(pHashMap) == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -3607,8 +3593,8 @@ static void removeSessionResults(SSHashObj* pHashMap, SArray* pWins) {
|
||||||
for (int32_t i = 0; i < size; i++) {
|
for (int32_t i = 0; i < size; i++) {
|
||||||
SSessionKey* pWin = taosArrayGet(pWins, i);
|
SSessionKey* pWin = taosArrayGet(pWins, i);
|
||||||
if (!pWin) continue;
|
if (!pWin) continue;
|
||||||
SSessionKey key = *pWin;
|
SSessionKey key = {0};
|
||||||
key.win.ekey = key.win.skey;
|
getSessionHashKey(pWin, &key);
|
||||||
tSimpleHashRemove(pHashMap, &key, sizeof(SSessionKey));
|
tSimpleHashRemove(pHashMap, &key, sizeof(SSessionKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3661,7 +3647,9 @@ static int32_t doOneWindowAggImpl(SColumnInfoData* pTimeWindowData, SResultWindo
|
||||||
|
|
||||||
static bool doDeleteSessionWindow(SStreamAggSupporter* pAggSup, SSessionKey* pKey) {
|
static bool doDeleteSessionWindow(SStreamAggSupporter* pAggSup, SSessionKey* pKey) {
|
||||||
streamStateSessionDel(pAggSup->pState, pKey);
|
streamStateSessionDel(pAggSup->pState, pKey);
|
||||||
tSimpleHashRemove(pAggSup->pResultRows, pKey, sizeof(SSessionKey));
|
SSessionKey hashKey = {0};
|
||||||
|
getSessionHashKey(pKey, &hashKey);
|
||||||
|
tSimpleHashRemove(pAggSup->pResultRows, &hashKey, sizeof(SSessionKey));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3772,8 +3760,8 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||||
SSessionKey key = winInfo.sessionWin;
|
SSessionKey key = {0};
|
||||||
key.win.ekey = key.win.skey;
|
getSessionHashKey(&winInfo.sessionWin, &key);
|
||||||
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &winInfo, sizeof(SResultWindowInfo));
|
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &winInfo, sizeof(SResultWindowInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3844,7 +3832,7 @@ static int32_t copyUpdateResult(SSHashObj* pStUpdated, SArray* pUpdated) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doBuildDeleteDataBlock(SSHashObj* pStDeleted, SSDataBlock* pBlock, void** Ite) {
|
void doBuildDeleteDataBlock(SOperatorInfo* pOp, SSHashObj* pStDeleted, SSDataBlock* pBlock, void** Ite) {
|
||||||
blockDataCleanup(pBlock);
|
blockDataCleanup(pBlock);
|
||||||
int32_t size = tSimpleHashGetSize(pStDeleted);
|
int32_t size = tSimpleHashGetSize(pStDeleted);
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
|
@ -3870,6 +3858,31 @@ void doBuildDeleteDataBlock(SSHashObj* pStDeleted, SSDataBlock* pBlock, void** I
|
||||||
colDataAppendNULL(pCalStCol, pBlock->info.rows);
|
colDataAppendNULL(pCalStCol, pBlock->info.rows);
|
||||||
SColumnInfoData* pCalEdCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
SColumnInfoData* pCalEdCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
||||||
colDataAppendNULL(pCalEdCol, pBlock->info.rows);
|
colDataAppendNULL(pCalEdCol, pBlock->info.rows);
|
||||||
|
|
||||||
|
SHashObj* pGroupIdTbNameMap = NULL;
|
||||||
|
if (pOp->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION ||
|
||||||
|
pOp->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION ||
|
||||||
|
pOp->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION) {
|
||||||
|
SStreamSessionAggOperatorInfo* pInfo = pOp->info;
|
||||||
|
pGroupIdTbNameMap = pInfo->pGroupIdTbNameMap;
|
||||||
|
} else if (pOp->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE) {
|
||||||
|
SStreamStateAggOperatorInfo* pInfo = pOp->info;
|
||||||
|
pGroupIdTbNameMap = pInfo->pGroupIdTbNameMap;
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* tbname = taosHashGet(pGroupIdTbNameMap, &res->groupId, sizeof(int64_t));
|
||||||
|
SColumnInfoData* pTableCol = taosArrayGet(pBlock->pDataBlock, TABLE_NAME_COLUMN_INDEX);
|
||||||
|
if (tbname == NULL) {
|
||||||
|
/*printf("\n\n no tbname for group id %" PRId64 "%p %p\n\n", res->groupId, pOp->info, pGroupIdTbNameMap);*/
|
||||||
|
colDataAppendNULL(pTableCol, pBlock->info.rows);
|
||||||
|
} else {
|
||||||
|
char parTbName[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN];
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(parTbName, tbname, sizeof(parTbName));
|
||||||
|
colDataAppend(pTableCol, pBlock->info.rows, (const char*)parTbName, false);
|
||||||
|
/*printf("\n\n get tbname %s group id %" PRId64 "\n\n", tbname, res->groupId);*/
|
||||||
|
}
|
||||||
pBlock->info.rows += 1;
|
pBlock->info.rows += 1;
|
||||||
}
|
}
|
||||||
if ((*Ite) == NULL) {
|
if ((*Ite) == NULL) {
|
||||||
|
@ -3895,8 +3908,8 @@ static void rebuildSessionWindow(SOperatorInfo* pOperator, SArray* pWinArray, SS
|
||||||
SOperatorInfo* pChild = taosArrayGetP(pInfo->pChildren, j);
|
SOperatorInfo* pChild = taosArrayGetP(pInfo->pChildren, j);
|
||||||
SStreamSessionAggOperatorInfo* pChInfo = pChild->info;
|
SStreamSessionAggOperatorInfo* pChInfo = pChild->info;
|
||||||
SStreamAggSupporter* pChAggSup = &pChInfo->streamAggSup;
|
SStreamAggSupporter* pChAggSup = &pChInfo->streamAggSup;
|
||||||
SSessionKey chWinKey = *pWinKey;
|
SSessionKey chWinKey = {0};
|
||||||
chWinKey.win.ekey = chWinKey.win.skey;
|
getSessionHashKey(pWinKey, &chWinKey);
|
||||||
SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentNext(pChAggSup->pState, &chWinKey);
|
SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentNext(pChAggSup->pState, &chWinKey);
|
||||||
SResultRow* pResult = NULL;
|
SResultRow* pResult = NULL;
|
||||||
SResultRow* pChResult = NULL;
|
SResultRow* pChResult = NULL;
|
||||||
|
@ -3977,8 +3990,8 @@ static void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted) {
|
||||||
for (int32_t i = 0; i < size; i++) {
|
for (int32_t i = 0; i < size; i++) {
|
||||||
SSessionKey* pWinKey = taosArrayGet(pResWins, i);
|
SSessionKey* pWinKey = taosArrayGet(pResWins, i);
|
||||||
if (!pWinKey) continue;
|
if (!pWinKey) continue;
|
||||||
SSessionKey winInfo = *pWinKey;
|
SSessionKey winInfo = {0};
|
||||||
winInfo.win.ekey = winInfo.win.skey;
|
getSessionHashKey(pWinKey, &winInfo);
|
||||||
tSimpleHashPut(pStDeleted, &winInfo, sizeof(SSessionKey), NULL, 0);
|
tSimpleHashPut(pStDeleted, &winInfo, sizeof(SSessionKey), NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4016,7 +4029,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if (pOperator->status == OP_RES_TO_RETURN) {
|
} else if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
doBuildDeleteDataBlock(pOperator, pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
||||||
if (pInfo->pDelRes->info.rows > 0) {
|
if (pInfo->pDelRes->info.rows > 0) {
|
||||||
printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "final session" : "single session");
|
printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "final session" : "single session");
|
||||||
return pInfo->pDelRes;
|
return pInfo->pDelRes;
|
||||||
|
@ -4027,7 +4040,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
return pBInfo->pRes;
|
return pBInfo->pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4045,7 +4058,8 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
if (pBlock->info.parTbName[0]) {
|
if (pBlock->info.parTbName[0]) {
|
||||||
taosHashPut(pInfo->pGroupIdTbNameMap, &pBlock->info.groupId, sizeof(int64_t), &pBlock->info.parTbName,
|
taosHashPut(pInfo->pGroupIdTbNameMap, &pBlock->info.groupId, sizeof(int64_t), &pBlock->info.parTbName,
|
||||||
TSDB_TABLE_NAME_LEN);
|
TSDB_TABLE_NAME_LEN);
|
||||||
/*printf("\n\n put tbname %s\n\n", pBlock->info.parTbName);*/
|
/*printf("\n\n put tbname %s group id %" PRId64 "\n\n into %p %p", pBlock->info.parTbName, pBlock->info.groupId,*/
|
||||||
|
/*pInfo, pInfo->pGroupIdTbNameMap);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pBlock->info.parTbName[0]) {
|
if (pBlock->info.parTbName[0]) {
|
||||||
|
@ -4121,7 +4135,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
taosMemoryFree(pBuf);
|
taosMemoryFree(pBuf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
doBuildDeleteDataBlock(pOperator, pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
||||||
if (pInfo->pDelRes->info.rows > 0) {
|
if (pInfo->pDelRes->info.rows > 0) {
|
||||||
printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "final session" : "single session");
|
printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "final session" : "single session");
|
||||||
return pInfo->pDelRes;
|
return pInfo->pDelRes;
|
||||||
|
@ -4133,7 +4147,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
return pBInfo->pRes;
|
return pBInfo->pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4200,13 +4214,11 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
|
||||||
pInfo->pGroupIdTbNameMap =
|
pInfo->pGroupIdTbNameMap =
|
||||||
taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_NO_LOCK);
|
taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_NO_LOCK);
|
||||||
|
|
||||||
pOperator->name = "StreamSessionWindowAggOperator";
|
setOperatorInfo(pOperator, "StreamSessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION, true,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION;
|
OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->blocking = true;
|
pOperator->fpSet =
|
||||||
pOperator->status = OP_NOT_OPENED;
|
createOperatorFpSet(operatorDummyOpenFn, doStreamSessionAgg, NULL, destroyStreamSessionAggOperatorInfo, NULL);
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamSessionAgg, NULL, NULL,
|
|
||||||
destroyStreamSessionAggOperatorInfo, NULL);
|
|
||||||
if (downstream) {
|
if (downstream) {
|
||||||
initDownStream(downstream, &pInfo->streamAggSup, pInfo->twAggSup.waterMark, pOperator->operatorType,
|
initDownStream(downstream, &pInfo->streamAggSup, pInfo->twAggSup.waterMark, pOperator->operatorType,
|
||||||
pInfo->primaryTsIndex);
|
pInfo->primaryTsIndex);
|
||||||
|
@ -4247,7 +4259,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
|
||||||
return pBInfo->pRes;
|
return pBInfo->pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
doBuildDeleteDataBlock(pOperator, pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
||||||
if (pInfo->pDelRes->info.rows > 0) {
|
if (pInfo->pDelRes->info.rows > 0) {
|
||||||
printDataBlock(pInfo->pDelRes, "semi session delete");
|
printDataBlock(pInfo->pDelRes, "semi session delete");
|
||||||
return pInfo->pDelRes;
|
return pInfo->pDelRes;
|
||||||
|
@ -4257,7 +4269,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
|
||||||
clearFunctionContext(&pOperator->exprSupp);
|
clearFunctionContext(&pOperator->exprSupp);
|
||||||
// semi interval operator clear disk buffer
|
// semi interval operator clear disk buffer
|
||||||
clearStreamSessionOperator(pInfo);
|
clearStreamSessionOperator(pInfo);
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4327,7 +4339,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
|
||||||
return pBInfo->pRes;
|
return pBInfo->pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
doBuildDeleteDataBlock(pOperator, pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
||||||
if (pInfo->pDelRes->info.rows > 0) {
|
if (pInfo->pDelRes->info.rows > 0) {
|
||||||
printDataBlock(pInfo->pDelRes, "semi session delete");
|
printDataBlock(pInfo->pDelRes, "semi session delete");
|
||||||
return pInfo->pDelRes;
|
return pInfo->pDelRes;
|
||||||
|
@ -4336,7 +4348,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
|
||||||
clearFunctionContext(&pOperator->exprSupp);
|
clearFunctionContext(&pOperator->exprSupp);
|
||||||
// semi interval operator clear disk buffer
|
// semi interval operator clear disk buffer
|
||||||
clearStreamSessionOperator(pInfo);
|
clearStreamSessionOperator(pInfo);
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4347,20 +4359,21 @@ SOperatorInfo* createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream
|
||||||
if (pOperator == NULL) {
|
if (pOperator == NULL) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamSessionAggOperatorInfo* pInfo = pOperator->info;
|
SStreamSessionAggOperatorInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION) {
|
pInfo->isFinal = (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION);
|
||||||
pInfo->isFinal = true;
|
char* name = (pInfo->isFinal) ? "StreamSessionFinalAggOperator" : "StreamSessionSemiAggOperator";
|
||||||
pOperator->name = "StreamSessionFinalAggOperator";
|
|
||||||
} else {
|
if (pPhyNode->type != QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION) {
|
||||||
pInfo->isFinal = false;
|
|
||||||
pInfo->pUpdateRes = createSpecialDataBlock(STREAM_CLEAR);
|
pInfo->pUpdateRes = createSpecialDataBlock(STREAM_CLEAR);
|
||||||
blockDataEnsureCapacity(pInfo->pUpdateRes, 128);
|
blockDataEnsureCapacity(pInfo->pUpdateRes, 128);
|
||||||
pOperator->name = "StreamSessionSemiAggOperator";
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamSessionSemiAgg, NULL,
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamSessionSemiAgg, NULL, NULL,
|
|
||||||
destroyStreamSessionAggOperatorInfo, NULL);
|
destroyStreamSessionAggOperatorInfo, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setOperatorInfo(pOperator, name, pPhyNode->type, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
|
|
||||||
pInfo->pGroupIdTbNameMap =
|
pInfo->pGroupIdTbNameMap =
|
||||||
taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_NO_LOCK);
|
taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_NO_LOCK);
|
||||||
|
|
||||||
|
@ -4561,8 +4574,8 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||||
SSessionKey key = curWin.winInfo.sessionWin;
|
SSessionKey key = {0};
|
||||||
key.win.ekey = key.win.skey;
|
getSessionHashKey(&curWin.winInfo.sessionWin, &key);
|
||||||
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &curWin.winInfo, sizeof(SResultWindowInfo));
|
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &curWin.winInfo, sizeof(SResultWindowInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4578,7 +4591,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
|
||||||
SOptrBasicInfo* pBInfo = &pInfo->binfo;
|
SOptrBasicInfo* pBInfo = &pInfo->binfo;
|
||||||
int64_t maxTs = INT64_MIN;
|
int64_t maxTs = INT64_MIN;
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
doBuildDeleteDataBlock(pInfo->pSeDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
doBuildDeleteDataBlock(pOperator, pInfo->pSeDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
||||||
if (pInfo->pDelRes->info.rows > 0) {
|
if (pInfo->pDelRes->info.rows > 0) {
|
||||||
printDataBlock(pInfo->pDelRes, "single state delete");
|
printDataBlock(pInfo->pDelRes, "single state delete");
|
||||||
return pInfo->pDelRes;
|
return pInfo->pDelRes;
|
||||||
|
@ -4590,7 +4603,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
|
||||||
return pBInfo->pRes;
|
return pBInfo->pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4645,7 +4658,13 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
|
||||||
initGroupResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
|
initGroupResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
|
||||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||||
|
|
||||||
doBuildDeleteDataBlock(pInfo->pSeDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
#if 0
|
||||||
|
char* pBuf = streamStateSessionDump(pInfo->streamAggSup.pState);
|
||||||
|
qDebug("===stream===final session%s", pBuf);
|
||||||
|
taosMemoryFree(pBuf);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
doBuildDeleteDataBlock(pOperator, pInfo->pSeDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
||||||
if (pInfo->pDelRes->info.rows > 0) {
|
if (pInfo->pDelRes->info.rows > 0) {
|
||||||
printDataBlock(pInfo->pDelRes, "single state delete");
|
printDataBlock(pInfo->pDelRes, "single state delete");
|
||||||
return pInfo->pDelRes;
|
return pInfo->pDelRes;
|
||||||
|
@ -4656,7 +4675,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
|
||||||
printDataBlock(pBInfo->pRes, "single state");
|
printDataBlock(pBInfo->pRes, "single state");
|
||||||
return pBInfo->pRes;
|
return pBInfo->pRes;
|
||||||
}
|
}
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4721,14 +4740,10 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
pInfo->pGroupIdTbNameMap =
|
pInfo->pGroupIdTbNameMap =
|
||||||
taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_NO_LOCK);
|
taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_NO_LOCK);
|
||||||
|
|
||||||
pOperator->name = "StreamStateAggOperator";
|
setOperatorInfo(pOperator, "StreamStateAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE, true, OP_NOT_OPENED,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE;
|
pInfo, pTaskInfo);
|
||||||
pOperator->blocking = true;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(operatorDummyOpenFn, doStreamStateAgg, NULL, NULL, destroyStreamStateOperatorInfo, NULL);
|
createOperatorFpSet(operatorDummyOpenFn, doStreamStateAgg, NULL, destroyStreamStateOperatorInfo, NULL);
|
||||||
initDownStream(downstream, &pInfo->streamAggSup, pInfo->twAggSup.waterMark, pOperator->operatorType,
|
initDownStream(downstream, &pInfo->streamAggSup, pInfo->twAggSup.waterMark, pOperator->operatorType,
|
||||||
pInfo->primaryTsIndex);
|
pInfo->primaryTsIndex);
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -4876,7 +4891,7 @@ static void doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
cleanupAfterGroupResultGen(pMiaInfo, pRes);
|
cleanupAfterGroupResultGen(pMiaInfo, pRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5001,16 +5016,11 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
|
|
||||||
initResultRowInfo(&iaInfo->binfo.resultRowInfo);
|
initResultRowInfo(&iaInfo->binfo.resultRowInfo);
|
||||||
blockDataEnsureCapacity(iaInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(iaInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||||
|
setOperatorInfo(pOperator, "TimeMergeAlignedIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL,
|
||||||
pOperator->name = "TimeMergeAlignedIntervalAggOperator";
|
false, OP_NOT_OPENED, miaInfo, pTaskInfo);
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL;
|
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
pOperator->info = miaInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(operatorDummyOpenFn, mergeAlignedIntervalAgg, NULL, NULL, destroyMAIOperatorInfo, NULL);
|
createOperatorFpSet(operatorDummyOpenFn, mergeAlignedIntervalAgg, NULL, destroyMAIOperatorInfo, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -5254,7 +5264,7 @@ static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRes->info.rows == 0) {
|
if (pRes->info.rows == 0) {
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t rows = pRes->info.rows;
|
size_t rows = pRes->info.rows;
|
||||||
|
@ -5313,16 +5323,10 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge
|
||||||
}
|
}
|
||||||
|
|
||||||
initResultRowInfo(&pIntervalInfo->binfo.resultRowInfo);
|
initResultRowInfo(&pIntervalInfo->binfo.resultRowInfo);
|
||||||
|
setOperatorInfo(pOperator, "TimeMergeIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL, false,
|
||||||
pOperator->name = "TimeMergeIntervalAggOperator";
|
OP_NOT_OPENED, pMergeIntervalInfo, pTaskInfo);
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL;
|
|
||||||
pOperator->blocking = false;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
pOperator->info = pMergeIntervalInfo;
|
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
createOperatorFpSet(operatorDummyOpenFn, doMergeIntervalAgg, NULL, NULL, destroyMergeIntervalOperatorInfo, NULL);
|
createOperatorFpSet(operatorDummyOpenFn, doMergeIntervalAgg, NULL, destroyMergeIntervalOperatorInfo, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -5366,7 +5370,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
deleteIntervalDiscBuf(pInfo->pState, NULL, pInfo->twAggSup.maxTs - pInfo->twAggSup.deleteMark, &pInfo->interval,
|
deleteIntervalDiscBuf(pInfo->pState, NULL, pInfo->twAggSup.maxTs - pInfo->twAggSup.deleteMark, &pInfo->interval,
|
||||||
&pInfo->delKey);
|
&pInfo->delKey);
|
||||||
doSetOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
streamStateCommit(pTaskInfo->streamInfo.pState);
|
streamStateCommit(pTaskInfo->streamInfo.pState);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -5550,13 +5554,10 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
pInfo->pGroupIdTbNameMap =
|
pInfo->pGroupIdTbNameMap =
|
||||||
taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_NO_LOCK);
|
taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_NO_LOCK);
|
||||||
|
|
||||||
pOperator->name = "StreamIntervalOperator";
|
setOperatorInfo(pOperator, "StreamIntervalOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL, true, OP_NOT_OPENED,
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL;
|
pInfo, pTaskInfo);
|
||||||
pOperator->blocking = true;
|
pOperator->fpSet =
|
||||||
pOperator->status = OP_NOT_OPENED;
|
createOperatorFpSet(operatorDummyOpenFn, doStreamIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, NULL);
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamIntervalAgg, NULL, NULL,
|
|
||||||
destroyStreamFinalIntervalOperatorInfo, NULL);
|
|
||||||
|
|
||||||
initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup);
|
initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup);
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
|
|
@ -911,6 +911,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
case TSDB_DATA_TYPE_FLOAT: {
|
||||||
float* plist = (float*)pCol->pData;
|
float* plist = (float*)pCol->pData;
|
||||||
|
// float val = 0;
|
||||||
for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) {
|
||||||
if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) {
|
if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -918,8 +919,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
numOfElem += 1;
|
numOfElem += 1;
|
||||||
pAvgRes->count += 1;
|
pAvgRes->count += 1;
|
||||||
pAvgRes->sum.dsum += plist[i];
|
pAvgRes->sum.dsum += plist[i];
|
||||||
}
|
}
|
||||||
|
// pAvgRes->sum.dsum = val;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1278,14 +1280,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
} else {
|
} else {
|
||||||
// ignore the equivalent data value
|
// ignore the equivalent data value
|
||||||
if ((*val) == pData[i]) {
|
// NOTE: An faster version to avoid one additional comparison with FPU.
|
||||||
continue;
|
if (isMinFunc) { // min
|
||||||
}
|
if (*val > pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
if ((*val < pData[i]) ^ isMinFunc) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
*val = pData[i];
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
}
|
||||||
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
}
|
||||||
|
} else { // max
|
||||||
|
if (*val < pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1309,14 +1317,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
} else {
|
} else {
|
||||||
// ignore the equivalent data value
|
// ignore the equivalent data value
|
||||||
if ((*val) == pData[i]) {
|
// NOTE: An faster version to avoid one additional comparison with FPU.
|
||||||
continue;
|
if (isMinFunc) { // min
|
||||||
}
|
if (*val > pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
if ((*val < pData[i]) ^ isMinFunc) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
*val = pData[i];
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
}
|
||||||
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
}
|
||||||
|
} else { // max
|
||||||
|
if (*val < pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1340,14 +1354,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
} else {
|
} else {
|
||||||
// ignore the equivalent data value
|
// ignore the equivalent data value
|
||||||
if ((*val) == pData[i]) {
|
// NOTE: An faster version to avoid one additional comparison with FPU.
|
||||||
continue;
|
if (isMinFunc) { // min
|
||||||
}
|
if (*val > pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
if ((*val < pData[i]) ^ isMinFunc) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
*val = pData[i];
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
}
|
||||||
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
}
|
||||||
|
} else { // max
|
||||||
|
if (*val < pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1371,14 +1391,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
} else {
|
} else {
|
||||||
// ignore the equivalent data value
|
// ignore the equivalent data value
|
||||||
if ((*val) == pData[i]) {
|
// NOTE: An faster version to avoid one additional comparison with FPU.
|
||||||
continue;
|
if (isMinFunc) { // min
|
||||||
}
|
if (*val > pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
if ((*val < pData[i]) ^ isMinFunc) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
*val = pData[i];
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
}
|
||||||
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
}
|
||||||
|
} else { // max
|
||||||
|
if (*val < pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1404,14 +1430,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
} else {
|
} else {
|
||||||
// ignore the equivalent data value
|
// ignore the equivalent data value
|
||||||
if ((*val) == pData[i]) {
|
// NOTE: An faster version to avoid one additional comparison with FPU.
|
||||||
continue;
|
if (isMinFunc) { // min
|
||||||
}
|
if (*val > pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
if ((*val < pData[i]) ^ isMinFunc) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
*val = pData[i];
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
}
|
||||||
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
}
|
||||||
|
} else { // max
|
||||||
|
if (*val < pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1435,14 +1467,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
} else {
|
} else {
|
||||||
// ignore the equivalent data value
|
// ignore the equivalent data value
|
||||||
if ((*val) == pData[i]) {
|
// NOTE: An faster version to avoid one additional comparison with FPU.
|
||||||
continue;
|
if (isMinFunc) { // min
|
||||||
}
|
if (*val > pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
if ((*val < pData[i]) ^ isMinFunc) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
*val = pData[i];
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
}
|
||||||
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
}
|
||||||
|
} else { // max
|
||||||
|
if (*val < pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1466,14 +1504,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
} else {
|
} else {
|
||||||
// ignore the equivalent data value
|
// ignore the equivalent data value
|
||||||
if ((*val) == pData[i]) {
|
// NOTE: An faster version to avoid one additional comparison with FPU.
|
||||||
continue;
|
if (isMinFunc) { // min
|
||||||
}
|
if (*val > pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
if ((*val < pData[i]) ^ isMinFunc) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
*val = pData[i];
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
}
|
||||||
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
}
|
||||||
|
} else { // max
|
||||||
|
if (*val < pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1497,14 +1541,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
} else {
|
} else {
|
||||||
// ignore the equivalent data value
|
// ignore the equivalent data value
|
||||||
if ((*val) == pData[i]) {
|
// NOTE: An faster version to avoid one additional comparison with FPU.
|
||||||
continue;
|
if (isMinFunc) { // min
|
||||||
}
|
if (*val > pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
if ((*val < pData[i]) ^ isMinFunc) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
*val = pData[i];
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
}
|
||||||
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
}
|
||||||
|
} else { // max
|
||||||
|
if (*val < pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1529,14 +1579,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
} else {
|
} else {
|
||||||
// ignore the equivalent data value
|
// ignore the equivalent data value
|
||||||
if ((*val) == pData[i]) {
|
// NOTE: An faster version to avoid one additional comparison with FPU.
|
||||||
continue;
|
if (isMinFunc) { // min
|
||||||
}
|
if (*val > pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
if ((*val < pData[i]) ^ isMinFunc) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
*val = pData[i];
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
}
|
||||||
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
}
|
||||||
|
} else { // max
|
||||||
|
if (*val < pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1559,7 +1615,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
}
|
}
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
} else {
|
} else {
|
||||||
// ignore the equivalent data value
|
#if 0
|
||||||
if ((*val) == pData[i]) {
|
if ((*val) == pData[i]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1570,6 +1626,23 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
// NOTE: An faster version to avoid one additional comparison with FPU.
|
||||||
|
if (isMinFunc) { // min
|
||||||
|
if (*val > pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { // max
|
||||||
|
if (*val < pData[i]) {
|
||||||
|
*val = pData[i];
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
|
@ -2934,6 +3007,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
int64_t* pts = (int64_t*) pInput->pPTS->pData;
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) {
|
||||||
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -2942,13 +3016,14 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
|
||||||
numOfElems++;
|
numOfElems++;
|
||||||
|
|
||||||
char* data = colDataGetData(pInputCol, i);
|
char* data = colDataGetData(pInputCol, i);
|
||||||
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
TSKEY cts = pts[i];
|
||||||
if (pResInfo->numOfRes == 0 || pInfo->ts > cts) {
|
if (pResInfo->numOfRes == 0 || pInfo->ts > cts) {
|
||||||
doSaveCurrentVal(pCtx, i, cts, pInputCol->info.type, data);
|
doSaveCurrentVal(pCtx, i, cts, pInputCol->info.type, data);
|
||||||
pResInfo->numOfRes = 1;
|
pResInfo->numOfRes = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (numOfElems == 0) {
|
if (numOfElems == 0) {
|
||||||
// save selectivity value for column consisted of all null values
|
// save selectivity value for column consisted of all null values
|
||||||
firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
|
firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
|
||||||
|
@ -3020,26 +3095,87 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
int64_t* pts = (int64_t*)pInput->pPTS->pData;
|
||||||
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
numOfElems++;
|
#if 0
|
||||||
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
|
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
char* data = colDataGetData(pInputCol, i);
|
numOfElems++;
|
||||||
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
if (pResInfo->numOfRes == 0 || pInfo->ts < pts[i]) {
|
||||||
if (pResInfo->numOfRes == 0 || pInfo->ts < cts) {
|
char* data = colDataGetData(pInputCol, i);
|
||||||
doSaveCurrentVal(pCtx, i, cts, type, data);
|
doSaveCurrentVal(pCtx, i, pts[i], type, data);
|
||||||
pResInfo->numOfRes = 1;
|
pResInfo->numOfRes = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (!pInputCol->hasNull) {
|
||||||
|
numOfElems = 1;
|
||||||
|
|
||||||
|
int32_t round = pInput->numOfRows >> 2;
|
||||||
|
int32_t reminder = pInput->numOfRows & 0x03;
|
||||||
|
|
||||||
|
int32_t tick = 0;
|
||||||
|
for (int32_t i = pInput->startRowIndex; tick < round; i += 4, tick += 1) {
|
||||||
|
int64_t cts = pts[i];
|
||||||
|
int32_t chosen = i;
|
||||||
|
|
||||||
|
if (cts < pts[i + 1]) {
|
||||||
|
cts = pts[i + 1];
|
||||||
|
chosen = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cts < pts[i + 2]) {
|
||||||
|
cts = pts[i + 2];
|
||||||
|
chosen = i + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cts < pts[i + 3]) {
|
||||||
|
cts = pts[i + 3];
|
||||||
|
chosen = i + 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pResInfo->numOfRes == 0 || pInfo->ts < cts) {
|
||||||
|
char* data = colDataGetData(pInputCol, chosen);
|
||||||
|
doSaveCurrentVal(pCtx, i, cts, type, data);
|
||||||
|
pResInfo->numOfRes = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = pInput->startRowIndex + round * 4; i < pInput->startRowIndex + pInput->numOfRows; ++i) {
|
||||||
|
if (pResInfo->numOfRes == 0 || pInfo->ts < pts[i]) {
|
||||||
|
char* data = colDataGetData(pInputCol, i);
|
||||||
|
doSaveCurrentVal(pCtx, i, pts[i], type, data);
|
||||||
|
pResInfo->numOfRes = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) {
|
||||||
|
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
|
if (pResInfo->numOfRes == 0 || pInfo->ts < pts[i]) {
|
||||||
|
char* data = colDataGetData(pInputCol, i);
|
||||||
|
doSaveCurrentVal(pCtx, i, pts[i], type, data);
|
||||||
|
pResInfo->numOfRes = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// save selectivity value for column consisted of all null values
|
||||||
if (numOfElems == 0) {
|
if (numOfElems == 0) {
|
||||||
// save selectivity value for column consisted of all null values
|
|
||||||
firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
|
firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
|
||||||
}
|
}
|
||||||
SET_VAL(pResInfo, numOfElems, 1);
|
|
||||||
|
// SET_VAL(pResInfo, numOfElems, 1);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3189,8 +3325,8 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
|
||||||
#if 0
|
#if 0
|
||||||
int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||||
|
|
||||||
// the optimized version only function if all tuples in one block are monotonious increasing or descreasing.
|
// the optimized version only valid if all tuples in one block are monotonious increasing or descreasing.
|
||||||
// this is NOT always works if project operator exists in downstream.
|
// this assumption is NOT always works if project operator exists in downstream.
|
||||||
if (blockDataOrder == TSDB_ORDER_ASC) {
|
if (blockDataOrder == TSDB_ORDER_ASC) {
|
||||||
for (int32_t i = pInput->numOfRows + pInput->startRowIndex - 1; i >= pInput->startRowIndex; --i) {
|
for (int32_t i = pInput->numOfRows + pInput->startRowIndex - 1; i >= pInput->startRowIndex; --i) {
|
||||||
char* data = colDataGetData(pInputCol, i);
|
char* data = colDataGetData(pInputCol, i);
|
||||||
|
@ -3216,11 +3352,13 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
int64_t* pts = (int64_t*)pInput->pPTS->pData;
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
char* data = colDataGetData(pInputCol, i);
|
char* data = colDataGetData(pInputCol, i);
|
||||||
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
TSKEY cts = pts[i];
|
||||||
numOfElems++;
|
|
||||||
|
|
||||||
|
numOfElems++;
|
||||||
if (pResInfo->numOfRes == 0 || pInfo->ts < cts) {
|
if (pResInfo->numOfRes == 0 || pInfo->ts < cts) {
|
||||||
doSaveLastrow(pCtx, data, i, cts, pInfo);
|
doSaveLastrow(pCtx, data, i, cts, pInfo);
|
||||||
pResInfo->numOfRes = 1;
|
pResInfo->numOfRes = 1;
|
||||||
|
|
|
@ -131,7 +131,8 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
|
||||||
|
|
||||||
char udfdPathLdLib[1024] = {0};
|
char udfdPathLdLib[1024] = {0};
|
||||||
size_t udfdLdLibPathLen = strlen(tsUdfdLdLibPath);
|
size_t udfdLdLibPathLen = strlen(tsUdfdLdLibPath);
|
||||||
strncpy(udfdPathLdLib, tsUdfdLdLibPath, udfdLdLibPathLen);
|
strncpy(udfdPathLdLib, tsUdfdLdLibPath, tListLen(udfdPathLdLib));
|
||||||
|
|
||||||
udfdPathLdLib[udfdLdLibPathLen] = ':';
|
udfdPathLdLib[udfdLdLibPathLen] = ':';
|
||||||
strncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen - 1);
|
strncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen - 1);
|
||||||
if (udfdLdLibPathLen + taosdLdLibPathLen < 1024) {
|
if (udfdLdLibPathLen + taosdLdLibPathLen < 1024) {
|
||||||
|
|
|
@ -864,6 +864,7 @@ void udfdCtrlAllocBufCb(uv_handle_t *handle, size_t suggested_size, uv_buf_t *bu
|
||||||
void udfdCtrlReadCb(uv_stream_t *q, ssize_t nread, const uv_buf_t *buf) {
|
void udfdCtrlReadCb(uv_stream_t *q, ssize_t nread, const uv_buf_t *buf) {
|
||||||
if (nread < 0) {
|
if (nread < 0) {
|
||||||
fnError("udfd ctrl pipe read error. %s", uv_err_name(nread));
|
fnError("udfd ctrl pipe read error. %s", uv_err_name(nread));
|
||||||
|
taosMemoryFree(buf->base);
|
||||||
uv_close((uv_handle_t *)q, NULL);
|
uv_close((uv_handle_t *)q, NULL);
|
||||||
uv_stop(global.loop);
|
uv_stop(global.loop);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -424,8 +424,9 @@ SNode* nodesMakeNode(ENodeType type) {
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
|
||||||
return makeNode(type, sizeof(SShowStmt));
|
return makeNode(type, sizeof(SShowStmt));
|
||||||
|
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
||||||
|
return makeNode(type, sizeof(SShowTableTagsStmt));
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
return makeNode(type, sizeof(SShowDnodeVariablesStmt));
|
return makeNode(type, sizeof(SShowDnodeVariablesStmt));
|
||||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
|
@ -942,13 +943,19 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
case QUERY_NODE_SHOW_TAGS_STMT: {
|
||||||
case QUERY_NODE_SHOW_TABLE_TAGS_STMT: {
|
|
||||||
SShowStmt* pStmt = (SShowStmt*)pNode;
|
SShowStmt* pStmt = (SShowStmt*)pNode;
|
||||||
nodesDestroyNode(pStmt->pDbName);
|
nodesDestroyNode(pStmt->pDbName);
|
||||||
nodesDestroyNode(pStmt->pTbName);
|
nodesDestroyNode(pStmt->pTbName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case QUERY_NODE_SHOW_TABLE_TAGS_STMT: {
|
||||||
|
SShowTableTagsStmt* pStmt = (SShowTableTagsStmt*)pNode;
|
||||||
|
nodesDestroyNode(pStmt->pDbName);
|
||||||
|
nodesDestroyNode(pStmt->pTbName);
|
||||||
|
nodesDestroyList(pStmt->pTags);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
nodesDestroyNode(((SShowDnodeVariablesStmt*)pNode)->pDnodeId);
|
nodesDestroyNode(((SShowDnodeVariablesStmt*)pNode)->pDnodeId);
|
||||||
nodesDestroyNode(((SShowDnodeVariablesStmt*)pNode)->pLikePattern);
|
nodesDestroyNode(((SShowDnodeVariablesStmt*)pNode)->pLikePattern);
|
||||||
|
|
|
@ -178,6 +178,7 @@ SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode*
|
||||||
SNode* createShowTableDistributedStmt(SAstCreateContext* pCxt, SNode* pRealTable);
|
SNode* createShowTableDistributedStmt(SAstCreateContext* pCxt, SNode* pRealTable);
|
||||||
SNode* createShowDnodeVariablesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pLikePattern);
|
SNode* createShowDnodeVariablesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pLikePattern);
|
||||||
SNode* createShowVnodesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pDnodeEndpoint);
|
SNode* createShowVnodesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pDnodeEndpoint);
|
||||||
|
SNode* createShowTableTagsStmt(SAstCreateContext* pCxt, SNode* pTbName, SNode* pDbName, SNodeList* pTags);
|
||||||
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo);
|
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo);
|
||||||
SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, const SToken* pVal);
|
SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, const SToken* pVal);
|
||||||
SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
|
SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
|
||||||
|
|
|
@ -108,7 +108,7 @@ int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, S
|
||||||
int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SArray** pVgInfo);
|
int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SArray** pVgInfo);
|
||||||
int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName, SVgroupInfo* pVgroup);
|
int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName, SVgroupInfo* pVgroup);
|
||||||
int32_t getDbVgVersionFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, int32_t* pVersion, int64_t* pDbId,
|
int32_t getDbVgVersionFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, int32_t* pVersion, int64_t* pDbId,
|
||||||
int32_t* pTableNum);
|
int32_t* pTableNum, int64_t* pStateTs);
|
||||||
int32_t getDbCfgFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SDbCfgInfo* pInfo);
|
int32_t getDbCfgFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SDbCfgInfo* pInfo);
|
||||||
int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, const char* pDbFName, AUTH_TYPE type,
|
int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, const char* pDbFName, AUTH_TYPE type,
|
||||||
bool* pPass);
|
bool* pPass);
|
||||||
|
|
|
@ -426,7 +426,7 @@ cmd ::= SHOW TABLE DISTRIBUTED full_table_name(A).
|
||||||
cmd ::= SHOW CONSUMERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); }
|
cmd ::= SHOW CONSUMERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); }
|
||||||
cmd ::= SHOW SUBSCRIPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); }
|
cmd ::= SHOW SUBSCRIPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); }
|
||||||
cmd ::= SHOW TAGS FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, B, A, OP_TYPE_EQUAL); }
|
cmd ::= SHOW TAGS FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, B, A, OP_TYPE_EQUAL); }
|
||||||
cmd ::= SHOW TABLE TAGS FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLE_TAGS_STMT, B, A, OP_TYPE_EQUAL); }
|
cmd ::= SHOW TABLE TAGS tag_list_opt(C) FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowTableTagsStmt(pCxt, A, B, C); }
|
||||||
cmd ::= SHOW VNODES NK_INTEGER(A). { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &A), NULL); }
|
cmd ::= SHOW VNODES NK_INTEGER(A). { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &A), NULL); }
|
||||||
cmd ::= SHOW VNODES NK_STRING(A). { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &A)); }
|
cmd ::= SHOW VNODES NK_STRING(A). { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &A)); }
|
||||||
|
|
||||||
|
@ -441,6 +441,18 @@ table_name_cond(A) ::= table_name(B).
|
||||||
from_db_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
|
from_db_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
|
||||||
from_db_opt(A) ::= FROM db_name(B). { A = createIdentifierValueNode(pCxt, &B); }
|
from_db_opt(A) ::= FROM db_name(B). { A = createIdentifierValueNode(pCxt, &B); }
|
||||||
|
|
||||||
|
%type tag_list_opt { SNodeList* }
|
||||||
|
%destructor tag_list_opt { nodesDestroyList($$); }
|
||||||
|
tag_list_opt(A) ::= . { A = NULL; }
|
||||||
|
tag_list_opt(A) ::= tag_item(B). { A = createNodeList(pCxt, B); }
|
||||||
|
tag_list_opt(A) ::= tag_list_opt(B) NK_COMMA tag_item(C). { A = addNodeToList(pCxt, B, C); }
|
||||||
|
|
||||||
|
tag_item(A) ::= TBNAME(B). { A = setProjectionAlias(pCxt, createFunctionNode(pCxt, &B, NULL), &B); }
|
||||||
|
tag_item(A) ::= QTAGS(B). { A = createFunctionNode(pCxt, &B, NULL); }
|
||||||
|
tag_item(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); }
|
||||||
|
tag_item(A) ::= column_name(B) column_alias(C). { A = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &B), &C); }
|
||||||
|
tag_item(A) ::= column_name(B) AS column_alias(C). { A = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &B), &C); }
|
||||||
|
|
||||||
/************************************************ create index ********************************************************/
|
/************************************************ create index ********************************************************/
|
||||||
cmd ::= CREATE SMA INDEX not_exists_opt(D)
|
cmd ::= CREATE SMA INDEX not_exists_opt(D)
|
||||||
full_table_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); }
|
full_table_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); }
|
||||||
|
|
|
@ -1390,6 +1390,21 @@ SNode* createShowVnodesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pDn
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SNode* createShowTableTagsStmt(SAstCreateContext* pCxt, SNode* pTbName, SNode* pDbName, SNodeList* pTags) {
|
||||||
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
if (NULL == pDbName) {
|
||||||
|
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "database not specified");
|
||||||
|
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
SShowTableTagsStmt* pStmt = (SShowTableTagsStmt*)nodesMakeNode(QUERY_NODE_SHOW_TABLE_TAGS_STMT);
|
||||||
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
|
pStmt->pDbName = pDbName;
|
||||||
|
pStmt->pTbName = pTbName;
|
||||||
|
pStmt->pTags = pTags;
|
||||||
|
return (SNode*)pStmt;
|
||||||
|
}
|
||||||
|
|
||||||
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo) {
|
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
char password[TSDB_USET_PASSWORD_LEN] = {0};
|
char password[TSDB_USET_PASSWORD_LEN] = {0};
|
||||||
|
|
|
@ -440,7 +440,7 @@ static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* p
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowStableTags(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowStableTags(SCollectMetaKeyCxt* pCxt, SShowTableTagsStmt* pStmt) {
|
||||||
return collectMetaKeyFromRealTableImpl(pCxt, ((SValueNode*)pStmt->pDbName)->literal,
|
return collectMetaKeyFromRealTableImpl(pCxt, ((SValueNode*)pStmt->pDbName)->literal,
|
||||||
((SValueNode*)pStmt->pTbName)->literal, AUTH_TYPE_READ);
|
((SValueNode*)pStmt->pTbName)->literal, AUTH_TYPE_READ);
|
||||||
}
|
}
|
||||||
|
@ -627,7 +627,7 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
return collectMetaKeyFromShowTags(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowTags(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
||||||
return collectMetaKeyFromShowStableTags(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowStableTags(pCxt, (SShowTableTagsStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_USERS_STMT:
|
case QUERY_NODE_SHOW_USERS_STMT:
|
||||||
return collectMetaKeyFromShowUsers(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowUsers(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_LICENCES_STMT:
|
case QUERY_NODE_SHOW_LICENCES_STMT:
|
||||||
|
|
|
@ -466,14 +466,14 @@ static int32_t getTableHashVgroup(STranslateContext* pCxt, const char* pDbName,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getDBVgVersion(STranslateContext* pCxt, const char* pDbFName, int32_t* pVersion, int64_t* pDbId,
|
static int32_t getDBVgVersion(STranslateContext* pCxt, const char* pDbFName, int32_t* pVersion, int64_t* pDbId,
|
||||||
int32_t* pTableNum) {
|
int32_t* pTableNum, int64_t* pStateTs) {
|
||||||
SParseContext* pParCxt = pCxt->pParseCxt;
|
SParseContext* pParCxt = pCxt->pParseCxt;
|
||||||
int32_t code = collectUseDatabaseImpl(pDbFName, pCxt->pDbs);
|
int32_t code = collectUseDatabaseImpl(pDbFName, pCxt->pDbs);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (pParCxt->async) {
|
if (pParCxt->async) {
|
||||||
code = getDbVgVersionFromCache(pCxt->pMetaCache, pDbFName, pVersion, pDbId, pTableNum);
|
code = getDbVgVersionFromCache(pCxt->pMetaCache, pDbFName, pVersion, pDbId, pTableNum, pStateTs);
|
||||||
} else {
|
} else {
|
||||||
code = catalogGetDBVgVersion(pParCxt->pCatalog, pDbFName, pVersion, pDbId, pTableNum);
|
code = catalogGetDBVgVersion(pParCxt->pCatalog, pDbFName, pVersion, pDbId, pTableNum, pStateTs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
@ -1252,6 +1252,19 @@ static bool dataTypeEqual(const SDataType* l, const SDataType* r) {
|
||||||
return (l->type == r->type && l->bytes == r->bytes && l->precision == r->precision && l->scale == r->scale);
|
return (l->type == r->type && l->bytes == r->bytes && l->precision == r->precision && l->scale == r->scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 0 means equal, 1 means the left shall prevail, -1 means the right shall prevail
|
||||||
|
static int32_t dataTypeComp(const SDataType* l, const SDataType* r) {
|
||||||
|
if (l->type != r->type) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (l->bytes != r->bytes) {
|
||||||
|
return l->bytes > r->bytes ? 1 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (l->precision == r->precision && l->scale == r->scale) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
||||||
if (isMultiResFunc(pOp->pLeft)) {
|
if (isMultiResFunc(pOp->pLeft)) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName);
|
||||||
|
@ -1865,6 +1878,7 @@ static int32_t rewriteIsTrue(SNode* pSrc, SNode** pIsTrue) {
|
||||||
|
|
||||||
static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseWhen) {
|
static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseWhen) {
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
bool allNullThen = true;
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
FOREACH(pNode, pCaseWhen->pWhenThenList) {
|
FOREACH(pNode, pCaseWhen->pWhenThenList) {
|
||||||
SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode;
|
SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode;
|
||||||
|
@ -1876,10 +1890,31 @@ static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseW
|
||||||
}
|
}
|
||||||
pWhenThen->pWhen = pIsTrue;
|
pWhenThen->pWhen = pIsTrue;
|
||||||
}
|
}
|
||||||
if (first) {
|
|
||||||
first = false;
|
SExprNode* pThenExpr = (SExprNode*)pNode;
|
||||||
pCaseWhen->node.resType = ((SExprNode*)pNode)->resType;
|
if (TSDB_DATA_TYPE_NULL == pThenExpr->resType.type) {
|
||||||
} else if (!dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pNode)->resType)) {
|
continue;
|
||||||
|
}
|
||||||
|
allNullThen = false;
|
||||||
|
if (first || dataTypeComp(&pCaseWhen->node.resType, &pThenExpr->resType) < 0) {
|
||||||
|
pCaseWhen->node.resType = pThenExpr->resType;
|
||||||
|
}
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allNullThen) {
|
||||||
|
if (NULL != pCaseWhen->pElse) {
|
||||||
|
pCaseWhen->node.resType = ((SExprNode*)pCaseWhen->pElse)->resType;
|
||||||
|
} else {
|
||||||
|
pCaseWhen->node.resType.type = TSDB_DATA_TYPE_NULL;
|
||||||
|
pCaseWhen->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes;
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FOREACH(pNode, pCaseWhen->pWhenThenList) {
|
||||||
|
SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode;
|
||||||
|
if (!dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pNode)->resType)) {
|
||||||
SNode* pCastFunc = NULL;
|
SNode* pCastFunc = NULL;
|
||||||
pCxt->errCode = createCastFunc(pCxt, pWhenThen->pThen, pCaseWhen->node.resType, &pCastFunc);
|
pCxt->errCode = createCastFunc(pCxt, pWhenThen->pThen, pCaseWhen->node.resType, &pCastFunc);
|
||||||
if (TSDB_CODE_SUCCESS != pCxt->errCode) {
|
if (TSDB_CODE_SUCCESS != pCxt->errCode) {
|
||||||
|
@ -1889,6 +1924,7 @@ static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseW
|
||||||
pWhenThen->node.resType = pCaseWhen->node.resType;
|
pWhenThen->node.resType = pCaseWhen->node.resType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != pCaseWhen->pElse && !dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pCaseWhen->pElse)->resType)) {
|
if (NULL != pCaseWhen->pElse && !dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pCaseWhen->pElse)->resType)) {
|
||||||
SNode* pCastFunc = NULL;
|
SNode* pCastFunc = NULL;
|
||||||
pCxt->errCode = createCastFunc(pCxt, pCaseWhen->pElse, pCaseWhen->node.resType, &pCastFunc);
|
pCxt->errCode = createCastFunc(pCxt, pCaseWhen->pElse, pCaseWhen->node.resType, &pCastFunc);
|
||||||
|
@ -2393,6 +2429,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
||||||
if (TSDB_SUPER_TABLE == pRealTable->pMeta->tableType) {
|
if (TSDB_SUPER_TABLE == pRealTable->pMeta->tableType) {
|
||||||
pCxt->stableQuery = true;
|
pCxt->stableQuery = true;
|
||||||
}
|
}
|
||||||
|
if (TSDB_SYSTEM_TABLE == pRealTable->pMeta->tableType && isSelectStmt(pCxt->pCurrStmt)) {
|
||||||
|
((SSelectStmt*)pCxt->pCurrStmt)->isTimeLineResult = false;
|
||||||
|
}
|
||||||
code = addNamespace(pCxt, pRealTable);
|
code = addNamespace(pCxt, pRealTable);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -3440,7 +3479,8 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
|
||||||
FORBOTH(pLeft, pLeftProjections, pRight, pRightProjections) {
|
FORBOTH(pLeft, pLeftProjections, pRight, pRightProjections) {
|
||||||
SExprNode* pLeftExpr = (SExprNode*)pLeft;
|
SExprNode* pLeftExpr = (SExprNode*)pLeft;
|
||||||
SExprNode* pRightExpr = (SExprNode*)pRight;
|
SExprNode* pRightExpr = (SExprNode*)pRight;
|
||||||
if (!dataTypeEqual(&pLeftExpr->resType, &pRightExpr->resType)) {
|
int32_t comp = dataTypeComp(&pLeftExpr->resType, &pRightExpr->resType);
|
||||||
|
if (comp > 0) {
|
||||||
SNode* pRightFunc = NULL;
|
SNode* pRightFunc = NULL;
|
||||||
int32_t code = createCastFunc(pCxt, pRight, pLeftExpr->resType, &pRightFunc);
|
int32_t code = createCastFunc(pCxt, pRight, pLeftExpr->resType, &pRightFunc);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
@ -3448,9 +3488,20 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
|
||||||
}
|
}
|
||||||
REPLACE_LIST2_NODE(pRightFunc);
|
REPLACE_LIST2_NODE(pRightFunc);
|
||||||
pRightExpr = (SExprNode*)pRightFunc;
|
pRightExpr = (SExprNode*)pRightFunc;
|
||||||
|
} else if (comp < 0) {
|
||||||
|
SNode* pLeftFunc = NULL;
|
||||||
|
int32_t code = createCastFunc(pCxt, pLeft, pRightExpr->resType, &pLeftFunc);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
REPLACE_LIST1_NODE(pLeftFunc);
|
||||||
|
SExprNode* pLeftFuncExpr = (SExprNode*)pLeftFunc;
|
||||||
|
snprintf(pLeftFuncExpr->aliasName, sizeof(pLeftFuncExpr->aliasName), "%s", pLeftExpr->aliasName);
|
||||||
|
snprintf(pLeftFuncExpr->userAlias, sizeof(pLeftFuncExpr->userAlias), "%s", pLeftExpr->userAlias);
|
||||||
|
pLeft = pLeftFunc;
|
||||||
|
pLeftExpr = pLeftFuncExpr;
|
||||||
}
|
}
|
||||||
strcpy(pRightExpr->aliasName, pLeftExpr->aliasName);
|
snprintf(pRightExpr->aliasName, sizeof(pRightExpr->aliasName), "%s", pLeftExpr->aliasName);
|
||||||
pRightExpr->aliasName[strlen(pLeftExpr->aliasName)] = '\0';
|
|
||||||
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pSetOperator->pProjectionList,
|
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pSetOperator->pProjectionList,
|
||||||
createSetOperProject(pSetOperator->stmtName, pLeft))) {
|
createSetOperProject(pSetOperator->stmtName, pLeft))) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -4941,7 +4992,8 @@ static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* p
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
||||||
tNameExtractFullName(&name, usedbReq.db);
|
tNameExtractFullName(&name, usedbReq.db);
|
||||||
int32_t code = getDBVgVersion(pCxt, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable);
|
int32_t code =
|
||||||
|
getDBVgVersion(pCxt, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable, &usedbReq.stateTs);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = buildCmdMsg(pCxt, TDMT_MND_USE_DB, (FSerializeFunc)tSerializeSUseDbReq, &usedbReq);
|
code = buildCmdMsg(pCxt, TDMT_MND_USE_DB, (FSerializeFunc)tSerializeSUseDbReq, &usedbReq);
|
||||||
}
|
}
|
||||||
|
@ -6253,21 +6305,29 @@ static SNode* createTagsFunction() {
|
||||||
return (SNode*)pFunc;
|
return (SNode*)pFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t createShowTableTagsProjections(SNodeList** pProjections, SNodeList** pTags) {
|
||||||
|
if (NULL != *pTags) {
|
||||||
|
TSWAP(*pProjections, *pTags);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
int32_t code = nodesListMakeStrictAppend(pProjections, createTbnameFunction());
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodesListStrictAppend(*pProjections, createTagsFunction());
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t rewriteShowStableTags(STranslateContext* pCxt, SQuery* pQuery) {
|
static int32_t rewriteShowStableTags(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
const char* cols[] = {"tbname", "_tags"};
|
SShowTableTagsStmt* pShow = (SShowTableTagsStmt*)pQuery->pRoot;
|
||||||
SShowStmt* pShow = (SShowStmt*)pQuery->pRoot;
|
SSelectStmt* pSelect = NULL;
|
||||||
SSelectStmt* pSelect = NULL;
|
|
||||||
int32_t code = createSimpleSelectStmt(((SValueNode*)pShow->pDbName)->literal, ((SValueNode*)pShow->pTbName)->literal,
|
int32_t code = createSimpleSelectStmt(((SValueNode*)pShow->pDbName)->literal, ((SValueNode*)pShow->pTbName)->literal,
|
||||||
-1, NULL, &pSelect);
|
-1, NULL, &pSelect);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesListMakeStrictAppend(&pSelect->pProjectionList, createTbnameFunction());
|
code = createShowTableTagsProjections(&pSelect->pProjectionList, &pShow->pTags);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesListMakeStrictAppend(&pSelect->pProjectionList, createTagsFunction());
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
pSelect->isDistinct = true;
|
|
||||||
pQuery->showRewrite = true;
|
pQuery->showRewrite = true;
|
||||||
|
pSelect->tagScan = true;
|
||||||
nodesDestroyNode(pQuery->pRoot);
|
nodesDestroyNode(pQuery->pRoot);
|
||||||
pQuery->pRoot = (SNode*)pSelect;
|
pQuery->pRoot = (SNode*)pSelect;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -138,7 +138,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
case TSDB_CODE_PAR_CANNOT_DROP_PRIMARY_KEY:
|
case TSDB_CODE_PAR_CANNOT_DROP_PRIMARY_KEY:
|
||||||
return "Primary timestamp column cannot be dropped";
|
return "Primary timestamp column cannot be dropped";
|
||||||
case TSDB_CODE_PAR_INVALID_MODIFY_COL:
|
case TSDB_CODE_PAR_INVALID_MODIFY_COL:
|
||||||
return "Only binary/nchar column length could be modified";
|
return "Only binary/nchar column length could be modified, and the length can only be increased, not decreased";
|
||||||
case TSDB_CODE_PAR_INVALID_TBNAME:
|
case TSDB_CODE_PAR_INVALID_TBNAME:
|
||||||
return "Invalid tbname pseudo column";
|
return "Invalid tbname pseudo column";
|
||||||
case TSDB_CODE_PAR_INVALID_FUNCTION_NAME:
|
case TSDB_CODE_PAR_INVALID_FUNCTION_NAME:
|
||||||
|
@ -876,13 +876,14 @@ int32_t reserveDbVgVersionInCache(int32_t acctId, const char* pDb, SParseMetaCac
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getDbVgVersionFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, int32_t* pVersion, int64_t* pDbId,
|
int32_t getDbVgVersionFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, int32_t* pVersion, int64_t* pDbId,
|
||||||
int32_t* pTableNum) {
|
int32_t* pTableNum, int64_t* pStateTs) {
|
||||||
SDbInfo* pDbInfo = NULL;
|
SDbInfo* pDbInfo = NULL;
|
||||||
int32_t code = getMetaDataFromHash(pDbFName, strlen(pDbFName), pMetaCache->pDbInfo, (void**)&pDbInfo);
|
int32_t code = getMetaDataFromHash(pDbFName, strlen(pDbFName), pMetaCache->pDbInfo, (void**)&pDbInfo);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
*pVersion = pDbInfo->vgVer;
|
*pVersion = pDbInfo->vgVer;
|
||||||
*pDbId = pDbInfo->dbId;
|
*pDbId = pDbInfo->dbId;
|
||||||
*pTableNum = pDbInfo->tbNum;
|
*pTableNum = pDbInfo->tbNum;
|
||||||
|
*pStateTs = pDbInfo->stateTs;
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -249,7 +249,7 @@ int32_t __catalogGetTableDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, con
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId,
|
int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId,
|
||||||
int32_t* tableNum) {
|
int32_t* tableNum, int64_t* stateTs) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -425,6 +425,8 @@ TEST_F(ParserSelectTest, informationSchema) {
|
||||||
run("SELECT * FROM ins_databases WHERE name = 'information_schema'");
|
run("SELECT * FROM ins_databases WHERE name = 'information_schema'");
|
||||||
|
|
||||||
run("SELECT * FROM ins_tags WHERE db_name = 'test' and table_name = 'st1'");
|
run("SELECT * FROM ins_tags WHERE db_name = 'test' and table_name = 'st1'");
|
||||||
|
|
||||||
|
run("SELECT * FROM (SELECT table_name FROM ins_tables) t WHERE table_name = 'a'");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserSelectTest, withoutFrom) {
|
TEST_F(ParserSelectTest, withoutFrom) {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue