enh: assert remove task
This commit is contained in:
commit
02dec5a10a
|
@ -141,12 +141,12 @@ ELSE ()
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
IF ("${SIMD_SUPPORT}" MATCHES "true")
|
||||||
IF (COMPILER_SUPPORT_FMA)
|
IF (COMPILER_SUPPORT_FMA)
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfma")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfma")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF ("${SIMD_SUPPORT}" MATCHES "true")
|
|
||||||
IF (COMPILER_SUPPORT_AVX)
|
IF (COMPILER_SUPPORT_AVX)
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# taosadapter
|
# taosadapter
|
||||||
ExternalProject_Add(taosadapter
|
ExternalProject_Add(taosadapter
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||||
GIT_TAG f0c1753
|
GIT_TAG 5662a6d
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -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 261fcca
|
GIT_TAG 11b60a4
|
||||||
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
|
||||||
|
|
|
@ -733,7 +733,7 @@ To prevent system resource from being exhausted by multiple concurrent streams,
|
||||||
| 42 | numOfCommitThreads | Yes | Yes |
|
| 42 | numOfCommitThreads | Yes | Yes |
|
||||||
| 43 | numOfMnodeReadThreads | No | Yes |
|
| 43 | numOfMnodeReadThreads | No | Yes |
|
||||||
| 44 | numOfVnodeQueryThreads | No | Yes |
|
| 44 | numOfVnodeQueryThreads | No | Yes |
|
||||||
| 45 | numOfVnodeStreamThreads | No | Yes |
|
| 45 | ratioOfVnodeStreamThreads | No | Yes |
|
||||||
| 46 | numOfVnodeFetchThreads | No | Yes |
|
| 46 | numOfVnodeFetchThreads | No | Yes |
|
||||||
| 47 | numOfVnodeRsmaThreads | No | Yes |
|
| 47 | numOfVnodeRsmaThreads | No | Yes |
|
||||||
| 48 | numOfQnodeQueryThreads | No | Yes |
|
| 48 | numOfQnodeQueryThreads | No | Yes |
|
||||||
|
|
|
@ -709,7 +709,7 @@ charset 的有效值是 UTF-8。
|
||||||
| 42 | numOfCommitThreads | 是 | 是 | |
|
| 42 | numOfCommitThreads | 是 | 是 | |
|
||||||
| 43 | numOfMnodeReadThreads | 否 | 是 | |
|
| 43 | numOfMnodeReadThreads | 否 | 是 | |
|
||||||
| 44 | numOfVnodeQueryThreads | 否 | 是 | |
|
| 44 | numOfVnodeQueryThreads | 否 | 是 | |
|
||||||
| 45 | numOfVnodeStreamThreads | 否 | 是 | |
|
| 45 | ratioOfVnodeStreamThreads | 否 | 是 | |
|
||||||
| 46 | numOfVnodeFetchThreads | 否 | 是 | |
|
| 46 | numOfVnodeFetchThreads | 否 | 是 | |
|
||||||
| 47 | numOfVnodeRsmaThreads | 否 | 是 | |
|
| 47 | numOfVnodeRsmaThreads | 否 | 是 | |
|
||||||
| 48 | numOfQnodeQueryThreads | 否 | 是 | |
|
| 48 | numOfQnodeQueryThreads | 否 | 是 | |
|
||||||
|
|
|
@ -161,6 +161,8 @@ DLL_EXPORT int taos_stmt_set_tags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags)
|
||||||
DLL_EXPORT int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name);
|
DLL_EXPORT int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name);
|
||||||
DLL_EXPORT int taos_stmt_get_tag_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields);
|
DLL_EXPORT int taos_stmt_get_tag_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields);
|
||||||
DLL_EXPORT int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields);
|
DLL_EXPORT int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields);
|
||||||
|
// let stmt to reclaim TAOS_FIELD_E that was allocated by `taos_stmt_get_tag_fields`/`taos_stmt_get_col_fields`
|
||||||
|
DLL_EXPORT void taos_stmt_reclaim_fields(TAOS_STMT *stmt, TAOS_FIELD_E *fields);
|
||||||
|
|
||||||
DLL_EXPORT int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert);
|
DLL_EXPORT int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert);
|
||||||
DLL_EXPORT int taos_stmt_num_params(TAOS_STMT *stmt, int *nums);
|
DLL_EXPORT int taos_stmt_num_params(TAOS_STMT *stmt, int *nums);
|
||||||
|
|
|
@ -55,7 +55,7 @@ extern int32_t tsNumOfMnodeQueryThreads;
|
||||||
extern int32_t tsNumOfMnodeFetchThreads;
|
extern int32_t tsNumOfMnodeFetchThreads;
|
||||||
extern int32_t tsNumOfMnodeReadThreads;
|
extern int32_t tsNumOfMnodeReadThreads;
|
||||||
extern int32_t tsNumOfVnodeQueryThreads;
|
extern int32_t tsNumOfVnodeQueryThreads;
|
||||||
extern int32_t tsNumOfVnodeStreamThreads;
|
extern float tsRatioOfVnodeStreamThreads;
|
||||||
extern int32_t tsNumOfVnodeFetchThreads;
|
extern int32_t tsNumOfVnodeFetchThreads;
|
||||||
extern int32_t tsNumOfVnodeRsmaThreads;
|
extern int32_t tsNumOfVnodeRsmaThreads;
|
||||||
extern int32_t tsNumOfQnodeQueryThreads;
|
extern int32_t tsNumOfQnodeQueryThreads;
|
||||||
|
|
|
@ -213,6 +213,7 @@ int32_t qStreamSourceRecoverStep1(qTaskInfo_t tinfo, int64_t ver);
|
||||||
int32_t qStreamSourceRecoverStep2(qTaskInfo_t tinfo, int64_t ver);
|
int32_t qStreamSourceRecoverStep2(qTaskInfo_t tinfo, int64_t ver);
|
||||||
int32_t qStreamRecoverFinish(qTaskInfo_t tinfo);
|
int32_t qStreamRecoverFinish(qTaskInfo_t tinfo);
|
||||||
int32_t qStreamRestoreParam(qTaskInfo_t tinfo);
|
int32_t qStreamRestoreParam(qTaskInfo_t tinfo);
|
||||||
|
bool qStreamRecoverScanFinished(qTaskInfo_t tinfo);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,6 +152,7 @@ typedef struct SqlFunctionCtx {
|
||||||
struct SSDataBlock *pSrcBlock;
|
struct SSDataBlock *pSrcBlock;
|
||||||
struct SSDataBlock *pDstBlock; // used by indefinite rows function to set selectivity
|
struct SSDataBlock *pDstBlock; // used by indefinite rows function to set selectivity
|
||||||
SSerializeDataHandle saveHandle;
|
SSerializeDataHandle saveHandle;
|
||||||
|
int32_t exprIdx;
|
||||||
char udfName[TSDB_FUNC_NAME_LEN];
|
char udfName[TSDB_FUNC_NAME_LEN];
|
||||||
} SqlFunctionCtx;
|
} SqlFunctionCtx;
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,7 @@ typedef struct SAggLogicNode {
|
||||||
bool hasLast;
|
bool hasLast;
|
||||||
bool hasTimeLineFunc;
|
bool hasTimeLineFunc;
|
||||||
bool onlyHasKeepOrderFunc;
|
bool onlyHasKeepOrderFunc;
|
||||||
|
bool hasGroupKeyOptimized;
|
||||||
} SAggLogicNode;
|
} SAggLogicNode;
|
||||||
|
|
||||||
typedef struct SProjectLogicNode {
|
typedef struct SProjectLogicNode {
|
||||||
|
@ -402,6 +403,7 @@ typedef struct SAggPhysiNode {
|
||||||
SNodeList* pGroupKeys;
|
SNodeList* pGroupKeys;
|
||||||
SNodeList* pAggFuncs;
|
SNodeList* pAggFuncs;
|
||||||
bool mergeDataBlock;
|
bool mergeDataBlock;
|
||||||
|
bool groupKeyOptimized;
|
||||||
} SAggPhysiNode;
|
} SAggPhysiNode;
|
||||||
|
|
||||||
typedef struct SDownstreamSourceNode {
|
typedef struct SDownstreamSourceNode {
|
||||||
|
|
|
@ -268,7 +268,7 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
||||||
((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
|
((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
|
||||||
#define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_MNODE_NOT_FOUND)
|
#define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_MNODE_NOT_FOUND)
|
||||||
|
|
||||||
#define NO_RET_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
|
#define NO_RET_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || (_code) == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED)
|
||||||
|
|
||||||
#define NEED_REDIRECT_ERROR(_code) \
|
#define NEED_REDIRECT_ERROR(_code) \
|
||||||
(NO_RET_REDIRECT_ERROR(_code) || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \
|
(NO_RET_REDIRECT_ERROR(_code) || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \
|
||||||
|
|
|
@ -392,21 +392,6 @@ static FORCE_INLINE void streamTaskInputFail(SStreamTask* pTask) {
|
||||||
atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__FAILED);
|
atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t streamTaskOutput(SStreamTask* pTask, SStreamDataBlock* pBlock) {
|
|
||||||
if (pTask->outputType == TASK_OUTPUT__TABLE) {
|
|
||||||
pTask->tbSink.tbSinkFunc(pTask, pTask->tbSink.vnode, 0, pBlock->blocks);
|
|
||||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes);
|
|
||||||
taosFreeQitem(pBlock);
|
|
||||||
} else if (pTask->outputType == TASK_OUTPUT__SMA) {
|
|
||||||
pTask->smaSink.smaSink(pTask->smaSink.vnode, pTask->smaSink.smaId, pBlock->blocks);
|
|
||||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes);
|
|
||||||
taosFreeQitem(pBlock);
|
|
||||||
} else {
|
|
||||||
taosWriteQitem(pTask->outputQueue->queue, pBlock);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMsgHead head;
|
SMsgHead head;
|
||||||
int64_t streamId;
|
int64_t streamId;
|
||||||
|
@ -584,6 +569,7 @@ int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp);
|
||||||
|
|
||||||
int32_t streamTryExec(SStreamTask* pTask);
|
int32_t streamTryExec(SStreamTask* pTask);
|
||||||
int32_t streamSchedExec(SStreamTask* pTask);
|
int32_t streamSchedExec(SStreamTask* pTask);
|
||||||
|
int32_t streamTaskOutput(SStreamTask* pTask, SStreamDataBlock* pBlock);
|
||||||
|
|
||||||
int32_t streamScanExec(SStreamTask* pTask, int32_t batchSz);
|
int32_t streamScanExec(SStreamTask* pTask, int32_t batchSz);
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,16 @@ extern "C" {
|
||||||
|
|
||||||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||||
// When you want to use this feature, you should find or add the same function in the following sectio
|
// When you want to use this feature, you should find or add the same function in the following sectio
|
||||||
|
#if !defined(WINDOWS)
|
||||||
|
|
||||||
#ifndef ALLOW_FORBID_FUNC
|
#ifndef ALLOW_FORBID_FUNC
|
||||||
#define malloc MALLOC_FUNC_TAOS_FORBID
|
#define malloc MALLOC_FUNC_TAOS_FORBID
|
||||||
#define calloc CALLOC_FUNC_TAOS_FORBID
|
#define calloc CALLOC_FUNC_TAOS_FORBID
|
||||||
#define realloc REALLOC_FUNC_TAOS_FORBID
|
#define realloc REALLOC_FUNC_TAOS_FORBID
|
||||||
#define free FREE_FUNC_TAOS_FORBID
|
#define free FREE_FUNC_TAOS_FORBID
|
||||||
#endif
|
#endif // ifndef ALLOW_FORBID_FUNC
|
||||||
|
|
||||||
|
#endif // if !defined(WINDOWS)
|
||||||
|
|
||||||
void *taosMemoryMalloc(int64_t size);
|
void *taosMemoryMalloc(int64_t size);
|
||||||
void *taosMemoryCalloc(int64_t num, int64_t size);
|
void *taosMemoryCalloc(int64_t num, int64_t size);
|
||||||
|
|
|
@ -70,6 +70,7 @@ typedef struct {
|
||||||
|
|
||||||
SysNameInfo taosGetSysNameInfo();
|
SysNameInfo taosGetSysNameInfo();
|
||||||
bool taosCheckCurrentInDll();
|
bool taosCheckCurrentInDll();
|
||||||
|
int taosGetlocalhostname(char *hostname, size_t maxLen);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,10 +62,37 @@ void taosResetTerminalMode();
|
||||||
taosMemoryFree(strings); \
|
taosMemoryFree(strings); \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
#include <windows.h>
|
||||||
|
#include <dbghelp.h>
|
||||||
|
|
||||||
|
#define STACKSIZE 64
|
||||||
#define taosPrintTrace(flags, level, dflag) \
|
#define taosPrintTrace(flags, level, dflag) \
|
||||||
{ \
|
{ \
|
||||||
taosPrintLog(flags, level, dflag, \
|
unsigned int i; \
|
||||||
"backtrace not implemented on windows, so detailed stack information cannot be printed"); \
|
void* stack[STACKSIZE]; \
|
||||||
|
unsigned short frames; \
|
||||||
|
SYMBOL_INFO* symbol; \
|
||||||
|
HANDLE process; \
|
||||||
|
\
|
||||||
|
process = GetCurrentProcess(); \
|
||||||
|
\
|
||||||
|
SymInitialize(process, NULL, TRUE); \
|
||||||
|
\
|
||||||
|
frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \
|
||||||
|
symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \
|
||||||
|
if (symbol != NULL) { \
|
||||||
|
symbol->MaxNameLen = 255; \
|
||||||
|
symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \
|
||||||
|
\
|
||||||
|
if (frames > 0) { \
|
||||||
|
taosPrintLog(flags, level, dflag, "obtained %d stack frames", frames); \
|
||||||
|
for (i = 0; i < frames; i++) { \
|
||||||
|
SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \
|
||||||
|
taosPrintLog(flags, level, dflag, "frame:%i: %s - 0x%0X", frames - i - 1, symbol->Name, symbol->Address); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
free(symbol); \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017) //
|
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017) //
|
||||||
#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018) //
|
#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018) //
|
||||||
#define TSDB_CODE_RPC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0019) //
|
#define TSDB_CODE_RPC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0019) //
|
||||||
|
#define TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED TAOS_DEF_ERROR_CODE(0, 0x0020) // "Vgroup could not be connected"
|
||||||
|
#define TSDB_CODE_RPC_SOMENODE_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0021) //
|
||||||
|
|
||||||
//common & util
|
//common & util
|
||||||
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) //
|
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) //
|
||||||
|
@ -517,6 +519,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_SYN_STANDBY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0912)
|
#define TSDB_CODE_SYN_STANDBY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0912)
|
||||||
#define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913)
|
#define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913)
|
||||||
#define TSDB_CODE_SYN_RESTORING TAOS_DEF_ERROR_CODE(0, 0x0914)
|
#define TSDB_CODE_SYN_RESTORING TAOS_DEF_ERROR_CODE(0, 0x0914)
|
||||||
|
#define TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG TAOS_DEF_ERROR_CODE(0, 0x0915) // internal
|
||||||
|
#define TSDB_CODE_SYN_BUFFER_FULL TAOS_DEF_ERROR_CODE(0, 0x0916) //
|
||||||
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
||||||
|
|
||||||
// tq
|
// tq
|
||||||
|
|
|
@ -36,17 +36,18 @@ extern "C" {
|
||||||
#define FLT_GREATEREQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) > (_y)))
|
#define FLT_GREATEREQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) > (_y)))
|
||||||
#define FLT_LESSEQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) < (_y)))
|
#define FLT_LESSEQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) < (_y)))
|
||||||
|
|
||||||
#define PATTERN_COMPARE_INFO_INITIALIZER \
|
#define PATTERN_COMPARE_INFO_INITIALIZER { '%', '_', L'%', L'_' }
|
||||||
{ '%', '_' }
|
|
||||||
|
|
||||||
typedef struct SPatternCompareInfo {
|
typedef struct SPatternCompareInfo {
|
||||||
char matchAll; // symbol for match all wildcard, default: '%'
|
char matchAll; // symbol for match all wildcard, default: '%'
|
||||||
char matchOne; // symbol for match one wildcard, default: '_'
|
char matchOne; // symbol for match one wildcard, default: '_'
|
||||||
|
TdUcs4 umatchAll; // unicode version matchAll
|
||||||
|
TdUcs4 umatchOne; // unicode version matchOne
|
||||||
} SPatternCompareInfo;
|
} SPatternCompareInfo;
|
||||||
|
|
||||||
int32_t patternMatch(const char *pattern, const char *str, size_t size, const SPatternCompareInfo *pInfo);
|
int32_t patternMatch(const char *pattern, size_t psize, const char *str, size_t ssize, const SPatternCompareInfo *pInfo);
|
||||||
|
|
||||||
int32_t WCSPatternMatch(const TdUcs4 *pattern, const TdUcs4 *str, size_t size, const SPatternCompareInfo *pInfo);
|
int32_t wcsPatternMatch(const TdUcs4 *pattern, size_t psize, const TdUcs4 *str, size_t ssize, const SPatternCompareInfo *pInfo);
|
||||||
|
|
||||||
int32_t taosArrayCompareString(const void *a, const void *b);
|
int32_t taosArrayCompareString(const void *a, const void *b);
|
||||||
|
|
||||||
|
@ -79,9 +80,11 @@ int32_t compareDoubleVal(const void *pLeft, const void *pRight);
|
||||||
int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight);
|
int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight);
|
||||||
int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight);
|
int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight);
|
||||||
|
|
||||||
int32_t compareStrRegexComp(const void *pLeft, const void *pRight);
|
int32_t comparestrRegexMatch(const void *pLeft, const void *pRight);
|
||||||
int32_t compareStrRegexCompMatch(const void *pLeft, const void *pRight);
|
int32_t comparestrRegexNMatch(const void *pLeft, const void *pRight);
|
||||||
int32_t compareStrRegexCompNMatch(const void *pLeft, const void *pRight);
|
|
||||||
|
int32_t comparewcsRegexMatch(const void *pLeft, const void *pRight);
|
||||||
|
int32_t comparewcsRegexNMatch(const void *pLeft, const void *pRight);
|
||||||
|
|
||||||
int32_t compareInt8ValDesc(const void *pLeft, const void *pRight);
|
int32_t compareInt8ValDesc(const void *pLeft, const void *pRight);
|
||||||
int32_t compareInt16ValDesc(const void *pLeft, const void *pRight);
|
int32_t compareInt16ValDesc(const void *pLeft, const void *pRight);
|
||||||
|
@ -99,11 +102,11 @@ int32_t compareUint64ValDesc(const void *pLeft, const void *pRight);
|
||||||
int32_t compareLenPrefixedStrDesc(const void *pLeft, const void *pRight);
|
int32_t compareLenPrefixedStrDesc(const void *pLeft, const void *pRight);
|
||||||
int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight);
|
int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight);
|
||||||
|
|
||||||
int32_t compareStrPatternMatch(const void *pLeft, const void *pRight);
|
int32_t comparestrPatternMatch(const void *pLeft, const void *pRight);
|
||||||
int32_t compareStrPatternNotMatch(const void *pLeft, const void *pRight);
|
int32_t comparestrPatternNMatch(const void *pLeft, const void *pRight);
|
||||||
|
|
||||||
int32_t compareWStrPatternMatch(const void *pLeft, const void *pRight);
|
int32_t comparewcsPatternMatch(const void *pLeft, const void *pRight);
|
||||||
int32_t compareWStrPatternNotMatch(const void *pLeft, const void *pRight);
|
int32_t comparewcsPatternNMatch(const void *pLeft, const void *pRight);
|
||||||
|
|
||||||
int32_t compareInt8Int16(const void *pLeft, const void *pRight);
|
int32_t compareInt8Int16(const void *pLeft, const void *pRight);
|
||||||
int32_t compareInt8Int32(const void *pLeft, const void *pRight);
|
int32_t compareInt8Int32(const void *pLeft, const void *pRight);
|
||||||
|
|
|
@ -193,6 +193,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string
|
#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string
|
||||||
#define TSDB_TOPIC_NAME_LEN 193 // it is a null-terminated string
|
#define TSDB_TOPIC_NAME_LEN 193 // it is a null-terminated string
|
||||||
#define TSDB_CGROUP_LEN 193 // it is a null-terminated string
|
#define TSDB_CGROUP_LEN 193 // it is a null-terminated string
|
||||||
|
#define TSDB_STREAM_NAME_LEN 193 // it is a null-terminated string
|
||||||
#define TSDB_DB_NAME_LEN 65
|
#define TSDB_DB_NAME_LEN 65
|
||||||
#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
||||||
|
|
||||||
|
@ -212,8 +213,8 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_INDEX_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_INDEX_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
#define TSDB_INDEX_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_INDEX_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
||||||
#define TSDB_TYPE_STR_MAX_LEN 32
|
#define TSDB_TYPE_STR_MAX_LEN 32
|
||||||
#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
||||||
#define TSDB_TOPIC_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
#define TSDB_TOPIC_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_TOPIC_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
||||||
#define TSDB_STREAM_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
#define TSDB_STREAM_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_STREAM_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
||||||
#define TSDB_SUBSCRIBE_KEY_LEN (TSDB_CGROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2)
|
#define TSDB_SUBSCRIBE_KEY_LEN (TSDB_CGROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2)
|
||||||
#define TSDB_PARTITION_KEY_LEN (TSDB_SUBSCRIBE_KEY_LEN + 20)
|
#define TSDB_PARTITION_KEY_LEN (TSDB_SUBSCRIBE_KEY_LEN + 20)
|
||||||
#define TSDB_COL_NAME_LEN 65
|
#define TSDB_COL_NAME_LEN 65
|
||||||
|
@ -254,7 +255,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6)
|
#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6)
|
||||||
#define TSDB_IPv4ADDR_LEN 16
|
#define TSDB_IPv4ADDR_LEN 16
|
||||||
#define TSDB_FILENAME_LEN 128
|
#define TSDB_FILENAME_LEN 128
|
||||||
#define TSDB_SHOW_SQL_LEN 1024
|
#define TSDB_SHOW_SQL_LEN 2048
|
||||||
#define TSDB_SLOW_QUERY_SQL_LEN 512
|
#define TSDB_SLOW_QUERY_SQL_LEN 512
|
||||||
#define TSDB_SHOW_SUBQUERY_LEN 1000
|
#define TSDB_SHOW_SUBQUERY_LEN 1000
|
||||||
|
|
||||||
|
|
|
@ -83,9 +83,14 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
bool taosAssert(bool condition, const char *file, int32_t line, const char *format, ...);
|
bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...);
|
||||||
#define ASSERTS(condition, ...) taosAssert(condition, __FILE__, __LINE__, __VA_ARGS__)
|
bool taosAssertRelease(bool condition);
|
||||||
#define ASSERT(condition) ASSERTS(condition, "assert info not provided")
|
#define ASSERTS(condition, ...) taosAssertDebug(condition, __FILE__, __LINE__, __VA_ARGS__)
|
||||||
|
#ifdef NDEBUG
|
||||||
|
#define ASSERT(condition) taosAssertRelease(condition)
|
||||||
|
#else
|
||||||
|
#define ASSERT(condition) taosAssertDebug(condition, __FILE__, __LINE__, "assert info not provided")
|
||||||
|
#endif
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||||
|
|
|
@ -29,11 +29,17 @@ extern "C" {
|
||||||
int32_t strdequote(char *src);
|
int32_t strdequote(char *src);
|
||||||
size_t strtrim(char *src);
|
size_t strtrim(char *src);
|
||||||
char *strnchr(const char *haystack, char needle, int32_t len, bool skipquote);
|
char *strnchr(const char *haystack, char needle, int32_t len, bool skipquote);
|
||||||
|
TdUcs4* wcsnchr(const TdUcs4* haystack, TdUcs4 needle, size_t len);
|
||||||
|
|
||||||
char **strsplit(char *src, const char *delim, int32_t *num);
|
char **strsplit(char *src, const char *delim, int32_t *num);
|
||||||
char *strtolower(char *dst, const char *src);
|
char *strtolower(char *dst, const char *src);
|
||||||
char *strntolower(char *dst, const char *src, int32_t n);
|
char *strntolower(char *dst, const char *src, int32_t n);
|
||||||
char *strntolower_s(char *dst, const char *src, int32_t n);
|
char *strntolower_s(char *dst, const char *src, int32_t n);
|
||||||
int64_t strnatoi(char *num, int32_t len);
|
int64_t strnatoi(char *num, int32_t len);
|
||||||
|
|
||||||
|
size_t tstrncspn(const char *str, size_t ssize, const char *reject, size_t rsize);
|
||||||
|
size_t twcsncspn(const TdUcs4 *wcs, size_t size, const TdUcs4 *reject, size_t rsize);
|
||||||
|
|
||||||
char *strbetween(char *string, char *begin, char *end);
|
char *strbetween(char *string, char *begin, char *end);
|
||||||
char *paGetToken(char *src, char **token, int32_t *tokenLen);
|
char *paGetToken(char *src, char **token, int32_t *tokenLen);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#define _TD_UTIL_WORKER_H_
|
#define _TD_UTIL_WORKER_H_
|
||||||
|
|
||||||
#include "tqueue.h"
|
#include "tqueue.h"
|
||||||
|
#include "tarray.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -29,7 +30,7 @@ typedef struct SQWorker {
|
||||||
int32_t id; // worker id
|
int32_t id; // worker id
|
||||||
int64_t pid; // thread pid
|
int64_t pid; // thread pid
|
||||||
TdThread thread; // thread id
|
TdThread thread; // thread id
|
||||||
SQWorkerPool *pool;
|
void *pool;
|
||||||
} SQWorker;
|
} SQWorker;
|
||||||
|
|
||||||
typedef struct SQWorkerPool {
|
typedef struct SQWorkerPool {
|
||||||
|
@ -42,6 +43,14 @@ typedef struct SQWorkerPool {
|
||||||
TdThreadMutex mutex;
|
TdThreadMutex mutex;
|
||||||
} SQWorkerPool;
|
} SQWorkerPool;
|
||||||
|
|
||||||
|
typedef struct SAutoQWorkerPool {
|
||||||
|
float ratio;
|
||||||
|
STaosQset *qset;
|
||||||
|
const char *name;
|
||||||
|
SArray *workers;
|
||||||
|
TdThreadMutex mutex;
|
||||||
|
} SAutoQWorkerPool;
|
||||||
|
|
||||||
typedef struct SWWorker {
|
typedef struct SWWorker {
|
||||||
int32_t id; // worker id
|
int32_t id; // worker id
|
||||||
int64_t pid; // thread pid
|
int64_t pid; // thread pid
|
||||||
|
@ -65,6 +74,11 @@ void tQWorkerCleanup(SQWorkerPool *pool);
|
||||||
STaosQueue *tQWorkerAllocQueue(SQWorkerPool *pool, void *ahandle, FItem fp);
|
STaosQueue *tQWorkerAllocQueue(SQWorkerPool *pool, void *ahandle, FItem fp);
|
||||||
void tQWorkerFreeQueue(SQWorkerPool *pool, STaosQueue *queue);
|
void tQWorkerFreeQueue(SQWorkerPool *pool, STaosQueue *queue);
|
||||||
|
|
||||||
|
int32_t tAutoQWorkerInit(SAutoQWorkerPool *pool);
|
||||||
|
void tAutoQWorkerCleanup(SAutoQWorkerPool *pool);
|
||||||
|
STaosQueue *tAutoQWorkerAllocQueue(SAutoQWorkerPool *pool, void *ahandle, FItem fp);
|
||||||
|
void tAutoQWorkerFreeQueue(SAutoQWorkerPool *pool, STaosQueue *queue);
|
||||||
|
|
||||||
int32_t tWWorkerInit(SWWorkerPool *pool);
|
int32_t tWWorkerInit(SWWorkerPool *pool);
|
||||||
void tWWorkerCleanup(SWWorkerPool *pool);
|
void tWWorkerCleanup(SWWorkerPool *pool);
|
||||||
STaosQueue *tWWorkerAllocQueue(SWWorkerPool *pool, void *ahandle, FItems fp);
|
STaosQueue *tWWorkerAllocQueue(SWWorkerPool *pool, void *ahandle, FItems fp);
|
||||||
|
|
|
@ -348,7 +348,8 @@ cd ${release_dir}
|
||||||
# install_dir has been distinguishes cluster from edege, so comments this code
|
# install_dir has been distinguishes cluster from edege, so comments this code
|
||||||
pkg_name=${install_dir}-${osType}-${cpuType}
|
pkg_name=${install_dir}-${osType}-${cpuType}
|
||||||
|
|
||||||
taostools_pkg_name=${taostools_install_dir}-${osType}-${cpuType}
|
versionCompFirst=$(echo ${versionComp} | awk -F '.' '{print $1}')
|
||||||
|
taostools_pkg_name=${taostools_install_dir}-${osType}-${cpuType}-comp${versionCompFirst}
|
||||||
|
|
||||||
# if [ "$verMode" == "cluster" ]; then
|
# if [ "$verMode" == "cluster" ]; then
|
||||||
# pkg_name=${install_dir}-${osType}-${cpuType}
|
# pkg_name=${install_dir}-${osType}-${cpuType}
|
||||||
|
|
|
@ -122,6 +122,12 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
|
||||||
|
|
||||||
char* key = getClusterKey(user, secretEncrypt, ip, port);
|
char* key = getClusterKey(user, secretEncrypt, ip, port);
|
||||||
|
|
||||||
|
tscInfo("connecting to server, numOfEps:%d inUse:%d user:%s db:%s key:%s", epSet.epSet.numOfEps, epSet.epSet.inUse,
|
||||||
|
user, db, key);
|
||||||
|
for (int32_t i = 0; i < epSet.epSet.numOfEps; ++i) {
|
||||||
|
tscInfo("ep:%d, %s:%u", i, epSet.epSet.eps[i].fqdn, epSet.epSet.eps[i].port);
|
||||||
|
}
|
||||||
|
|
||||||
SAppInstInfo** pInst = NULL;
|
SAppInstInfo** pInst = NULL;
|
||||||
taosThreadMutexLock(&appInfo.mutex);
|
taosThreadMutexLock(&appInfo.mutex);
|
||||||
|
|
||||||
|
@ -142,7 +148,7 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
|
||||||
taosHashPut(appInfo.pInstMap, key, strlen(key), &p, POINTER_BYTES);
|
taosHashPut(appInfo.pInstMap, key, strlen(key), &p, POINTER_BYTES);
|
||||||
p->instKey = key;
|
p->instKey = key;
|
||||||
key = NULL;
|
key = NULL;
|
||||||
tscDebug("new app inst mgr %p, user:%s, ip:%s, port:%d", p, user, ip, port);
|
tscDebug("new app inst mgr %p, user:%s, ip:%s, port:%d", p, user, epSet.epSet.eps[0].fqdn, epSet.epSet.eps[0].port);
|
||||||
|
|
||||||
pInst = &p;
|
pInst = &p;
|
||||||
}
|
}
|
||||||
|
@ -1424,6 +1430,21 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||||
memcpy((void*)tEpSet, (void*)pEpSet, sizeof(SEpSet));
|
memcpy((void*)tEpSet, (void*)pEpSet, sizeof(SEpSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pMsg is response msg
|
||||||
|
if (pMsg->msgType == TDMT_MND_CONNECT + 1) {
|
||||||
|
// restore origin code
|
||||||
|
if (pMsg->code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED) {
|
||||||
|
pMsg->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||||
|
} else if (pMsg->code == TSDB_CODE_RPC_SOMENODE_BROKEN_LINK) {
|
||||||
|
pMsg->code = TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// uniform to one error code: TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
|
||||||
|
if (pMsg->code == TSDB_CODE_RPC_SOMENODE_BROKEN_LINK) {
|
||||||
|
pMsg->code = TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AsyncArg* arg = taosMemoryCalloc(1, sizeof(AsyncArg));
|
AsyncArg* arg = taosMemoryCalloc(1, sizeof(AsyncArg));
|
||||||
arg->msg = *pMsg;
|
arg->msg = *pMsg;
|
||||||
arg->pEpset = tEpSet;
|
arg->pEpset = tEpSet;
|
||||||
|
|
|
@ -1331,6 +1331,14 @@ int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fiel
|
||||||
return stmtGetColFields(stmt, fieldNum, fields);
|
return stmtGetColFields(stmt, fieldNum, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// let stmt to reclaim TAOS_FIELD_E that was allocated by `taos_stmt_get_tag_fields`/`taos_stmt_get_col_fields`
|
||||||
|
void taos_stmt_reclaim_fields(TAOS_STMT *stmt, TAOS_FIELD_E *fields)
|
||||||
|
{
|
||||||
|
(void)stmt;
|
||||||
|
if (!fields) return;
|
||||||
|
taosMemoryFree(fields);
|
||||||
|
}
|
||||||
|
|
||||||
int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
|
int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
|
||||||
if (stmt == NULL || bind == NULL) {
|
if (stmt == NULL || bind == NULL) {
|
||||||
tscError("NULL parameter for %s", __FUNCTION__);
|
tscError("NULL parameter for %s", __FUNCTION__);
|
||||||
|
|
|
@ -47,7 +47,7 @@ int32_t tsNumOfMnodeQueryThreads = 4;
|
||||||
int32_t tsNumOfMnodeFetchThreads = 1;
|
int32_t tsNumOfMnodeFetchThreads = 1;
|
||||||
int32_t tsNumOfMnodeReadThreads = 1;
|
int32_t tsNumOfMnodeReadThreads = 1;
|
||||||
int32_t tsNumOfVnodeQueryThreads = 4;
|
int32_t tsNumOfVnodeQueryThreads = 4;
|
||||||
int32_t tsNumOfVnodeStreamThreads = 2;
|
float tsRatioOfVnodeStreamThreads = 1.0;
|
||||||
int32_t tsNumOfVnodeFetchThreads = 4;
|
int32_t tsNumOfVnodeFetchThreads = 4;
|
||||||
int32_t tsNumOfVnodeRsmaThreads = 2;
|
int32_t tsNumOfVnodeRsmaThreads = 2;
|
||||||
int32_t tsNumOfQnodeQueryThreads = 4;
|
int32_t tsNumOfQnodeQueryThreads = 4;
|
||||||
|
@ -392,9 +392,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 4);
|
tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 4);
|
||||||
if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 4, 1024, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 4, 1024, 0) != 0) return -1;
|
||||||
|
|
||||||
tsNumOfVnodeStreamThreads = tsNumOfCores / 4;
|
if (cfgAddFloat(pCfg, "ratioOfVnodeStreamThreads", tsRatioOfVnodeStreamThreads, 0.01, 100, 0) != 0) return -1;
|
||||||
tsNumOfVnodeStreamThreads = TMAX(tsNumOfVnodeStreamThreads, 4);
|
|
||||||
if (cfgAddInt32(pCfg, "numOfVnodeStreamThreads", tsNumOfVnodeStreamThreads, 4, 1024, 0) != 0) return -1;
|
|
||||||
|
|
||||||
tsNumOfVnodeFetchThreads = tsNumOfCores / 4;
|
tsNumOfVnodeFetchThreads = tsNumOfCores / 4;
|
||||||
tsNumOfVnodeFetchThreads = TMAX(tsNumOfVnodeFetchThreads, 4);
|
tsNumOfVnodeFetchThreads = TMAX(tsNumOfVnodeFetchThreads, 4);
|
||||||
|
@ -513,11 +511,9 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
}
|
}
|
||||||
|
|
||||||
pItem = cfgGetItem(tsCfg, "numOfVnodeStreamThreads");
|
pItem = cfgGetItem(tsCfg, "ratioOfVnodeStreamThreads");
|
||||||
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
||||||
tsNumOfVnodeStreamThreads = numOfCores / 4;
|
pItem->fval = tsRatioOfVnodeStreamThreads;
|
||||||
tsNumOfVnodeStreamThreads = TMAX(tsNumOfVnodeStreamThreads, 4);
|
|
||||||
pItem->i32 = tsNumOfVnodeStreamThreads;
|
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +706,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
|
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
|
||||||
tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32;
|
tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32;
|
||||||
tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32;
|
tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32;
|
||||||
tsNumOfVnodeStreamThreads = cfgGetItem(pCfg, "numOfVnodeStreamThreads")->i32;
|
tsRatioOfVnodeStreamThreads = cfgGetItem(pCfg, "ratioOfVnodeStreamThreads")->fval;
|
||||||
tsNumOfVnodeFetchThreads = cfgGetItem(pCfg, "numOfVnodeFetchThreads")->i32;
|
tsNumOfVnodeFetchThreads = cfgGetItem(pCfg, "numOfVnodeFetchThreads")->i32;
|
||||||
tsNumOfVnodeRsmaThreads = cfgGetItem(pCfg, "numOfVnodeRsmaThreads")->i32;
|
tsNumOfVnodeRsmaThreads = cfgGetItem(pCfg, "numOfVnodeRsmaThreads")->i32;
|
||||||
tsNumOfQnodeQueryThreads = cfgGetItem(pCfg, "numOfQnodeQueryThreads")->i32;
|
tsNumOfQnodeQueryThreads = cfgGetItem(pCfg, "numOfQnodeQueryThreads")->i32;
|
||||||
|
@ -719,6 +715,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
tsNumOfSnodeWriteThreads = cfgGetItem(pCfg, "numOfSnodeUniqueThreads")->i32;
|
tsNumOfSnodeWriteThreads = cfgGetItem(pCfg, "numOfSnodeUniqueThreads")->i32;
|
||||||
tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64;
|
tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64;
|
||||||
|
|
||||||
|
tsSIMDBuiltins = (bool) cfgGetItem(pCfg, "SIMD-builtins")->bval;
|
||||||
|
|
||||||
tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval;
|
tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval;
|
||||||
tsMonitorInterval = cfgGetItem(pCfg, "monitorInterval")->i32;
|
tsMonitorInterval = cfgGetItem(pCfg, "monitorInterval")->i32;
|
||||||
tstrncpy(tsMonitorFqdn, cfgGetItem(pCfg, "monitorFqdn")->str, TSDB_FQDN_LEN);
|
tstrncpy(tsMonitorFqdn, cfgGetItem(pCfg, "monitorFqdn")->str, TSDB_FQDN_LEN);
|
||||||
|
@ -1316,12 +1314,17 @@ void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal,
|
||||||
if (pItem != NULL && (rewrite || pItem->i32 == 0)) {
|
if (pItem != NULL && (rewrite || pItem->i32 == 0)) {
|
||||||
pItem->i32 = flagVal;
|
pItem->i32 = flagVal;
|
||||||
}
|
}
|
||||||
|
if (pFlagPtr != NULL) {
|
||||||
*pFlagPtr = flagVal;
|
*pFlagPtr = flagVal;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void taosSetAllDebugFlag(int32_t flag, bool rewrite) {
|
void taosSetAllDebugFlag(int32_t flag, bool rewrite) {
|
||||||
if (flag <= 0) return;
|
if (flag <= 0) return;
|
||||||
|
|
||||||
|
taosSetDebugFlag(NULL, "debugFlag", flag, rewrite);
|
||||||
|
taosSetDebugFlag(NULL, "simDebugFlag", flag, rewrite);
|
||||||
|
taosSetDebugFlag(NULL, "tmrDebugFlag", flag, rewrite);
|
||||||
taosSetDebugFlag(&uDebugFlag, "uDebugFlag", flag, rewrite);
|
taosSetDebugFlag(&uDebugFlag, "uDebugFlag", flag, rewrite);
|
||||||
taosSetDebugFlag(&rpcDebugFlag, "rpcDebugFlag", flag, rewrite);
|
taosSetDebugFlag(&rpcDebugFlag, "rpcDebugFlag", flag, rewrite);
|
||||||
taosSetDebugFlag(&jniDebugFlag, "jniDebugFlag", flag, rewrite);
|
taosSetDebugFlag(&jniDebugFlag, "jniDebugFlag", flag, rewrite);
|
||||||
|
@ -1340,6 +1343,5 @@ void taosSetAllDebugFlag(int32_t flag, bool rewrite) {
|
||||||
taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag, rewrite);
|
taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag, rewrite);
|
||||||
taosSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag, rewrite);
|
taosSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag, rewrite);
|
||||||
taosSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag, rewrite);
|
taosSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag, rewrite);
|
||||||
taosSetDebugFlag(&metaDebugFlag, "tmrDebugFlag", flag, rewrite);
|
|
||||||
uInfo("all debug flag are set to %d", flag);
|
uInfo("all debug flag are set to %d", flag);
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,10 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) {
|
||||||
varDataCopy(val, src);
|
varDataCopy(val, src);
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
|
if (len > 0) {
|
||||||
memcpy(val, src, len);
|
memcpy(val, src, len);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ static int32_t dmInitLog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void taosCleanupArgs() {
|
static void taosCleanupArgs() {
|
||||||
if (global.envCmd != NULL) taosMemoryFree(global.envCmd);
|
if (global.envCmd != NULL) taosMemoryFreeClear(global.envCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char const *argv[]) {
|
int main(int argc, char const *argv[]) {
|
||||||
|
@ -268,6 +268,10 @@ int mainWindows(int argc, char **argv) {
|
||||||
|
|
||||||
if (dmInit() != 0) {
|
if (dmInit() != 0) {
|
||||||
dError("failed to init dnode since %s", terrstr());
|
dError("failed to init dnode since %s", terrstr());
|
||||||
|
|
||||||
|
taosCleanupCfg();
|
||||||
|
taosCloseLog();
|
||||||
|
taosConvDestroy();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ typedef struct SVnodeMgmt {
|
||||||
const char *path;
|
const char *path;
|
||||||
const char *name;
|
const char *name;
|
||||||
SQWorkerPool queryPool;
|
SQWorkerPool queryPool;
|
||||||
SQWorkerPool streamPool;
|
SAutoQWorkerPool streamPool;
|
||||||
SWWorkerPool fetchPool;
|
SWWorkerPool fetchPool;
|
||||||
SSingleWorker mgmtWorker;
|
SSingleWorker mgmtWorker;
|
||||||
SHashObj *hash;
|
SHashObj *hash;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "vmInt.h"
|
#include "vmInt.h"
|
||||||
|
|
||||||
#define MAX_CONTENT_LEN 1024 * 1024
|
#define MAX_CONTENT_LEN 2 * 1024 * 1024
|
||||||
|
|
||||||
SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
|
SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
|
||||||
taosThreadRwlockRdlock(&pMgmt->lock);
|
taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
|
@ -60,7 +60,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
||||||
|
|
||||||
pFile = taosOpenFile(file, TD_FILE_READ);
|
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
dDebug("file %s not exist", file);
|
dInfo("file %s not exist", file);
|
||||||
code = 0;
|
code = 0;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
||||||
|
|
||||||
*numOfVnodes = vnodesNum;
|
*numOfVnodes = vnodesNum;
|
||||||
code = 0;
|
code = 0;
|
||||||
dDebug("succcessed to read file %s, numOfVnodes:%d", file, vnodesNum);
|
dInfo("succcessed to read file %s, numOfVnodes:%d", file, vnodesNum);
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (content != NULL) taosMemoryFree(content);
|
if (content != NULL) taosMemoryFree(content);
|
||||||
|
@ -163,6 +163,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
if (ppVnodes == NULL) {
|
if (ppVnodes == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
code = -1;
|
code = -1;
|
||||||
|
dError("failed to write %s while get vnodelist", file);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +173,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
if (content == NULL) {
|
if (content == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
code = -1;
|
code = -1;
|
||||||
|
dError("failed to write %s while malloc content", file);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +215,12 @@ _OVER:
|
||||||
|
|
||||||
if (code != 0) return -1;
|
if (code != 0) return -1;
|
||||||
|
|
||||||
dDebug("successed to write %s, numOfVnodes:%d", realfile, numOfVnodes);
|
dInfo("successed to write %s, numOfVnodes:%d", realfile, numOfVnodes);
|
||||||
return taosRenameFile(file, realfile);
|
code = taosRenameFile(file, realfile);
|
||||||
|
|
||||||
|
if (code != 0) {
|
||||||
|
dError("failed to rename %s to %s", file, realfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
|
@ -213,7 +213,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
|
|
||||||
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, req.vgId);
|
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, req.vgId);
|
||||||
if (pVnode != NULL) {
|
if (pVnode != NULL) {
|
||||||
dDebug("vgId:%d, already exist", req.vgId);
|
dInfo("vgId:%d, already exist", req.vgId);
|
||||||
tFreeSCreateVnodeReq(&req);
|
tFreeSCreateVnodeReq(&req);
|
||||||
vmReleaseVnode(pMgmt, pVnode);
|
vmReleaseVnode(pMgmt, pVnode);
|
||||||
terrno = TSDB_CODE_VND_ALREADY_EXIST;
|
terrno = TSDB_CODE_VND_ALREADY_EXIST;
|
||||||
|
@ -358,7 +358,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vgId = dropReq.vgId;
|
int32_t vgId = dropReq.vgId;
|
||||||
dDebug("vgId:%d, start to drop vnode", vgId);
|
dInfo("vgId:%d, start to drop vnode", vgId);
|
||||||
|
|
||||||
if (dropReq.dnodeId != pMgmt->pData->dnodeId) {
|
if (dropReq.dnodeId != pMgmt->pData->dnodeId) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
@ -368,7 +368,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
|
|
||||||
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, vgId);
|
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, vgId);
|
||||||
if (pVnode == NULL) {
|
if (pVnode == NULL) {
|
||||||
dDebug("vgId:%d, failed to drop since %s", vgId, terrstr());
|
dInfo("vgId:%d, failed to drop since %s", vgId, terrstr());
|
||||||
terrno = TSDB_CODE_VND_NOT_EXIST;
|
terrno = TSDB_CODE_VND_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -383,6 +383,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
vmCloseVnode(pMgmt, pVnode);
|
vmCloseVnode(pMgmt, pVnode);
|
||||||
vmWriteVnodeListToFile(pMgmt);
|
vmWriteVnodeListToFile(pMgmt);
|
||||||
|
|
||||||
|
dInfo("vgId:%d, is dropped", vgId);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ static void *vmOpenVnodeInThread(void *param) {
|
||||||
SVnodeMgmt *pMgmt = pThread->pMgmt;
|
SVnodeMgmt *pMgmt = pThread->pMgmt;
|
||||||
char path[TSDB_FILENAME_LEN];
|
char path[TSDB_FILENAME_LEN];
|
||||||
|
|
||||||
dDebug("thread:%d, start to open %d vnodes", pThread->threadIndex, pThread->vnodeNum);
|
dInfo("thread:%d, start to open %d vnodes", pThread->threadIndex, pThread->vnodeNum);
|
||||||
setThreadName("open-vnodes");
|
setThreadName("open-vnodes");
|
||||||
|
|
||||||
for (int32_t v = 0; v < pThread->vnodeNum; ++v) {
|
for (int32_t v = 0; v < pThread->vnodeNum; ++v) {
|
||||||
|
@ -156,13 +156,13 @@ static void *vmOpenVnodeInThread(void *param) {
|
||||||
pThread->failed++;
|
pThread->failed++;
|
||||||
} else {
|
} else {
|
||||||
vmOpenVnode(pMgmt, pCfg, pImpl);
|
vmOpenVnode(pMgmt, pCfg, pImpl);
|
||||||
dDebug("vgId:%d, is opened by thread:%d", pCfg->vgId, pThread->threadIndex);
|
dInfo("vgId:%d, is opened by thread:%d", pCfg->vgId, pThread->threadIndex);
|
||||||
pThread->opened++;
|
pThread->opened++;
|
||||||
atomic_add_fetch_32(&pMgmt->state.openVnodes, 1);
|
atomic_add_fetch_32(&pMgmt->state.openVnodes, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("thread:%d, numOfVnodes:%d, opened:%d failed:%d", pThread->threadIndex, pThread->vnodeNum, pThread->opened,
|
dInfo("thread:%d, numOfVnodes:%d, opened:%d failed:%d", pThread->threadIndex, pThread->vnodeNum, pThread->opened,
|
||||||
pThread->failed);
|
pThread->failed);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -496,7 +496,7 @@ static void *vmRestoreVnodeInThread(void *param) {
|
||||||
dError("vgId:%d, failed to restore vnode by thread:%d", pVnode->vgId, pThread->threadIndex);
|
dError("vgId:%d, failed to restore vnode by thread:%d", pVnode->vgId, pThread->threadIndex);
|
||||||
pThread->failed++;
|
pThread->failed++;
|
||||||
} else {
|
} else {
|
||||||
dDebug("vgId:%d, is restored by thread:%d", pVnode->vgId, pThread->threadIndex);
|
dInfo("vgId:%d, is restored by thread:%d", pVnode->vgId, pThread->threadIndex);
|
||||||
pThread->opened++;
|
pThread->opened++;
|
||||||
atomic_add_fetch_32(&pMgmt->state.openVnodes, 1);
|
atomic_add_fetch_32(&pMgmt->state.openVnodes, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,12 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
|
||||||
|
|
||||||
static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtype) {
|
static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtype) {
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
|
if (pMsg->contLen < sizeof(SMsgHead)) {
|
||||||
|
dGError("invalid rpc msg with no msg head at pCont. pMsg:%p, type:%s, contLen:%d", pMsg, TMSG_INFO(pMsg->msgType),
|
||||||
|
pMsg->contLen);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
SMsgHead *pHead = pMsg->pCont;
|
SMsgHead *pHead = pMsg->pCont;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -233,6 +239,14 @@ int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
|
if (pRpc->contLen < sizeof(SMsgHead)) {
|
||||||
|
dError("invalid rpc msg with no msg head at pCont. pRpc:%p, type:%s, len:%d", pRpc, TMSG_INFO(pRpc->msgType),
|
||||||
|
pRpc->contLen);
|
||||||
|
rpcFreeCont(pRpc->pCont);
|
||||||
|
pRpc->pCont = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM, pRpc->contLen);
|
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM, pRpc->contLen);
|
||||||
if (pMsg == NULL) {
|
if (pMsg == NULL) {
|
||||||
rpcFreeCont(pRpc->pCont);
|
rpcFreeCont(pRpc->pCont);
|
||||||
|
@ -304,7 +318,7 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
(void)tMultiWorkerInit(&pVnode->pApplyW, &acfg);
|
(void)tMultiWorkerInit(&pVnode->pApplyW, &acfg);
|
||||||
|
|
||||||
pVnode->pQueryQ = tQWorkerAllocQueue(&pMgmt->queryPool, pVnode, (FItem)vmProcessQueryQueue);
|
pVnode->pQueryQ = tQWorkerAllocQueue(&pMgmt->queryPool, pVnode, (FItem)vmProcessQueryQueue);
|
||||||
pVnode->pStreamQ = tQWorkerAllocQueue(&pMgmt->streamPool, pVnode, (FItem)vmProcessStreamQueue);
|
pVnode->pStreamQ = tAutoQWorkerAllocQueue(&pMgmt->streamPool, pVnode, (FItem)vmProcessStreamQueue);
|
||||||
pVnode->pFetchQ = tWWorkerAllocQueue(&pMgmt->fetchPool, pVnode, (FItems)vmProcessFetchQueue);
|
pVnode->pFetchQ = tWWorkerAllocQueue(&pMgmt->fetchPool, pVnode, (FItems)vmProcessFetchQueue);
|
||||||
|
|
||||||
if (pVnode->pWriteW.queue == NULL || pVnode->pSyncW.queue == NULL || pVnode->pSyncCtrlW.queue == NULL ||
|
if (pVnode->pWriteW.queue == NULL || pVnode->pSyncW.queue == NULL || pVnode->pSyncCtrlW.queue == NULL ||
|
||||||
|
@ -330,7 +344,7 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
|
|
||||||
void vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
void vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
tQWorkerFreeQueue(&pMgmt->queryPool, pVnode->pQueryQ);
|
tQWorkerFreeQueue(&pMgmt->queryPool, pVnode->pQueryQ);
|
||||||
tQWorkerFreeQueue(&pMgmt->streamPool, pVnode->pStreamQ);
|
tAutoQWorkerFreeQueue(&pMgmt->streamPool, pVnode->pStreamQ);
|
||||||
tWWorkerFreeQueue(&pMgmt->fetchPool, pVnode->pFetchQ);
|
tWWorkerFreeQueue(&pMgmt->fetchPool, pVnode->pFetchQ);
|
||||||
pVnode->pQueryQ = NULL;
|
pVnode->pQueryQ = NULL;
|
||||||
pVnode->pStreamQ = NULL;
|
pVnode->pStreamQ = NULL;
|
||||||
|
@ -345,11 +359,10 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
|
||||||
pQPool->max = tsNumOfVnodeQueryThreads;
|
pQPool->max = tsNumOfVnodeQueryThreads;
|
||||||
if (tQWorkerInit(pQPool) != 0) return -1;
|
if (tQWorkerInit(pQPool) != 0) return -1;
|
||||||
|
|
||||||
SQWorkerPool *pStreamPool = &pMgmt->streamPool;
|
SAutoQWorkerPool *pStreamPool = &pMgmt->streamPool;
|
||||||
pStreamPool->name = "vnode-stream";
|
pStreamPool->name = "vnode-stream";
|
||||||
pStreamPool->min = tsNumOfVnodeStreamThreads;
|
pStreamPool->ratio = tsRatioOfVnodeStreamThreads;
|
||||||
pStreamPool->max = tsNumOfVnodeStreamThreads;
|
if (tAutoQWorkerInit(pStreamPool) != 0) return -1;
|
||||||
if (tQWorkerInit(pStreamPool) != 0) return -1;
|
|
||||||
|
|
||||||
SWWorkerPool *pFPool = &pMgmt->fetchPool;
|
SWWorkerPool *pFPool = &pMgmt->fetchPool;
|
||||||
pFPool->name = "vnode-fetch";
|
pFPool->name = "vnode-fetch";
|
||||||
|
@ -371,7 +384,7 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
|
||||||
|
|
||||||
void vmStopWorker(SVnodeMgmt *pMgmt) {
|
void vmStopWorker(SVnodeMgmt *pMgmt) {
|
||||||
tQWorkerCleanup(&pMgmt->queryPool);
|
tQWorkerCleanup(&pMgmt->queryPool);
|
||||||
tQWorkerCleanup(&pMgmt->streamPool);
|
tAutoQWorkerCleanup(&pMgmt->streamPool);
|
||||||
tWWorkerCleanup(&pMgmt->fetchPool);
|
tWWorkerCleanup(&pMgmt->fetchPool);
|
||||||
dDebug("vnode workers are closed");
|
dDebug("vnode workers are closed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,11 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
dGError("msg:%p, type:%s pCont is NULL", pRpc, TMSG_INFO(pRpc->msgType));
|
dGError("msg:%p, type:%s pCont is NULL", pRpc, TMSG_INFO(pRpc->msgType));
|
||||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
} else if ((pRpc->code == TSDB_CODE_RPC_NETWORK_UNAVAIL || pRpc->code == TSDB_CODE_RPC_BROKEN_LINK) &&
|
||||||
|
(!IsReq(pRpc)) && (pRpc->pCont == NULL)) {
|
||||||
|
dGError("msg:%p, type:%s pCont is NULL, err: %s", pRpc, TMSG_INFO(pRpc->msgType), tstrerror(pRpc->code));
|
||||||
|
terrno = pRpc->code;
|
||||||
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pHandle->defaultNtype == NODE_END) {
|
if (pHandle->defaultNtype == NODE_END) {
|
||||||
|
@ -243,8 +248,9 @@ static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { rpcRe
|
||||||
|
|
||||||
static bool rpcRfp(int32_t code, tmsg_t msgType) {
|
static bool rpcRfp(int32_t code, tmsg_t msgType) {
|
||||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_MNODE_NOT_FOUND ||
|
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_MNODE_NOT_FOUND ||
|
||||||
code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_VND_STOPPED ||
|
code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED || code == TSDB_CODE_SYN_NOT_LEADER ||
|
||||||
code == TSDB_CODE_APP_IS_STARTING || code == TSDB_CODE_APP_IS_STOPPING) {
|
code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_VND_STOPPED || code == TSDB_CODE_APP_IS_STARTING ||
|
||||||
|
code == TSDB_CODE_APP_IS_STOPPING) {
|
||||||
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH ||
|
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH ||
|
||||||
msgType == TDMT_SCH_MERGE_FETCH) {
|
msgType == TDMT_SCH_MERGE_FETCH) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -193,6 +193,7 @@ typedef struct {
|
||||||
int64_t lastAccessTime;
|
int64_t lastAccessTime;
|
||||||
int32_t accessTimes;
|
int32_t accessTimes;
|
||||||
int32_t numOfVnodes;
|
int32_t numOfVnodes;
|
||||||
|
int32_t numOfOtherNodes;
|
||||||
int32_t numOfSupportVnodes;
|
int32_t numOfSupportVnodes;
|
||||||
float numOfCores;
|
float numOfCores;
|
||||||
int64_t memTotal;
|
int64_t memTotal;
|
||||||
|
|
|
@ -397,8 +397,6 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
||||||
bool needCheck = !online || dnodeChanged || reboot;
|
bool needCheck = !online || dnodeChanged || reboot;
|
||||||
|
|
||||||
pDnode->accessTimes++;
|
|
||||||
pDnode->lastAccessTime = curMs;
|
|
||||||
const STraceId *trace = &pReq->info.traceId;
|
const STraceId *trace = &pReq->info.traceId;
|
||||||
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
||||||
pDnode->accessTimes, needCheck, online, reboot, dnodeChanged, statusReq.statusSeq);
|
pDnode->accessTimes, needCheck, online, reboot, dnodeChanged, statusReq.statusSeq);
|
||||||
|
@ -534,6 +532,8 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
pReq->info.rsp = pHead;
|
pReq->info.rsp = pHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pDnode->accessTimes++;
|
||||||
|
pDnode->lastAccessTime = curMs;
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
|
|
@ -957,7 +957,7 @@ 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) {
|
||||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
|
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED) {
|
||||||
code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL;
|
code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL;
|
||||||
}
|
}
|
||||||
if (code == TSDB_CODE_SYN_TIMEOUT) {
|
if (code == TSDB_CODE_SYN_TIMEOUT) {
|
||||||
|
|
|
@ -425,6 +425,7 @@ void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgOb
|
||||||
static bool mndResetDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
|
static bool mndResetDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
|
||||||
SDnodeObj *pDnode = pObj;
|
SDnodeObj *pDnode = pObj;
|
||||||
pDnode->numOfVnodes = 0;
|
pDnode->numOfVnodes = 0;
|
||||||
|
pDnode->numOfOtherNodes = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,7 +448,7 @@ static bool mndBuildDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2
|
||||||
pDnode->numOfVnodes, pDnode->numOfSupportVnodes, isMnode, online, pDnode->memAvail, pDnode->memUsed);
|
pDnode->numOfVnodes, pDnode->numOfSupportVnodes, isMnode, online, pDnode->memAvail, pDnode->memUsed);
|
||||||
|
|
||||||
if (isMnode) {
|
if (isMnode) {
|
||||||
pDnode->numOfVnodes++;
|
pDnode->numOfOtherNodes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (online && pDnode->numOfSupportVnodes > 0) {
|
if (online && pDnode->numOfSupportVnodes > 0) {
|
||||||
|
@ -468,14 +469,25 @@ SArray *mndBuildDnodesArray(SMnode *pMnode, int32_t exceptDnodeId) {
|
||||||
|
|
||||||
sdbTraverse(pSdb, SDB_DNODE, mndResetDnodesArrayFp, NULL, NULL, NULL);
|
sdbTraverse(pSdb, SDB_DNODE, mndResetDnodesArrayFp, NULL, NULL, NULL);
|
||||||
sdbTraverse(pSdb, SDB_DNODE, mndBuildDnodesArrayFp, pArray, &exceptDnodeId, NULL);
|
sdbTraverse(pSdb, SDB_DNODE, mndBuildDnodesArrayFp, pArray, &exceptDnodeId, NULL);
|
||||||
|
|
||||||
|
mDebug("build %d dnodes array", (int32_t)taosArrayGetSize(pArray));
|
||||||
|
for (int32_t i = 0; i < (int32_t)taosArrayGetSize(pArray); ++i) {
|
||||||
|
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||||
|
mDebug("dnode:%d, vnodes:%d others:%d", pDnode->id, pDnode->numOfVnodes, pDnode->numOfOtherNodes);
|
||||||
|
}
|
||||||
return pArray;
|
return pArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCompareDnodeId(int32_t *dnode1Id, int32_t *dnode2Id) { return *dnode1Id >= *dnode2Id ? 1 : 0; }
|
static int32_t mndCompareDnodeId(int32_t *dnode1Id, int32_t *dnode2Id) { return *dnode1Id >= *dnode2Id ? 1 : 0; }
|
||||||
|
|
||||||
|
static float mndGetDnodeScore(SDnodeObj *pDnode, int32_t additionDnodes, float ratio) {
|
||||||
|
float totalDnodes = pDnode->numOfVnodes + (float)pDnode->numOfOtherNodes * ratio + additionDnodes;
|
||||||
|
return totalDnodes / pDnode->numOfSupportVnodes;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) {
|
static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) {
|
||||||
float d1Score = (float)pDnode1->numOfVnodes / pDnode1->numOfSupportVnodes;
|
float d1Score = mndGetDnodeScore(pDnode1, 0, 0.9);
|
||||||
float d2Score = (float)pDnode2->numOfVnodes / pDnode2->numOfSupportVnodes;
|
float d2Score = mndGetDnodeScore(pDnode2, 0, 0.9);
|
||||||
return d1Score >= d2Score ? 1 : 0;
|
return d1Score >= d2Score ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,7 +506,12 @@ static int32_t mndGetAvailableDnode(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup
|
||||||
int32_t allocedVnodes = 0;
|
int32_t allocedVnodes = 0;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
|
|
||||||
|
mDebug("start to sort %d dnodes", (int32_t)taosArrayGetSize(pArray));
|
||||||
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
||||||
|
for (int32_t i = 0; i < (int32_t)taosArrayGetSize(pArray); ++i) {
|
||||||
|
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||||
|
mDebug("dnode:%d, score:%f", pDnode->id, mndGetDnodeScore(pDnode, 0, 0.9));
|
||||||
|
}
|
||||||
|
|
||||||
int32_t size = taosArrayGetSize(pArray);
|
int32_t size = taosArrayGetSize(pArray);
|
||||||
if (size < pVgroup->replica) {
|
if (size < pVgroup->replica) {
|
||||||
|
@ -875,7 +892,7 @@ static int32_t mndAddVnodeToVgroup(SMnode *pMnode, STrans *pTrans, SVgObj *pVgro
|
||||||
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
||||||
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||||
mInfo("dnode:%d, equivalent vnodes:%d", pDnode->id, pDnode->numOfVnodes);
|
mInfo("dnode:%d, equivalent vnodes:%d others:%d", pDnode->id, pDnode->numOfVnodes, pDnode->numOfOtherNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
SVnodeGid *pVgid = &pVgroup->vnodeGid[pVgroup->replica];
|
SVnodeGid *pVgid = &pVgroup->vnodeGid[pVgroup->replica];
|
||||||
|
@ -935,7 +952,7 @@ static int32_t mndRemoveVnodeFromVgroup(SMnode *pMnode, STrans *pTrans, SVgObj *
|
||||||
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
||||||
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||||
mInfo("dnode:%d, equivalent vnodes:%d", pDnode->id, pDnode->numOfVnodes);
|
mInfo("dnode:%d, equivalent vnodes:%d others:%d", pDnode->id, pDnode->numOfVnodes, pDnode->numOfOtherNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
@ -1970,16 +1987,16 @@ static int32_t mndBalanceVgroup(SMnode *pMnode, SRpcMsg *pReq, SArray *pArray) {
|
||||||
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
||||||
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||||
mInfo("dnode:%d, equivalent vnodes:%d support:%d, score:%f", pDnode->id, pDnode->numOfVnodes,
|
mInfo("dnode:%d, equivalent vnodes:%d others:%d support:%d, score:%f", pDnode->id, pDnode->numOfVnodes,
|
||||||
pDnode->numOfSupportVnodes, (float)pDnode->numOfVnodes / pDnode->numOfSupportVnodes);
|
pDnode->numOfSupportVnodes, pDnode->numOfOtherNodes, mndGetDnodeScore(pDnode, 0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObj *pSrc = taosArrayGet(pArray, taosArrayGetSize(pArray) - 1);
|
SDnodeObj *pSrc = taosArrayGet(pArray, taosArrayGetSize(pArray) - 1);
|
||||||
SDnodeObj *pDst = taosArrayGet(pArray, 0);
|
SDnodeObj *pDst = taosArrayGet(pArray, 0);
|
||||||
|
|
||||||
float srcScore = (float)(pSrc->numOfVnodes - 1) / pSrc->numOfSupportVnodes;
|
float srcScore = mndGetDnodeScore(pSrc, -1, 1);
|
||||||
float dstScore = (float)(pDst->numOfVnodes + 1) / pDst->numOfSupportVnodes;
|
float dstScore = mndGetDnodeScore(pDst, 1, 1);
|
||||||
mInfo("trans:%d, after balance, src dnode:%d score:%f, dst dnode:%d score:%f", pTrans->id, pSrc->id, srcScore,
|
mInfo("trans:%d, after balance, src dnode:%d score:%f, dst dnode:%d score:%f", pTrans->id, pSrc->id, dstScore,
|
||||||
pDst->id, dstScore);
|
pDst->id, dstScore);
|
||||||
|
|
||||||
if (srcScore > dstScore - 0.000001) {
|
if (srcScore > dstScore - 0.000001) {
|
||||||
|
|
|
@ -185,7 +185,7 @@ void *tsdbGetIvtIdx(SMeta *pMeta);
|
||||||
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
||||||
|
|
||||||
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||||
uint64_t suid, void **pReader);
|
uint64_t suid, void **pReader, const char* idstr);
|
||||||
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids);
|
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids);
|
||||||
void *tsdbCacherowsReaderClose(void *pReader);
|
void *tsdbCacherowsReaderClose(void *pReader);
|
||||||
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
||||||
|
|
|
@ -121,6 +121,7 @@ typedef struct {
|
||||||
struct STQ {
|
struct STQ {
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
char* path;
|
char* path;
|
||||||
|
int64_t walLogLastVer;
|
||||||
|
|
||||||
SRWLatch pushLock;
|
SRWLatch pushLock;
|
||||||
|
|
||||||
|
|
|
@ -723,13 +723,13 @@ typedef struct SCacheRowsReader {
|
||||||
int32_t numOfCols;
|
int32_t numOfCols;
|
||||||
int32_t type;
|
int32_t type;
|
||||||
int32_t tableIndex; // currently returned result tables
|
int32_t tableIndex; // currently returned result tables
|
||||||
|
|
||||||
STableKeyInfo *pTableList; // table id list
|
STableKeyInfo *pTableList; // table id list
|
||||||
int32_t numOfTables;
|
int32_t numOfTables;
|
||||||
SSttBlockLoadInfo *pLoadInfo;
|
SSttBlockLoadInfo *pLoadInfo;
|
||||||
STsdbReadSnap *pReadSnap;
|
STsdbReadSnap *pReadSnap;
|
||||||
SDataFReader *pDataFReader;
|
SDataFReader *pDataFReader;
|
||||||
SDataFReader *pDataFReaderLast;
|
SDataFReader *pDataFReaderLast;
|
||||||
|
const char *idstr;
|
||||||
} SCacheRowsReader;
|
} SCacheRowsReader;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -752,8 +752,6 @@ int32_t tsdbCacheDelete(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
|
||||||
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
|
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
|
||||||
size_t tsdbCacheGetCapacity(SVnode *pVnode);
|
size_t tsdbCacheGetCapacity(SVnode *pVnode);
|
||||||
|
|
||||||
int32_t tsdbCacheLastArray2Row(SArray *pLastArray, STSRow **ppRow, STSchema *pSchema);
|
|
||||||
|
|
||||||
// ========== inline functions ==========
|
// ========== inline functions ==========
|
||||||
static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
|
static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
|
||||||
TSDBKEY *pKey1 = (TSDBKEY *)p1;
|
TSDBKEY *pKey1 = (TSDBKEY *)p1;
|
||||||
|
|
|
@ -201,6 +201,7 @@ int32_t tqProcessTaskRecover1Req(STQ* pTq, SRpcMsg* pMsg);
|
||||||
int32_t tqProcessTaskRecover2Req(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
int32_t tqProcessTaskRecover2Req(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||||
int32_t tqProcessTaskRecoverFinishReq(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessTaskRecoverFinishReq(STQ* pTq, SRpcMsg* pMsg);
|
||||||
int32_t tqProcessTaskRecoverFinishRsp(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessTaskRecoverFinishRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||||
|
int32_t tqCheckLogInWal(STQ* pTq, int64_t version);
|
||||||
|
|
||||||
SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema,
|
SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema,
|
||||||
SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName,
|
SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName,
|
||||||
|
|
|
@ -57,7 +57,6 @@ struct SMetaCache {
|
||||||
TdThreadMutex lock;
|
TdThreadMutex lock;
|
||||||
SHashObj* pTableEntry;
|
SHashObj* pTableEntry;
|
||||||
SLRUCache* pUidResCache;
|
SLRUCache* pUidResCache;
|
||||||
uint64_t keyBuf[3];
|
|
||||||
} sTagFilterResCache;
|
} sTagFilterResCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -429,20 +428,20 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
|
||||||
bool* acquireRes) {
|
bool* acquireRes) {
|
||||||
// generate the composed key for LRU cache
|
// generate the composed key for LRU cache
|
||||||
SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache;
|
SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache;
|
||||||
uint64_t* pBuf = pMeta->pCache->sTagFilterResCache.keyBuf;
|
|
||||||
SHashObj* pTableMap = pMeta->pCache->sTagFilterResCache.pTableEntry;
|
SHashObj* pTableMap = pMeta->pCache->sTagFilterResCache.pTableEntry;
|
||||||
TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock;
|
TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock;
|
||||||
|
|
||||||
|
uint64_t buf[3] = {0};
|
||||||
uint32_t times = 0;
|
uint32_t times = 0;
|
||||||
|
|
||||||
*acquireRes = 0;
|
*acquireRes = 0;
|
||||||
pBuf[0] = suid;
|
buf[0] = suid;
|
||||||
memcpy(&pBuf[1], pKey, keyLen);
|
memcpy(&buf[1], pKey, keyLen);
|
||||||
|
|
||||||
taosThreadMutexLock(pLock);
|
taosThreadMutexLock(pLock);
|
||||||
|
|
||||||
int32_t len = keyLen + sizeof(uint64_t);
|
int32_t len = keyLen + sizeof(uint64_t);
|
||||||
LRUHandle* pHandle = taosLRUCacheLookup(pCache, pBuf, len);
|
LRUHandle* pHandle = taosLRUCacheLookup(pCache, buf, len);
|
||||||
if (pHandle == NULL) {
|
if (pHandle == NULL) {
|
||||||
taosThreadMutexUnlock(pLock);
|
taosThreadMutexUnlock(pLock);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -476,10 +475,10 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
|
||||||
|
|
||||||
SListNode* pNode = NULL;
|
SListNode* pNode = NULL;
|
||||||
while ((pNode = tdListNext(&iter)) != NULL) {
|
while ((pNode = tdListNext(&iter)) != NULL) {
|
||||||
memcpy(&pBuf[1], pNode->data, keyLen);
|
memcpy(&buf[1], pNode->data, keyLen);
|
||||||
|
|
||||||
// check whether it is existed in LRU cache, and remove it from linked list if not.
|
// check whether it is existed in LRU cache, and remove it from linked list if not.
|
||||||
LRUHandle* pRes = taosLRUCacheLookup(pCache, pBuf, len);
|
LRUHandle* pRes = taosLRUCacheLookup(pCache, buf, len);
|
||||||
if (pRes == NULL) { // remove the item in the linked list
|
if (pRes == NULL) { // remove the item in the linked list
|
||||||
taosArrayPush(pInvalidRes, &pNode);
|
taosArrayPush(pInvalidRes, &pNode);
|
||||||
} else {
|
} else {
|
||||||
|
@ -547,14 +546,14 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
|
||||||
tdListAppend(&(*pEntry)->list, pKey);
|
tdListAppend(&(*pEntry)->list, pKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t* pBuf = pMeta->pCache->sTagFilterResCache.keyBuf;
|
uint64_t buf[3] = {0};
|
||||||
pBuf[0] = suid;
|
buf[0] = suid;
|
||||||
|
|
||||||
memcpy(&pBuf[1], pKey, keyLen);
|
memcpy(&buf[1], pKey, keyLen);
|
||||||
ASSERT(sizeof(uint64_t) + keyLen == 24);
|
ASSERT(sizeof(uint64_t) + keyLen == 24);
|
||||||
|
|
||||||
// add to cache.
|
// add to cache.
|
||||||
taosLRUCacheInsert(pCache, pBuf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL,
|
taosLRUCacheInsert(pCache, buf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL,
|
||||||
TAOS_LRU_PRIORITY_LOW);
|
TAOS_LRU_PRIORITY_LOW);
|
||||||
|
|
||||||
taosThreadMutexUnlock(pLock);
|
taosThreadMutexUnlock(pLock);
|
||||||
|
|
|
@ -99,7 +99,9 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
|
||||||
}
|
}
|
||||||
if (tDecodeTSma(pCoder, pME->smaEntry.tsma, true) < 0) return -1;
|
if (tDecodeTSma(pCoder, pME->smaEntry.tsma, true) < 0) return -1;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
metaError("meta/entry: invalide table type: %" PRId8 " decode failed.", pME->type);
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tEndDecode(pCoder);
|
tEndDecode(pCoder);
|
||||||
|
|
|
@ -113,7 +113,7 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
|
||||||
pHdr->size = nData;
|
pHdr->size = nData;
|
||||||
memcpy(pHdr->data, pData, nData);
|
memcpy(pHdr->data, pData, nData);
|
||||||
|
|
||||||
metaInfo("vgId:%d, vnode snapshot meta read data, version:%" PRId64 " uid:%" PRId64 " nData:%d",
|
metaDebug("vgId:%d, vnode snapshot meta read data, version:%" PRId64 " uid:%" PRId64 " blockLen:%d",
|
||||||
TD_VID(pReader->pMeta->pVnode), key.version, key.uid, nData);
|
TD_VID(pReader->pMeta->pVnode), key.version, key.uid, nData);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -189,7 +189,8 @@ int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData)
|
||||||
SDecoder* pDecoder = &(SDecoder){0};
|
SDecoder* pDecoder = &(SDecoder){0};
|
||||||
|
|
||||||
tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||||
metaDecodeEntry(pDecoder, &metaEntry);
|
code = metaDecodeEntry(pDecoder, &metaEntry);
|
||||||
|
if (code) goto _err;
|
||||||
|
|
||||||
code = metaHandleEntry(pMeta, &metaEntry);
|
code = metaHandleEntry(pMeta, &metaEntry);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
@ -198,6 +199,7 @@ int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData)
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
tDecoderClear(pDecoder);
|
||||||
metaError("vgId:%d, vnode snapshot meta write failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
metaError("vgId:%d, vnode snapshot meta write failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ STQ* tqOpen(const char* path, SVnode* pVnode) {
|
||||||
}
|
}
|
||||||
pTq->path = strdup(path);
|
pTq->path = strdup(path);
|
||||||
pTq->pVnode = pVnode;
|
pTq->pVnode = pVnode;
|
||||||
|
pTq->walLogLastVer = pVnode->pWal->vers.lastVer;
|
||||||
|
|
||||||
pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||||
taosHashSetFreeFp(pTq->pHandle, destroySTqHandle);
|
taosHashSetFreeFp(pTq->pHandle, destroySTqHandle);
|
||||||
|
@ -1003,8 +1004,10 @@ int32_t tqProcessStreamTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
int32_t len;
|
int32_t len;
|
||||||
tEncodeSize(tEncodeSStreamTaskCheckRsp, &rsp, len, code);
|
tEncodeSize(tEncodeSStreamTaskCheckRsp, &rsp, len, code);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
ASSERT(0);
|
tqDebug("tq encode stream check rsp error");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* buf = rpcMallocCont(sizeof(SMsgHead) + len);
|
void* buf = rpcMallocCont(sizeof(SMsgHead) + len);
|
||||||
((SMsgHead*)buf)->vgId = htonl(req.upstreamNodeId);
|
((SMsgHead*)buf)->vgId = htonl(req.upstreamNodeId);
|
||||||
|
|
||||||
|
@ -1109,6 +1112,11 @@ int32_t tqProcessTaskRecover1Req(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
// do recovery step 1
|
// do recovery step 1
|
||||||
streamSourceRecoverScanStep1(pTask);
|
streamSourceRecoverScanStep1(pTask);
|
||||||
|
|
||||||
|
if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) {
|
||||||
|
streamMetaReleaseTask(pTq->pStreamMeta, pTask);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// build msg to launch next step
|
// build msg to launch next step
|
||||||
SStreamRecoverStep2Req req;
|
SStreamRecoverStep2Req req;
|
||||||
code = streamBuildSourceRecover2Req(pTask, &req);
|
code = streamBuildSourceRecover2Req(pTask, &req);
|
||||||
|
@ -1119,6 +1127,10 @@ int32_t tqProcessTaskRecover1Req(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
|
|
||||||
streamMetaReleaseTask(pTq->pStreamMeta, pTask);
|
streamMetaReleaseTask(pTq->pStreamMeta, pTask);
|
||||||
|
|
||||||
|
if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// serialize msg
|
// serialize msg
|
||||||
int32_t len = sizeof(SStreamRecoverStep1Req);
|
int32_t len = sizeof(SStreamRecoverStep1Req);
|
||||||
|
|
||||||
|
@ -1157,6 +1169,11 @@ int32_t tqProcessTaskRecover2Req(STQ* pTq, int64_t version, char* msg, int32_t m
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) {
|
||||||
|
streamMetaReleaseTask(pTq->pStreamMeta, pTask);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// restore param
|
// restore param
|
||||||
code = streamRestoreParam(pTask);
|
code = streamRestoreParam(pTask);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
|
@ -1536,3 +1553,5 @@ FAIL:
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tqCheckLogInWal(STQ* pTq, int64_t version) { return version <= pTq->walLogLastVer; }
|
||||||
|
|
|
@ -1406,30 +1406,6 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbCacheLastArray2Row(SArray *pLastArray, STSRow **ppRow, STSchema *pTSchema) {
|
|
||||||
int32_t code = 0;
|
|
||||||
int16_t nCol = taosArrayGetSize(pLastArray);
|
|
||||||
SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal));
|
|
||||||
|
|
||||||
for (int16_t iCol = 0; iCol < nCol; ++iCol) {
|
|
||||||
SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLastArray, iCol);
|
|
||||||
SColVal *tColVal = &tTsVal->colVal;
|
|
||||||
taosArrayPush(pColArray, tColVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
code = tdSTSRowNew(pColArray, pTSchema, ppRow);
|
|
||||||
if (code) goto _err;
|
|
||||||
|
|
||||||
taosArrayDestroy(pColArray);
|
|
||||||
|
|
||||||
return code;
|
|
||||||
|
|
||||||
_err:
|
|
||||||
taosArrayDestroy(pColArray);
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr, LRUHandle **handle) {
|
int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr, LRUHandle **handle) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
char key[32] = {0};
|
char key[32] = {0};
|
||||||
|
|
|
@ -20,9 +20,8 @@
|
||||||
|
|
||||||
#define HASTYPE(_type, _t) (((_type) & (_t)) == (_t))
|
#define HASTYPE(_type, _t) (((_type) & (_t)) == (_t))
|
||||||
|
|
||||||
static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pReader, const int32_t* slotIds,
|
static int32_t saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pReader, const int32_t* slotIds,
|
||||||
void** pRes) {
|
void** pRes, const char* idStr) {
|
||||||
ASSERT(pReader->numOfCols <= taosArrayGetSize(pBlock->pDataBlock));
|
|
||||||
int32_t numOfRows = pBlock->info.rows;
|
int32_t numOfRows = pBlock->info.rows;
|
||||||
|
|
||||||
if (HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST)) {
|
if (HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST)) {
|
||||||
|
@ -65,9 +64,7 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea
|
||||||
}
|
}
|
||||||
|
|
||||||
pBlock->info.rows += allNullRow ? 0 : 1;
|
pBlock->info.rows += allNullRow ? 0 : 1;
|
||||||
} else {
|
} else if (HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST_ROW)) {
|
||||||
ASSERT(HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST_ROW));
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pReader->numOfCols; ++i) {
|
for (int32_t i = 0; i < pReader->numOfCols; ++i) {
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
|
||||||
|
@ -94,11 +91,16 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea
|
||||||
}
|
}
|
||||||
|
|
||||||
pBlock->info.rows += 1;
|
pBlock->info.rows += 1;
|
||||||
|
} else {
|
||||||
|
tsdbError("invalid retrieve type:%d, %s", pReader->type, idStr);
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||||
uint64_t suid, void** pReader) {
|
uint64_t suid, void** pReader, const char* idstr) {
|
||||||
*pReader = NULL;
|
*pReader = NULL;
|
||||||
SCacheRowsReader* p = taosMemoryCalloc(1, sizeof(SCacheRowsReader));
|
SCacheRowsReader* p = taosMemoryCalloc(1, sizeof(SCacheRowsReader));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
|
@ -142,6 +144,8 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->idstr = taosMemoryStrDup(idstr);
|
||||||
|
|
||||||
*pReader = p;
|
*pReader = p;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -160,6 +164,7 @@ void* tsdbCacherowsReaderClose(void* pReader) {
|
||||||
|
|
||||||
destroyLastBlockLoadInfo(p->pLoadInfo);
|
destroyLastBlockLoadInfo(p->pLoadInfo);
|
||||||
|
|
||||||
|
taosMemoryFree((void*) p->idstr);
|
||||||
taosMemoryFree(pReader);
|
taosMemoryFree(pReader);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -308,7 +313,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasRes) {
|
if (hasRes) {
|
||||||
saveOneRow(pLastCols, pResBlock, pr, slotIds, pRes);
|
saveOneRow(pLastCols, pResBlock, pr, slotIds, pRes, pr->idstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_ALL)) {
|
} else if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_ALL)) {
|
||||||
|
@ -323,7 +328,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveOneRow(pRow, pResBlock, pr, slotIds, pRes);
|
saveOneRow(pRow, pResBlock, pr, slotIds, pRes, pr->idstr);
|
||||||
// TODO reset the pRes
|
// TODO reset the pRes
|
||||||
|
|
||||||
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
||||||
|
|
|
@ -567,7 +567,6 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
|
||||||
|
|
||||||
pMTree->pLoadInfo = pBlockLoadInfo;
|
pMTree->pLoadInfo = pBlockLoadInfo;
|
||||||
pMTree->destroyLoadInfo = destroyLoadInfo;
|
pMTree->destroyLoadInfo = destroyLoadInfo;
|
||||||
ASSERT(pMTree->pLoadInfo != NULL);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pFReader->pSet->nSttF; ++i) { // open all last file
|
for (int32_t i = 0; i < pFReader->pSet->nSttF; ++i) { // open all last file
|
||||||
struct SLDataIter *pIter = NULL;
|
struct SLDataIter *pIter = NULL;
|
||||||
|
|
|
@ -243,7 +243,7 @@ static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pC
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo) {
|
static int32_t updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo) {
|
||||||
int32_t i = 0, j = 0;
|
int32_t i = 0, j = 0;
|
||||||
|
|
||||||
while(i < pSchema->numOfCols && j < pSupInfo->numOfCols) {
|
while(i < pSchema->numOfCols && j < pSupInfo->numOfCols) {
|
||||||
|
@ -251,7 +251,7 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo)
|
||||||
if (pTCol->colId == pSupInfo->colId[j]) {
|
if (pTCol->colId == pSupInfo->colId[j]) {
|
||||||
if (!IS_BSMA_ON(pTCol)) {
|
if (!IS_BSMA_ON(pTCol)) {
|
||||||
pSupInfo->smaValid = false;
|
pSupInfo->smaValid = false;
|
||||||
return;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
i += 1;
|
i += 1;
|
||||||
|
@ -260,9 +260,11 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo)
|
||||||
// do nothing
|
// do nothing
|
||||||
i += 1;
|
i += 1;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t initBlockScanInfoBuf(SBlockInfoBuf* pBuf, int32_t numOfTables) {
|
static int32_t initBlockScanInfoBuf(SBlockInfoBuf* pBuf, int32_t numOfTables) {
|
||||||
|
@ -396,7 +398,6 @@ static void destroyAllBlockScanInfo(SHashObj* pTableMap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isEmptyQueryTimeWindow(STimeWindow* pWindow) {
|
static bool isEmptyQueryTimeWindow(STimeWindow* pWindow) {
|
||||||
ASSERT(pWindow != NULL);
|
|
||||||
return pWindow->skey > pWindow->ekey;
|
return pWindow->skey > pWindow->ekey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,7 +581,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VND_IS_TSMA(pVnode)) {
|
if (VND_IS_TSMA(pVnode)) {
|
||||||
tsdbDebug("vgId:%d, tsma is selected to query", TD_VID(pVnode));
|
tsdbDebug("vgId:%d, tsma is selected to query, %s", TD_VID(pVnode), idstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
initReaderStatus(&pReader->status);
|
initReaderStatus(&pReader->status);
|
||||||
|
@ -595,7 +596,6 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
|
||||||
pReader->type = pCond->type;
|
pReader->type = pCond->type;
|
||||||
pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows);
|
pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows);
|
||||||
pReader->blockInfoBuf.numPerBucket = 1000; // 1000 tables per bucket
|
pReader->blockInfoBuf.numPerBucket = 1000; // 1000 tables per bucket
|
||||||
ASSERT(pCond->numOfCols > 0);
|
|
||||||
|
|
||||||
if (pReader->pResBlock == NULL) {
|
if (pReader->pResBlock == NULL) {
|
||||||
pReader->freeBlock = true;
|
pReader->freeBlock = true;
|
||||||
|
@ -606,6 +606,12 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pCond->numOfCols <= 0) {
|
||||||
|
tsdbError("vgId:%d, invalid column number %d in query cond, %s", TD_VID(pVnode), pCond->numOfCols, idstr);
|
||||||
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
|
||||||
// todo refactor.
|
// todo refactor.
|
||||||
limitOutputBufferSize(pCond, &pReader->capacity);
|
limitOutputBufferSize(pCond, &pReader->capacity);
|
||||||
|
|
||||||
|
@ -795,8 +801,9 @@ static void doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) {
|
static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) {
|
||||||
if (taosArrayGetSize(pBlockIter->blockList) == 0) {
|
size_t num = taosArrayGetSize(pBlockIter->blockList);
|
||||||
ASSERT(pBlockIter->numOfBlocks == taosArrayGetSize(pBlockIter->blockList));
|
if (num == 0) {
|
||||||
|
ASSERT(pBlockIter->numOfBlocks == num);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -806,73 +813,6 @@ static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) {
|
||||||
|
|
||||||
static SDataBlk* getCurrentBlock(SDataBlockIter* pBlockIter) { return &pBlockIter->block; }
|
static SDataBlk* getCurrentBlock(SDataBlockIter* pBlockIter) { return &pBlockIter->block; }
|
||||||
|
|
||||||
int32_t binarySearchForTs(char* pValue, int num, TSKEY key, int order) {
|
|
||||||
int32_t midPos = -1;
|
|
||||||
int32_t numOfRows;
|
|
||||||
|
|
||||||
ASSERT(order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC);
|
|
||||||
|
|
||||||
TSKEY* keyList = (TSKEY*)pValue;
|
|
||||||
int32_t firstPos = 0;
|
|
||||||
int32_t lastPos = num - 1;
|
|
||||||
|
|
||||||
if (order == TSDB_ORDER_DESC) {
|
|
||||||
// find the first position which is smaller than the key
|
|
||||||
while (1) {
|
|
||||||
if (key >= keyList[firstPos]) return firstPos;
|
|
||||||
if (key == keyList[lastPos]) return lastPos;
|
|
||||||
|
|
||||||
if (key < keyList[lastPos]) {
|
|
||||||
lastPos += 1;
|
|
||||||
if (lastPos >= num) {
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
return lastPos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
numOfRows = lastPos - firstPos + 1;
|
|
||||||
midPos = (numOfRows >> 1) + firstPos;
|
|
||||||
|
|
||||||
if (key < keyList[midPos]) {
|
|
||||||
firstPos = midPos + 1;
|
|
||||||
} else if (key > keyList[midPos]) {
|
|
||||||
lastPos = midPos - 1;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// find the first position which is bigger than the key
|
|
||||||
while (1) {
|
|
||||||
if (key <= keyList[firstPos]) return firstPos;
|
|
||||||
if (key == keyList[lastPos]) return lastPos;
|
|
||||||
|
|
||||||
if (key > keyList[lastPos]) {
|
|
||||||
lastPos = lastPos + 1;
|
|
||||||
if (lastPos >= num)
|
|
||||||
return -1;
|
|
||||||
else
|
|
||||||
return lastPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
numOfRows = lastPos - firstPos + 1;
|
|
||||||
midPos = (numOfRows >> 1u) + firstPos;
|
|
||||||
|
|
||||||
if (key < keyList[midPos]) {
|
|
||||||
lastPos = midPos - 1;
|
|
||||||
} else if (key > keyList[midPos]) {
|
|
||||||
firstPos = midPos + 1;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return midPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int order) {
|
static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int order) {
|
||||||
// start end position
|
// start end position
|
||||||
int s, e;
|
int s, e;
|
||||||
|
@ -973,8 +913,8 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo
|
||||||
|
|
||||||
int32_t step = asc? 1:-1;
|
int32_t step = asc? 1:-1;
|
||||||
|
|
||||||
// make sure it is aligned to 8bit
|
// make sure it is aligned to 8bit, the allocated memory address is aligned to 256bit
|
||||||
ASSERT((((uint64_t)pColData->pData) & (0x8 - 1)) == 0);
|
// ASSERT((((uint64_t)pColData->pData) & (0x8 - 1)) == 0);
|
||||||
|
|
||||||
// 1. copy data in a batch model
|
// 1. copy data in a batch model
|
||||||
memcpy(pColData->pData, p, dumpedRows * tDataTypes[pData->type].bytes);
|
memcpy(pColData->pData, p, dumpedRows * tDataTypes[pData->type].bytes);
|
||||||
|
@ -1073,11 +1013,20 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
// pDumpInfo->rowIndex = 0;
|
// pDumpInfo->rowIndex = 0;
|
||||||
} else if (!asc && pReader->window.ekey >= pBlock->maxKey.ts) {
|
} else if (!asc && pReader->window.ekey >= pBlock->maxKey.ts) {
|
||||||
// pDumpInfo->rowIndex = pBlock->nRow - 1;
|
// pDumpInfo->rowIndex = pBlock->nRow - 1;
|
||||||
} else {
|
} else { // find the appropriate the start position in current block, and set it to be the current rowIndex
|
||||||
int32_t pos = asc ? pBlock->nRow - 1 : 0;
|
int32_t pos = asc ? pBlock->nRow - 1 : 0;
|
||||||
int32_t order = asc ? TSDB_ORDER_DESC : TSDB_ORDER_ASC;
|
int32_t order = asc ? TSDB_ORDER_DESC : TSDB_ORDER_ASC;
|
||||||
int64_t key = asc ? pReader->window.skey : pReader->window.ekey;
|
int64_t key = asc ? pReader->window.skey : pReader->window.ekey;
|
||||||
pDumpInfo->rowIndex = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, key, order);
|
pDumpInfo->rowIndex = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, key, order);
|
||||||
|
|
||||||
|
if (pDumpInfo->rowIndex < 0) {
|
||||||
|
tsdbError(
|
||||||
|
"%p failed to locate the start position in current block, global index:%d, table index:%d, brange:%" PRId64
|
||||||
|
"-%" PRId64 ", minVer:%" PRId64 ", maxVer:%" PRId64 " %s",
|
||||||
|
pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, pBlock->minVer,
|
||||||
|
pBlock->maxVer, pReader->idStr);
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1184,7 +1133,6 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI
|
||||||
|
|
||||||
SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter);
|
SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter);
|
||||||
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
||||||
ASSERT(pBlockInfo != NULL);
|
|
||||||
|
|
||||||
SDataBlk* pBlock = getCurrentBlock(pBlockIter);
|
SDataBlk* pBlock = getCurrentBlock(pBlockIter);
|
||||||
code = tsdbReadDataBlock(pReader->pFileReader, pBlock, pBlockData);
|
code = tsdbReadDataBlock(pReader->pFileReader, pBlock, pBlockData);
|
||||||
|
@ -1222,8 +1170,6 @@ static void cleanupBlockOrderSupporter(SBlockOrderSupporter* pSup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t initBlockOrderSupporter(SBlockOrderSupporter* pSup, int32_t numOfTables) {
|
static int32_t initBlockOrderSupporter(SBlockOrderSupporter* pSup, int32_t numOfTables) {
|
||||||
ASSERT(numOfTables >= 1);
|
|
||||||
|
|
||||||
pSup->numOfBlocksPerTable = taosMemoryCalloc(1, sizeof(int32_t) * numOfTables);
|
pSup->numOfBlocksPerTable = taosMemoryCalloc(1, sizeof(int32_t) * numOfTables);
|
||||||
pSup->indexPerTable = taosMemoryCalloc(1, sizeof(int32_t) * numOfTables);
|
pSup->indexPerTable = taosMemoryCalloc(1, sizeof(int32_t) * numOfTables);
|
||||||
pSup->pDataBlockInfo = taosMemoryCalloc(1, POINTER_BYTES * numOfTables);
|
pSup->pDataBlockInfo = taosMemoryCalloc(1, POINTER_BYTES * numOfTables);
|
||||||
|
@ -1330,7 +1276,10 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
|
||||||
sup.numOfTables += 1;
|
sup.numOfTables += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(numOfBlocks == cnt);
|
if (numOfBlocks != cnt && sup.numOfTables != numOfTables) {
|
||||||
|
cleanupBlockOrderSupporter(&sup);
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
|
||||||
// since there is only one table qualified, blocks are not sorted
|
// since there is only one table qualified, blocks are not sorted
|
||||||
if (sup.numOfTables == 1) {
|
if (sup.numOfTables == 1) {
|
||||||
|
@ -1352,9 +1301,8 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
|
||||||
tsdbDebug("%p create data blocks info struct completed, %d blocks in %d tables %s", pReader, cnt, sup.numOfTables,
|
tsdbDebug("%p create data blocks info struct completed, %d blocks in %d tables %s", pReader, cnt, sup.numOfTables,
|
||||||
pReader->idStr);
|
pReader->idStr);
|
||||||
|
|
||||||
ASSERT(cnt <= numOfBlocks && sup.numOfTables <= numOfTables);
|
|
||||||
|
|
||||||
SMultiwayMergeTreeInfo* pTree = NULL;
|
SMultiwayMergeTreeInfo* pTree = NULL;
|
||||||
|
|
||||||
uint8_t ret = tMergeTreeCreate(&pTree, sup.numOfTables, &sup, fileDataBlockOrderCompar);
|
uint8_t ret = tMergeTreeCreate(&pTree, sup.numOfTables, &sup, fileDataBlockOrderCompar);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
cleanupBlockOrderSupporter(&sup);
|
cleanupBlockOrderSupporter(&sup);
|
||||||
|
@ -1433,8 +1381,6 @@ static bool getNeighborBlockOfSameTable(SFileDataBlockInfo* pBlockInfo, STableBl
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t findFileBlockInfoIndex(SDataBlockIter* pBlockIter, SFileDataBlockInfo* pFBlockInfo) {
|
static int32_t findFileBlockInfoIndex(SDataBlockIter* pBlockIter, SFileDataBlockInfo* pFBlockInfo) {
|
||||||
ASSERT(pBlockIter != NULL && pFBlockInfo != NULL);
|
|
||||||
|
|
||||||
int32_t step = ASCENDING_TRAVERSE(pBlockIter->order) ? 1 : -1;
|
int32_t step = ASCENDING_TRAVERSE(pBlockIter->order) ? 1 : -1;
|
||||||
int32_t index = pBlockIter->index;
|
int32_t index = pBlockIter->index;
|
||||||
|
|
||||||
|
@ -1447,7 +1393,6 @@ static int32_t findFileBlockInfoIndex(SDataBlockIter* pBlockIter, SFileDataBlock
|
||||||
index += step;
|
index += step;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1926,7 +1871,6 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
|
||||||
}
|
}
|
||||||
|
|
||||||
doMergeRowsInLastBlock(pLastBlockReader, pBlockScanInfo, tsLastBlock, &merge, &pReader->verRange);
|
doMergeRowsInLastBlock(pLastBlockReader, pBlockScanInfo, tsLastBlock, &merge, &pReader->verRange);
|
||||||
ASSERT(mergeBlockData);
|
|
||||||
|
|
||||||
// merge with block data if ts == key
|
// merge with block data if ts == key
|
||||||
if (tsLastBlock == pBlockData->aTSKEY[pDumpInfo->rowIndex]) {
|
if (tsLastBlock == pBlockData->aTSKEY[pDumpInfo->rowIndex]) {
|
||||||
|
@ -1992,7 +1936,6 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
|
||||||
tRowMergerClear(&merge);
|
tRowMergerClear(&merge);
|
||||||
return code;
|
return code;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
} else { // desc order
|
} else { // desc order
|
||||||
|
@ -2013,7 +1956,6 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
|
||||||
|
|
||||||
TSDBROW* pRow = getValidMemRow(&pBlockScanInfo->iter, pDelList, pReader);
|
TSDBROW* pRow = getValidMemRow(&pBlockScanInfo->iter, pDelList, pReader);
|
||||||
TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pDelList, pReader);
|
TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pDelList, pReader);
|
||||||
ASSERT(pRow != NULL && piRow != NULL);
|
|
||||||
|
|
||||||
int64_t tsLast = INT64_MIN;
|
int64_t tsLast = INT64_MIN;
|
||||||
if (hasDataInLastBlock(pLastBlockReader)) {
|
if (hasDataInLastBlock(pLastBlockReader)) {
|
||||||
|
@ -2237,7 +2179,6 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
||||||
if (pReader->pReadSnap->pMem != NULL) {
|
if (pReader->pReadSnap->pMem != NULL) {
|
||||||
d = tsdbGetTbDataFromMemTable(pReader->pReadSnap->pMem, pReader->suid, pBlockScanInfo->uid);
|
d = tsdbGetTbDataFromMemTable(pReader->pReadSnap->pMem, pReader->suid, pBlockScanInfo->uid);
|
||||||
if (d != NULL) {
|
if (d != NULL) {
|
||||||
ASSERT(pBlockScanInfo->iter.iter == NULL);
|
|
||||||
code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter);
|
code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
pBlockScanInfo->iter.hasVal = (tsdbTbDataIterGet(pBlockScanInfo->iter.iter) != NULL);
|
pBlockScanInfo->iter.hasVal = (tsdbTbDataIterGet(pBlockScanInfo->iter.iter) != NULL);
|
||||||
|
@ -2351,10 +2292,9 @@ static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader) {
|
||||||
static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader) { return pLastBlockReader->mergeTree.pIter != NULL; }
|
static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader) { return pLastBlockReader->mergeTree.pIter != NULL; }
|
||||||
|
|
||||||
bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo) {
|
bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo) {
|
||||||
if (pBlockData->nRow > 0) {
|
if ((pBlockData->nRow > 0) && (pBlockData->nRow != pDumpInfo->totalRows)) {
|
||||||
ASSERT(pBlockData->nRow == pDumpInfo->totalRows);
|
return false; // this is an invalid result.
|
||||||
}
|
}
|
||||||
|
|
||||||
return pBlockData->nRow > 0 && (!pDumpInfo->allDumped);
|
return pBlockData->nRow > 0 && (!pDumpInfo->allDumped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2421,6 +2361,46 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t loadNeighborIfOverlap(SFileDataBlockInfo* pBlockInfo, STableBlockScanInfo* pBlockScanInfo,
|
||||||
|
STsdbReader* pReader, bool* loadNeighbor) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
||||||
|
int32_t nextIndex = -1;
|
||||||
|
SBlockIndex nxtBIndex = {0};
|
||||||
|
|
||||||
|
*loadNeighbor = false;
|
||||||
|
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||||
|
|
||||||
|
bool hasNeighbor = getNeighborBlockOfSameTable(pBlockInfo, pBlockScanInfo, &nextIndex, pReader->order, &nxtBIndex);
|
||||||
|
if (!hasNeighbor) { // do nothing
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overlapWithNeighborBlock(pBlock, &nxtBIndex, pReader->order)) { // load next block
|
||||||
|
SReaderStatus* pStatus = &pReader->status;
|
||||||
|
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||||
|
|
||||||
|
// 1. find the next neighbor block in the scan block list
|
||||||
|
SFileDataBlockInfo fb = {.uid = pBlockInfo->uid, .tbBlockIdx = nextIndex};
|
||||||
|
int32_t neighborIndex = findFileBlockInfoIndex(pBlockIter, &fb);
|
||||||
|
|
||||||
|
// 2. remove it from the scan block list
|
||||||
|
setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step);
|
||||||
|
|
||||||
|
// 3. load the neighbor block, and set it to be the currently accessed file data block
|
||||||
|
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pBlockInfo->uid);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. check the data values
|
||||||
|
initBlockDumpInfo(pReader, pBlockIter);
|
||||||
|
*loadNeighbor = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -2479,38 +2459,13 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||||
|
|
||||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||||
if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) {
|
if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) {
|
||||||
|
|
||||||
int32_t nextIndex = -1;
|
|
||||||
SBlockIndex bIndex = {0};
|
|
||||||
pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); // NOTE: get the new block info
|
pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); // NOTE: get the new block info
|
||||||
|
|
||||||
bool hasNeighbor = getNeighborBlockOfSameTable(pBlockInfo, pBlockScanInfo, &nextIndex, pReader->order, &bIndex);
|
// continue check for the next file block if the last ts in the current block
|
||||||
if (!hasNeighbor) { // do nothing
|
// is overlapped with the next neighbor block
|
||||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
bool loadNeighbor = false;
|
||||||
break;
|
code = loadNeighborIfOverlap(pBlockInfo, pBlockScanInfo, pReader, &loadNeighbor);
|
||||||
}
|
if ((!loadNeighbor) || (code != 0)) {
|
||||||
|
|
||||||
if (overlapWithNeighborBlock(pBlock, &bIndex, pReader->order)) { // load next block
|
|
||||||
SReaderStatus* pStatus = &pReader->status;
|
|
||||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
|
||||||
|
|
||||||
// 1. find the next neighbor block in the scan block list
|
|
||||||
SFileDataBlockInfo fb = {.uid = pBlockInfo->uid, .tbBlockIdx = nextIndex};
|
|
||||||
int32_t neighborIndex = findFileBlockInfoIndex(pBlockIter, &fb);
|
|
||||||
|
|
||||||
// 2. remove it from the scan block list
|
|
||||||
setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step);
|
|
||||||
|
|
||||||
// 3. load the neighbor block, and set it to be the currently accessed file data block
|
|
||||||
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pBlockInfo->uid);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. check the data values
|
|
||||||
initBlockDumpInfo(pReader, pBlockIter);
|
|
||||||
} else {
|
|
||||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2570,7 +2525,6 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
||||||
ASSERT(pReader->pReadSnap != NULL);
|
|
||||||
|
|
||||||
SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile;
|
SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile;
|
||||||
if (pDelFile && taosArrayGetSize(pReader->pDelIdx) > 0) {
|
if (pDelFile && taosArrayGetSize(pReader->pDelIdx) > 0) {
|
||||||
|
@ -2777,7 +2731,10 @@ static bool moveToNextTable(SUidOrderCheckInfo* pOrderedCheckInfo, SReaderStatus
|
||||||
|
|
||||||
uint64_t uid = pOrderedCheckInfo->tableUidList[pOrderedCheckInfo->currentIndex];
|
uint64_t uid = pOrderedCheckInfo->tableUidList[pOrderedCheckInfo->currentIndex];
|
||||||
pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid));
|
pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid));
|
||||||
ASSERT(pStatus->pTableIter != NULL);
|
if (pStatus->pTableIter == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2852,7 +2809,6 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
|
||||||
TSDBKEY keyInBuf = getCurrentKeyInBuf(pScanInfo, pReader);
|
TSDBKEY keyInBuf = getCurrentKeyInBuf(pScanInfo, pReader);
|
||||||
|
|
||||||
if (pBlockInfo == NULL) { // build data block from last data file
|
if (pBlockInfo == NULL) { // build data block from last data file
|
||||||
ASSERT(pBlockIter->numOfBlocks == 0);
|
|
||||||
code = buildComposedDataBlock(pReader);
|
code = buildComposedDataBlock(pReader);
|
||||||
} else if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader)) {
|
} else if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader)) {
|
||||||
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pScanInfo->uid);
|
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pScanInfo->uid);
|
||||||
|
@ -3117,10 +3073,10 @@ SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond, int8_
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32_t order, SVersionRange* pVerRange) {
|
bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32_t order, SVersionRange* pVerRange) {
|
||||||
ASSERT(pKey != NULL);
|
|
||||||
if (pDelList == NULL) {
|
if (pDelList == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t num = taosArrayGetSize(pDelList);
|
size_t num = taosArrayGetSize(pDelList);
|
||||||
bool asc = ASCENDING_TRAVERSE(order);
|
bool asc = ASCENDING_TRAVERSE(order);
|
||||||
int32_t step = asc ? 1 : -1;
|
int32_t step = asc ? 1 : -1;
|
||||||
|
@ -3318,35 +3274,10 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
*state = CHECK_FILEBLOCK_QUIT;
|
*state = CHECK_FILEBLOCK_QUIT;
|
||||||
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
||||||
|
|
||||||
int32_t nextIndex = -1;
|
bool loadNeighbor = true;
|
||||||
SBlockIndex bIndex = {0};
|
int32_t code = loadNeighborIfOverlap(pFBlock, pScanInfo, pReader, &loadNeighbor);
|
||||||
|
|
||||||
bool hasNeighbor = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &nextIndex, pReader->order, &bIndex);
|
|
||||||
if (!hasNeighbor) { // do nothing
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool overlap = overlapWithNeighborBlock(pBlock, &bIndex, pReader->order);
|
|
||||||
if (overlap) { // load next block
|
|
||||||
SReaderStatus* pStatus = &pReader->status;
|
|
||||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
|
||||||
|
|
||||||
// 1. find the next neighbor block in the scan block list
|
|
||||||
SFileDataBlockInfo fb = {.uid = pFBlock->uid, .tbBlockIdx = nextIndex};
|
|
||||||
int32_t neighborIndex = findFileBlockInfoIndex(pBlockIter, &fb);
|
|
||||||
|
|
||||||
// 2. remove it from the scan block list
|
|
||||||
setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step);
|
|
||||||
|
|
||||||
// 3. load the neighbor block, and set it to be the currently accessed file data block
|
|
||||||
int32_t code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pFBlock->uid);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. check the data values
|
|
||||||
initBlockDumpInfo(pReader, pBlockIter);
|
|
||||||
|
|
||||||
|
if (loadNeighbor && (code == TSDB_CODE_SUCCESS)) {
|
||||||
pDumpInfo->rowIndex =
|
pDumpInfo->rowIndex =
|
||||||
doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, key, pMerger, &pReader->verRange, step);
|
doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, key, pMerger, &pReader->verRange, step);
|
||||||
if (pDumpInfo->rowIndex >= pDumpInfo->totalRows) {
|
if (pDumpInfo->rowIndex >= pDumpInfo->totalRows) {
|
||||||
|
@ -3354,7 +3285,7 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, STsdbReader* pReader,
|
int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, STsdbReader* pReader,
|
||||||
|
@ -3709,13 +3640,11 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
|
||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
ASSERT(pBlock->info.rows <= capacity);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO refactor: with createDataBlockScanInfo
|
// TODO refactor: with createDataBlockScanInfo
|
||||||
int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t num) {
|
int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t num) {
|
||||||
ASSERT(pReader != NULL);
|
|
||||||
int32_t size = taosHashGetSize(pReader->status.pTableMap);
|
int32_t size = taosHashGetSize(pReader->status.pTableMap);
|
||||||
|
|
||||||
STableBlockScanInfo** p = NULL;
|
STableBlockScanInfo** p = NULL;
|
||||||
|
@ -3848,15 +3777,16 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pReader->pSchema != NULL) {
|
if (pReader->pSchema != NULL) {
|
||||||
updateBlockSMAInfo(pReader->pSchema, &pReader->suppInfo);
|
code = updateBlockSMAInfo(pReader->pSchema, &pReader->suppInfo);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STsdbReader* p = (pReader->innerReader[0] != NULL) ? pReader->innerReader[0] : pReader;
|
STsdbReader* p = (pReader->innerReader[0] != NULL) ? pReader->innerReader[0] : pReader;
|
||||||
pReader->status.pTableMap = createDataBlockScanInfo(p, &pReader->blockInfoBuf, pTableList, numOfTables);
|
pReader->status.pTableMap = createDataBlockScanInfo(p, &pReader->blockInfoBuf, pTableList, numOfTables);
|
||||||
if (pReader->status.pTableMap == NULL) {
|
if (pReader->status.pTableMap == NULL) {
|
||||||
tsdbReaderClose(p);
|
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
|
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -4079,7 +4009,6 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) {
|
static void setBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) {
|
||||||
ASSERT(pReader != NULL);
|
|
||||||
*rows = pReader->pResBlock->info.rows;
|
*rows = pReader->pResBlock->info.rows;
|
||||||
*uid = pReader->pResBlock->info.id.uid;
|
*uid = pReader->pResBlock->info.id.uid;
|
||||||
*pWindow = pReader->pResBlock->info.window;
|
*pWindow = pReader->pResBlock->info.window;
|
||||||
|
@ -4125,25 +4054,27 @@ static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, bool* allHave) {
|
int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, bool* allHave) {
|
||||||
int32_t code = 0;
|
|
||||||
SColumnDataAgg*** pBlockSMA = &pDataBlock->pBlockAgg;
|
SColumnDataAgg*** pBlockSMA = &pDataBlock->pBlockAgg;
|
||||||
|
|
||||||
|
int32_t code = 0;
|
||||||
*allHave = false;
|
*allHave = false;
|
||||||
|
*pBlockSMA = NULL;
|
||||||
|
|
||||||
if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
||||||
*pBlockSMA = NULL;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// there is no statistics data for composed block
|
// there is no statistics data for composed block
|
||||||
if (pReader->status.composedDataBlock || (!pReader->suppInfo.smaValid)) {
|
if (pReader->status.composedDataBlock || (!pReader->suppInfo.smaValid)) {
|
||||||
*pBlockSMA = NULL;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter);
|
SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter);
|
||||||
SBlockLoadSuppInfo* pSup = &pReader->suppInfo;
|
SBlockLoadSuppInfo* pSup = &pReader->suppInfo;
|
||||||
|
|
||||||
ASSERT(pReader->pResBlock->info.id.uid == pFBlock->uid);
|
if (pReader->pResBlock->info.id.uid != pFBlock->uid) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||||
if (tDataBlkHasSma(pBlock)) {
|
if (tDataBlkHasSma(pBlock)) {
|
||||||
|
@ -4171,9 +4102,6 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
|
||||||
// update the number of NULL data rows
|
// update the number of NULL data rows
|
||||||
size_t numOfCols = pSup->numOfCols;
|
size_t numOfCols = pSup->numOfCols;
|
||||||
|
|
||||||
int32_t i = 0, j = 0;
|
|
||||||
size_t size = taosArrayGetSize(pSup->pColAgg);
|
|
||||||
|
|
||||||
// ensure capacity
|
// ensure capacity
|
||||||
if (pDataBlock->pDataBlock) {
|
if (pDataBlock->pDataBlock) {
|
||||||
size_t colsNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
size_t colsNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||||
|
@ -4188,8 +4116,9 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
|
||||||
|
|
||||||
// do fill all null column value SMA info
|
// do fill all null column value SMA info
|
||||||
doFillNullColSMA(pSup, pBlock->nRow, numOfCols, pTsAgg);
|
doFillNullColSMA(pSup, pBlock->nRow, numOfCols, pTsAgg);
|
||||||
|
size_t size = taosArrayGetSize(pSup->pColAgg);
|
||||||
|
|
||||||
i = 0, j = 0;
|
int32_t i = 0, j = 0;
|
||||||
while (j < numOfCols && i < size) {
|
while (j < numOfCols && i < size) {
|
||||||
SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i);
|
SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i);
|
||||||
if (pAgg->colId == pSup->colId[j]) {
|
if (pAgg->colId == pSup->colId[j]) {
|
||||||
|
@ -4199,7 +4128,7 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
|
||||||
} else if (pAgg->colId < pSup->colId[j]) {
|
} else if (pAgg->colId < pSup->colId[j]) {
|
||||||
i += 1;
|
i += 1;
|
||||||
} else if (pSup->colId[j] < pAgg->colId) {
|
} else if (pSup->colId[j] < pAgg->colId) {
|
||||||
ASSERT(pSup->colId[j] == PRIMARYKEY_TIMESTAMP_COL_ID);
|
// ASSERT(pSup->colId[j] == PRIMARYKEY_TIMESTAMP_COL_ID);
|
||||||
pResBlock->pBlockAgg[pSup->slotId[j]] = &pSup->tsColAgg;
|
pResBlock->pBlockAgg[pSup->slotId[j]] = &pSup->tsColAgg;
|
||||||
j += 1;
|
j += 1;
|
||||||
}
|
}
|
||||||
|
@ -4432,9 +4361,12 @@ int32_t tsdbGetTableSchema(SVnode* pVnode, int64_t uid, STSchema** pSchema, int6
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
sversion = mr.me.stbEntry.schemaRow.version;
|
sversion = mr.me.stbEntry.schemaRow.version;
|
||||||
} else {
|
} else if (mr.me.type == TSDB_NORMAL_TABLE) {
|
||||||
ASSERT(mr.me.type == TSDB_NORMAL_TABLE);
|
|
||||||
sversion = mr.me.ntbEntry.schemaRow.version;
|
sversion = mr.me.ntbEntry.schemaRow.version;
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
|
|
|
@ -184,16 +184,51 @@ _err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vnodePrepareCommit(SVnode *pVnode) {
|
static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
|
char dir[TSDB_FILENAME_LEN] = {0};
|
||||||
|
|
||||||
tsem_wait(&pVnode->canCommit);
|
tsem_wait(&pVnode->canCommit);
|
||||||
|
|
||||||
|
pVnode->state.commitTerm = pVnode->state.applyTerm;
|
||||||
|
|
||||||
|
pInfo->info.config = pVnode->config;
|
||||||
|
pInfo->info.state.committed = pVnode->state.applied;
|
||||||
|
pInfo->info.state.commitTerm = pVnode->state.applyTerm;
|
||||||
|
pInfo->info.state.commitID = pVnode->state.commitID;
|
||||||
|
pInfo->pVnode = pVnode;
|
||||||
|
pInfo->txn = metaGetTxn(pVnode->pMeta);
|
||||||
|
|
||||||
|
// save info
|
||||||
|
if (pVnode->pTfs) {
|
||||||
|
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
||||||
|
} else {
|
||||||
|
snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
|
||||||
|
}
|
||||||
|
if (vnodeSaveInfo(dir, &pInfo->info) < 0) {
|
||||||
|
code = terrno;
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
}
|
||||||
|
|
||||||
tsdbPrepareCommit(pVnode->pTsdb);
|
tsdbPrepareCommit(pVnode->pTsdb);
|
||||||
metaPrepareAsyncCommit(pVnode->pMeta);
|
|
||||||
smaPrepareAsyncCommit(pVnode->pSma);
|
smaPrepareAsyncCommit(pVnode->pSma);
|
||||||
|
|
||||||
|
metaPrepareAsyncCommit(pVnode->pMeta);
|
||||||
|
|
||||||
vnodeBufPoolUnRef(pVnode->inUse);
|
vnodeBufPoolUnRef(pVnode->inUse);
|
||||||
pVnode->inUse = NULL;
|
pVnode->inUse = NULL;
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (code) {
|
||||||
|
vError("vgId:%d, %s failed at line %d since %s, commit id:%" PRId64, TD_VID(pVnode), __func__, lino,
|
||||||
|
tstrerror(code), pVnode->state.commitID);
|
||||||
|
} else {
|
||||||
|
vDebug("vgId:%d, %s done", TD_VID(pVnode), __func__);
|
||||||
}
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t vnodeCommitTask(void *arg) {
|
static int32_t vnodeCommitTask(void *arg) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -213,31 +248,31 @@ _exit:
|
||||||
int vnodeAsyncCommit(SVnode *pVnode) {
|
int vnodeAsyncCommit(SVnode *pVnode) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
// prepare to commit
|
|
||||||
vnodePrepareCommit(pVnode);
|
|
||||||
|
|
||||||
// schedule the task
|
|
||||||
pVnode->state.commitTerm = pVnode->state.applyTerm;
|
|
||||||
|
|
||||||
SCommitInfo *pInfo = (SCommitInfo *)taosMemoryCalloc(1, sizeof(*pInfo));
|
SCommitInfo *pInfo = (SCommitInfo *)taosMemoryCalloc(1, sizeof(*pInfo));
|
||||||
if (NULL == pInfo) {
|
if (NULL == pInfo) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
pInfo->info.config = pVnode->config;
|
|
||||||
pInfo->info.state.committed = pVnode->state.applied;
|
// prepare to commit
|
||||||
pInfo->info.state.commitTerm = pVnode->state.applyTerm;
|
code = vnodePrepareCommit(pVnode, pInfo);
|
||||||
pInfo->info.state.commitID = pVnode->state.commitID;
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
pInfo->pVnode = pVnode;
|
goto _exit;
|
||||||
pInfo->txn = metaGetTxn(pVnode->pMeta);
|
}
|
||||||
|
|
||||||
|
// schedule the task
|
||||||
vnodeScheduleTask(vnodeCommitTask, pInfo);
|
vnodeScheduleTask(vnodeCommitTask, pInfo);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
vError("vgId:%d, %s failed since %s, commit id:%" PRId64, TD_VID(pVnode), __func__, tstrerror(code),
|
if (NULL != pInfo) {
|
||||||
|
taosMemoryFree(pInfo);
|
||||||
|
}
|
||||||
|
vError("vgId:%d, vnode async commit failed since %s, commitId:%" PRId64, TD_VID(pVnode), tstrerror(code),
|
||||||
pVnode->state.commitID);
|
pVnode->state.commitID);
|
||||||
} else {
|
} else {
|
||||||
vDebug("vgId:%d, %s done", TD_VID(pVnode), __func__);
|
vInfo("vgId:%d, vnode async commit done, commitId:%" PRId64 " term:%" PRId64 " applied:%" PRId64, TD_VID(pVnode),
|
||||||
|
pVnode->state.commitID, pVnode->state.applyTerm, pVnode->state.applied);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +291,7 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
|
||||||
char dir[TSDB_FILENAME_LEN] = {0};
|
char dir[TSDB_FILENAME_LEN] = {0};
|
||||||
SVnode *pVnode = pInfo->pVnode;
|
SVnode *pVnode = pInfo->pVnode;
|
||||||
|
|
||||||
vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64 " term: %" PRId64, TD_VID(pVnode),
|
vInfo("vgId:%d, start to commit, commitId:%" PRId64 " version:%" PRId64 " term: %" PRId64, TD_VID(pVnode),
|
||||||
pVnode->state.commitID, pVnode->state.applied, pVnode->state.applyTerm);
|
pVnode->state.commitID, pVnode->state.applied, pVnode->state.applyTerm);
|
||||||
|
|
||||||
// persist wal before starting
|
// persist wal before starting
|
||||||
|
@ -265,16 +300,11 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// save info
|
|
||||||
if (pVnode->pTfs) {
|
if (pVnode->pTfs) {
|
||||||
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
||||||
} else {
|
} else {
|
||||||
snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
|
snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
|
||||||
}
|
}
|
||||||
if (vnodeSaveInfo(dir, &pInfo->info) < 0) {
|
|
||||||
code = terrno;
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
}
|
|
||||||
|
|
||||||
// walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
|
// walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
|
||||||
syncBeginSnapshot(pVnode->sync, pVnode->state.applied);
|
syncBeginSnapshot(pVnode->sync, pVnode->state.applied);
|
||||||
|
|
|
@ -257,7 +257,7 @@ _exit:
|
||||||
pReader->index++;
|
pReader->index++;
|
||||||
*nData = sizeof(SSnapDataHdr) + pHdr->size;
|
*nData = sizeof(SSnapDataHdr) + pHdr->size;
|
||||||
pHdr->index = pReader->index;
|
pHdr->index = pReader->index;
|
||||||
vInfo("vgId:%d, vnode snapshot read data,index:%" PRId64 " type:%d nData:%d ", TD_VID(pReader->pVnode),
|
vDebug("vgId:%d, vnode snapshot read data, index:%" PRId64 " type:%d blockLen:%d ", TD_VID(pReader->pVnode),
|
||||||
pReader->index, pHdr->type, *nData);
|
pReader->index, pHdr->type, *nData);
|
||||||
} else {
|
} else {
|
||||||
vInfo("vgId:%d, vnode snapshot read data end, index:%" PRId64, TD_VID(pReader->pVnode), pReader->index);
|
vInfo("vgId:%d, vnode snapshot read data end, index:%" PRId64, TD_VID(pReader->pVnode), pReader->index);
|
||||||
|
@ -423,7 +423,7 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
|
||||||
ASSERT(pHdr->index == pWriter->index + 1);
|
ASSERT(pHdr->index == pWriter->index + 1);
|
||||||
pWriter->index = pHdr->index;
|
pWriter->index = pHdr->index;
|
||||||
|
|
||||||
vInfo("vgId:%d, vnode snapshot write data, index:%" PRId64 " type:%d nData:%d", TD_VID(pVnode), pHdr->index,
|
vDebug("vgId:%d, vnode snapshot write data, index:%" PRId64 " type:%d blockLen:%d", TD_VID(pVnode), pHdr->index,
|
||||||
pHdr->type, nData);
|
pHdr->type, nData);
|
||||||
|
|
||||||
switch (pHdr->type) {
|
switch (pHdr->type) {
|
||||||
|
|
|
@ -197,6 +197,10 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
||||||
|
|
||||||
if (!syncUtilUserCommit(pMsg->msgType)) goto _exit;
|
if (!syncUtilUserCommit(pMsg->msgType)) goto _exit;
|
||||||
|
|
||||||
|
if (pMsg->msgType == TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE || pMsg->msgType == TDMT_STREAM_TASK_CHECK_RSP) {
|
||||||
|
if (tqCheckLogInWal(pVnode->pTq, version)) return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// skip header
|
// skip header
|
||||||
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||||
len = pMsg->contLen - sizeof(SMsgHead);
|
len = pMsg->contLen - sizeof(SMsgHead);
|
||||||
|
|
|
@ -391,9 +391,9 @@ static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsm
|
||||||
|
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
vGTrace("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", term:%" PRIu64 ", msg-index:%" PRId64
|
vGTrace("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", term:%" PRIu64 ", msg-index:%" PRId64
|
||||||
", weak:%d, code:%d, state:%d %s, type:%s",
|
", weak:%d, code:%d, state:%d %s, type:%s code:0x%x",
|
||||||
pVnode->config.vgId, pFsm, pMeta->index, pMeta->term, pMsg->info.conn.applyIndex, pMeta->isWeak, pMeta->code,
|
pVnode->config.vgId, pFsm, pMeta->index, pMeta->term, pMsg->info.conn.applyIndex, pMeta->isWeak, pMeta->code,
|
||||||
pMeta->state, syncStr(pMeta->state), TMSG_INFO(pMsg->msgType));
|
pMeta->state, syncStr(pMeta->state), TMSG_INFO(pMsg->msgType), pMsg->code);
|
||||||
|
|
||||||
return tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, pMsg);
|
return tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, pMsg);
|
||||||
}
|
}
|
||||||
|
@ -465,9 +465,9 @@ static int32_t vnodeSnapshotStopWrite(const SSyncFSM *pFsm, void *pWriter, bool
|
||||||
|
|
||||||
static int32_t vnodeSnapshotDoWrite(const SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
|
static int32_t vnodeSnapshotDoWrite(const SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
|
||||||
SVnode *pVnode = pFsm->data;
|
SVnode *pVnode = pFsm->data;
|
||||||
vDebug("vgId:%d, continue write vnode snapshot, len:%d", pVnode->config.vgId, len);
|
vDebug("vgId:%d, continue write vnode snapshot, blockLen:%d", pVnode->config.vgId, len);
|
||||||
int32_t code = vnodeSnapWrite(pWriter, pBuf, len);
|
int32_t code = vnodeSnapWrite(pWriter, pBuf, len);
|
||||||
vDebug("vgId:%d, continue write vnode snapshot finished, len:%d", pVnode->config.vgId, len);
|
vDebug("vgId:%d, continue write vnode snapshot finished, blockLen:%d", pVnode->config.vgId, len);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -471,17 +471,20 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, con
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgInitTask(SCtgJob* pJob, CTG_TASK_TYPE type, void* param, int32_t* taskId) {
|
int32_t ctgInitTask(SCtgJob* pJob, CTG_TASK_TYPE type, void* param, int32_t* taskId) {
|
||||||
|
int32_t code = 0;
|
||||||
int32_t tid = atomic_fetch_add_32(&pJob->taskIdx, 1);
|
int32_t tid = atomic_fetch_add_32(&pJob->taskIdx, 1);
|
||||||
|
|
||||||
CTG_LOCK(CTG_WRITE, &pJob->taskLock);
|
CTG_LOCK(CTG_WRITE, &pJob->taskLock);
|
||||||
CTG_ERR_RET((*gCtgAsyncFps[type].initFp)(pJob, tid, param));
|
CTG_ERR_JRET((*gCtgAsyncFps[type].initFp)(pJob, tid, param));
|
||||||
CTG_UNLOCK(CTG_WRITE, &pJob->taskLock);
|
|
||||||
|
|
||||||
if (taskId) {
|
if (taskId) {
|
||||||
*taskId = tid;
|
*taskId = tid;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
_return:
|
||||||
|
CTG_UNLOCK(CTG_WRITE, &pJob->taskLock);
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp,
|
int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp,
|
||||||
|
|
|
@ -2500,6 +2500,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
|
||||||
|
|
||||||
CTG_LOCK(CTG_READ, &pCache->metaLock);
|
CTG_LOCK(CTG_READ, &pCache->metaLock);
|
||||||
if (NULL == pCache->pMeta) {
|
if (NULL == pCache->pMeta) {
|
||||||
|
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
||||||
ctgDebug("tb %s meta not in cache, dbFName:%s", pName->tname, dbFName);
|
ctgDebug("tb %s meta not in cache, dbFName:%s", pName->tname, dbFName);
|
||||||
ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
|
ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
|
||||||
taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
|
taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
|
||||||
|
|
|
@ -136,6 +136,7 @@ typedef struct {
|
||||||
SSchemaWrapper* schema;
|
SSchemaWrapper* schema;
|
||||||
char tbName[TSDB_TABLE_NAME_LEN];
|
char tbName[TSDB_TABLE_NAME_LEN];
|
||||||
int8_t recoverStep;
|
int8_t recoverStep;
|
||||||
|
int8_t recoverScanFinished;
|
||||||
SQueryTableDataCond tableCond;
|
SQueryTableDataCond tableCond;
|
||||||
int64_t fillHistoryVer1;
|
int64_t fillHistoryVer1;
|
||||||
int64_t fillHistoryVer2;
|
int64_t fillHistoryVer2;
|
||||||
|
@ -354,7 +355,6 @@ typedef struct STableMergeScanInfo {
|
||||||
SLimitInfo limitInfo;
|
SLimitInfo limitInfo;
|
||||||
int64_t numOfRows;
|
int64_t numOfRows;
|
||||||
SScanInfo scanInfo;
|
SScanInfo scanInfo;
|
||||||
int32_t scanTimes;
|
|
||||||
SSDataBlock* pResBlock;
|
SSDataBlock* pResBlock;
|
||||||
SSampleExecInfo sample; // sample execution info
|
SSampleExecInfo sample; // sample execution info
|
||||||
SSortExecInfo sortExecInfo;
|
SSortExecInfo sortExecInfo;
|
||||||
|
@ -469,6 +469,11 @@ typedef struct SStreamScanInfo {
|
||||||
SNodeList* pGroupTags;
|
SNodeList* pGroupTags;
|
||||||
SNode* pTagCond;
|
SNode* pTagCond;
|
||||||
SNode* pTagIndexCond;
|
SNode* pTagIndexCond;
|
||||||
|
|
||||||
|
// recover
|
||||||
|
int32_t blockRecoverContiCnt;
|
||||||
|
int32_t blockRecoverTotCnt;
|
||||||
|
|
||||||
} SStreamScanInfo;
|
} SStreamScanInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -688,7 +693,7 @@ void cleanupExprSupp(SExprSupp* pSup);
|
||||||
void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs);
|
void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs);
|
||||||
|
|
||||||
int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize,
|
int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize,
|
||||||
const char* pkey);
|
const char* pkey, void* pState);
|
||||||
void cleanupAggSup(SAggSupporter* pAggSup);
|
void cleanupAggSup(SAggSupporter* pAggSup);
|
||||||
|
|
||||||
void initResultSizeInfo(SResultInfo* pResultInfo, int32_t numOfRows);
|
void initResultSizeInfo(SResultInfo* pResultInfo, int32_t numOfRows);
|
||||||
|
@ -847,6 +852,8 @@ int32_t releaseOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResul
|
||||||
int32_t saveOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult, int32_t resSize);
|
int32_t saveOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult, int32_t resSize);
|
||||||
void getNextIntervalWindow(SInterval* pInterval, STimeWindow* tw, int32_t order);
|
void getNextIntervalWindow(SInterval* pInterval, STimeWindow* tw, int32_t order);
|
||||||
int32_t qAppendTaskStopInfo(SExecTaskInfo* pTaskInfo, SExchangeOpStopInfo* pInfo);
|
int32_t qAppendTaskStopInfo(SExecTaskInfo* pTaskInfo, SExchangeOpStopInfo* pInfo);
|
||||||
|
int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn_t searchFn, TSKEY ekey, int32_t pos,
|
||||||
|
int32_t order, int64_t* pData);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
||||||
|
|
||||||
uint64_t suid = tableListGetSuid(pTableList);
|
uint64_t suid = tableListGetSuid(pTableList);
|
||||||
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, totalTables,
|
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, totalTables,
|
||||||
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader);
|
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader, pTaskInfo->id.str);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, num,
|
tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, num,
|
||||||
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader);
|
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader, pTaskInfo->id.str);
|
||||||
taosArrayClear(pInfo->pUidList);
|
taosArrayClear(pInfo->pUidList);
|
||||||
|
|
||||||
code = tsdbRetrieveCacheRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pUidList);
|
code = tsdbRetrieveCacheRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pUidList);
|
||||||
|
|
|
@ -62,8 +62,8 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp
|
||||||
pEntry->numOfCols = taosArrayGetSize(pInput->pData->pDataBlock);
|
pEntry->numOfCols = taosArrayGetSize(pInput->pData->pDataBlock);
|
||||||
pEntry->dataLen = sizeof(SDeleterRes);
|
pEntry->dataLen = sizeof(SDeleterRes);
|
||||||
|
|
||||||
ASSERT(1 == pEntry->numOfRows);
|
// ASSERT(1 == pEntry->numOfRows);
|
||||||
ASSERT(3 == pEntry->numOfCols);
|
// ASSERT(3 == pEntry->numOfCols);
|
||||||
|
|
||||||
pBuf->useSize = sizeof(SDataCacheEntry);
|
pBuf->useSize = sizeof(SDataCacheEntry);
|
||||||
|
|
||||||
|
@ -167,7 +167,6 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
|
||||||
|
|
||||||
SDataDeleterBuf* pBuf = NULL;
|
SDataDeleterBuf* pBuf = NULL;
|
||||||
taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf);
|
taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf);
|
||||||
ASSERT(NULL != pBuf);
|
|
||||||
memcpy(&pDeleter->nextOutput, pBuf, sizeof(SDataDeleterBuf));
|
memcpy(&pDeleter->nextOutput, pBuf, sizeof(SDataDeleterBuf));
|
||||||
taosFreeQitem(pBuf);
|
taosFreeQitem(pBuf);
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,8 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
|
||||||
|
|
||||||
pBuf->useSize = sizeof(SDataCacheEntry);
|
pBuf->useSize = sizeof(SDataCacheEntry);
|
||||||
pEntry->dataLen = blockEncode(pInput->pData, pEntry->data, numOfCols);
|
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));
|
||||||
|
|
||||||
pBuf->useSize += pEntry->dataLen;
|
pBuf->useSize += pEntry->dataLen;
|
||||||
|
|
||||||
|
@ -162,15 +162,14 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
|
||||||
|
|
||||||
SDataDispatchBuf* pBuf = NULL;
|
SDataDispatchBuf* pBuf = NULL;
|
||||||
taosReadQitem(pDispatcher->pDataBlocks, (void**)&pBuf);
|
taosReadQitem(pDispatcher->pDataBlocks, (void**)&pBuf);
|
||||||
ASSERT(NULL != pBuf);
|
|
||||||
memcpy(&pDispatcher->nextOutput, pBuf, sizeof(SDataDispatchBuf));
|
memcpy(&pDispatcher->nextOutput, pBuf, sizeof(SDataDispatchBuf));
|
||||||
taosFreeQitem(pBuf);
|
taosFreeQitem(pBuf);
|
||||||
|
|
||||||
SDataCacheEntry* pEntry = (SDataCacheEntry*)pDispatcher->nextOutput.pData;
|
SDataCacheEntry* pEntry = (SDataCacheEntry*)pDispatcher->nextOutput.pData;
|
||||||
*pLen = pEntry->dataLen;
|
*pLen = pEntry->dataLen;
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
*pQueryEnd = pDispatcher->queryEnd;
|
*pQueryEnd = pDispatcher->queryEnd;
|
||||||
qDebug("got data len %" PRId64 ", row num %d in sink", *pLen,
|
qDebug("got data len %" PRId64 ", row num %d in sink", *pLen,
|
||||||
|
@ -193,8 +192,8 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
|
||||||
pOutput->numOfCols = pEntry->numOfCols;
|
pOutput->numOfCols = pEntry->numOfCols;
|
||||||
pOutput->compressed = pEntry->compressed;
|
pOutput->compressed = pEntry->compressed;
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
atomic_sub_fetch_64(&pDispatcher->cachedSize, pEntry->dataLen);
|
atomic_sub_fetch_64(&pDispatcher->cachedSize, pEntry->dataLen);
|
||||||
atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen);
|
atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen);
|
||||||
|
|
|
@ -373,7 +373,6 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
pRsp->useconds = htobe64(pRsp->useconds);
|
pRsp->useconds = htobe64(pRsp->useconds);
|
||||||
pRsp->numOfBlocks = htonl(pRsp->numOfBlocks);
|
pRsp->numOfBlocks = htonl(pRsp->numOfBlocks);
|
||||||
|
|
||||||
ASSERT(pRsp != NULL);
|
|
||||||
qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%" PRId64 ", %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks,
|
qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%" PRId64 ", %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks,
|
||||||
pRsp->numOfRows, pExchangeInfo);
|
pRsp->numOfRows, pExchangeInfo);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -936,6 +936,10 @@ int32_t qStreamRestoreParam(qTaskInfo_t tinfo) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
bool qStreamRecoverScanFinished(qTaskInfo_t tinfo) {
|
||||||
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
|
return pTaskInfo->streamInfo.recoverScanFinished;
|
||||||
|
}
|
||||||
|
|
||||||
void* qExtractReaderFromStreamScanner(void* scanner) {
|
void* qExtractReaderFromStreamScanner(void* scanner) {
|
||||||
SStreamScanInfo* pInfo = scanner;
|
SStreamScanInfo* pInfo = scanner;
|
||||||
|
|
|
@ -83,6 +83,7 @@ typedef struct SAggOperatorInfo {
|
||||||
uint64_t groupId;
|
uint64_t groupId;
|
||||||
SGroupResInfo groupResInfo;
|
SGroupResInfo groupResInfo;
|
||||||
SExprSupp scalarExprSup;
|
SExprSupp scalarExprSup;
|
||||||
|
bool groupKeyOptimized;
|
||||||
} SAggOperatorInfo;
|
} SAggOperatorInfo;
|
||||||
|
|
||||||
static void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock);
|
static void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock);
|
||||||
|
@ -99,11 +100,11 @@ static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SC
|
||||||
int32_t status);
|
int32_t status);
|
||||||
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
|
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
|
||||||
bool createDummyCol);
|
bool createDummyCol);
|
||||||
|
static int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
|
||||||
|
SGroupResInfo* pGroupResInfo);
|
||||||
|
|
||||||
void setOperatorCompleted(SOperatorInfo* pOperator) {
|
void setOperatorCompleted(SOperatorInfo* pOperator) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
ASSERT(pOperator->pTaskInfo != NULL);
|
|
||||||
|
|
||||||
pOperator->cost.totalCost = (taosGetTimestampUs() - pOperator->pTaskInfo->cost.start) / 1000.0;
|
pOperator->cost.totalCost = (taosGetTimestampUs() - pOperator->pTaskInfo->cost.start) / 1000.0;
|
||||||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
||||||
}
|
}
|
||||||
|
@ -139,9 +140,6 @@ SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn,
|
||||||
return fpSet;
|
return fpSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
|
|
||||||
SGroupResInfo* pGroupResInfo);
|
|
||||||
|
|
||||||
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize) {
|
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize) {
|
||||||
SFilePage* pData = NULL;
|
SFilePage* pData = NULL;
|
||||||
|
|
||||||
|
@ -245,7 +243,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
|
||||||
}
|
}
|
||||||
|
|
||||||
// a new buffer page for each table. Needs to opt this design
|
// a new buffer page for each table. Needs to opt this design
|
||||||
static int32_t addNewWindowResultBuf(SResultRow* pWindowRes, SDiskbasedBuf* pResultBuf, int32_t tid, uint32_t size) {
|
static int32_t addNewWindowResultBuf(SResultRow* pWindowRes, SDiskbasedBuf* pResultBuf, uint32_t size) {
|
||||||
if (pWindowRes->pageId != -1) {
|
if (pWindowRes->pageId != -1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -525,7 +523,7 @@ bool functionNeedToExecute(SqlFunctionCtx* pCtx) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, int32_t type,
|
static int32_t doCreateConstantValColumnSMAInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, int32_t type,
|
||||||
int32_t paramIndex, int32_t numOfRows) {
|
int32_t paramIndex, int32_t numOfRows) {
|
||||||
if (pInput->pData[paramIndex] == NULL) {
|
if (pInput->pData[paramIndex] == NULL) {
|
||||||
pInput->pData[paramIndex] = taosMemoryCalloc(1, sizeof(SColumnInfoData));
|
pInput->pData[paramIndex] = taosMemoryCalloc(1, sizeof(SColumnInfoData));
|
||||||
|
@ -549,8 +547,6 @@ static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SF
|
||||||
da = pInput->pColumnDataAgg[paramIndex];
|
da = pInput->pColumnDataAgg[paramIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(!IS_VAR_DATA_TYPE(type));
|
|
||||||
|
|
||||||
if (type == TSDB_DATA_TYPE_BIGINT) {
|
if (type == TSDB_DATA_TYPE_BIGINT) {
|
||||||
int64_t v = pFuncParam->param.i;
|
int64_t v = pFuncParam->param.i;
|
||||||
*da = (SColumnDataAgg){.numOfNull = 0, .min = v, .max = v, .sum = v * numOfRows};
|
*da = (SColumnDataAgg){.numOfNull = 0, .min = v, .max = v, .sum = v * numOfRows};
|
||||||
|
@ -571,7 +567,7 @@ static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SF
|
||||||
} else if (type == TSDB_DATA_TYPE_TIMESTAMP) {
|
} else if (type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
qError("invalid constant type for sma info");
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -601,7 +597,7 @@ void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pB
|
||||||
// the data in the corresponding SColumnInfoData will not be used.
|
// the data in the corresponding SColumnInfoData will not be used.
|
||||||
pInput->pData[j] = taosArrayGet(pBlock->pDataBlock, slotId);
|
pInput->pData[j] = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
} else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) {
|
} else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) {
|
||||||
doCreateConstantValColumnAggInfo(pInput, pFuncParam, pFuncParam->param.nType, j, pBlock->info.rows);
|
doCreateConstantValColumnSMAInfo(pInput, pFuncParam, pFuncParam->param.nType, j, pBlock->info.rows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -609,9 +605,7 @@ void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isTaskKilled(SExecTaskInfo* pTaskInfo) {
|
bool isTaskKilled(SExecTaskInfo* pTaskInfo) { return (0 != pTaskInfo->code) ? true : false; }
|
||||||
return (0 != pTaskInfo->code) ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTaskKilled(SExecTaskInfo* pTaskInfo, int32_t rspCode) { pTaskInfo->code = rspCode; }
|
void setTaskKilled(SExecTaskInfo* pTaskInfo, int32_t rspCode) { pTaskInfo->code = rspCode; }
|
||||||
|
|
||||||
|
@ -916,8 +910,7 @@ void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uin
|
||||||
* all group belong to one result set, and each group result has different group id so set the id to be one
|
* all group belong to one result set, and each group result has different group id so set the id to be one
|
||||||
*/
|
*/
|
||||||
if (pResultRow->pageId == -1) {
|
if (pResultRow->pageId == -1) {
|
||||||
int32_t ret =
|
int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->aggSup.pResultBuf, pAggInfo->binfo.pRes->info.rowSize);
|
||||||
addNewWindowResultBuf(pResultRow, pAggInfo->aggSup.pResultBuf, groupId, pAggInfo->binfo.pRes->info.rowSize);
|
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1360,6 +1353,11 @@ static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBloc
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SAggOperatorInfo* pAggInfo = pOperator->info;
|
||||||
|
if (pAggInfo->groupKeyOptimized) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||||
if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_PARTITION ||
|
if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_PARTITION ||
|
||||||
(downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN &&
|
(downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN &&
|
||||||
|
@ -1487,7 +1485,6 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyDataBlockForEmptyInput(blockAllocated, &pBlock);
|
destroyDataBlockForEmptyInput(blockAllocated, &pBlock);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// the downstream operator may return with error code, so let's check the code before generating results.
|
// the downstream operator may return with error code, so let's check the code before generating results.
|
||||||
|
@ -1579,8 +1576,7 @@ void destroyOperatorInfo(SOperatorInfo* pOperator) {
|
||||||
// each operator should be set their own function to return total cost buffer
|
// each operator should be set their own function to return total cost buffer
|
||||||
int32_t optrDefaultBufFn(SOperatorInfo* pOperator) {
|
int32_t optrDefaultBufFn(SOperatorInfo* pOperator) {
|
||||||
if (pOperator->blocking) {
|
if (pOperator->blocking) {
|
||||||
ASSERT(0);
|
return -1;
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1643,7 +1639,7 @@ void cleanupAggSup(SAggSupporter* pAggSup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize,
|
int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize,
|
||||||
const char* pkey) {
|
const char* pkey, void* pState) {
|
||||||
int32_t code = initExprSupp(pSup, pExprInfo, numOfCols);
|
int32_t code = initExprSupp(pSup, pExprInfo, numOfCols);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -1655,8 +1651,14 @@ int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
if (pState) {
|
||||||
|
pSup->pCtx[i].saveHandle.pBuf = NULL;
|
||||||
|
pSup->pCtx[i].saveHandle.pState = pState;
|
||||||
|
pSup->pCtx[i].exprIdx = i;
|
||||||
|
} else {
|
||||||
pSup->pCtx[i].saveHandle.pBuf = pAggSup->pResultBuf;
|
pSup->pCtx[i].saveHandle.pBuf = pAggSup->pResultBuf;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1740,7 +1742,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN
|
||||||
|
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num);
|
SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num);
|
||||||
int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str);
|
int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str,
|
||||||
|
pTaskInfo->streamInfo.pState);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -1762,11 +1765,13 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->binfo.mergeResultBlock = pAggNode->mergeDataBlock;
|
pInfo->binfo.mergeResultBlock = pAggNode->mergeDataBlock;
|
||||||
|
pInfo->groupKeyOptimized = pAggNode->groupKeyOptimized;
|
||||||
pInfo->groupId = UINT64_MAX;
|
pInfo->groupId = UINT64_MAX;
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, true, OP_NOT_OPENED, pInfo,
|
setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, true, OP_NOT_OPENED, pInfo,
|
||||||
pTaskInfo);
|
pTaskInfo);
|
||||||
pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, optrDefaultBufFn, NULL);
|
pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo,
|
||||||
|
optrDefaultBufFn, 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;
|
||||||
|
@ -2207,7 +2212,6 @@ static int32_t extractTbscanInStreamOpTree(SOperatorInfo* pOperator, STableScanI
|
||||||
return extractTbscanInStreamOpTree(pOperator->pDownstream[0], ppInfo);
|
return extractTbscanInStreamOpTree(pOperator->pDownstream[0], ppInfo);
|
||||||
} else {
|
} else {
|
||||||
SStreamScanInfo* pInfo = pOperator->info;
|
SStreamScanInfo* pInfo = pOperator->info;
|
||||||
ASSERT(pInfo->pTableScanOp->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN);
|
|
||||||
*ppInfo = pInfo->pTableScanOp->info;
|
*ppInfo = pInfo->pTableScanOp->info;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2219,13 +2223,11 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) {
|
||||||
*ppNode = (STableScanPhysiNode*)pNode;
|
*ppNode = (STableScanPhysiNode*)pNode;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
|
||||||
terrno = TSDB_CODE_APP_ERROR;
|
terrno = TSDB_CODE_APP_ERROR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (LIST_LENGTH(pNode->pChildren) != 1) {
|
if (LIST_LENGTH(pNode->pChildren) != 1) {
|
||||||
ASSERT(0);
|
|
||||||
terrno = TSDB_CODE_APP_ERROR;
|
terrno = TSDB_CODE_APP_ERROR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -2235,32 +2237,6 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
int32_t rebuildReader(SOperatorInfo* pOperator, SSubplan* plan, SReadHandle* pHandle, int64_t uid, int64_t ts) {
|
|
||||||
STableScanInfo* pTableScanInfo = NULL;
|
|
||||||
if (extractTbscanInStreamOpTree(pOperator, &pTableScanInfo) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
STableScanPhysiNode* pNode = NULL;
|
|
||||||
if (extractTableScanNode(plan->pNode, &pNode) < 0) {
|
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
tsdbReaderClose(pTableScanInfo->dataReader);
|
|
||||||
|
|
||||||
STableListInfo info = {0};
|
|
||||||
pTableScanInfo->dataReader = doCreateDataReader(pNode, pHandle, &info, NULL);
|
|
||||||
if (pTableScanInfo->dataReader == NULL) {
|
|
||||||
ASSERT(0);
|
|
||||||
qError("failed to create data reader");
|
|
||||||
return TSDB_CODE_APP_ERROR;
|
|
||||||
}
|
|
||||||
// TODO: set uid and ts to data reader
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle) {
|
int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle) {
|
||||||
SExecTaskInfo* pTask = *(SExecTaskInfo**)pTaskInfo;
|
SExecTaskInfo* pTask = *(SExecTaskInfo**)pTaskInfo;
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,7 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey);
|
taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey);
|
||||||
} else {
|
} else {
|
||||||
|
pBlock->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pBlock, pInfo->primarySrcSlotId);
|
blockDataUpdateTsWindow(pBlock, pInfo->primarySrcSlotId);
|
||||||
|
|
||||||
blockDataCleanup(pInfo->pRes);
|
blockDataCleanup(pInfo->pRes);
|
||||||
|
@ -170,6 +171,7 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
|
||||||
// Fill the previous group data block, before handle the data block of new group.
|
// Fill the previous group data block, before handle the data block of new group.
|
||||||
// Close the fill operation for previous group data block
|
// Close the fill operation for previous group data block
|
||||||
taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey);
|
taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey);
|
||||||
|
pInfo->pFillInfo->prev.key = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -458,7 +458,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode*
|
||||||
|
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num);
|
SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num);
|
||||||
code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, pInfo->groupKeyLen, pTaskInfo->id.str);
|
code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, pInfo->groupKeyLen, pTaskInfo->id.str,
|
||||||
|
pTaskInfo->streamInfo.pState);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,13 +42,17 @@ typedef struct SJoinOperatorInfo {
|
||||||
static void setJoinColumnInfo(SColumnInfo* pColumn, const SColumnNode* pColumnNode);
|
static void setJoinColumnInfo(SColumnInfo* pColumn, const SColumnNode* pColumnNode);
|
||||||
static SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator);
|
static SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator);
|
||||||
static void destroyMergeJoinOperator(void* param);
|
static void destroyMergeJoinOperator(void* param);
|
||||||
static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDownstream, int32_t numOfDownstream,
|
static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDownstream, int32_t num,
|
||||||
SSortMergeJoinPhysiNode* pJoinNode);
|
SSortMergeJoinPhysiNode* pJoinNode, const char* idStr);
|
||||||
|
|
||||||
static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDownstream, int32_t numOfDownstream,
|
static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDownstream, int32_t num,
|
||||||
SSortMergeJoinPhysiNode* pJoinNode) {
|
SSortMergeJoinPhysiNode* pJoinNode, const char* idStr) {
|
||||||
SNode* pMergeCondition = pJoinNode->pMergeCondition;
|
SNode* pMergeCondition = pJoinNode->pMergeCondition;
|
||||||
if (nodeType(pMergeCondition) == QUERY_NODE_OPERATOR) {
|
if (nodeType(pMergeCondition) != QUERY_NODE_OPERATOR) {
|
||||||
|
qError("not support this in join operator, %s", idStr);
|
||||||
|
return; // do not handle this
|
||||||
|
}
|
||||||
|
|
||||||
SOperatorNode* pNode = (SOperatorNode*)pMergeCondition;
|
SOperatorNode* pNode = (SOperatorNode*)pMergeCondition;
|
||||||
SColumnNode* col1 = (SColumnNode*)pNode->pLeft;
|
SColumnNode* col1 = (SColumnNode*)pNode->pLeft;
|
||||||
SColumnNode* col2 = (SColumnNode*)pNode->pRight;
|
SColumnNode* col2 = (SColumnNode*)pNode->pRight;
|
||||||
|
@ -71,9 +75,7 @@ static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDown
|
||||||
}
|
}
|
||||||
setJoinColumnInfo(&pInfo->leftCol, leftTsCol);
|
setJoinColumnInfo(&pInfo->leftCol, leftTsCol);
|
||||||
setJoinColumnInfo(&pInfo->rightCol, rightTsCol);
|
setJoinColumnInfo(&pInfo->rightCol, rightTsCol);
|
||||||
} else {
|
}
|
||||||
ASSERT(false);
|
|
||||||
}}
|
|
||||||
|
|
||||||
SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream,
|
SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream,
|
||||||
SSortMergeJoinPhysiNode* pJoinNode, SExecTaskInfo* pTaskInfo) {
|
SSortMergeJoinPhysiNode* pJoinNode, SExecTaskInfo* pTaskInfo) {
|
||||||
|
@ -97,7 +99,7 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
|
||||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||||
|
|
||||||
extractTimeCondition(pInfo, pDownstream, numOfDownstream, pJoinNode);
|
extractTimeCondition(pInfo, pDownstream, numOfDownstream, pJoinNode, GET_TASKID(pTaskInfo));
|
||||||
|
|
||||||
if (pJoinNode->pOnConditions != NULL && pJoinNode->node.pConditions != NULL) {
|
if (pJoinNode->pOnConditions != NULL && pJoinNode->node.pConditions != NULL) {
|
||||||
pInfo->pCondAfterMerge = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
pInfo->pCondAfterMerge = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||||
|
@ -364,8 +366,6 @@ static bool mergeJoinGetNextTimestamp(SOperatorInfo* pOperator, int64_t* pLeftTs
|
||||||
char* pRightVal = colDataGetData(pRightCol, pJoinInfo->rightPos);
|
char* pRightVal = colDataGetData(pRightCol, pJoinInfo->rightPos);
|
||||||
*pRightTs = *(int64_t*)pRightVal;
|
*pRightTs = *(int64_t*)pRightVal;
|
||||||
|
|
||||||
ASSERT(pLeftCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
|
||||||
ASSERT(pRightCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
||||||
}
|
}
|
||||||
|
|
||||||
initResultSizeInfo(&pOperator->resultInfo, numOfRows);
|
initResultSizeInfo(&pOperator->resultInfo, numOfRows);
|
||||||
code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str,
|
||||||
|
pTaskInfo->streamInfo.pState);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +318,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
if (pProjectInfo->mergeDataBlocks) {
|
if (pProjectInfo->mergeDataBlocks) {
|
||||||
if (pRes->info.rows > 0) {
|
if (pRes->info.rows > 0) {
|
||||||
pFinalRes->info.id.groupId = pRes->info.id.groupId;
|
pFinalRes->info.id.groupId = 0; // clear groupId
|
||||||
pFinalRes->info.version = pRes->info.version;
|
pFinalRes->info.version = pRes->info.version;
|
||||||
|
|
||||||
// continue merge data, ignore the group id
|
// continue merge data, ignore the group id
|
||||||
|
@ -402,7 +403,8 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
|
||||||
initResultSizeInfo(&pOperator->resultInfo, numOfRows);
|
initResultSizeInfo(&pOperator->resultInfo, numOfRows);
|
||||||
blockDataEnsureCapacity(pResBlock, numOfRows);
|
blockDataEnsureCapacity(pResBlock, numOfRows);
|
||||||
|
|
||||||
int32_t code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, numOfExpr, keyBufSize, pTaskInfo->id.str);
|
int32_t code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, numOfExpr, keyBufSize, pTaskInfo->id.str,
|
||||||
|
pTaskInfo->streamInfo.pState);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,30 +232,6 @@ static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock,
|
||||||
if (!allColumnsHaveAgg) {
|
if (!allColumnsHaveAgg) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
// if (allColumnsHaveAgg == true) {
|
|
||||||
int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
|
||||||
|
|
||||||
// todo create this buffer during creating operator
|
|
||||||
if (pBlock->pBlockAgg == NULL) {
|
|
||||||
pBlock->pBlockAgg = taosMemoryCalloc(numOfCols, POINTER_BYTES);
|
|
||||||
if (pBlock->pBlockAgg == NULL) {
|
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t num = taosArrayGetSize(pTableScanInfo->matchInfo.pList);
|
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
|
||||||
SColMatchItem* pColMatchInfo = taosArrayGet(pTableScanInfo->matchInfo.pList, i);
|
|
||||||
if (!pColMatchInfo->needOutput) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBlock->pBlockAgg[pColMatchInfo->dstSlotId] = pColAgg[i];
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -768,8 +744,8 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
||||||
tableListGetGroupList(pTaskInfo->pTableInfoList, pInfo->currentGroupId, &pList, &num);
|
tableListGetGroupList(pTaskInfo->pTableInfoList, pInfo->currentGroupId, &pList, &num);
|
||||||
ASSERT(pInfo->base.dataReader == NULL);
|
ASSERT(pInfo->base.dataReader == NULL);
|
||||||
|
|
||||||
int32_t code = tsdbReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, pList, num,
|
int32_t code = tsdbReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, pList, num, pInfo->pResBlock,
|
||||||
pInfo->pResBlock, (STsdbReader**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo));
|
(STsdbReader**)&pInfo->base.dataReader, 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);
|
||||||
}
|
}
|
||||||
|
@ -986,8 +962,8 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
|
||||||
|
|
||||||
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
||||||
STsdbReader* pReader = NULL;
|
STsdbReader* pReader = NULL;
|
||||||
int32_t code = tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &cond, &tblInfo, 1, pBlock, (STsdbReader**)&pReader,
|
int32_t code = tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &cond, &tblInfo, 1, pBlock,
|
||||||
GET_TASKID(pTaskInfo));
|
(STsdbReader**)&pReader, GET_TASKID(pTaskInfo));
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
|
@ -1753,11 +1729,18 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
||||||
pTSInfo->scanTimes = 0;
|
pTSInfo->scanTimes = 0;
|
||||||
pTSInfo->currentGroupId = -1;
|
pTSInfo->currentGroupId = -1;
|
||||||
pTaskInfo->streamInfo.recoverStep = STREAM_RECOVER_STEP__SCAN;
|
pTaskInfo->streamInfo.recoverStep = STREAM_RECOVER_STEP__SCAN;
|
||||||
|
pTaskInfo->streamInfo.recoverScanFinished = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__SCAN) {
|
if (pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__SCAN) {
|
||||||
|
if (pInfo->blockRecoverContiCnt > 100) {
|
||||||
|
pInfo->blockRecoverTotCnt += pInfo->blockRecoverContiCnt;
|
||||||
|
pInfo->blockRecoverContiCnt = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
SSDataBlock* pBlock = doTableScan(pInfo->pTableScanOp);
|
SSDataBlock* pBlock = doTableScan(pInfo->pTableScanOp);
|
||||||
if (pBlock != NULL) {
|
if (pBlock != NULL) {
|
||||||
|
pInfo->blockRecoverContiCnt++;
|
||||||
calBlockTbName(pInfo, pBlock);
|
calBlockTbName(pInfo, pBlock);
|
||||||
if (pInfo->pUpdateInfo) {
|
if (pInfo->pUpdateInfo) {
|
||||||
TSKEY maxTs = updateInfoFillBlockData(pInfo->pUpdateInfo, pBlock, pInfo->primaryTsIndex);
|
TSKEY maxTs = updateInfoFillBlockData(pInfo->pUpdateInfo, pBlock, pInfo->primaryTsIndex);
|
||||||
|
@ -1775,6 +1758,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
||||||
pTSInfo->base.cond.startVersion = -1;
|
pTSInfo->base.cond.startVersion = -1;
|
||||||
pTSInfo->base.cond.endVersion = -1;
|
pTSInfo->base.cond.endVersion = -1;
|
||||||
|
|
||||||
|
pTaskInfo->streamInfo.recoverScanFinished = true;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2206,6 +2190,7 @@ static void destroyStreamScanOperatorInfo(void* param) {
|
||||||
|
|
||||||
SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond,
|
SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond,
|
||||||
SExecTaskInfo* pTaskInfo) {
|
SExecTaskInfo* pTaskInfo) {
|
||||||
|
SArray* pColIds = NULL;
|
||||||
SStreamScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamScanInfo));
|
SStreamScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamScanInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
|
|
||||||
|
@ -2228,7 +2213,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfOutput = taosArrayGetSize(pInfo->matchInfo.pList);
|
int32_t numOfOutput = taosArrayGetSize(pInfo->matchInfo.pList);
|
||||||
SArray* pColIds = taosArrayInit(numOfOutput, sizeof(int16_t));
|
pColIds = taosArrayInit(numOfOutput, sizeof(int16_t));
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
SColMatchItem* id = taosArrayGet(pInfo->matchInfo.pList, i);
|
SColMatchItem* id = taosArrayGet(pInfo->matchInfo.pList, i);
|
||||||
|
|
||||||
|
@ -2285,7 +2270,8 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
if (pHandle->initTableReader) {
|
if (pHandle->initTableReader) {
|
||||||
pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER;
|
pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER;
|
||||||
pTSInfo->base.dataReader = NULL;
|
pTSInfo->base.dataReader = NULL;
|
||||||
code = tsdbReaderOpen(pHandle->vnode, &pTSInfo->base.cond, pList, num, pTSInfo->pResBlock, &pTSInfo->base.dataReader, NULL);
|
code = tsdbReaderOpen(pHandle->vnode, &pTSInfo->base.cond, pList, num, pTSInfo->pResBlock,
|
||||||
|
&pTSInfo->base.dataReader, NULL);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
destroyTableScanOperatorInfo(pTableScanOp);
|
destroyTableScanOperatorInfo(pTableScanOp);
|
||||||
|
@ -2324,6 +2310,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
memcpy(&pTaskInfo->streamInfo.tableCond, &pTSInfo->base.cond, sizeof(SQueryTableDataCond));
|
memcpy(&pTaskInfo->streamInfo.tableCond, &pTSInfo->base.cond, sizeof(SQueryTableDataCond));
|
||||||
} else {
|
} else {
|
||||||
taosArrayDestroy(pColIds);
|
taosArrayDestroy(pColIds);
|
||||||
|
pColIds = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the pseduo columns info
|
// create the pseduo columns info
|
||||||
|
@ -2355,7 +2342,8 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
||||||
|
|
||||||
__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(optrDummyOpenFn, nextFn, NULL, destroyStreamScanOperatorInfo, optrDefaultBufFn, NULL);
|
pOperator->fpSet =
|
||||||
|
createOperatorFpSet(optrDummyOpenFn, nextFn, NULL, destroyStreamScanOperatorInfo, optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
|
@ -2492,7 +2480,8 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTagScan, NULL, destroyTagScanOperatorInfo, optrDefaultBufFn, NULL);
|
pOperator->fpSet =
|
||||||
|
createOperatorFpSet(optrDummyOpenFn, doTagScan, NULL, destroyTagScanOperatorInfo, optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
|
@ -2517,7 +2506,8 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
|
||||||
void* p = tableListGetInfo(pTaskInfo->pTableInfoList, readIdx + pInfo->tableStartIndex);
|
void* p = tableListGetInfo(pTaskInfo->pTableInfoList, readIdx + pInfo->tableStartIndex);
|
||||||
SReadHandle* pHandle = &pInfo->base.readHandle;
|
SReadHandle* pHandle = &pInfo->base.readHandle;
|
||||||
|
|
||||||
int32_t code = tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, pBlock, &pInfo->base.dataReader, GET_TASKID(pTaskInfo));
|
int32_t code =
|
||||||
|
tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, pBlock, &pInfo->base.dataReader, GET_TASKID(pTaskInfo));
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
@ -3041,8 +3031,8 @@ SOperatorInfo* createTableCountScanOperatorInfo(SReadHandle* readHandle, STableC
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "TableCountScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN, false, OP_NOT_OPENED,
|
setOperatorInfo(pOperator, "TableCountScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN, false, OP_NOT_OPENED,
|
||||||
pInfo, pTaskInfo);
|
pInfo, pTaskInfo);
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTableCountScan, NULL, destoryTableCountScanOperator,
|
||||||
createOperatorFpSet(optrDummyOpenFn, doTableCountScan, NULL, destoryTableCountScanOperator, optrDefaultBufFn, NULL);
|
optrDefaultBufFn, NULL);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
|
|
|
@ -47,12 +47,14 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
|
||||||
SDataBlockDescNode* pDescNode = pSortNode->node.pOutputDataBlockDesc;
|
SDataBlockDescNode* pDescNode = pSortNode->node.pOutputDataBlockDesc;
|
||||||
|
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
SSDataBlock* pResBlock = createDataBlockFromDescNode(pDescNode);
|
|
||||||
SExprInfo* pExprInfo = createExprInfo(pSortNode->pExprs, NULL, &numOfCols);
|
SExprInfo* pExprInfo = createExprInfo(pSortNode->pExprs, NULL, &numOfCols);
|
||||||
|
|
||||||
int32_t numOfOutputCols = 0;
|
int32_t numOfOutputCols = 0;
|
||||||
int32_t code =
|
int32_t code =
|
||||||
extractColMatchInfo(pSortNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID, &pInfo->matchInfo);
|
extractColMatchInfo(pSortNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID, &pInfo->matchInfo);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
pOperator->exprSupp.pCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pOperator->exprSupp.rowEntryInfoOffset);
|
pOperator->exprSupp.pCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pOperator->exprSupp.rowEntryInfoOffset);
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 1024);
|
initResultSizeInfo(&pOperator->resultInfo, 1024);
|
||||||
|
@ -61,7 +63,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->binfo.pRes = pResBlock;
|
pInfo->binfo.pRes = createDataBlockFromDescNode(pDescNode);
|
||||||
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);
|
||||||
|
|
||||||
|
@ -86,7 +88,10 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
taosMemoryFree(pInfo);
|
if (pInfo != NULL) {
|
||||||
|
destroySortOperatorInfo(pInfo);
|
||||||
|
}
|
||||||
|
|
||||||
taosMemoryFree(pOperator);
|
taosMemoryFree(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -139,7 +144,6 @@ SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, i
|
||||||
int32_t numOfCols = taosArrayGetSize(pColMatchInfo);
|
int32_t numOfCols = taosArrayGetSize(pColMatchInfo);
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColMatchItem* pmInfo = taosArrayGet(pColMatchInfo, i);
|
SColMatchItem* pmInfo = taosArrayGet(pColMatchInfo, i);
|
||||||
// ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID);
|
|
||||||
|
|
||||||
SColumnInfoData* pSrc = taosArrayGet(p->pDataBlock, pmInfo->srcSlotId);
|
SColumnInfoData* pSrc = taosArrayGet(p->pDataBlock, pmInfo->srcSlotId);
|
||||||
SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->dstSlotId);
|
SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->dstSlotId);
|
||||||
|
@ -272,7 +276,6 @@ void destroySortOperatorInfo(void* param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) {
|
int32_t getExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) {
|
||||||
ASSERT(pOptr != NULL);
|
|
||||||
SSortExecInfo* pInfo = taosMemoryCalloc(1, sizeof(SSortExecInfo));
|
SSortExecInfo* pInfo = taosMemoryCalloc(1, sizeof(SSortExecInfo));
|
||||||
|
|
||||||
SSortOperatorInfo* pOperatorInfo = (SSortOperatorInfo*)pOptr->info;
|
SSortOperatorInfo* pOperatorInfo = (SSortOperatorInfo*)pOptr->info;
|
||||||
|
@ -329,7 +332,6 @@ SSDataBlock* getGroupSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlo
|
||||||
int32_t numOfCols = taosArrayGetSize(pColMatchInfo);
|
int32_t numOfCols = taosArrayGetSize(pColMatchInfo);
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColMatchItem* pmInfo = taosArrayGet(pColMatchInfo, i);
|
SColMatchItem* pmInfo = taosArrayGet(pColMatchInfo, i);
|
||||||
// ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID);
|
|
||||||
|
|
||||||
SColumnInfoData* pSrc = taosArrayGet(p->pDataBlock, pmInfo->srcSlotId);
|
SColumnInfoData* pSrc = taosArrayGet(p->pDataBlock, pmInfo->srcSlotId);
|
||||||
SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->dstSlotId);
|
SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->dstSlotId);
|
||||||
|
@ -746,7 +748,6 @@ void destroyMultiwayMergeOperatorInfo(void* param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getMultiwayMergeExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) {
|
int32_t getMultiwayMergeExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) {
|
||||||
ASSERT(pOptr != NULL);
|
|
||||||
SSortExecInfo* pSortExecInfo = taosMemoryCalloc(1, sizeof(SSortExecInfo));
|
SSortExecInfo* pSortExecInfo = taosMemoryCalloc(1, sizeof(SSortExecInfo));
|
||||||
|
|
||||||
SMultiwayMergeOperatorInfo* pInfo = (SMultiwayMergeOperatorInfo*)pOptr->info;
|
SMultiwayMergeOperatorInfo* pInfo = (SMultiwayMergeOperatorInfo*)pOptr->info;
|
||||||
|
|
|
@ -65,6 +65,8 @@ typedef struct SSysTableScanInfo {
|
||||||
SSDataBlock* pRes;
|
SSDataBlock* pRes;
|
||||||
int64_t numOfBlocks; // extract basic running information.
|
int64_t numOfBlocks; // extract basic running information.
|
||||||
SLoadRemoteDataInfo loadInfo;
|
SLoadRemoteDataInfo loadInfo;
|
||||||
|
|
||||||
|
int32_t tbnameSlotId;
|
||||||
} SSysTableScanInfo;
|
} SSysTableScanInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -346,6 +348,11 @@ static int32_t optSysTabFilteImpl(void* arg, SNode* cond, SArray* result);
|
||||||
static int32_t optSysCheckOper(SNode* pOpear);
|
static int32_t optSysCheckOper(SNode* pOpear);
|
||||||
static int32_t optSysMergeRslt(SArray* mRslt, SArray* rslt);
|
static int32_t optSysMergeRslt(SArray* mRslt, SArray* rslt);
|
||||||
|
|
||||||
|
static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableScanInfo* pInfo, const char* name,
|
||||||
|
SExecTaskInfo* pTaskInfo);
|
||||||
|
void extractTbnameSlotId(SSysTableScanInfo* pInfo, const SScanPhysiNode* pScanNode);
|
||||||
|
static SSDataBlock* sysTableScanFillTbName(SOperatorInfo* pOperator, const SSysTableScanInfo* pInfo,
|
||||||
|
const char* name, SSDataBlock* pBlock);
|
||||||
__optSysFilter optSysGetFilterFunc(int32_t ctype, bool* reverse) {
|
__optSysFilter optSysGetFilterFunc(int32_t ctype, bool* reverse) {
|
||||||
if (ctype == OP_TYPE_LOWER_EQUAL || ctype == OP_TYPE_LOWER_THAN) {
|
if (ctype == OP_TYPE_LOWER_EQUAL || ctype == OP_TYPE_LOWER_THAN) {
|
||||||
*reverse = true;
|
*reverse = true;
|
||||||
|
@ -1309,15 +1316,44 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
|
||||||
getDBNameFromCondition(pInfo->pCondition, dbName);
|
getDBNameFromCondition(pInfo->pCondition, dbName);
|
||||||
sprintf(pInfo->req.db, "%d.%s", pInfo->accountId, dbName);
|
sprintf(pInfo->req.db, "%d.%s", pInfo->accountId, dbName);
|
||||||
}
|
}
|
||||||
|
SSDataBlock* pBlock = NULL;
|
||||||
if (strncasecmp(name, TSDB_INS_TABLE_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
if (strncasecmp(name, TSDB_INS_TABLE_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
return sysTableScanUserTables(pOperator);
|
pBlock = sysTableScanUserTables(pOperator);
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TAGS, TSDB_TABLE_FNAME_LEN) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_TAGS, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
return sysTableScanUserTags(pOperator);
|
pBlock = sysTableScanUserTags(pOperator);
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, TSDB_TABLE_FNAME_LEN) == 0 && pInfo->showRewrite &&
|
} else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, TSDB_TABLE_FNAME_LEN) == 0 && pInfo->showRewrite &&
|
||||||
IS_SYS_DBNAME(dbName)) {
|
IS_SYS_DBNAME(dbName)) {
|
||||||
return sysTableScanUserSTables(pOperator);
|
pBlock = sysTableScanUserSTables(pOperator);
|
||||||
} else { // load the meta from mnode of the given epset
|
} else { // load the meta from mnode of the given epset
|
||||||
|
pBlock = sysTableScanFromMNode(pOperator, pInfo, name, pTaskInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sysTableScanFillTbName(pOperator, pInfo, name, pBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* sysTableScanFillTbName(SOperatorInfo* pOperator, const SSysTableScanInfo* pInfo,
|
||||||
|
const char* name, SSDataBlock* pBlock) {
|
||||||
|
if (pBlock != NULL) {
|
||||||
|
if (pInfo->tbnameSlotId != -1) {
|
||||||
|
SColumnInfoData* pColumnInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, pInfo->tbnameSlotId);
|
||||||
|
char varTbName[TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
memcpy(varDataVal(varTbName), name, strlen(name));
|
||||||
|
varDataSetLen(varTbName, strlen(name));
|
||||||
|
for (int i = 0; i < pBlock->info.rows; ++i) {
|
||||||
|
colDataAppend(pColumnInfoData, i, varTbName, NULL);
|
||||||
|
}
|
||||||
|
doFilterResult(pBlock, pOperator->exprSupp.pFilterInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pBlock && pBlock->info.rows != 0) {
|
||||||
|
return pBlock;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableScanInfo* pInfo, const char* name,
|
||||||
|
SExecTaskInfo* pTaskInfo) {
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1388,7 +1424,6 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode* pScanPhyNode,
|
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode* pScanPhyNode,
|
||||||
const char* pUser, SExecTaskInfo* pTaskInfo) {
|
const char* pUser, SExecTaskInfo* pTaskInfo) {
|
||||||
|
@ -1407,6 +1442,8 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extractTbnameSlotId(pInfo, pScanNode);
|
||||||
|
|
||||||
pInfo->accountId = pScanPhyNode->accountId;
|
pInfo->accountId = pScanPhyNode->accountId;
|
||||||
pInfo->pUser = taosMemoryStrDup((void*)pUser);
|
pInfo->pUser = taosMemoryStrDup((void*)pUser);
|
||||||
pInfo->sysInfo = pScanPhyNode->sysInfo;
|
pInfo->sysInfo = pScanPhyNode->sysInfo;
|
||||||
|
@ -1449,6 +1486,26 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void extractTbnameSlotId(SSysTableScanInfo* pInfo, const SScanPhysiNode* pScanNode) {
|
||||||
|
pInfo->tbnameSlotId = -1;
|
||||||
|
if (pScanNode->pScanPseudoCols != NULL) {
|
||||||
|
SNode* pNode = NULL;
|
||||||
|
FOREACH(pNode, pScanNode->pScanPseudoCols) {
|
||||||
|
STargetNode* pTargetNode = NULL;
|
||||||
|
if (nodeType(pNode) == QUERY_NODE_TARGET) {
|
||||||
|
pTargetNode = (STargetNode*)pNode;
|
||||||
|
SNode* expr = pTargetNode->pExpr;
|
||||||
|
if (nodeType(expr) == QUERY_NODE_FUNCTION) {
|
||||||
|
SFunctionNode* pFuncNode = (SFunctionNode*)expr;
|
||||||
|
if (pFuncNode->funcType == FUNCTION_TYPE_TBNAME) {
|
||||||
|
pInfo->tbnameSlotId = pTargetNode->slotId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void destroySysScanOperator(void* param) {
|
void destroySysScanOperator(void* param) {
|
||||||
SSysTableScanInfo* pInfo = (SSysTableScanInfo*)param;
|
SSysTableScanInfo* pInfo = (SSysTableScanInfo*)param;
|
||||||
tsem_destroy(&pInfo->ready);
|
tsem_destroy(&pInfo->ready);
|
||||||
|
|
|
@ -37,6 +37,18 @@
|
||||||
|
|
||||||
static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey);
|
static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey);
|
||||||
|
|
||||||
|
static void setNotFillColumn(SFillInfo* pFillInfo, SColumnInfoData* pDstColInfo, int32_t rowIndex, int32_t colIdx) {
|
||||||
|
SRowVal* p = NULL;
|
||||||
|
if (pFillInfo->type == TSDB_FILL_NEXT) {
|
||||||
|
p = FILL_IS_ASC_FILL(pFillInfo) ? &pFillInfo->next : &pFillInfo->prev;
|
||||||
|
} else {
|
||||||
|
p = FILL_IS_ASC_FILL(pFillInfo) ? &pFillInfo->prev : &pFillInfo->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
SGroupKeys* pKey = taosArrayGet(p->pRowVal, colIdx);
|
||||||
|
doSetVal(pDstColInfo, rowIndex, pKey);
|
||||||
|
}
|
||||||
|
|
||||||
static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowIndex) {
|
static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowIndex) {
|
||||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
|
@ -45,19 +57,7 @@ static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowInd
|
||||||
if (pCol->notFillCol) {
|
if (pCol->notFillCol) {
|
||||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfo, rowIndex);
|
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfo, rowIndex);
|
||||||
if (!filled) {
|
if (!filled) {
|
||||||
SRowVal* p = NULL;
|
setNotFillColumn(pFillInfo, pDstColInfo, rowIndex, i);
|
||||||
if (FILL_IS_ASC_FILL(pFillInfo)) {
|
|
||||||
if (pFillInfo->prev.key != 0) {
|
|
||||||
p = &pFillInfo->prev; // prev has been set value
|
|
||||||
} else { // otherwise, use the value in the next row
|
|
||||||
p = &pFillInfo->next;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p = &pFillInfo->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
SGroupKeys* pKey = taosArrayGet(p->pRowVal, i);
|
|
||||||
doSetVal(pDstColInfo, rowIndex, pKey);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
colDataAppendNULL(pDstColInfo, rowIndex);
|
colDataAppendNULL(pDstColInfo, rowIndex);
|
||||||
|
@ -124,28 +124,23 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
||||||
|
|
||||||
// set the other values
|
// set the other values
|
||||||
if (pFillInfo->type == TSDB_FILL_PREV) {
|
if (pFillInfo->type == TSDB_FILL_PREV) {
|
||||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal;
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
|
|
||||||
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
||||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index);
|
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index);
|
||||||
if (!filled) {
|
if (!filled) {
|
||||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
setNotFillColumn(pFillInfo, pDstColInfoData, index, i);
|
||||||
doSetVal(pDstColInfoData, index, pKey);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
|
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
|
||||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next.pRowVal : pFillInfo->prev.pRowVal;
|
|
||||||
// todo refactor: start from 0 not 1
|
// todo refactor: start from 0 not 1
|
||||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
||||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index);
|
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index);
|
||||||
if (!filled) {
|
if (!filled) {
|
||||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
setNotFillColumn(pFillInfo, pDstColInfoData, index, i);
|
||||||
doSetVal(pDstColInfoData, index, pKey);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
|
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
|
||||||
|
@ -163,9 +158,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
||||||
if (pCol->notFillCol) {
|
if (pCol->notFillCol) {
|
||||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstCol, index);
|
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstCol, index);
|
||||||
if (!filled) {
|
if (!filled) {
|
||||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal;
|
setNotFillColumn(pFillInfo, pDstCol, index, i);
|
||||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
|
||||||
doSetVal(pDstCol, index, pKey);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SGroupKeys* pKey = taosArrayGet(pFillInfo->prev.pRowVal, i);
|
SGroupKeys* pKey = taosArrayGet(pFillInfo->prev.pRowVal, i);
|
||||||
|
@ -205,9 +198,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
||||||
if (pCol->notFillCol) {
|
if (pCol->notFillCol) {
|
||||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDst, index);
|
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDst, index);
|
||||||
if (!filled) {
|
if (!filled) {
|
||||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal;
|
setNotFillColumn(pFillInfo, pDst, index, i);
|
||||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
|
||||||
doSetVal(pDst, index, pKey);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SVariant* pVar = &pFillInfo->pFillCol[i].fillVal;
|
SVariant* pVar = &pFillInfo->pFillCol[i].fillVal;
|
||||||
|
@ -263,8 +254,15 @@ static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SRowVa
|
||||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
int32_t type = pFillInfo->pFillCol[i].pExpr->pExpr->nodeType;
|
int32_t type = pFillInfo->pFillCol[i].pExpr->pExpr->nodeType;
|
||||||
if ( type == QUERY_NODE_COLUMN || type == QUERY_NODE_OPERATOR || type == QUERY_NODE_FUNCTION) {
|
if ( type == QUERY_NODE_COLUMN || type == QUERY_NODE_OPERATOR || type == QUERY_NODE_FUNCTION) {
|
||||||
|
if (!pFillInfo->pFillCol[i].notFillCol && pFillInfo->type != TSDB_FILL_NEXT) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int32_t srcSlotId = GET_DEST_SLOT_ID(&pFillInfo->pFillCol[i]);
|
int32_t srcSlotId = GET_DEST_SLOT_ID(&pFillInfo->pFillCol[i]);
|
||||||
|
|
||||||
|
if (srcSlotId == pFillInfo->srcTsSlotId && pFillInfo->type == TSDB_FILL_LINEAR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
SColumnInfoData* pSrcCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, srcSlotId);
|
SColumnInfoData* pSrcCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, srcSlotId);
|
||||||
|
|
||||||
bool isNull = colDataIsNull_s(pSrcCol, rowIndex);
|
bool isNull = colDataIsNull_s(pSrcCol, rowIndex);
|
||||||
|
@ -293,8 +291,12 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
|
||||||
int64_t ts = ((int64_t*)pTsCol->pData)[pFillInfo->index];
|
int64_t ts = ((int64_t*)pTsCol->pData)[pFillInfo->index];
|
||||||
|
|
||||||
// set the next value for interpolation
|
// set the next value for interpolation
|
||||||
if ((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) {
|
if (pFillInfo->currentKey < ts && ascFill) {
|
||||||
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, &pFillInfo->next);
|
SRowVal* pRVal = pFillInfo->type == TSDB_FILL_NEXT ? &pFillInfo->next : &pFillInfo->prev;
|
||||||
|
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pRVal);
|
||||||
|
} else if (pFillInfo->currentKey > ts && !ascFill) {
|
||||||
|
SRowVal* pRVal = pFillInfo->type == TSDB_FILL_NEXT ? &pFillInfo->prev : &pFillInfo->next;
|
||||||
|
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pRVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) &&
|
if (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) &&
|
||||||
|
|
|
@ -119,8 +119,8 @@ static void doKeepNewWindowStartInfo(SWindowRowsSup* pRowSup, const int64_t* tsL
|
||||||
pRowSup->groupId = groupId;
|
pRowSup->groupId = groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn_t searchFn, TSKEY ekey,
|
FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn_t searchFn, TSKEY ekey,
|
||||||
int16_t pos, int16_t order, int64_t* pData) {
|
int32_t pos, int32_t order, int64_t* pData) {
|
||||||
int32_t forwardRows = 0;
|
int32_t forwardRows = 0;
|
||||||
|
|
||||||
if (order == TSDB_ORDER_ASC) {
|
if (order == TSDB_ORDER_ASC) {
|
||||||
|
@ -666,8 +666,8 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
|
||||||
setNotInterpoWindowKey(pSup->pCtx, numOfExprs, RESULT_ROW_START_INTERP);
|
setNotInterpoWindowKey(pSup->pCtx, numOfExprs, RESULT_ROW_START_INTERP);
|
||||||
|
|
||||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &w, true);
|
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &w, true);
|
||||||
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, 0, pBlock->info.rows,
|
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, 0,
|
||||||
numOfExprs);
|
pBlock->info.rows, numOfExprs);
|
||||||
|
|
||||||
if (isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)) {
|
if (isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)) {
|
||||||
closeResultRow(pr);
|
closeResultRow(pr);
|
||||||
|
@ -907,7 +907,7 @@ static void removeDeleteResults(SHashObj* pUpdatedMap, SArray* pDelWins) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isOverdue(TSKEY ekey, STimeWindowAggSupp* pTwSup) {
|
bool isOverdue(TSKEY ekey, STimeWindowAggSupp* pTwSup) {
|
||||||
ASSERT(pTwSup->maxTs == INT64_MIN || pTwSup->maxTs > 0);
|
ASSERTS(pTwSup->maxTs == INT64_MIN || pTwSup->maxTs > 0, "maxts should greater than 0");
|
||||||
return pTwSup->maxTs != INT64_MIN && ekey < pTwSup->maxTs - pTwSup->waterMark;
|
return pTwSup->maxTs != INT64_MIN && ekey < pTwSup->maxTs - pTwSup->waterMark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,8 +961,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true);
|
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true);
|
||||||
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, pBlock->info.rows,
|
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows,
|
||||||
numOfOutput);
|
pBlock->info.rows, numOfOutput);
|
||||||
|
|
||||||
doCloseWindow(pResultRowInfo, pInfo, pResult);
|
doCloseWindow(pResultRowInfo, pInfo, pResult);
|
||||||
|
|
||||||
|
@ -996,8 +996,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true);
|
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true);
|
||||||
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, pBlock->info.rows,
|
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows,
|
||||||
numOfOutput);
|
pBlock->info.rows, numOfOutput);
|
||||||
doCloseWindow(pResultRowInfo, pInfo, pResult);
|
doCloseWindow(pResultRowInfo, pInfo, pResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1188,8 +1188,8 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, false);
|
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, false);
|
||||||
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex, pRowSup->numOfRows,
|
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex,
|
||||||
pBlock->info.rows, numOfOutput);
|
pRowSup->numOfRows, pBlock->info.rows, numOfOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t openStateWindowAggOptr(SOperatorInfo* pOperator) {
|
static int32_t openStateWindowAggOptr(SOperatorInfo* pOperator) {
|
||||||
|
@ -1396,7 +1396,6 @@ static int32_t getAllIntervalWindow(SSHashObj* pHashMap, SHashObj* resWins) {
|
||||||
while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) {
|
while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) {
|
||||||
void* key = tSimpleHashGetKey(pIte, &keyLen);
|
void* key = tSimpleHashGetKey(pIte, &keyLen);
|
||||||
uint64_t groupId = *(uint64_t*)key;
|
uint64_t groupId = *(uint64_t*)key;
|
||||||
ASSERT(keyLen == GET_RES_WINDOW_KEY_LEN(sizeof(TSKEY)));
|
|
||||||
TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t));
|
TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t));
|
||||||
SResultRowPosition* pPos = (SResultRowPosition*)pIte;
|
SResultRowPosition* pPos = (SResultRowPosition*)pIte;
|
||||||
int32_t code = saveWinResult(ts, pPos->pageId, pPos->offset, groupId, resWins);
|
int32_t code = saveWinResult(ts, pPos->pageId, pPos->offset, groupId, resWins);
|
||||||
|
@ -1547,7 +1546,7 @@ static void closeChildIntervalWindow(SOperatorInfo* pOperator, SArray* pChildren
|
||||||
for (int32_t i = 0; i < size; i++) {
|
for (int32_t i = 0; i < size; i++) {
|
||||||
SOperatorInfo* pChildOp = taosArrayGetP(pChildren, i);
|
SOperatorInfo* pChildOp = taosArrayGetP(pChildren, i);
|
||||||
SStreamIntervalOperatorInfo* pChInfo = pChildOp->info;
|
SStreamIntervalOperatorInfo* pChInfo = pChildOp->info;
|
||||||
ASSERT(pChInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);
|
ASSERTS(pChInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE, "children trigger type should be at once");
|
||||||
pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, maxTs);
|
pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, maxTs);
|
||||||
closeStreamIntervalWindow(pChInfo->aggSup.pResultRowHashTable, &pChInfo->twAggSup, &pChInfo->interval, NULL, NULL,
|
closeStreamIntervalWindow(pChInfo->aggSup.pResultRowHashTable, &pChInfo->twAggSup, &pChInfo->interval, NULL, NULL,
|
||||||
NULL, pOperator);
|
NULL, pOperator);
|
||||||
|
@ -1749,7 +1748,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
|
||||||
|
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
SExprInfo* pExprInfo = createExprInfo(pPhyNode->window.pFuncs, NULL, &num);
|
SExprInfo* pExprInfo = createExprInfo(pPhyNode->window.pFuncs, NULL, &num);
|
||||||
int32_t code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str);
|
int32_t code =
|
||||||
|
initAggSup(pSup, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str, pTaskInfo->streamInfo.pState);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -1767,8 +1767,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
|
||||||
.maxTs = INT64_MIN,
|
.maxTs = INT64_MIN,
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT(as.calTrigger != STREAM_TRIGGER_MAX_DELAY);
|
|
||||||
|
|
||||||
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;
|
||||||
|
@ -1803,8 +1801,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
|
||||||
setOperatorInfo(pOperator, "TimeIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL, true, OP_NOT_OPENED,
|
setOperatorInfo(pOperator, "TimeIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL, true, OP_NOT_OPENED,
|
||||||
pInfo, pTaskInfo);
|
pInfo, pTaskInfo);
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, destroyIntervalOperatorInfo,
|
||||||
createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, destroyIntervalOperatorInfo, optrDefaultBufFn, NULL);
|
optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -1889,8 +1887,8 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, false);
|
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, false);
|
||||||
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex, pRowSup->numOfRows,
|
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex,
|
||||||
pBlock->info.rows, numOfOutput);
|
pRowSup->numOfRows, pBlock->info.rows, numOfOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
|
static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
|
||||||
|
@ -2003,7 +2001,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi
|
||||||
SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &num);
|
SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &num);
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||||
|
|
||||||
code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str);
|
code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str,
|
||||||
|
pTaskInfo->streamInfo.pState);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -2021,8 +2020,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "StateWindowOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE, true, OP_NOT_OPENED, pInfo,
|
setOperatorInfo(pOperator, "StateWindowOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE, true, OP_NOT_OPENED, pInfo,
|
||||||
pTaskInfo);
|
pTaskInfo);
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(openStateWindowAggOptr, doStateWindowAgg, NULL, destroyStateWindowOperatorInfo,
|
||||||
createOperatorFpSet(openStateWindowAggOptr, doStateWindowAgg, NULL, destroyStateWindowOperatorInfo, optrDefaultBufFn, NULL);
|
optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -2071,7 +2070,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW
|
||||||
SSDataBlock* pResBlock = createDataBlockFromDescNode(pSessionNode->window.node.pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createDataBlockFromDescNode(pSessionNode->window.node.pOutputDataBlockDesc);
|
||||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||||
|
|
||||||
int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str,
|
||||||
|
pTaskInfo->streamInfo.pState);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -2094,8 +2094,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "SessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION, true, OP_NOT_OPENED,
|
setOperatorInfo(pOperator, "SessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION, true, OP_NOT_OPENED,
|
||||||
pInfo, pTaskInfo);
|
pInfo, pTaskInfo);
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doSessionWindowAgg, NULL, destroySWindowOperatorInfo,
|
||||||
createOperatorFpSet(optrDummyOpenFn, doSessionWindowAgg, NULL, destroySWindowOperatorInfo, optrDefaultBufFn, NULL);
|
optrDefaultBufFn, 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) {
|
||||||
|
@ -2252,7 +2252,6 @@ static void doBuildPullDataBlock(SArray* array, int32_t* pIndex, SSDataBlock* pB
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
blockDataEnsureCapacity(pBlock, size - (*pIndex));
|
blockDataEnsureCapacity(pBlock, size - (*pIndex));
|
||||||
ASSERT(3 <= taosArrayGetSize(pBlock->pDataBlock));
|
|
||||||
SColumnInfoData* pStartTs = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
SColumnInfoData* pStartTs = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pEndTs = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
SColumnInfoData* pEndTs = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pGroupId = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
SColumnInfoData* pGroupId = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
|
@ -2313,7 +2312,8 @@ static void addRetriveWindow(SArray* wins, SStreamIntervalOperatorInfo* pInfo) {
|
||||||
if (needDeleteWindowBuf(&nextWin, &pInfo->twAggSup) && !pInfo->ignoreExpiredData) {
|
if (needDeleteWindowBuf(&nextWin, &pInfo->twAggSup) && !pInfo->ignoreExpiredData) {
|
||||||
void* chIds = taosHashGet(pInfo->pPullDataMap, winKey, sizeof(SWinKey));
|
void* chIds = taosHashGet(pInfo->pPullDataMap, winKey, sizeof(SWinKey));
|
||||||
if (!chIds) {
|
if (!chIds) {
|
||||||
SPullWindowInfo pull = {.window = nextWin, .groupId = winKey->groupId, .calWin.skey = nextWin.skey, .calWin.ekey = nextWin.skey};
|
SPullWindowInfo pull = {
|
||||||
|
.window = nextWin, .groupId = winKey->groupId, .calWin.skey = nextWin.skey, .calWin.ekey = nextWin.skey};
|
||||||
// add pull data request
|
// add pull data request
|
||||||
if (savePullWindow(&pull, pInfo->pPullWins) == TSDB_CODE_SUCCESS) {
|
if (savePullWindow(&pull, pInfo->pPullWins) == TSDB_CODE_SUCCESS) {
|
||||||
int32_t size1 = taosArrayGetSize(pInfo->pChildren);
|
int32_t size1 = taosArrayGetSize(pInfo->pChildren);
|
||||||
|
@ -2346,6 +2346,17 @@ void doBuildResult(SOperatorInfo* pOperator, SStreamState* pState, SSDataBlock*
|
||||||
buildDataBlockFromGroupRes(pOperator, pState, pBlock, &pOperator->exprSupp, pGroupResInfo);
|
buildDataBlockFromGroupRes(pOperator, pState, pBlock, &pOperator->exprSupp, pGroupResInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t getNextQualifiedFinalWindow(SInterval* pInterval, STimeWindow* pNext, SDataBlockInfo* pDataBlockInfo,
|
||||||
|
TSKEY* primaryKeys, int32_t prevPosition) {
|
||||||
|
int32_t startPos = prevPosition + 1;
|
||||||
|
if (startPos == pDataBlockInfo->rows) {
|
||||||
|
startPos = -1;
|
||||||
|
} else {
|
||||||
|
*pNext = getFinalTimeWindow(primaryKeys[startPos], pInterval);
|
||||||
|
}
|
||||||
|
return startPos;
|
||||||
|
}
|
||||||
|
|
||||||
static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t groupId,
|
static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t groupId,
|
||||||
SHashObj* pUpdatedMap) {
|
SHashObj* pUpdatedMap) {
|
||||||
SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperatorInfo->info;
|
SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperatorInfo->info;
|
||||||
|
@ -2359,7 +2370,6 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p
|
||||||
SResultRow* pResult = NULL;
|
SResultRow* pResult = NULL;
|
||||||
int32_t forwardRows = 0;
|
int32_t forwardRows = 0;
|
||||||
|
|
||||||
ASSERT(pSDataBlock->pDataBlock != NULL);
|
|
||||||
SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex);
|
SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||||
tsCols = (int64_t*)pColDataInfo->pData;
|
tsCols = (int64_t*)pColDataInfo->pData;
|
||||||
|
|
||||||
|
@ -2389,7 +2399,8 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p
|
||||||
};
|
};
|
||||||
void* chIds = taosHashGet(pInfo->pPullDataMap, &winRes, sizeof(SWinKey));
|
void* chIds = taosHashGet(pInfo->pPullDataMap, &winRes, sizeof(SWinKey));
|
||||||
if (isDeletedStreamWindow(&nextWin, groupId, pInfo->pState, &pInfo->twAggSup) && !chIds) {
|
if (isDeletedStreamWindow(&nextWin, groupId, pInfo->pState, &pInfo->twAggSup) && !chIds) {
|
||||||
SPullWindowInfo pull = {.window = nextWin, .groupId = groupId, .calWin.skey = nextWin.skey, .calWin.ekey = nextWin.skey};
|
SPullWindowInfo pull = {
|
||||||
|
.window = nextWin, .groupId = groupId, .calWin.skey = nextWin.skey, .calWin.ekey = nextWin.skey};
|
||||||
// add pull data request
|
// add pull data request
|
||||||
if (savePullWindow(&pull, pInfo->pPullWins) == TSDB_CODE_SUCCESS) {
|
if (savePullWindow(&pull, pInfo->pPullWins) == TSDB_CODE_SUCCESS) {
|
||||||
int32_t size = taosArrayGetSize(pInfo->pChildren);
|
int32_t size = taosArrayGetSize(pInfo->pChildren);
|
||||||
|
@ -2456,8 +2467,12 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p
|
||||||
}
|
}
|
||||||
int32_t prevEndPos = (forwardRows - 1) * step + startPos;
|
int32_t prevEndPos = (forwardRows - 1) * step + startPos;
|
||||||
ASSERT(pSDataBlock->info.window.skey > 0 && pSDataBlock->info.window.ekey > 0);
|
ASSERT(pSDataBlock->info.window.skey > 0 && pSDataBlock->info.window.ekey > 0);
|
||||||
|
if (IS_FINAL_OP(pInfo)) {
|
||||||
|
startPos = getNextQualifiedFinalWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos);
|
||||||
|
} else {
|
||||||
startPos =
|
startPos =
|
||||||
getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, TSDB_ORDER_ASC);
|
getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, TSDB_ORDER_ASC);
|
||||||
|
}
|
||||||
if (startPos < 0) {
|
if (startPos < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2482,7 +2497,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
doBuildPullDataBlock(pInfo->pPullWins, &pInfo->pullIndex, pInfo->pPullDataRes);
|
doBuildPullDataBlock(pInfo->pPullWins, &pInfo->pullIndex, pInfo->pPullDataRes);
|
||||||
if (pInfo->pPullDataRes->info.rows != 0) {
|
if (pInfo->pPullDataRes->info.rows != 0) {
|
||||||
// process the rest of the data
|
// process the rest of the data
|
||||||
ASSERT(IS_FINAL_OP(pInfo));
|
|
||||||
printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi");
|
printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi");
|
||||||
return pInfo->pPullDataRes;
|
return pInfo->pPullDataRes;
|
||||||
}
|
}
|
||||||
|
@ -2536,14 +2550,14 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
qDebug("===stream===return data:%s. recv datablock num:%" PRIu64 , IS_FINAL_OP(pInfo) ? "interval final" : "interval semi", pInfo->numOfDatapack);
|
qDebug("===stream===return data:%s. recv datablock num:%" PRIu64,
|
||||||
|
IS_FINAL_OP(pInfo) ? "interval final" : "interval semi", pInfo->numOfDatapack);
|
||||||
pInfo->numOfDatapack = 0;
|
pInfo->numOfDatapack = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pInfo->numOfDatapack++;
|
pInfo->numOfDatapack++;
|
||||||
printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "interval final recv" : "interval semi recv");
|
printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "interval final recv" : "interval semi recv");
|
||||||
|
|
||||||
ASSERT(pBlock->info.type != STREAM_INVERT);
|
|
||||||
if (pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_PULL_DATA) {
|
if (pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_PULL_DATA) {
|
||||||
pInfo->binfo.pRes->info.type = pBlock->info.type;
|
pInfo->binfo.pRes->info.type = pBlock->info.type;
|
||||||
} else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT ||
|
} else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT ||
|
||||||
|
@ -2633,7 +2647,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
doBuildPullDataBlock(pInfo->pPullWins, &pInfo->pullIndex, pInfo->pPullDataRes);
|
doBuildPullDataBlock(pInfo->pPullWins, &pInfo->pullIndex, pInfo->pPullDataRes);
|
||||||
if (pInfo->pPullDataRes->info.rows != 0) {
|
if (pInfo->pPullDataRes->info.rows != 0) {
|
||||||
// process the rest of the data
|
// process the rest of the data
|
||||||
ASSERT(IS_FINAL_OP(pInfo));
|
|
||||||
printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi");
|
printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi");
|
||||||
return pInfo->pPullDataRes;
|
return pInfo->pPullDataRes;
|
||||||
}
|
}
|
||||||
|
@ -2688,7 +2701,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
.deleteMarkSaved = 0,
|
.deleteMarkSaved = 0,
|
||||||
.calTriggerSaved = 0,
|
.calTriggerSaved = 0,
|
||||||
};
|
};
|
||||||
ASSERT(pInfo->twAggSup.calTrigger != STREAM_TRIGGER_MAX_DELAY);
|
ASSERTS(pInfo->twAggSup.calTrigger != STREAM_TRIGGER_MAX_DELAY, "trigger type should not be max delay");
|
||||||
pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
||||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||||
|
@ -2706,14 +2719,14 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
SSDataBlock* pResBlock = createDataBlockFromDescNode(pPhyNode->pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createDataBlockFromDescNode(pPhyNode->pOutputDataBlockDesc);
|
||||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||||
|
|
||||||
int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str,
|
||||||
|
pTaskInfo->streamInfo.pState);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
initStreamFunciton(pOperator->exprSupp.pCtx, pOperator->exprSupp.numOfExprs);
|
initStreamFunciton(pOperator->exprSupp.pCtx, pOperator->exprSupp.numOfExprs);
|
||||||
|
|
||||||
ASSERT(numOfCols > 0);
|
|
||||||
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
|
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
|
||||||
|
|
||||||
pInfo->pState = taosMemoryCalloc(1, sizeof(SStreamState));
|
pInfo->pState = taosMemoryCalloc(1, sizeof(SStreamState));
|
||||||
|
@ -2724,6 +2737,9 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
pInfo->pChildren = NULL;
|
pInfo->pChildren = NULL;
|
||||||
if (numOfChild > 0) {
|
if (numOfChild > 0) {
|
||||||
pInfo->pChildren = taosArrayInit(numOfChild, sizeof(void*));
|
pInfo->pChildren = taosArrayInit(numOfChild, sizeof(void*));
|
||||||
|
if (!pInfo->pChildren) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
for (int32_t i = 0; i < numOfChild; i++) {
|
for (int32_t i = 0; i < numOfChild; i++) {
|
||||||
SOperatorInfo* pChildOp = createStreamFinalIntervalOperatorInfo(NULL, pPhyNode, pTaskInfo, 0);
|
SOperatorInfo* pChildOp = createStreamFinalIntervalOperatorInfo(NULL, pPhyNode, pTaskInfo, 0);
|
||||||
if (pChildOp) {
|
if (pChildOp) {
|
||||||
|
@ -2746,7 +2762,6 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
// semi interval operator does not catch result
|
// semi interval operator does not catch result
|
||||||
pInfo->isFinal = false;
|
pInfo->isFinal = false;
|
||||||
pOperator->name = "StreamSemiIntervalOperator";
|
pOperator->name = "StreamSemiIntervalOperator";
|
||||||
ASSERT(pInfo->aggSup.currentPageId == -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_FINAL_OP(pInfo) || numOfChild == 0) {
|
if (!IS_FINAL_OP(pInfo) || numOfChild == 0) {
|
||||||
|
@ -2770,8 +2785,8 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo,
|
||||||
createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, optrDefaultBufFn, NULL);
|
optrDefaultBufFn, 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);
|
||||||
}
|
}
|
||||||
|
@ -3162,15 +3177,6 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteWindow(SArray* pWinInfos, int32_t index, FDelete fp) {
|
|
||||||
ASSERT(index >= 0 && index < taosArrayGetSize(pWinInfos));
|
|
||||||
if (fp) {
|
|
||||||
void* ptr = taosArrayGet(pWinInfos, index);
|
|
||||||
fp(ptr);
|
|
||||||
}
|
|
||||||
taosArrayRemove(pWinInfos, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SArray* result) {
|
static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SArray* result) {
|
||||||
SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
TSKEY* startDatas = (TSKEY*)pStartTsCol->pData;
|
TSKEY* startDatas = (TSKEY*)pStartTsCol->pData;
|
||||||
|
@ -3218,7 +3224,6 @@ static int32_t copyUpdateResult(SSHashObj* pStUpdated, SArray* pUpdated) {
|
||||||
int32_t iter = 0;
|
int32_t iter = 0;
|
||||||
while ((pIte = tSimpleHashIterate(pStUpdated, pIte, &iter)) != NULL) {
|
while ((pIte = tSimpleHashIterate(pStUpdated, pIte, &iter)) != NULL) {
|
||||||
void* key = tSimpleHashGetKey(pIte, &keyLen);
|
void* key = tSimpleHashGetKey(pIte, &keyLen);
|
||||||
ASSERT(keyLen == sizeof(SSessionKey));
|
|
||||||
taosArrayPush(pUpdated, key);
|
taosArrayPush(pUpdated, key);
|
||||||
}
|
}
|
||||||
taosArraySort(pUpdated, sessionKeyCompareAsc);
|
taosArraySort(pUpdated, sessionKeyCompareAsc);
|
||||||
|
@ -3279,7 +3284,6 @@ static void rebuildSessionWindow(SOperatorInfo* pOperator, SArray* pWinArray, SS
|
||||||
SStreamAggSupporter* pAggSup = &pInfo->streamAggSup;
|
SStreamAggSupporter* pAggSup = &pInfo->streamAggSup;
|
||||||
int32_t numOfOutput = pSup->numOfExprs;
|
int32_t numOfOutput = pSup->numOfExprs;
|
||||||
int32_t numOfChildren = taosArrayGetSize(pInfo->pChildren);
|
int32_t numOfChildren = taosArrayGetSize(pInfo->pChildren);
|
||||||
ASSERT(pInfo->pChildren);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < size; i++) {
|
for (int32_t i = 0; i < size; i++) {
|
||||||
SSessionKey* pWinKey = taosArrayGet(pWinArray, i);
|
SSessionKey* pWinKey = taosArrayGet(pWinArray, i);
|
||||||
|
@ -3380,7 +3384,6 @@ static void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted) {
|
||||||
void initGroupResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList) {
|
void initGroupResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList) {
|
||||||
pGroupResInfo->pRows = pArrayList;
|
pGroupResInfo->pRows = pArrayList;
|
||||||
pGroupResInfo->index = 0;
|
pGroupResInfo->index = 0;
|
||||||
ASSERT(pGroupResInfo->index <= getNumOfTotalRes(pGroupResInfo));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void doBuildSessionResult(SOperatorInfo* pOperator, SStreamState* pState, SGroupResInfo* pGroupResInfo,
|
void doBuildSessionResult(SOperatorInfo* pOperator, SStreamState* pState, SGroupResInfo* pGroupResInfo,
|
||||||
|
@ -3582,8 +3585,8 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "StreamSessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION, true,
|
setOperatorInfo(pOperator, "StreamSessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION, true,
|
||||||
OP_NOT_OPENED, pInfo, pTaskInfo);
|
OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamSessionAgg, NULL, destroyStreamSessionAggOperatorInfo,
|
||||||
createOperatorFpSet(optrDummyOpenFn, doStreamSessionAgg, NULL, destroyStreamSessionAggOperatorInfo, optrDefaultBufFn, NULL);
|
optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
if (downstream) {
|
if (downstream) {
|
||||||
initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup);
|
initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup);
|
||||||
|
@ -4087,8 +4090,8 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "StreamStateAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE, true, OP_NOT_OPENED,
|
setOperatorInfo(pOperator, "StreamStateAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE, true, OP_NOT_OPENED,
|
||||||
pInfo, pTaskInfo);
|
pInfo, pTaskInfo);
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamStateAgg, NULL, destroyStreamStateOperatorInfo,
|
||||||
createOperatorFpSet(optrDummyOpenFn, doStreamStateAgg, NULL, destroyStreamStateOperatorInfo, optrDefaultBufFn, NULL);
|
optrDefaultBufFn, NULL);
|
||||||
initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup);
|
initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup);
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -4173,8 +4176,8 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &currWin, true);
|
updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &currWin, true);
|
||||||
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &iaInfo->twAggSup.timeWindowData, startPos, currPos - startPos,
|
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &iaInfo->twAggSup.timeWindowData, startPos,
|
||||||
pBlock->info.rows, pSup->numOfExprs);
|
currPos - startPos, pBlock->info.rows, pSup->numOfExprs);
|
||||||
|
|
||||||
finalizeResultRows(iaInfo->aggSup.pResultBuf, &pResultRowInfo->cur, pSup, pResultBlock, pTaskInfo);
|
finalizeResultRows(iaInfo->aggSup.pResultBuf, &pResultRowInfo->cur, pSup, pResultBlock, pTaskInfo);
|
||||||
resetResultRow(miaInfo->pResultRow, iaInfo->aggSup.resultRowSize - sizeof(SResultRow));
|
resetResultRow(miaInfo->pResultRow, iaInfo->aggSup.resultRowSize - sizeof(SResultRow));
|
||||||
|
@ -4345,7 +4348,8 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
SExprInfo* pExprInfo = createExprInfo(pNode->window.pFuncs, NULL, &num);
|
SExprInfo* pExprInfo = createExprInfo(pNode->window.pFuncs, NULL, &num);
|
||||||
|
|
||||||
code = initAggSup(&pOperator->exprSupp, &iaInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str);
|
code = initAggSup(&pOperator->exprSupp, &iaInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str,
|
||||||
|
pTaskInfo->streamInfo.pState);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -4364,8 +4368,8 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
setOperatorInfo(pOperator, "TimeMergeAlignedIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL,
|
setOperatorInfo(pOperator, "TimeMergeAlignedIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL,
|
||||||
false, OP_NOT_OPENED, miaInfo, pTaskInfo);
|
false, OP_NOT_OPENED, miaInfo, pTaskInfo);
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, mergeAlignedIntervalAgg, NULL, destroyMAIOperatorInfo,
|
||||||
createOperatorFpSet(optrDummyOpenFn, mergeAlignedIntervalAgg, NULL, destroyMAIOperatorInfo, optrDefaultBufFn, NULL);
|
optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -4649,7 +4653,8 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge
|
||||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||||
|
|
||||||
int32_t code = initAggSup(pExprSupp, &pIntervalInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str);
|
int32_t code = initAggSup(pExprSupp, &pIntervalInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str,
|
||||||
|
pTaskInfo->streamInfo.pState);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -4669,8 +4674,8 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge
|
||||||
initResultRowInfo(&pIntervalInfo->binfo.resultRowInfo);
|
initResultRowInfo(&pIntervalInfo->binfo.resultRowInfo);
|
||||||
setOperatorInfo(pOperator, "TimeMergeIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL, false,
|
setOperatorInfo(pOperator, "TimeMergeIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL, false,
|
||||||
OP_NOT_OPENED, pMergeIntervalInfo, pTaskInfo);
|
OP_NOT_OPENED, pMergeIntervalInfo, pTaskInfo);
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doMergeIntervalAgg, NULL, destroyMergeIntervalOperatorInfo,
|
||||||
createOperatorFpSet(optrDummyOpenFn, doMergeIntervalAgg, NULL, destroyMergeIntervalOperatorInfo, optrDefaultBufFn, NULL);
|
optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -4811,7 +4816,6 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &numOfCols);
|
SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &numOfCols);
|
||||||
ASSERT(numOfCols > 0);
|
|
||||||
|
|
||||||
SSDataBlock* pResBlock = createDataBlockFromDescNode(pPhyNode->pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createDataBlockFromDescNode(pPhyNode->pOutputDataBlockDesc);
|
||||||
SInterval interval = {
|
SInterval interval = {
|
||||||
|
@ -4831,7 +4835,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
.deleteMark = getDeleteMark(pIntervalPhyNode),
|
.deleteMark = getDeleteMark(pIntervalPhyNode),
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT(twAggSupp.calTrigger != STREAM_TRIGGER_MAX_DELAY);
|
ASSERTS(twAggSupp.calTrigger != STREAM_TRIGGER_MAX_DELAY, "trigger type should not be max delay");
|
||||||
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
pInfo->interval = interval;
|
pInfo->interval = interval;
|
||||||
|
@ -4848,7 +4852,8 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||||
|
|
||||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||||
code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str,
|
||||||
|
pTaskInfo->streamInfo.pState);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,9 @@ static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn) {
|
SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn) {
|
||||||
ASSERT(fn != NULL);
|
if (fn == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (capacity == 0) {
|
if (capacity == 0) {
|
||||||
capacity = 4;
|
capacity = 4;
|
||||||
|
@ -66,7 +68,6 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn) {
|
||||||
|
|
||||||
pHashObj->equalFp = memcmp;
|
pHashObj->equalFp = memcmp;
|
||||||
pHashObj->hashFp = fn;
|
pHashObj->hashFp = fn;
|
||||||
ASSERT((pHashObj->capacity & (pHashObj->capacity - 1)) == 0);
|
|
||||||
|
|
||||||
pHashObj->hashList = (SHNode **)taosMemoryCalloc(pHashObj->capacity, sizeof(void *));
|
pHashObj->hashList = (SHNode **)taosMemoryCalloc(pHashObj->capacity, sizeof(void *));
|
||||||
if (!pHashObj->hashList) {
|
if (!pHashObj->hashList) {
|
||||||
|
|
|
@ -800,6 +800,7 @@ STupleHandle* tsortNextTuple(SSortHandle* pHandle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// all sources are completed.
|
||||||
if (pHandle->cmpParam.numOfSources == pHandle->numOfCompletedSources) {
|
if (pHandle->cmpParam.numOfSources == pHandle->numOfCompletedSources) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,19 @@ enum {
|
||||||
data_desc = 0x3,
|
data_desc = 0x3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TEST(testCase, windowFunctionTest) {
|
||||||
|
int64_t tsCol[100000];
|
||||||
|
int32_t rows = 100000;
|
||||||
|
for (int32_t i = 0; i < rows; i++) {
|
||||||
|
tsCol[i] = 1648791213000 + i;
|
||||||
|
}
|
||||||
|
int32_t ekeyNum = 50000;
|
||||||
|
int32_t pos = 40000;
|
||||||
|
int64_t ekey = tsCol[ekeyNum];
|
||||||
|
int32_t num = getForwardStepsInBlock(rows, binarySearchForKey, ekey, pos, TSDB_ORDER_ASC, tsCol);
|
||||||
|
ASSERT_EQ(num, ekeyNum - pos + 1);
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct SDummyInputInfo {
|
typedef struct SDummyInputInfo {
|
||||||
int32_t totalPages; // numOfPages
|
int32_t totalPages; // numOfPages
|
||||||
int32_t current;
|
int32_t current;
|
||||||
|
|
|
@ -32,6 +32,7 @@ typedef struct SSumRes {
|
||||||
int16_t type;
|
int16_t type;
|
||||||
int64_t prevTs;
|
int64_t prevTs;
|
||||||
bool isPrevTsSet;
|
bool isPrevTsSet;
|
||||||
|
bool overflow; // if overflow is true, dsum to be used for any type;
|
||||||
} SSumRes;
|
} SSumRes;
|
||||||
|
|
||||||
typedef struct SMinmaxResInfo {
|
typedef struct SMinmaxResInfo {
|
||||||
|
@ -45,7 +46,7 @@ typedef struct SMinmaxResInfo {
|
||||||
} SMinmaxResInfo;
|
} SMinmaxResInfo;
|
||||||
int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc);
|
int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc);
|
||||||
|
|
||||||
STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, const STupleKey* pKey);
|
STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock);
|
||||||
int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos);
|
int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos);
|
||||||
const char* loadTupleData(SqlFunctionCtx* pCtx, const STuplePos* pPos);
|
const char* loadTupleData(SqlFunctionCtx* pCtx, const STuplePos* pPos);
|
||||||
|
|
||||||
|
|
|
@ -540,7 +540,7 @@ int32_t countFunction(SqlFunctionCtx* pCtx) {
|
||||||
if (IS_NULL_TYPE(type)) {
|
if (IS_NULL_TYPE(type)) {
|
||||||
// select count(NULL) returns 0
|
// select count(NULL) returns 0
|
||||||
numOfElem = 1;
|
numOfElem = 1;
|
||||||
*((int64_t*)buf) = 0;
|
*((int64_t*)buf) += 0;
|
||||||
} else {
|
} else {
|
||||||
numOfElem = getNumOfElems(pCtx);
|
numOfElem = getNumOfElems(pCtx);
|
||||||
*((int64_t*)buf) += numOfElem;
|
*((int64_t*)buf) += numOfElem;
|
||||||
|
@ -818,8 +818,8 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCtx->saveHandle.pBuf != NULL) {
|
if ((pCtx->saveHandle.pBuf != NULL && pTuplePos->pageId != -1) ||
|
||||||
if (pTuplePos->pageId != -1) {
|
(pCtx->saveHandle.pState && pTuplePos->streamTupleKey.ts > 0)) {
|
||||||
int32_t numOfCols = pCtx->subsidiaries.num;
|
int32_t numOfCols = pCtx->subsidiaries.num;
|
||||||
const char* p = loadTupleData(pCtx, pTuplePos);
|
const char* p = loadTupleData(pCtx, pTuplePos);
|
||||||
|
|
||||||
|
@ -840,6 +840,9 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple
|
||||||
}
|
}
|
||||||
pStart += pDstCol->info.bytes;
|
pStart += pDstCol->info.bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pCtx->saveHandle.pState) {
|
||||||
|
tdbFree((void*)p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2018,7 +2021,7 @@ static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowInde
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pInfo->hasResult) {
|
if (!pInfo->hasResult) {
|
||||||
pInfo->pos = saveTupleData(pCtx, rowIndex, pSrcBlock, NULL);
|
pInfo->pos = saveTupleData(pCtx, rowIndex, pSrcBlock);
|
||||||
} else {
|
} else {
|
||||||
updateTupleData(pCtx, rowIndex, pSrcBlock, &pInfo->pos);
|
updateTupleData(pCtx, rowIndex, pSrcBlock, &pInfo->pos);
|
||||||
}
|
}
|
||||||
|
@ -2071,8 +2074,8 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||||
|
|
||||||
// please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first function.
|
// please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first
|
||||||
// we will use this opt implementation in an new version that is only available in scan subplan
|
// function. we will use this opt implementation in an new version that is only available in scan subplan
|
||||||
#if 0
|
#if 0
|
||||||
if (blockDataOrder == TSDB_ORDER_ASC) {
|
if (blockDataOrder == TSDB_ORDER_ASC) {
|
||||||
// filter according to current result firstly
|
// filter according to current result firstly
|
||||||
|
@ -2179,7 +2182,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||||
|
|
||||||
// please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first function.
|
// please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first
|
||||||
|
// function.
|
||||||
#if 0
|
#if 0
|
||||||
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) {
|
||||||
|
@ -2777,7 +2781,7 @@ int32_t topFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pRes->nullTupleSaved) {
|
if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pRes->nullTupleSaved) {
|
||||||
pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL);
|
pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock);
|
||||||
pRes->nullTupleSaved = true;
|
pRes->nullTupleSaved = true;
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -2805,7 +2809,7 @@ int32_t bottomFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pRes->nullTupleSaved) {
|
if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pRes->nullTupleSaved) {
|
||||||
pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL);
|
pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock);
|
||||||
pRes->nullTupleSaved = true;
|
pRes->nullTupleSaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2863,7 +2867,7 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData
|
||||||
|
|
||||||
// save the data of this tuple
|
// save the data of this tuple
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
pItem->tuplePos = saveTupleData(pCtx, rowIndex, pSrcBlock, NULL);
|
pItem->tuplePos = saveTupleData(pCtx, rowIndex, pSrcBlock);
|
||||||
}
|
}
|
||||||
#ifdef BUF_PAGE_DEBUG
|
#ifdef BUF_PAGE_DEBUG
|
||||||
qDebug("page_saveTuple i:%d, item:%p,pageId:%d, offset:%d\n", pEntryInfo->numOfRes, pItem, pItem->tuplePos.pageId,
|
qDebug("page_saveTuple i:%d, item:%p,pageId:%d, offset:%d\n", pEntryInfo->numOfRes, pItem, pItem->tuplePos.pageId,
|
||||||
|
@ -2937,8 +2941,7 @@ void* serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsid
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length,
|
static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STupleKey key) {
|
||||||
const STupleKey* pKey) {
|
|
||||||
STuplePos p = {0};
|
STuplePos p = {0};
|
||||||
if (pHandle->pBuf != NULL) {
|
if (pHandle->pBuf != NULL) {
|
||||||
SFilePage* pPage = NULL;
|
SFilePage* pPage = NULL;
|
||||||
|
@ -2964,20 +2967,31 @@ static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf
|
||||||
releaseBufPage(pHandle->pBuf, pPage);
|
releaseBufPage(pHandle->pBuf, pPage);
|
||||||
} else {
|
} else {
|
||||||
// other tuple save policy
|
// other tuple save policy
|
||||||
if (streamStateFuncPut(pHandle->pState, pKey, pBuf, length) < 0) {
|
if (streamStateFuncPut(pHandle->pState, &key, pBuf, length) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
p.streamTupleKey = *pKey;
|
p.streamTupleKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, const STupleKey* pKey) {
|
STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock) {
|
||||||
prepareBuf(pCtx);
|
prepareBuf(pCtx);
|
||||||
|
|
||||||
|
STupleKey key;
|
||||||
|
if (pCtx->saveHandle.pBuf == NULL) {
|
||||||
|
SColumnInfoData* pColInfo = taosArrayGet(pSrcBlock->pDataBlock, 0);
|
||||||
|
ASSERT(pColInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||||
|
int64_t skey = *(int64_t*)colDataGetData(pColInfo, rowIndex);
|
||||||
|
|
||||||
|
key.groupId = pSrcBlock->info.id.groupId;
|
||||||
|
key.ts = skey;
|
||||||
|
key.exprIdx = pCtx->exprIdx;
|
||||||
|
}
|
||||||
|
|
||||||
char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf);
|
char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf);
|
||||||
return doSaveTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, pKey);
|
return doSaveTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doUpdateTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STuplePos* pPos) {
|
static int32_t doUpdateTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STuplePos* pPos) {
|
||||||
|
@ -3947,7 +3961,6 @@ int32_t hllFunctionMerge(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
int32_t start = pInput->startRowIndex;
|
int32_t start = pInput->startRowIndex;
|
||||||
|
|
||||||
|
|
||||||
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
||||||
char* data = colDataGetData(pCol, i);
|
char* data = colDataGetData(pCol, i);
|
||||||
SHLLInfo* pInputInfo = (SHLLInfo*)varDataVal(data);
|
SHLLInfo* pInputInfo = (SHLLInfo*)varDataVal(data);
|
||||||
|
@ -4423,7 +4436,7 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da
|
||||||
if (pInfo->numSampled < pInfo->samples) {
|
if (pInfo->numSampled < pInfo->samples) {
|
||||||
sampleAssignResult(pInfo, data, pInfo->numSampled);
|
sampleAssignResult(pInfo, data, pInfo->numSampled);
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
pInfo->tuplePos[pInfo->numSampled] = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
pInfo->tuplePos[pInfo->numSampled] = saveTupleData(pCtx, index, pCtx->pSrcBlock);
|
||||||
}
|
}
|
||||||
pInfo->numSampled++;
|
pInfo->numSampled++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4454,7 +4467,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->numSampled == 0 && pCtx->subsidiaries.num > 0 && !pInfo->nullTupleSaved) {
|
if (pInfo->numSampled == 0 && pCtx->subsidiaries.num > 0 && !pInfo->nullTupleSaved) {
|
||||||
pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL);
|
pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock);
|
||||||
pInfo->nullTupleSaved = true;
|
pInfo->nullTupleSaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4758,7 +4771,7 @@ static void doModeAdd(SModeInfo* pInfo, int32_t rowIndex, SqlFunctionCtx* pCtx,
|
||||||
pItem->count += 1;
|
pItem->count += 1;
|
||||||
|
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
pItem->tuplePos = saveTupleData(pCtx, rowIndex, pCtx->pSrcBlock, NULL);
|
pItem->tuplePos = saveTupleData(pCtx, rowIndex, pCtx->pSrcBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashPut(pInfo->pHash, data, hashKeyBytes, &pItem, sizeof(SModeItem*));
|
taosHashPut(pInfo->pHash, data, hashKeyBytes, &pItem, sizeof(SModeItem*));
|
||||||
|
@ -4798,7 +4811,7 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pInfo->nullTupleSaved) {
|
if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pInfo->nullTupleSaved) {
|
||||||
pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL);
|
pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock);
|
||||||
pInfo->nullTupleSaved = true;
|
pInfo->nullTupleSaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,57 @@
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
// define signed number sum with check overflow
|
||||||
|
#define CHECK_OVERFLOW_SUM_SIGNED(out, val) \
|
||||||
|
if (out->sum.overflow) { \
|
||||||
|
out->sum.dsum += val; \
|
||||||
|
} else if (out->sum.isum > 0 && val > 0 && INT64_MAX - out->sum.isum <= val || \
|
||||||
|
out->sum.isum < 0 && val < 0 && INT64_MIN - out->sum.isum >= val) { \
|
||||||
|
double dsum = (double)out->sum.isum; \
|
||||||
|
out->sum.overflow = true; \
|
||||||
|
out->sum.dsum = dsum + val; \
|
||||||
|
} else { \
|
||||||
|
out->sum.isum += val; \
|
||||||
|
}
|
||||||
|
|
||||||
|
// val is big than INT64_MAX, val come from merge
|
||||||
|
#define CHECK_OVERFLOW_SUM_SIGNED_BIG(out, val, big) \
|
||||||
|
if (out->sum.overflow) { \
|
||||||
|
out->sum.dsum += val; \
|
||||||
|
} else if (out->sum.isum > 0 && val > 0 && INT64_MAX - out->sum.isum <= val || \
|
||||||
|
out->sum.isum < 0 && val < 0 && INT64_MIN - out->sum.isum >= val || \
|
||||||
|
big) { \
|
||||||
|
double dsum = (double)out->sum.isum; \
|
||||||
|
out->sum.overflow = true; \
|
||||||
|
out->sum.dsum = dsum + val; \
|
||||||
|
} else { \
|
||||||
|
out->sum.isum += val; \
|
||||||
|
}
|
||||||
|
|
||||||
|
// define unsigned number sum with check overflow
|
||||||
|
#define CHECK_OVERFLOW_SUM_UNSIGNED(out, val) \
|
||||||
|
if (out->sum.overflow) { \
|
||||||
|
out->sum.dsum += val; \
|
||||||
|
} else if (UINT64_MAX - out->sum.usum <= val) { \
|
||||||
|
double dsum = (double)out->sum.usum; \
|
||||||
|
out->sum.overflow = true; \
|
||||||
|
out->sum.dsum = dsum + val; \
|
||||||
|
} else { \
|
||||||
|
out->sum.usum += val; \
|
||||||
|
}
|
||||||
|
|
||||||
|
// val is big than UINT64_MAX, val come from merge
|
||||||
|
#define CHECK_OVERFLOW_SUM_UNSIGNED_BIG(out, val, big) \
|
||||||
|
if (out->sum.overflow) { \
|
||||||
|
out->sum.dsum += val; \
|
||||||
|
} else if (UINT64_MAX - out->sum.usum <= val || big) { \
|
||||||
|
double dsum = (double)out->sum.usum; \
|
||||||
|
out->sum.overflow = true; \
|
||||||
|
out->sum.dsum = dsum + val; \
|
||||||
|
} else { \
|
||||||
|
out->sum.usum += val; \
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct SAvgRes {
|
typedef struct SAvgRes {
|
||||||
double result;
|
double result;
|
||||||
SSumRes sum;
|
SSumRes sum;
|
||||||
|
@ -319,9 +370,9 @@ static int32_t calculateAvgBySMAInfo(SAvgRes* pRes, int32_t numOfRows, int32_t t
|
||||||
|
|
||||||
pRes->count += numOfElem;
|
pRes->count += numOfElem;
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||||
pRes->sum.isum += pAgg->sum;
|
CHECK_OVERFLOW_SUM_SIGNED(pRes, pAgg->sum);
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
pRes->sum.usum += pAgg->sum;
|
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, pAgg->sum);
|
||||||
} else if (IS_FLOAT_TYPE(type)) {
|
} else if (IS_FLOAT_TYPE(type)) {
|
||||||
pRes->sum.dsum += GET_DOUBLE_VAL((const char*)&(pAgg->sum));
|
pRes->sum.dsum += GET_DOUBLE_VAL((const char*)&(pAgg->sum));
|
||||||
}
|
}
|
||||||
|
@ -344,7 +395,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -359,7 +410,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -373,7 +424,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -388,7 +439,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -402,7 +453,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.usum += plist[i];
|
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -417,7 +468,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.usum += plist[i];
|
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -431,7 +482,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.usum += plist[i];
|
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -446,7 +497,8 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.usum += plist[i];
|
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, plist[i])
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -527,9 +579,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
||||||
} else {
|
} else {
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
if (type == TSDB_DATA_TYPE_TINYINT) {
|
if (type == TSDB_DATA_TYPE_TINYINT) {
|
||||||
pAvgRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pAvgRes, plist[i])
|
||||||
} else {
|
} else {
|
||||||
pAvgRes->sum.usum += (uint8_t)plist[i];
|
CHECK_OVERFLOW_SUM_UNSIGNED(pAvgRes, (uint8_t)plist[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -546,9 +598,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
||||||
} else {
|
} else {
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
if (type == TSDB_DATA_TYPE_SMALLINT) {
|
if (type == TSDB_DATA_TYPE_SMALLINT) {
|
||||||
pAvgRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pAvgRes, plist[i])
|
||||||
} else {
|
} else {
|
||||||
pAvgRes->sum.usum += (uint16_t)plist[i];
|
CHECK_OVERFLOW_SUM_UNSIGNED(pAvgRes, (uint16_t)plist[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -565,9 +617,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
||||||
} else {
|
} else {
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
if (type == TSDB_DATA_TYPE_INT) {
|
if (type == TSDB_DATA_TYPE_INT) {
|
||||||
pAvgRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pAvgRes, plist[i])
|
||||||
} else {
|
} else {
|
||||||
pAvgRes->sum.usum += (uint32_t)plist[i];
|
CHECK_OVERFLOW_SUM_UNSIGNED(pAvgRes, (uint32_t)plist[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -584,9 +636,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
||||||
} else {
|
} else {
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
if (type == TSDB_DATA_TYPE_BIGINT) {
|
if (type == TSDB_DATA_TYPE_BIGINT) {
|
||||||
pAvgRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pAvgRes, plist[i])
|
||||||
} else {
|
} else {
|
||||||
pAvgRes->sum.usum += (uint64_t)plist[i];
|
CHECK_OVERFLOW_SUM_UNSIGNED(pAvgRes, (uint64_t)plist[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -639,9 +691,11 @@ static void avgTransferInfo(SAvgRes* pInput, SAvgRes* pOutput) {
|
||||||
|
|
||||||
pOutput->type = pInput->type;
|
pOutput->type = pInput->type;
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(pOutput->type)) {
|
if (IS_SIGNED_NUMERIC_TYPE(pOutput->type)) {
|
||||||
pOutput->sum.isum += pInput->sum.isum;
|
bool overflow = pInput->sum.overflow;
|
||||||
|
CHECK_OVERFLOW_SUM_SIGNED_BIG(pOutput, (overflow ? pInput->sum.dsum : pInput->sum.isum), overflow);
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(pOutput->type)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(pOutput->type)) {
|
||||||
pOutput->sum.usum += pInput->sum.usum;
|
bool overflow = pInput->sum.overflow;
|
||||||
|
CHECK_OVERFLOW_SUM_UNSIGNED_BIG(pOutput, (overflow ? pInput->sum.dsum : pInput->sum.usum), overflow);
|
||||||
} else {
|
} else {
|
||||||
pOutput->sum.dsum += pInput->sum.dsum;
|
pOutput->sum.dsum += pInput->sum.dsum;
|
||||||
}
|
}
|
||||||
|
@ -741,9 +795,9 @@ int32_t avgCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
||||||
int16_t type = pDBuf->type == TSDB_DATA_TYPE_NULL ? pSBuf->type : pDBuf->type;
|
int16_t type = pDBuf->type == TSDB_DATA_TYPE_NULL ? pSBuf->type : pDBuf->type;
|
||||||
|
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||||
pDBuf->sum.isum += pSBuf->sum.isum;
|
CHECK_OVERFLOW_SUM_SIGNED(pDBuf, pSBuf->sum.isum)
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
pDBuf->sum.usum += pSBuf->sum.usum;
|
CHECK_OVERFLOW_SUM_UNSIGNED(pDBuf, pSBuf->sum.usum)
|
||||||
} else {
|
} else {
|
||||||
pDBuf->sum.dsum += pSBuf->sum.dsum;
|
pDBuf->sum.dsum += pSBuf->sum.dsum;
|
||||||
}
|
}
|
||||||
|
@ -759,7 +813,10 @@ int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
int32_t type = pRes->type;
|
int32_t type = pRes->type;
|
||||||
|
|
||||||
if (pRes->count > 0) {
|
if (pRes->count > 0) {
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
if(pRes->sum.overflow) {
|
||||||
|
// overflow flag set , use dsum
|
||||||
|
pRes->result = pRes->sum.dsum / ((double)pRes->count);
|
||||||
|
}else if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||||
pRes->result = pRes->sum.isum / ((double)pRes->count);
|
pRes->result = pRes->sum.isum / ((double)pRes->count);
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
pRes->result = pRes->sum.usum / ((double)pRes->count);
|
pRes->result = pRes->sum.usum / ((double)pRes->count);
|
||||||
|
|
|
@ -93,7 +93,6 @@ static void calculateRounds(int32_t numOfRows, int32_t bytes, int32_t* remainder
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int8_t i8VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal) {
|
static int8_t i8VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal) {
|
||||||
int8_t v = 0;
|
int8_t v = 0;
|
||||||
const int8_t* p = pData;
|
const int8_t* p = pData;
|
||||||
|
@ -495,7 +494,8 @@ static void handleInt64Col(const void* data, int32_t start, int32_t numOfRows, S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, bool isMinFunc) {
|
static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf,
|
||||||
|
bool isMinFunc) {
|
||||||
float* pData = (float*)pCol->pData;
|
float* pData = (float*)pCol->pData;
|
||||||
float* val = (float*)&pBuf->v;
|
float* val = (float*)&pBuf->v;
|
||||||
|
|
||||||
|
@ -525,7 +525,8 @@ static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRo
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleDoubleCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, bool isMinFunc) {
|
static void handleDoubleCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf,
|
||||||
|
bool isMinFunc) {
|
||||||
double* pData = (double*)pCol->pData;
|
double* pData = (double*)pCol->pData;
|
||||||
double* val = (double*)&pBuf->v;
|
double* val = (double*)&pBuf->v;
|
||||||
|
|
||||||
|
@ -740,7 +741,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -754,7 +755,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -768,7 +769,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -782,7 +783,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -798,7 +799,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -819,7 +820,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
memcpy(&pBuf->v, pCol->pData + (pCol->info.bytes * i), pCol->info.bytes);
|
memcpy(&pBuf->v, pCol->pData + (pCol->info.bytes * i), pCol->info.bytes);
|
||||||
|
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
pBuf->tuplePos = saveTupleData(pCtx, i, pCtx->pSrcBlock, NULL);
|
pBuf->tuplePos = saveTupleData(pCtx, i, pCtx->pSrcBlock);
|
||||||
}
|
}
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
numOfElems = 1;
|
numOfElems = 1;
|
||||||
|
@ -883,7 +884,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
|
|
||||||
_over:
|
_over:
|
||||||
if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pBuf->nullTupleSaved) {
|
if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pBuf->nullTupleSaved) {
|
||||||
pBuf->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL);
|
pBuf->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock);
|
||||||
pBuf->nullTupleSaved = true;
|
pBuf->nullTupleSaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -841,36 +841,42 @@ int32_t convertScalarParamToDataBlock(SScalarParam *input, int32_t numOfCols, SS
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
numOfRows = (input[i].numOfRows > numOfRows) ? input[i].numOfRows : numOfRows;
|
numOfRows = (input[i].numOfRows > numOfRows) ? input[i].numOfRows : numOfRows;
|
||||||
}
|
}
|
||||||
output->info.rows = numOfRows;
|
|
||||||
output->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
// create the basic block info structure
|
||||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||||
if ((input+i)->numOfRows < numOfRows) {
|
SColumnInfoData* pInfo = input[i].columnData;
|
||||||
SColumnInfoData* pColInfoData = (input+i)->columnData;
|
SColumnInfoData d = {0};
|
||||||
int32_t startRow = (input+i)->numOfRows;
|
d.info = pInfo->info;
|
||||||
int32_t expandRows = numOfRows - startRow;
|
|
||||||
colInfoDataEnsureCapacity(pColInfoData, numOfRows, false);
|
blockDataAppendColInfo(output, &d);
|
||||||
|
}
|
||||||
|
|
||||||
|
blockDataEnsureCapacity(output, numOfRows);
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SColumnInfoData* pDest = taosArrayGet(output->pDataBlock, i);
|
||||||
|
|
||||||
|
SColumnInfoData* pColInfoData = input[i].columnData;
|
||||||
|
colDataAssign(pDest, pColInfoData, input[i].numOfRows, &output->info);
|
||||||
|
|
||||||
|
if (input[i].numOfRows < numOfRows) {
|
||||||
|
int32_t startRow = input[i].numOfRows;
|
||||||
|
int expandRows = numOfRows - startRow;
|
||||||
bool isNull = colDataIsNull_s(pColInfoData, (input+i)->numOfRows - 1);
|
bool isNull = colDataIsNull_s(pColInfoData, (input+i)->numOfRows - 1);
|
||||||
if (isNull) {
|
if (isNull) {
|
||||||
colDataAppendNNULL(pColInfoData, startRow, expandRows);
|
colDataAppendNNULL(pDest, startRow, expandRows);
|
||||||
} else {
|
} else {
|
||||||
char* src = colDataGetData(pColInfoData, (input + i)->numOfRows - 1);
|
char* src = colDataGetData(pColInfoData, (input + i)->numOfRows - 1);
|
||||||
int32_t bytes = pColInfoData->info.bytes;
|
|
||||||
char* data = taosMemoryMalloc(bytes);
|
|
||||||
memcpy(data, src, bytes);
|
|
||||||
for (int j = 0; j < expandRows; ++j) {
|
for (int j = 0; j < expandRows; ++j) {
|
||||||
colDataAppend(pColInfoData, startRow+j, data, false);
|
colDataAppend(pDest, startRow+j, src, false);
|
||||||
}
|
}
|
||||||
//colDataAppendNItems(pColInfoData, startRow, data, expandRows);
|
//colDataAppendNItems(pColInfoData, startRow, data, expandRows);
|
||||||
taosMemoryFree(data);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(output->pDataBlock, (input + i)->columnData);
|
output->info.rows = numOfRows;
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE((input + i)->columnData->info.type)) {
|
|
||||||
output->info.hasVarCol = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1224,7 +1230,6 @@ int32_t udfcGetUdfTaskResultFromUvTask(SClientUdfTask *task, SClientUvTaskNode *
|
||||||
if (uvTask->rspBuf.base != NULL) {
|
if (uvTask->rspBuf.base != NULL) {
|
||||||
SUdfResponse rsp = {0};
|
SUdfResponse rsp = {0};
|
||||||
void *buf = decodeUdfResponse(uvTask->rspBuf.base, &rsp);
|
void *buf = decodeUdfResponse(uvTask->rspBuf.base, &rsp);
|
||||||
assert(uvTask->rspBuf.len == POINTER_DISTANCE(buf, uvTask->rspBuf.base));
|
|
||||||
task->errCode = rsp.code;
|
task->errCode = rsp.code;
|
||||||
|
|
||||||
switch (task->type) {
|
switch (task->type) {
|
||||||
|
@ -1825,7 +1830,7 @@ int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t
|
||||||
taosArrayDestroy(resultBlock.pDataBlock);
|
taosArrayDestroy(resultBlock.pDataBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(inputBlock.pDataBlock);
|
blockDataFreeRes(&inputBlock);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -400,7 +400,6 @@ void udfdProcessTeardownRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
||||||
|
|
||||||
void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
SUdfdRpcSendRecvInfo *msgInfo = (SUdfdRpcSendRecvInfo *)pMsg->info.ahandle;
|
SUdfdRpcSendRecvInfo *msgInfo = (SUdfdRpcSendRecvInfo *)pMsg->info.ahandle;
|
||||||
ASSERT(pMsg->info.ahandle != NULL);
|
|
||||||
|
|
||||||
if (pEpSet) {
|
if (pEpSet) {
|
||||||
if (!isEpsetEqual(&global.mgmtEp.epSet, pEpSet)) {
|
if (!isEpsetEqual(&global.mgmtEp.epSet, pEpSet)) {
|
||||||
|
@ -606,6 +605,7 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) {
|
||||||
}
|
}
|
||||||
static bool udfdRpcRfp(int32_t code, tmsg_t msgType) {
|
static bool udfdRpcRfp(int32_t code, tmsg_t msgType) {
|
||||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_SYN_NOT_LEADER ||
|
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_SYN_NOT_LEADER ||
|
||||||
|
code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED ||
|
||||||
code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_MNODE_NOT_FOUND || code == TSDB_CODE_APP_IS_STARTING ||
|
code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_MNODE_NOT_FOUND || code == TSDB_CODE_APP_IS_STARTING ||
|
||||||
code == TSDB_CODE_APP_IS_STOPPING) {
|
code == TSDB_CODE_APP_IS_STOPPING) {
|
||||||
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH ||
|
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH ||
|
||||||
|
|
|
@ -44,6 +44,11 @@ typedef struct IFileCtx {
|
||||||
bool readOnly;
|
bool readOnly;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
int64_t size;
|
int64_t size;
|
||||||
|
|
||||||
|
char* wBuf;
|
||||||
|
int32_t wBufOffset;
|
||||||
|
int32_t wBufCap;
|
||||||
|
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
char* ptr;
|
char* ptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,14 +38,41 @@ static FORCE_INLINE void idxGenLRUKey(char* buf, const char* path, int32_t block
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static FORCE_INLINE int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) {
|
static FORCE_INLINE int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) {
|
||||||
|
int tlen = len;
|
||||||
if (ctx->type == TFILE) {
|
if (ctx->type == TFILE) {
|
||||||
int nwr = taosWriteFile(ctx->file.pFile, buf, len);
|
int32_t cap = ctx->file.wBufCap;
|
||||||
assert(nwr == len);
|
if (len + ctx->file.wBufOffset >= cap) {
|
||||||
|
int32_t nw = cap - ctx->file.wBufOffset;
|
||||||
|
memcpy(ctx->file.wBuf + ctx->file.wBufOffset, buf, nw);
|
||||||
|
taosWriteFile(ctx->file.pFile, ctx->file.wBuf, cap);
|
||||||
|
|
||||||
|
memset(ctx->file.wBuf, 0, cap);
|
||||||
|
ctx->file.wBufOffset = 0;
|
||||||
|
|
||||||
|
len -= nw;
|
||||||
|
buf += nw;
|
||||||
|
|
||||||
|
nw = (len / cap) * cap;
|
||||||
|
if (nw != 0) {
|
||||||
|
taosWriteFile(ctx->file.pFile, buf, nw);
|
||||||
|
}
|
||||||
|
|
||||||
|
len -= nw;
|
||||||
|
buf += nw;
|
||||||
|
if (len != 0) {
|
||||||
|
memcpy(ctx->file.wBuf, buf, len);
|
||||||
|
}
|
||||||
|
ctx->file.wBufOffset += len;
|
||||||
|
} else {
|
||||||
|
memcpy(ctx->file.wBuf + ctx->file.wBufOffset, buf, len);
|
||||||
|
ctx->file.wBufOffset += len;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
memcpy(ctx->mem.buf + ctx->offset, buf, len);
|
memcpy(ctx->mem.buf + ctx->offset, buf, len);
|
||||||
}
|
}
|
||||||
ctx->offset += len;
|
ctx->offset += tlen;
|
||||||
return len;
|
return tlen;
|
||||||
}
|
}
|
||||||
static FORCE_INLINE int idxFileCtxDoRead(IFileCtx* ctx, uint8_t* buf, int len) {
|
static FORCE_INLINE int idxFileCtxDoRead(IFileCtx* ctx, uint8_t* buf, int len) {
|
||||||
int nRead = 0;
|
int nRead = 0;
|
||||||
|
@ -127,14 +154,22 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of
|
||||||
}
|
}
|
||||||
static FORCE_INLINE int idxFileCtxGetSize(IFileCtx* ctx) {
|
static FORCE_INLINE int idxFileCtxGetSize(IFileCtx* ctx) {
|
||||||
if (ctx->type == TFILE) {
|
if (ctx->type == TFILE) {
|
||||||
|
if (ctx->file.readOnly == false) {
|
||||||
|
return ctx->offset;
|
||||||
|
} else {
|
||||||
int64_t file_size = 0;
|
int64_t file_size = 0;
|
||||||
taosStatFile(ctx->file.buf, &file_size, NULL);
|
taosStatFile(ctx->file.buf, &file_size, NULL);
|
||||||
return (int)file_size;
|
return (int)file_size;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static FORCE_INLINE int idxFileCtxDoFlush(IFileCtx* ctx) {
|
static FORCE_INLINE int idxFileCtxDoFlush(IFileCtx* ctx) {
|
||||||
if (ctx->type == TFILE) {
|
if (ctx->type == TFILE) {
|
||||||
|
if (ctx->file.wBufOffset > 0) {
|
||||||
|
int32_t nw = taosWriteFile(ctx->file.pFile, ctx->file.wBuf, ctx->file.wBufOffset);
|
||||||
|
ctx->file.wBufOffset = 0;
|
||||||
|
}
|
||||||
taosFsyncFile(ctx->file.pFile);
|
taosFsyncFile(ctx->file.pFile);
|
||||||
} else {
|
} else {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -157,10 +192,15 @@ IFileCtx* idxFileCtxCreate(WriterType type, const char* path, bool readOnly, int
|
||||||
ctx->file.pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
ctx->file.pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
||||||
taosFtruncateFile(ctx->file.pFile, 0);
|
taosFtruncateFile(ctx->file.pFile, 0);
|
||||||
taosStatFile(path, &ctx->file.size, NULL);
|
taosStatFile(path, &ctx->file.size, NULL);
|
||||||
|
|
||||||
|
ctx->file.wBufOffset = 0;
|
||||||
|
ctx->file.wBufCap = kBlockSize * 4;
|
||||||
|
ctx->file.wBuf = taosMemoryCalloc(1, ctx->file.wBufCap);
|
||||||
} else {
|
} else {
|
||||||
ctx->file.pFile = taosOpenFile(path, TD_FILE_READ);
|
ctx->file.pFile = taosOpenFile(path, TD_FILE_READ);
|
||||||
|
|
||||||
taosFStatFile(ctx->file.pFile, &ctx->file.size, NULL);
|
taosFStatFile(ctx->file.pFile, &ctx->file.size, NULL);
|
||||||
|
ctx->file.wBufOffset = 0;
|
||||||
|
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
ctx->file.ptr = (char*)tfMmapReadOnly(ctx->file.pFile, ctx->file.size);
|
ctx->file.ptr = (char*)tfMmapReadOnly(ctx->file.pFile, ctx->file.size);
|
||||||
#endif
|
#endif
|
||||||
|
@ -195,17 +235,18 @@ void idxFileCtxDestroy(IFileCtx* ctx, bool remove) {
|
||||||
if (ctx->type == TMEMORY) {
|
if (ctx->type == TMEMORY) {
|
||||||
taosMemoryFree(ctx->mem.buf);
|
taosMemoryFree(ctx->mem.buf);
|
||||||
} else {
|
} else {
|
||||||
|
if (ctx->file.wBufOffset > 0) {
|
||||||
|
int32_t nw = taosWriteFile(ctx->file.pFile, ctx->file.wBuf, ctx->file.wBufOffset);
|
||||||
|
ctx->file.wBufOffset = 0;
|
||||||
|
}
|
||||||
ctx->flush(ctx);
|
ctx->flush(ctx);
|
||||||
|
taosMemoryFreeClear(ctx->file.wBuf);
|
||||||
taosCloseFile(&ctx->file.pFile);
|
taosCloseFile(&ctx->file.pFile);
|
||||||
if (ctx->file.readOnly) {
|
if (ctx->file.readOnly) {
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
munmap(ctx->file.ptr, ctx->file.size);
|
munmap(ctx->file.ptr, ctx->file.size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (ctx->file.readOnly == false) {
|
|
||||||
int64_t file_size = 0;
|
|
||||||
taosStatFile(ctx->file.buf, &file_size, NULL);
|
|
||||||
}
|
|
||||||
if (remove) {
|
if (remove) {
|
||||||
unlink(ctx->file.buf);
|
unlink(ctx->file.buf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,6 +402,7 @@ static int32_t logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pGroupKeys);
|
CLONE_NODE_LIST_FIELD(pGroupKeys);
|
||||||
CLONE_NODE_LIST_FIELD(pAggFuncs);
|
CLONE_NODE_LIST_FIELD(pAggFuncs);
|
||||||
|
COPY_SCALAR_FIELD(hasGroupKeyOptimized);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1829,6 +1829,7 @@ static const char* jkAggPhysiPlanExprs = "Exprs";
|
||||||
static const char* jkAggPhysiPlanGroupKeys = "GroupKeys";
|
static const char* jkAggPhysiPlanGroupKeys = "GroupKeys";
|
||||||
static const char* jkAggPhysiPlanAggFuncs = "AggFuncs";
|
static const char* jkAggPhysiPlanAggFuncs = "AggFuncs";
|
||||||
static const char* jkAggPhysiPlanMergeDataBlock = "MergeDataBlock";
|
static const char* jkAggPhysiPlanMergeDataBlock = "MergeDataBlock";
|
||||||
|
static const char* jkAggPhysiPlanGroupKeyOptimized = "GroupKeyOptimized";
|
||||||
|
|
||||||
static int32_t physiAggNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physiAggNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SAggPhysiNode* pNode = (const SAggPhysiNode*)pObj;
|
const SAggPhysiNode* pNode = (const SAggPhysiNode*)pObj;
|
||||||
|
@ -1846,6 +1847,9 @@ static int32_t physiAggNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddBoolToObject(pJson, jkAggPhysiPlanMergeDataBlock, pNode->mergeDataBlock);
|
code = tjsonAddBoolToObject(pJson, jkAggPhysiPlanMergeDataBlock, pNode->mergeDataBlock);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddBoolToObject(pJson, jkAggPhysiPlanGroupKeyOptimized, pNode->groupKeyOptimized);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1866,6 +1870,9 @@ static int32_t jsonToPhysiAggNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBoolValue(pJson, jkAggPhysiPlanMergeDataBlock, &pNode->mergeDataBlock);
|
code = tjsonGetBoolValue(pJson, jkAggPhysiPlanMergeDataBlock, &pNode->mergeDataBlock);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBoolValue(pJson, jkAggPhysiPlanGroupKeyOptimized, &pNode->groupKeyOptimized);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2370,7 +2370,8 @@ enum {
|
||||||
PHY_AGG_CODE_EXPR,
|
PHY_AGG_CODE_EXPR,
|
||||||
PHY_AGG_CODE_GROUP_KEYS,
|
PHY_AGG_CODE_GROUP_KEYS,
|
||||||
PHY_AGG_CODE_AGG_FUNCS,
|
PHY_AGG_CODE_AGG_FUNCS,
|
||||||
PHY_AGG_CODE_MERGE_DATA_BLOCK
|
PHY_AGG_CODE_MERGE_DATA_BLOCK,
|
||||||
|
PHY_AGG_CODE_GROUP_KEY_OPTIMIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
static int32_t physiAggNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
static int32_t physiAggNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||||
|
@ -2389,6 +2390,9 @@ static int32_t physiAggNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tlvEncodeBool(pEncoder, PHY_AGG_CODE_MERGE_DATA_BLOCK, pNode->mergeDataBlock);
|
code = tlvEncodeBool(pEncoder, PHY_AGG_CODE_MERGE_DATA_BLOCK, pNode->mergeDataBlock);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tlvEncodeBool(pEncoder, PHY_AGG_CODE_GROUP_KEY_OPTIMIZE, pNode->groupKeyOptimized);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2415,6 +2419,9 @@ static int32_t msgToPhysiAggNode(STlvDecoder* pDecoder, void* pObj) {
|
||||||
case PHY_AGG_CODE_MERGE_DATA_BLOCK:
|
case PHY_AGG_CODE_MERGE_DATA_BLOCK:
|
||||||
code = tlvDecodeBool(pTlv, &pNode->mergeDataBlock);
|
code = tlvDecodeBool(pTlv, &pNode->mergeDataBlock);
|
||||||
break;
|
break;
|
||||||
|
case PHY_AGG_CODE_GROUP_KEY_OPTIMIZE:
|
||||||
|
code = tlvDecodeBool(pTlv, &pNode->groupKeyOptimized);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,6 +186,7 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
|
||||||
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort);
|
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort);
|
||||||
SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, bool force);
|
SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, bool force);
|
||||||
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue);
|
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue);
|
||||||
|
SNode* createRealTableNodeForIndexName(SAstCreateContext* pCxt, SToken* pDbName, SToken* pIndexName);
|
||||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SNode* pIndexName,
|
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SNode* pIndexName,
|
||||||
SNode* pRealTable, SNodeList* pCols, SNode* pOptions);
|
SNode* pRealTable, SNodeList* pCols, SNode* pOptions);
|
||||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding,
|
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding,
|
||||||
|
@ -193,15 +194,13 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
|
||||||
SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pIndexName);
|
SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pIndexName);
|
||||||
SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
||||||
SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
||||||
SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName,
|
SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pQuery);
|
||||||
SNode* pQuery);
|
SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SToken* pSubDbName,
|
||||||
SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName,
|
bool withMeta);
|
||||||
const SToken* pSubDbName, bool withMeta);
|
SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pRealTable,
|
||||||
SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName,
|
bool withMeta);
|
||||||
SNode* pRealTable, bool withMeta);
|
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pTopicName);
|
||||||
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName);
|
SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId, SToken* pTopicName);
|
||||||
SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId,
|
|
||||||
const SToken* pTopicName);
|
|
||||||
SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue);
|
SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue);
|
||||||
SNode* createDefaultExplainOptions(SAstCreateContext* pCxt);
|
SNode* createDefaultExplainOptions(SAstCreateContext* pCxt);
|
||||||
SNode* setExplainVerbose(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal);
|
SNode* setExplainVerbose(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal);
|
||||||
|
@ -214,9 +213,9 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool
|
||||||
const SToken* pLibPath, SDataType dataType, int32_t bufSize);
|
const SToken* pLibPath, SDataType dataType, int32_t bufSize);
|
||||||
SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName);
|
SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName);
|
||||||
SNode* createStreamOptions(SAstCreateContext* pCxt);
|
SNode* createStreamOptions(SAstCreateContext* pCxt);
|
||||||
SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable,
|
SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pStreamName, SNode* pRealTable,
|
||||||
SNode* pOptions, SNodeList* pTags, SNode* pSubtable, SNode* pQuery);
|
SNode* pOptions, SNodeList* pTags, SNode* pSubtable, SNode* pQuery);
|
||||||
SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName);
|
SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pStreamName);
|
||||||
SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId);
|
SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId);
|
||||||
SNode* createKillQueryStmt(SAstCreateContext* pCxt, const SToken* pQueryId);
|
SNode* createKillQueryStmt(SAstCreateContext* pCxt, const SToken* pQueryId);
|
||||||
SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt);
|
SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt);
|
||||||
|
|
|
@ -459,8 +459,11 @@ tag_item(A) ::= column_name(B) AS column_alias(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_index_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); }
|
||||||
cmd ::= DROP INDEX exists_opt(B) full_table_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, A); }
|
cmd ::= DROP INDEX exists_opt(B) full_index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, A); }
|
||||||
|
|
||||||
|
full_index_name(A) ::= index_name(B). { A = createRealTableNodeForIndexName(pCxt, NULL, &B); }
|
||||||
|
full_index_name(A) ::= db_name(B) NK_DOT index_name(C). { A = createRealTableNodeForIndexName(pCxt, &B, &C); }
|
||||||
|
|
||||||
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
|
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
|
||||||
NK_LP duration_literal(C) NK_RP sliding_opt(D) sma_stream_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D, E); }
|
NK_LP duration_literal(C) NK_RP sliding_opt(D) sma_stream_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D, E); }
|
||||||
|
@ -657,6 +660,10 @@ stream_name(A) ::= NK_ID(B).
|
||||||
%destructor cgroup_name { }
|
%destructor cgroup_name { }
|
||||||
cgroup_name(A) ::= NK_ID(B). { A = B; }
|
cgroup_name(A) ::= NK_ID(B). { A = B; }
|
||||||
|
|
||||||
|
%type index_name { SToken }
|
||||||
|
%destructor index_name { }
|
||||||
|
index_name(A) ::= NK_ID(B). { A = B; }
|
||||||
|
|
||||||
/************************************************ expression **********************************************************/
|
/************************************************ expression **********************************************************/
|
||||||
expr_or_subquery(A) ::= expression(B). { A = B; }
|
expr_or_subquery(A) ::= expression(B). { A = B; }
|
||||||
//expr_or_subquery(A) ::= subquery(B). { A = createTempTableNode(pCxt, releaseRawExprNode(pCxt, B), NULL); }
|
//expr_or_subquery(A) ::= subquery(B). { A = createTempTableNode(pCxt, releaseRawExprNode(pCxt, B), NULL); }
|
||||||
|
|
|
@ -201,6 +201,24 @@ static bool checkIndexName(SAstCreateContext* pCxt, SToken* pIndexName) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool checkTopicName(SAstCreateContext* pCxt, SToken* pTopicName) {
|
||||||
|
trimEscape(pTopicName);
|
||||||
|
if (pTopicName->n >= TSDB_TOPIC_NAME_LEN) {
|
||||||
|
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pTopicName->z);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool checkStreamName(SAstCreateContext* pCxt, SToken* pStreamName) {
|
||||||
|
trimEscape(pStreamName);
|
||||||
|
if (pStreamName->n >= TSDB_STREAM_NAME_LEN) {
|
||||||
|
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pStreamName->z);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool checkComment(SAstCreateContext* pCxt, const SToken* pCommentToken, bool demand) {
|
static bool checkComment(SAstCreateContext* pCxt, const SToken* pCommentToken, bool demand) {
|
||||||
if (NULL == pCommentToken) {
|
if (NULL == pCommentToken) {
|
||||||
pCxt->errCode = demand ? TSDB_CODE_PAR_SYNTAX_ERROR : TSDB_CODE_SUCCESS;
|
pCxt->errCode = demand ? TSDB_CODE_PAR_SYNTAX_ERROR : TSDB_CODE_SUCCESS;
|
||||||
|
@ -1509,6 +1527,13 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SNode* createRealTableNodeForIndexName(SAstCreateContext* pCxt, SToken* pDbName, SToken* pIndexName) {
|
||||||
|
if (!checkIndexName(pCxt, pIndexName)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return createRealTableNode(pCxt, pDbName, pIndexName, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SNode* pIndexName,
|
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SNode* pIndexName,
|
||||||
SNode* pRealTable, SNodeList* pCols, SNode* pOptions) {
|
SNode* pRealTable, SNodeList* pCols, SNode* pOptions) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
@ -1567,9 +1592,11 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName,
|
SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pQuery) {
|
||||||
SNode* pQuery) {
|
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
if (!checkTopicName(pCxt, pTopicName)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
||||||
|
@ -1578,9 +1605,12 @@ SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists,
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName,
|
SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SToken* pSubDbName,
|
||||||
const SToken* pSubDbName, bool withMeta) {
|
bool withMeta) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
if (!checkTopicName(pCxt, pTopicName) || !checkDbName(pCxt, pSubDbName, true)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
||||||
|
@ -1590,9 +1620,12 @@ SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, co
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName,
|
SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pRealTable,
|
||||||
SNode* pRealTable, bool withMeta) {
|
bool withMeta) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
if (!checkTopicName(pCxt, pTopicName)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
||||||
|
@ -1604,8 +1637,11 @@ SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists,
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName) {
|
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pTopicName) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
if (!checkTopicName(pCxt, pTopicName)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
SDropTopicStmt* pStmt = (SDropTopicStmt*)nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT);
|
SDropTopicStmt* pStmt = (SDropTopicStmt*)nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
||||||
|
@ -1614,8 +1650,11 @@ SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId,
|
SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId,
|
||||||
const SToken* pTopicName) {
|
SToken* pTopicName) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
if (!checkTopicName(pCxt, pTopicName)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
SDropCGroupStmt* pStmt = (SDropCGroupStmt*)nodesMakeNode(QUERY_NODE_DROP_CGROUP_STMT);
|
SDropCGroupStmt* pStmt = (SDropCGroupStmt*)nodesMakeNode(QUERY_NODE_DROP_CGROUP_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->ignoreNotExists = ignoreNotExists;
|
pStmt->ignoreNotExists = ignoreNotExists;
|
||||||
|
@ -1727,9 +1766,12 @@ SNode* createStreamOptions(SAstCreateContext* pCxt) {
|
||||||
return (SNode*)pOptions;
|
return (SNode*)pOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable,
|
SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pStreamName, SNode* pRealTable,
|
||||||
SNode* pOptions, SNodeList* pTags, SNode* pSubtable, SNode* pQuery) {
|
SNode* pOptions, SNodeList* pTags, SNode* pSubtable, SNode* pQuery) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
if (!checkStreamName(pCxt, pStreamName)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT);
|
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
COPY_STRING_FORM_ID_TOKEN(pStmt->streamName, pStreamName);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->streamName, pStreamName);
|
||||||
|
@ -1746,8 +1788,11 @@ SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName) {
|
SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pStreamName) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
if (!checkStreamName(pCxt, pStreamName)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
SDropStreamStmt* pStmt = (SDropStreamStmt*)nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT);
|
SDropStreamStmt* pStmt = (SDropStreamStmt*)nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
COPY_STRING_FORM_ID_TOKEN(pStmt->streamName, pStreamName);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->streamName, pStreamName);
|
||||||
|
|
|
@ -4948,6 +4948,10 @@ static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTable
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getNumOfTags(pTableMeta) == 1 && pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, "the only tag cannot be dropped");
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tagsLen = 0;
|
int32_t tagsLen = 0;
|
||||||
for (int32_t i = 0; i < pTableMeta->tableInfo.numOfTags; ++i) {
|
for (int32_t i = 0; i < pTableMeta->tableInfo.numOfTags; ++i) {
|
||||||
tagsLen += pTagsSchema[i].bytes;
|
tagsLen += pTagsSchema[i].bytes;
|
||||||
|
@ -5640,7 +5644,8 @@ static int32_t addSubtableInfoToCreateStreamQuery(STranslateContext* pCxt, SCrea
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkStreamQuery(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt) {
|
||||||
|
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
||||||
if (TSDB_DATA_TYPE_TIMESTAMP != ((SExprNode*)nodesListGetNode(pSelect->pProjectionList, 0))->resType.type ||
|
if (TSDB_DATA_TYPE_TIMESTAMP != ((SExprNode*)nodesListGetNode(pSelect->pProjectionList, 0))->resType.type ||
|
||||||
!pSelect->isTimeLineResult || crossTableWithoutAggOper(pSelect) || NULL != pSelect->pOrderByList ||
|
!pSelect->isTimeLineResult || crossTableWithoutAggOper(pSelect) || NULL != pSelect->pOrderByList ||
|
||||||
crossTableWithUdaf(pSelect)) {
|
crossTableWithUdaf(pSelect)) {
|
||||||
|
@ -5650,6 +5655,10 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
"SUBTABLE expression must be of VARCHAR type");
|
"SUBTABLE expression must be of VARCHAR type");
|
||||||
}
|
}
|
||||||
|
if (NULL == pSelect->pWindow && STREAM_TRIGGER_AT_ONCE != pStmt->pOptions->triggerType) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
|
"The trigger mode of non window query can only be AT_ONCE");
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5663,7 +5672,7 @@ static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt
|
||||||
code = translateQuery(pCxt, pStmt->pQuery);
|
code = translateQuery(pCxt, pStmt->pQuery);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkStreamQuery(pCxt, (SSelectStmt*)pStmt->pQuery);
|
code = checkStreamQuery(pCxt, pStmt);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
getSourceDatabase(pStmt->pQuery, pCxt->pParseCxt->acctId, pReq->sourceDB);
|
getSourceDatabase(pStmt->pQuery, pCxt->pParseCxt->acctId, pReq->sourceDB);
|
||||||
|
@ -7477,7 +7486,7 @@ static void destoryAlterTbReq(SVAlterTbReq* pReq) {
|
||||||
static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
|
static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
|
||||||
SQuery* pQuery) {
|
SQuery* pQuery) {
|
||||||
if (getNumOfTags(pTableMeta) == 1 && pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG) {
|
if (getNumOfTags(pTableMeta) == 1 && pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, "the only tag cannot be dropped");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_SUPER_TABLE == pTableMeta->tableType) {
|
if (TSDB_SUPER_TABLE == pTableMeta->tableType) {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -545,6 +545,7 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
|
||||||
pAgg->hasLastRow = pSelect->hasLastRowFunc;
|
pAgg->hasLastRow = pSelect->hasLastRowFunc;
|
||||||
pAgg->hasLast = pSelect->hasLastFunc;
|
pAgg->hasLast = pSelect->hasLastFunc;
|
||||||
pAgg->hasTimeLineFunc = pSelect->hasTimeLineFunc;
|
pAgg->hasTimeLineFunc = pSelect->hasTimeLineFunc;
|
||||||
|
pAgg->hasGroupKeyOptimized = false;
|
||||||
pAgg->onlyHasKeepOrderFunc = pSelect->onlyHasKeepOrderFunc;
|
pAgg->onlyHasKeepOrderFunc = pSelect->onlyHasKeepOrderFunc;
|
||||||
pAgg->node.groupAction = getGroupAction(pCxt, pSelect);
|
pAgg->node.groupAction = getGroupAction(pCxt, pSelect);
|
||||||
pAgg->node.requireDataOrder = getRequireDataOrder(pAgg->hasTimeLineFunc, pSelect);
|
pAgg->node.requireDataOrder = getRequireDataOrder(pAgg->hasTimeLineFunc, pSelect);
|
||||||
|
|
|
@ -1544,6 +1544,11 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
|
||||||
code = adjustLogicNodeDataRequirement((SLogicNode*)pScan, pNode->resultDataOrder);
|
code = adjustLogicNodeDataRequirement((SLogicNode*)pScan, pNode->resultDataOrder);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
if (QUERY_NODE_LOGIC_PLAN_AGG == pNode->pParent->type) {
|
||||||
|
SAggLogicNode* pParent = (SAggLogicNode*)(pNode->pParent);
|
||||||
|
pParent->hasGroupKeyOptimized = true;
|
||||||
|
}
|
||||||
|
|
||||||
NODES_CLEAR_LIST(pNode->pChildren);
|
NODES_CLEAR_LIST(pNode->pChildren);
|
||||||
nodesDestroyNode((SNode*)pNode);
|
nodesDestroyNode((SNode*)pNode);
|
||||||
}
|
}
|
||||||
|
@ -1569,6 +1574,8 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pAgg->hasGroupKeyOptimized = true;
|
||||||
|
|
||||||
NODES_DESTORY_LIST(pAgg->pGroupKeys);
|
NODES_DESTORY_LIST(pAgg->pGroupKeys);
|
||||||
if (TSDB_CODE_SUCCESS == code && start >= 0) {
|
if (TSDB_CODE_SUCCESS == code && start >= 0) {
|
||||||
code = partTagsRewriteGroupTagsToFuncs(pScan->pGroupTags, start, pAgg);
|
code = partTagsRewriteGroupTagsToFuncs(pScan->pGroupTags, start, pAgg);
|
||||||
|
@ -1577,6 +1584,7 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = partTagsOptRebuildTbanme(pScan->pGroupTags);
|
code = partTagsOptRebuildTbanme(pScan->pGroupTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
pCxt->optimized = true;
|
pCxt->optimized = true;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2380,6 +2388,9 @@ static bool tagScanOptShouldBeOptimized(SLogicNode* pNode) {
|
||||||
if (pScan->hasNormalCols) {
|
if (pScan->hasNormalCols) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (pScan->tableType == TSDB_SYSTEM_TABLE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (NULL == pNode->pParent || QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent) ||
|
if (NULL == pNode->pParent || QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent) ||
|
||||||
1 != LIST_LENGTH(pNode->pParent->pChildren)) {
|
1 != LIST_LENGTH(pNode->pParent->pChildren)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -872,6 +872,7 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
}
|
}
|
||||||
|
|
||||||
pAgg->mergeDataBlock = (GROUP_ACTION_KEEP == pAggLogicNode->node.groupAction ? false : true);
|
pAgg->mergeDataBlock = (GROUP_ACTION_KEEP == pAggLogicNode->node.groupAction ? false : true);
|
||||||
|
pAgg->groupKeyOptimized = pAggLogicNode->hasGroupKeyOptimized;
|
||||||
|
|
||||||
SNodeList* pPrecalcExprs = NULL;
|
SNodeList* pPrecalcExprs = NULL;
|
||||||
SNodeList* pGroupKeys = NULL;
|
SNodeList* pGroupKeys = NULL;
|
||||||
|
|
|
@ -333,13 +333,23 @@ static bool stbSplHasPartTbname(SNodeList* pPartKeys) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool stbSplIsPartTableAgg(SAggLogicNode* pAgg) {
|
static bool stbSplNotSystemScan(SLogicNode* pNode) {
|
||||||
if (NULL != pAgg->pGroupKeys) {
|
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) {
|
||||||
return stbSplHasPartTbname(pAgg->pGroupKeys);
|
return SCAN_TYPE_SYSTEM_TABLE != ((SScanLogicNode*)pNode)->scanType;
|
||||||
|
} else if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode)) {
|
||||||
|
return stbSplNotSystemScan((SLogicNode*)nodesListGetNode(pNode->pChildren, 0));
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool stbSplIsPartTableAgg(SAggLogicNode* pAgg) {
|
||||||
if (1 != LIST_LENGTH(pAgg->node.pChildren)) {
|
if (1 != LIST_LENGTH(pAgg->node.pChildren)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (NULL != pAgg->pGroupKeys) {
|
||||||
|
return stbSplHasPartTbname(pAgg->pGroupKeys) && stbSplNotSystemScan((SLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0));
|
||||||
|
}
|
||||||
return stbSplHasPartTbname(stbSplGetPartKeys((SLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0)));
|
return stbSplHasPartTbname(stbSplGetPartKeys((SLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,14 +114,14 @@ typedef struct SQWTaskStatus {
|
||||||
typedef struct SQWTaskCtx {
|
typedef struct SQWTaskCtx {
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
int8_t phase;
|
int8_t phase;
|
||||||
|
int8_t inFetch;
|
||||||
int8_t taskType;
|
int8_t taskType;
|
||||||
int8_t explain;
|
int8_t explain;
|
||||||
int8_t needFetch;
|
int8_t needFetch;
|
||||||
int8_t localExec;
|
int8_t localExec;
|
||||||
int32_t msgType;
|
int32_t msgType;
|
||||||
int32_t fetchType;
|
|
||||||
int32_t execId;
|
|
||||||
int32_t level;
|
int32_t level;
|
||||||
|
uint64_t sId;
|
||||||
|
|
||||||
bool queryGotData;
|
bool queryGotData;
|
||||||
bool queryRsped;
|
bool queryRsped;
|
||||||
|
@ -221,8 +221,16 @@ typedef struct SQWorkerMgmt {
|
||||||
#define QW_GET_PHASE(ctx) atomic_load_8(&(ctx)->phase)
|
#define QW_GET_PHASE(ctx) atomic_load_8(&(ctx)->phase)
|
||||||
#define QW_SET_PHASE(ctx, _value) \
|
#define QW_SET_PHASE(ctx, _value) \
|
||||||
do { \
|
do { \
|
||||||
if ((_value) != QW_PHASE_PRE_FETCH && (_value) != QW_PHASE_POST_FETCH) { \
|
switch (_value) { \
|
||||||
|
case QW_PHASE_PRE_FETCH: \
|
||||||
|
ctx->inFetch = 1; \
|
||||||
|
break; \
|
||||||
|
case QW_PHASE_POST_FETCH: \
|
||||||
|
ctx->inFetch = 0; \
|
||||||
|
break; \
|
||||||
|
default: \
|
||||||
atomic_store_8(&(ctx)->phase, _value); \
|
atomic_store_8(&(ctx)->phase, _value); \
|
||||||
|
break; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -230,6 +238,7 @@ typedef struct SQWorkerMgmt {
|
||||||
#define QW_UPDATE_RSP_CODE(ctx, code) atomic_val_compare_exchange_32(&(ctx)->rspCode, 0, code)
|
#define QW_UPDATE_RSP_CODE(ctx, code) atomic_val_compare_exchange_32(&(ctx)->rspCode, 0, code)
|
||||||
|
|
||||||
#define QW_QUERY_RUNNING(ctx) (QW_GET_PHASE(ctx) == QW_PHASE_PRE_QUERY || QW_GET_PHASE(ctx) == QW_PHASE_PRE_CQUERY)
|
#define QW_QUERY_RUNNING(ctx) (QW_GET_PHASE(ctx) == QW_PHASE_PRE_QUERY || QW_GET_PHASE(ctx) == QW_PHASE_PRE_CQUERY)
|
||||||
|
#define QW_FETCH_RUNNING(ctx) ((ctx)->inFetch)
|
||||||
|
|
||||||
#define QW_SET_QTID(id, qId, tId, eId) \
|
#define QW_SET_QTID(id, qId, tId, eId) \
|
||||||
do { \
|
do { \
|
||||||
|
|
|
@ -124,11 +124,11 @@ void qwDbgDumpTasksInfo(SQWorker *mgmt) {
|
||||||
void *key = taosHashGetKey(pIter, NULL);
|
void *key = taosHashGetKey(pIter, NULL);
|
||||||
QW_GET_QTID(key, qId, tId, eId);
|
QW_GET_QTID(key, qId, tId, eId);
|
||||||
|
|
||||||
QW_TASK_DLOG("%p lock:%x, phase:%d, type:%d, explain:%d, needFetch:%d, localExec:%d, msgType:%d, fetchType:%d, "
|
QW_TASK_DLOG("%p lock:%x, phase:%d, type:%d, explain:%d, needFetch:%d, localExec:%d, msgType:%d, "
|
||||||
"execId:%x, level:%d, queryGotData:%d, queryRsped:%d, queryEnd:%d, queryContinue:%d, queryInQueue:%d, "
|
"sId:%" PRId64 ", level:%d, queryGotData:%d, queryRsped:%d, queryEnd:%d, queryContinue:%d, queryInQueue:%d, "
|
||||||
"rspCode:%x, affectedRows:%" PRId64 ", taskHandle:%p, sinkHandle:%p, tbFName:%s, sver:%d, tver:%d, events:%d,%d,%d,%d,%d",
|
"rspCode:%x, affectedRows:%" PRId64 ", taskHandle:%p, sinkHandle:%p, tbFName:%s, sver:%d, tver:%d, events:%d,%d,%d,%d,%d",
|
||||||
ctx, ctx->lock, ctx->phase, ctx->taskType, ctx->explain, ctx->needFetch, ctx->localExec, ctx->msgType,
|
ctx, ctx->lock, ctx->phase, ctx->taskType, ctx->explain, ctx->needFetch, ctx->localExec, ctx->msgType,
|
||||||
ctx->fetchType, ctx->execId, ctx->level, ctx->queryGotData, ctx->queryRsped, ctx->queryEnd, ctx->queryContinue,
|
ctx->sId, ctx->level, ctx->queryGotData, ctx->queryRsped, ctx->queryEnd, ctx->queryContinue,
|
||||||
ctx->queryInQueue, ctx->rspCode, ctx->affectedRows, ctx->taskHandle, ctx->sinkHandle, ctx->tbInfo.tbFName,
|
ctx->queryInQueue, ctx->rspCode, ctx->affectedRows, ctx->taskHandle, ctx->sinkHandle, ctx->tbInfo.tbFName,
|
||||||
ctx->tbInfo.sversion, ctx->tbInfo.tversion, ctx->events[QW_EVENT_CANCEL], ctx->events[QW_EVENT_READY],
|
ctx->tbInfo.sversion, ctx->tbInfo.tversion, ctx->events[QW_EVENT_CANCEL], ctx->events[QW_EVENT_READY],
|
||||||
ctx->events[QW_EVENT_FETCH], ctx->events[QW_EVENT_DROP], ctx->events[QW_EVENT_CQUERY]);
|
ctx->events[QW_EVENT_FETCH], ctx->events[QW_EVENT_DROP], ctx->events[QW_EVENT_CQUERY]);
|
||||||
|
|
|
@ -508,14 +508,6 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) {
|
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) {
|
||||||
if (QW_PHASE_POST_FETCH == phase) {
|
|
||||||
QW_TASK_WLOG("drop received at wrong phase %s", qwPhaseStr(phase));
|
|
||||||
QW_ERR_JRET(TSDB_CODE_APP_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// qwBuildAndSendDropRsp(&ctx->ctrlConnInfo, code);
|
|
||||||
// QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", ctx->ctrlConnInfo.handle, code, tstrerror(code));
|
|
||||||
|
|
||||||
QW_ERR_JRET(qwDropTask(QW_FPARAMS()));
|
QW_ERR_JRET(qwDropTask(QW_FPARAMS()));
|
||||||
QW_ERR_JRET(ctx->rspCode);
|
QW_ERR_JRET(ctx->rspCode);
|
||||||
}
|
}
|
||||||
|
@ -580,6 +572,7 @@ int32_t qwPreprocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
QW_ERR_JRET(qwAcquireTaskCtx(QW_FPARAMS(), &ctx));
|
QW_ERR_JRET(qwAcquireTaskCtx(QW_FPARAMS(), &ctx));
|
||||||
|
|
||||||
ctx->ctrlConnInfo = qwMsg->connInfo;
|
ctx->ctrlConnInfo = qwMsg->connInfo;
|
||||||
|
ctx->sId = sId;
|
||||||
ctx->phase = -1;
|
ctx->phase = -1;
|
||||||
|
|
||||||
QW_ERR_JRET(qwAddTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_INIT));
|
QW_ERR_JRET(qwAddTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_INIT));
|
||||||
|
@ -670,7 +663,7 @@ _return:
|
||||||
qwMsg->connInfo = ctx->dataConnInfo;
|
qwMsg->connInfo = ctx->dataConnInfo;
|
||||||
QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_FETCH);
|
QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_FETCH);
|
||||||
|
|
||||||
qwBuildAndSendFetchRsp(ctx->fetchType, &qwMsg->connInfo, rsp, dataLen, code);
|
qwBuildAndSendFetchRsp(ctx->msgType + 1, &qwMsg->connInfo, rsp, dataLen, code);
|
||||||
rsp = NULL;
|
rsp = NULL;
|
||||||
|
|
||||||
QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code),
|
QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code),
|
||||||
|
@ -688,6 +681,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
void *rsp = NULL;
|
void *rsp = NULL;
|
||||||
int32_t dataLen = 0;
|
int32_t dataLen = 0;
|
||||||
bool queryStop = false;
|
bool queryStop = false;
|
||||||
|
bool qComplete = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ctx = NULL;
|
ctx = NULL;
|
||||||
|
@ -712,17 +706,18 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rsp) {
|
if (rsp) {
|
||||||
bool qComplete = (DS_BUF_EMPTY == sOutput.bufStatus && sOutput.queryEnd);
|
qComplete = (DS_BUF_EMPTY == sOutput.bufStatus && sOutput.queryEnd);
|
||||||
|
|
||||||
qwBuildFetchRsp(rsp, &sOutput, dataLen, qComplete);
|
qwBuildFetchRsp(rsp, &sOutput, dataLen, qComplete);
|
||||||
if (qComplete) {
|
if (qComplete) {
|
||||||
atomic_store_8((int8_t *)&ctx->queryEnd, true);
|
atomic_store_8((int8_t *)&ctx->queryEnd, true);
|
||||||
|
atomic_store_8((int8_t *)&ctx->queryContinue, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
qwMsg->connInfo = ctx->dataConnInfo;
|
qwMsg->connInfo = ctx->dataConnInfo;
|
||||||
QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_FETCH);
|
QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_FETCH);
|
||||||
|
|
||||||
qwBuildAndSendFetchRsp(ctx->fetchType, &qwMsg->connInfo, rsp, dataLen, code);
|
qwBuildAndSendFetchRsp(ctx->msgType + 1, &qwMsg->connInfo, rsp, dataLen, code);
|
||||||
rsp = NULL;
|
rsp = NULL;
|
||||||
|
|
||||||
QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code,
|
QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code,
|
||||||
|
@ -744,14 +739,13 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
rsp = NULL;
|
rsp = NULL;
|
||||||
|
|
||||||
qwMsg->connInfo = ctx->dataConnInfo;
|
qwMsg->connInfo = ctx->dataConnInfo;
|
||||||
qwBuildAndSendFetchRsp(ctx->fetchType, &qwMsg->connInfo, NULL, 0, code);
|
qwBuildAndSendFetchRsp(ctx->msgType + 1, &qwMsg->connInfo, NULL, 0, code);
|
||||||
QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code),
|
QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code),
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QW_LOCK(QW_WRITE, &ctx->lock);
|
QW_LOCK(QW_WRITE, &ctx->lock);
|
||||||
if ((queryStop && (0 == atomic_load_8((int8_t *)&ctx->queryContinue))) || code ||
|
if (qComplete || (queryStop && (0 == atomic_load_8((int8_t *)&ctx->queryContinue))) || code) {
|
||||||
0 == atomic_load_8((int8_t *)&ctx->queryContinue)) {
|
|
||||||
// Note: query is not running anymore
|
// Note: query is not running anymore
|
||||||
QW_SET_PHASE(ctx, 0);
|
QW_SET_PHASE(ctx, 0);
|
||||||
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
||||||
|
@ -1178,8 +1172,9 @@ void qWorkerStopAllTasks(void *qWorkerMgmt) {
|
||||||
|
|
||||||
QW_DLOG("start to stop all tasks, taskNum:%d", taosHashGetSize(mgmt->ctxHash));
|
QW_DLOG("start to stop all tasks, taskNum:%d", taosHashGetSize(mgmt->ctxHash));
|
||||||
|
|
||||||
uint64_t qId, tId;
|
uint64_t qId, tId, sId;
|
||||||
int32_t eId;
|
int32_t eId;
|
||||||
|
int64_t rId = 0;
|
||||||
void *pIter = taosHashIterate(mgmt->ctxHash, NULL);
|
void *pIter = taosHashIterate(mgmt->ctxHash, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SQWTaskCtx *ctx = (SQWTaskCtx *)pIter;
|
SQWTaskCtx *ctx = (SQWTaskCtx *)pIter;
|
||||||
|
@ -1188,6 +1183,8 @@ void qWorkerStopAllTasks(void *qWorkerMgmt) {
|
||||||
|
|
||||||
QW_LOCK(QW_WRITE, &ctx->lock);
|
QW_LOCK(QW_WRITE, &ctx->lock);
|
||||||
|
|
||||||
|
sId = ctx->sId;
|
||||||
|
|
||||||
QW_TASK_DLOG_E("start to force stop task");
|
QW_TASK_DLOG_E("start to force stop task");
|
||||||
|
|
||||||
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP) || QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) {
|
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP) || QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) {
|
||||||
|
@ -1200,9 +1197,11 @@ void qWorkerStopAllTasks(void *qWorkerMgmt) {
|
||||||
|
|
||||||
if (QW_QUERY_RUNNING(ctx)) {
|
if (QW_QUERY_RUNNING(ctx)) {
|
||||||
qwKillTaskHandle(ctx, TSDB_CODE_VND_STOPPED);
|
qwKillTaskHandle(ctx, TSDB_CODE_VND_STOPPED);
|
||||||
} else if (!QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) {
|
} else if (QW_FETCH_RUNNING(ctx)) {
|
||||||
QW_UPDATE_RSP_CODE(ctx, TSDB_CODE_VND_STOPPED);
|
QW_UPDATE_RSP_CODE(ctx, TSDB_CODE_VND_STOPPED);
|
||||||
QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_DROP);
|
QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_DROP);
|
||||||
|
} else {
|
||||||
|
qwDropTask(QW_FPARAMS());
|
||||||
}
|
}
|
||||||
|
|
||||||
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
||||||
|
|
|
@ -53,9 +53,6 @@ typedef struct SScalarCtx {
|
||||||
#define SCL_IS_COMPARISON_OPERATOR(_opType) ((_opType) >= OP_TYPE_GREATER_THAN && (_opType) < OP_TYPE_IS_NOT_UNKNOWN)
|
#define SCL_IS_COMPARISON_OPERATOR(_opType) ((_opType) >= OP_TYPE_GREATER_THAN && (_opType) < OP_TYPE_IS_NOT_UNKNOWN)
|
||||||
#define SCL_DOWNGRADE_DATETYPE(_type) \
|
#define SCL_DOWNGRADE_DATETYPE(_type) \
|
||||||
((_type) == TSDB_DATA_TYPE_BIGINT || TSDB_DATA_TYPE_DOUBLE == (_type) || (_type) == TSDB_DATA_TYPE_UBIGINT)
|
((_type) == TSDB_DATA_TYPE_BIGINT || TSDB_DATA_TYPE_DOUBLE == (_type) || (_type) == TSDB_DATA_TYPE_UBIGINT)
|
||||||
#define SCL_NO_NEED_CONVERT_COMPARISION(_ltype, _rtype, _optr) \
|
|
||||||
(IS_NUMERIC_TYPE(_ltype) && IS_NUMERIC_TYPE(_rtype) && \
|
|
||||||
((_optr) >= OP_TYPE_GREATER_THAN && (_optr) <= OP_TYPE_NOT_EQUAL))
|
|
||||||
|
|
||||||
#define sclFatal(...) qFatal(__VA_ARGS__)
|
#define sclFatal(...) qFatal(__VA_ARGS__)
|
||||||
#define sclError(...) qError(__VA_ARGS__)
|
#define sclError(...) qError(__VA_ARGS__)
|
||||||
|
|
|
@ -130,9 +130,9 @@ __compar_fn_t gDataCompare[] = {compareInt32Val,
|
||||||
compareFloatVal,
|
compareFloatVal,
|
||||||
compareDoubleVal,
|
compareDoubleVal,
|
||||||
compareLenPrefixedStr,
|
compareLenPrefixedStr,
|
||||||
compareStrPatternMatch,
|
comparestrPatternMatch,
|
||||||
compareChkInString,
|
compareChkInString,
|
||||||
compareWStrPatternMatch,
|
comparewcsPatternMatch,
|
||||||
compareLenPrefixedWStr,
|
compareLenPrefixedWStr,
|
||||||
compareUint8Val,
|
compareUint8Val,
|
||||||
compareUint16Val,
|
compareUint16Val,
|
||||||
|
@ -142,15 +142,17 @@ __compar_fn_t gDataCompare[] = {compareInt32Val,
|
||||||
setChkInBytes2,
|
setChkInBytes2,
|
||||||
setChkInBytes4,
|
setChkInBytes4,
|
||||||
setChkInBytes8,
|
setChkInBytes8,
|
||||||
compareStrRegexCompMatch,
|
comparestrRegexMatch,
|
||||||
compareStrRegexCompNMatch,
|
comparestrRegexNMatch,
|
||||||
setChkNotInBytes1,
|
setChkNotInBytes1,
|
||||||
setChkNotInBytes2,
|
setChkNotInBytes2,
|
||||||
setChkNotInBytes4,
|
setChkNotInBytes4,
|
||||||
setChkNotInBytes8,
|
setChkNotInBytes8,
|
||||||
compareChkNotInString,
|
compareChkNotInString,
|
||||||
compareStrPatternNotMatch,
|
comparestrPatternNMatch,
|
||||||
compareWStrPatternNotMatch};
|
comparewcsPatternNMatch,
|
||||||
|
comparewcsRegexMatch,
|
||||||
|
comparewcsRegexNMatch,};
|
||||||
|
|
||||||
__compar_fn_t gInt8SignCompare[] = {compareInt8Val, compareInt8Int16, compareInt8Int32,
|
__compar_fn_t gInt8SignCompare[] = {compareInt8Val, compareInt8Int16, compareInt8Int32,
|
||||||
compareInt8Int64, compareInt8Float, compareInt8Double};
|
compareInt8Int64, compareInt8Float, compareInt8Double};
|
||||||
|
@ -295,9 +297,9 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
if (optr == OP_TYPE_MATCH) {
|
if (optr == OP_TYPE_MATCH) {
|
||||||
comparFn = 19;
|
comparFn = 28;
|
||||||
} else if (optr == OP_TYPE_NMATCH) {
|
} else if (optr == OP_TYPE_NMATCH) {
|
||||||
comparFn = 20;
|
comparFn = 29;
|
||||||
} else if (optr == OP_TYPE_LIKE) {
|
} else if (optr == OP_TYPE_LIKE) {
|
||||||
comparFn = 9;
|
comparFn = 9;
|
||||||
} else if (optr == OP_TYPE_NOT_LIKE) {
|
} else if (optr == OP_TYPE_NOT_LIKE) {
|
||||||
|
@ -336,7 +338,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
|
||||||
__compar_fn_t filterGetCompFunc(int32_t type, int32_t optr) { return gDataCompare[filterGetCompFuncIdx(type, optr)]; }
|
__compar_fn_t filterGetCompFunc(int32_t type, int32_t optr) { return gDataCompare[filterGetCompFuncIdx(type, optr)]; }
|
||||||
|
|
||||||
__compar_fn_t filterGetCompFuncEx(int32_t lType, int32_t rType, int32_t optr) {
|
__compar_fn_t filterGetCompFuncEx(int32_t lType, int32_t rType, int32_t optr) {
|
||||||
if (TSDB_DATA_TYPE_NULL == rType) {
|
if (TSDB_DATA_TYPE_NULL == rType || TSDB_DATA_TYPE_JSON == rType) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4085,7 +4087,7 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SC
|
||||||
SArray *pList = taosArrayInit(1, POINTER_BYTES);
|
SArray *pList = taosArrayInit(1, POINTER_BYTES);
|
||||||
taosArrayPush(pList, &pSrc);
|
taosArrayPush(pList, &pSrc);
|
||||||
|
|
||||||
int32_t code = scalarCalculate(info->sclCtx.node, pList, &output);
|
code = scalarCalculate(info->sclCtx.node, pList, &output);
|
||||||
taosArrayDestroy(pList);
|
taosArrayDestroy(pList);
|
||||||
|
|
||||||
FLT_ERR_RET(code);
|
FLT_ERR_RET(code);
|
||||||
|
|
|
@ -37,6 +37,11 @@
|
||||||
|
|
||||||
#define IS_HELPER_NULL(col, i) colDataIsNull_s(col, i) || IS_JSON_NULL(col->info.type, colDataGetVarData(col, i))
|
#define IS_HELPER_NULL(col, i) colDataIsNull_s(col, i) || IS_JSON_NULL(col->info.type, colDataGetVarData(col, i))
|
||||||
|
|
||||||
|
bool noConvertBeforeCompare(int32_t leftType, int32_t rightType, int32_t optr) {
|
||||||
|
return IS_NUMERIC_TYPE(leftType) && IS_NUMERIC_TYPE(rightType) &&
|
||||||
|
(optr >= OP_TYPE_GREATER_THAN && optr <= OP_TYPE_NOT_EQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
void convertNumberToNumber(const void *inData, void *outData, int8_t inType, int8_t outType) {
|
void convertNumberToNumber(const void *inData, void *outData, int8_t inType, int8_t outType) {
|
||||||
switch (outType) {
|
switch (outType) {
|
||||||
case TSDB_DATA_TYPE_BOOL: {
|
case TSDB_DATA_TYPE_BOOL: {
|
||||||
|
@ -338,6 +343,7 @@ static FORCE_INLINE void varToBool(char *buf, SScalarParam *pOut, int32_t rowInd
|
||||||
colDataAppendInt8(pOut->columnData, rowIndex, (int8_t *)&v);
|
colDataAppendInt8(pOut->columnData, rowIndex, (int8_t *)&v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo remove this malloc
|
||||||
static FORCE_INLINE void varToNchar(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) {
|
static FORCE_INLINE void varToNchar(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) {
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t inputLen = varDataLen(buf);
|
int32_t inputLen = varDataLen(buf);
|
||||||
|
@ -399,6 +405,8 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pCtx->pOut->numOfRows = pCtx->pIn->numOfRows;
|
pCtx->pOut->numOfRows = pCtx->pIn->numOfRows;
|
||||||
|
char* tmp = NULL;
|
||||||
|
|
||||||
for (int32_t i = pCtx->startIndex; i <= pCtx->endIndex; ++i) {
|
for (int32_t i = pCtx->startIndex; i <= pCtx->endIndex; ++i) {
|
||||||
if (IS_HELPER_NULL(pCtx->pIn->columnData, i)) {
|
if (IS_HELPER_NULL(pCtx->pIn->columnData, i)) {
|
||||||
colDataAppendNULL(pCtx->pOut->columnData, i);
|
colDataAppendNULL(pCtx->pOut->columnData, i);
|
||||||
|
@ -421,12 +429,16 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t bufSize = pCtx->pIn->columnData->info.bytes;
|
int32_t bufSize = pCtx->pIn->columnData->info.bytes;
|
||||||
char *tmp = taosMemoryMalloc(varDataTLen(data));
|
if (tmp == NULL) {
|
||||||
if (!tmp) {
|
tmp = taosMemoryMalloc(bufSize);
|
||||||
|
if (tmp == NULL) {
|
||||||
sclError("out of memory in vectorConvertFromVarData");
|
sclError("out of memory in vectorConvertFromVarData");
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (vton) {
|
if (vton) {
|
||||||
memcpy(tmp, data, varDataTLen(data));
|
memcpy(tmp, data, varDataTLen(data));
|
||||||
} else {
|
} else {
|
||||||
|
@ -434,6 +446,7 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
|
||||||
memcpy(tmp, varDataVal(data), varDataLen(data));
|
memcpy(tmp, varDataVal(data), varDataLen(data));
|
||||||
tmp[varDataLen(data)] = 0;
|
tmp[varDataLen(data)] = 0;
|
||||||
} else if (TSDB_DATA_TYPE_NCHAR == convertType) {
|
} else if (TSDB_DATA_TYPE_NCHAR == convertType) {
|
||||||
|
// we need to convert it to native char string, and then perform the string to numeric data
|
||||||
ASSERT(varDataLen(data) <= bufSize);
|
ASSERT(varDataLen(data) <= bufSize);
|
||||||
|
|
||||||
int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(data), varDataLen(data), tmp);
|
int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(data), varDataLen(data), tmp);
|
||||||
|
@ -448,9 +461,11 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
(*func)(tmp, pCtx->pOut, i, overflow);
|
(*func)(tmp, pCtx->pOut, i, overflow);
|
||||||
taosMemoryFreeClear(tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tmp != NULL) {
|
||||||
|
taosMemoryFreeClear(tmp);
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -901,9 +916,11 @@ int32_t vectorGetConvertType(int32_t type1, int32_t type2) {
|
||||||
|
|
||||||
int32_t vectorConvertSingleCol(SScalarParam *input, SScalarParam *output, int32_t type, int32_t startIndex,
|
int32_t vectorConvertSingleCol(SScalarParam *input, SScalarParam *output, int32_t type, int32_t startIndex,
|
||||||
int32_t numOfRows) {
|
int32_t numOfRows) {
|
||||||
SDataType t = {.type = type, .bytes = tDataTypes[type].bytes};
|
|
||||||
output->numOfRows = input->numOfRows;
|
output->numOfRows = input->numOfRows;
|
||||||
|
|
||||||
|
SDataType t = {.type = type};
|
||||||
|
t.bytes = IS_VAR_DATA_TYPE(t.type)? input->columnData->info.bytes:tDataTypes[type].bytes;
|
||||||
|
|
||||||
int32_t code = sclCreateColumnInfoData(&t, input->numOfRows, output);
|
int32_t code = sclCreateColumnInfoData(&t, input->numOfRows, output);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -925,10 +942,27 @@ int32_t vectorConvertCols(SScalarParam *pLeft, SScalarParam *pRight, SScalarPara
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SScalarParam *param1 = NULL, *paramOut1 = NULL;
|
int8_t type = 0;
|
||||||
SScalarParam *param2 = NULL, *paramOut2 = NULL;
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
SScalarParam *param1 = NULL, *paramOut1 = NULL;
|
||||||
|
SScalarParam *param2 = NULL, *paramOut2 = NULL;
|
||||||
|
|
||||||
|
// always convert least data
|
||||||
|
if (IS_VAR_DATA_TYPE(leftType) && IS_VAR_DATA_TYPE(rightType) && (pLeft->numOfRows != pRight->numOfRows) &&
|
||||||
|
leftType != TSDB_DATA_TYPE_JSON && rightType != TSDB_DATA_TYPE_JSON) {
|
||||||
|
param1 = pLeft;
|
||||||
|
param2 = pRight;
|
||||||
|
paramOut1 = pLeftOut;
|
||||||
|
paramOut2 = pRightOut;
|
||||||
|
|
||||||
|
if (pLeft->numOfRows > pRight->numOfRows) {
|
||||||
|
type = leftType;
|
||||||
|
} else {
|
||||||
|
type = rightType;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// we only define half value in the convert-matrix, so make sure param1 always less equal than param2
|
||||||
if (leftType < rightType) {
|
if (leftType < rightType) {
|
||||||
param1 = pLeft;
|
param1 = pLeft;
|
||||||
param2 = pRight;
|
param2 = pRight;
|
||||||
|
@ -941,10 +975,11 @@ int32_t vectorConvertCols(SScalarParam *pLeft, SScalarParam *pRight, SScalarPara
|
||||||
paramOut2 = pLeftOut;
|
paramOut2 = pLeftOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t type = vectorGetConvertType(GET_PARAM_TYPE(param1), GET_PARAM_TYPE(param2));
|
type = vectorGetConvertType(GET_PARAM_TYPE(param1), GET_PARAM_TYPE(param2));
|
||||||
if (0 == type) {
|
if (0 == type) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (type != GET_PARAM_TYPE(param1)) {
|
if (type != GET_PARAM_TYPE(param1)) {
|
||||||
code = vectorConvertSingleCol(param1, paramOut1, type, startIndex, numOfRows);
|
code = vectorConvertSingleCol(param1, paramOut1, type, startIndex, numOfRows);
|
||||||
|
@ -1683,23 +1718,13 @@ void vectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *
|
||||||
SScalarParam *param1 = NULL;
|
SScalarParam *param1 = NULL;
|
||||||
SScalarParam *param2 = NULL;
|
SScalarParam *param2 = NULL;
|
||||||
|
|
||||||
if (SCL_NO_NEED_CONVERT_COMPARISION(GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), optr)) {
|
if (noConvertBeforeCompare(GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), optr)) {
|
||||||
param1 = pLeft;
|
param1 = pLeft;
|
||||||
param2 = pRight;
|
param2 = pRight;
|
||||||
} else {
|
} else {
|
||||||
vectorConvertCols(pLeft, pRight, &pLeftOut, &pRightOut, startIndex, numOfRows);
|
vectorConvertCols(pLeft, pRight, &pLeftOut, &pRightOut, startIndex, numOfRows);
|
||||||
|
param1 = (pLeftOut.columnData != NULL) ? &pLeftOut : pLeft;
|
||||||
if (pLeftOut.columnData != NULL) {
|
param2 = (pRightOut.columnData != NULL) ? &pRightOut : pRight;
|
||||||
param1 = &pLeftOut;
|
|
||||||
} else {
|
|
||||||
param1 = pLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pRightOut.columnData != NULL) {
|
|
||||||
param2 = &pRightOut;
|
|
||||||
} else {
|
|
||||||
param2 = pRight;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
doVectorCompare(param1, param2, pOut, startIndex, numOfRows, _ord, optr);
|
doVectorCompare(param1, param2, pOut, startIndex, numOfRows, _ord, optr);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue