TD-13675 merge 3.0_query_integrate
This commit is contained in:
commit
98a5e28586
|
@ -6,40 +6,14 @@ project(
|
||||||
DESCRIPTION "An open-source big data platform designed and optimized for the Internet of Things(IOT)"
|
DESCRIPTION "An open-source big data platform designed and optimized for the Internet of Things(IOT)"
|
||||||
)
|
)
|
||||||
|
|
||||||
IF ("${BUILD_TOOLS}" STREQUAL "")
|
|
||||||
IF (TD_LINUX)
|
|
||||||
IF (TD_ARM_32)
|
|
||||||
SET(BUILD_TOOLS "false")
|
|
||||||
ELSEIF (TD_ARM_64)
|
|
||||||
SET(BUILD_TOOLS "false")
|
|
||||||
ELSE ()
|
|
||||||
SET(BUILD_TOOLS "false")
|
|
||||||
ENDIF ()
|
|
||||||
ELSEIF (TD_DARWIN)
|
|
||||||
SET(BUILD_TOOLS "false")
|
|
||||||
ELSE ()
|
|
||||||
SET(BUILD_TOOLS "false")
|
|
||||||
ENDIF ()
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
IF ("${BUILD_TOOLS}" MATCHES "false")
|
|
||||||
MESSAGE("${Yellow} Will _not_ build taos_tools! ${ColourReset}")
|
|
||||||
SET(TD_TAOS_TOOLS FALSE)
|
|
||||||
ELSE ()
|
|
||||||
MESSAGE("")
|
|
||||||
MESSAGE("${Green} Will build taos_tools! ${ColourReset}")
|
|
||||||
MESSAGE("")
|
|
||||||
SET(TD_TAOS_TOOLS TRUE)
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
set(CMAKE_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/cmake")
|
set(CMAKE_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
set(CMAKE_CONTRIB_DIR "${CMAKE_SOURCE_DIR}/contrib")
|
set(CMAKE_CONTRIB_DIR "${CMAKE_SOURCE_DIR}/contrib")
|
||||||
|
|
||||||
|
include(${CMAKE_SUPPORT_DIR}/cmake.platform)
|
||||||
|
include(${CMAKE_SUPPORT_DIR}/cmake.define)
|
||||||
include(${CMAKE_SUPPORT_DIR}/cmake.options)
|
include(${CMAKE_SUPPORT_DIR}/cmake.options)
|
||||||
include(${CMAKE_SUPPORT_DIR}/cmake.version)
|
include(${CMAKE_SUPPORT_DIR}/cmake.version)
|
||||||
|
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -fPIC -gdwarf-2 -msse4.2 -mfma -g3")
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fPIC -gdwarf-2 -msse4.2 -mfma -g3")
|
|
||||||
|
|
||||||
# contrib
|
# contrib
|
||||||
add_subdirectory(contrib)
|
add_subdirectory(contrib)
|
||||||
|
|
||||||
|
@ -52,6 +26,7 @@ if(${BUILD_TEST})
|
||||||
include(CTest)
|
include(CTest)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
||||||
|
|
||||||
add_subdirectory(source)
|
add_subdirectory(source)
|
||||||
add_subdirectory(tools)
|
add_subdirectory(tools)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
IF ("${BUILD_TOOLS}" STREQUAL "")
|
||||||
|
IF (TD_LINUX)
|
||||||
|
IF (TD_ARM_32)
|
||||||
|
SET(BUILD_TOOLS "false")
|
||||||
|
ELSEIF (TD_ARM_64)
|
||||||
|
SET(BUILD_TOOLS "false")
|
||||||
|
ELSE ()
|
||||||
|
SET(BUILD_TOOLS "false")
|
||||||
|
ENDIF ()
|
||||||
|
ELSEIF (TD_DARWIN)
|
||||||
|
SET(BUILD_TOOLS "false")
|
||||||
|
ELSE ()
|
||||||
|
SET(BUILD_TOOLS "false")
|
||||||
|
ENDIF ()
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
IF ("${BUILD_TOOLS}" MATCHES "false")
|
||||||
|
MESSAGE("${Yellow} Will _not_ build taos_tools! ${ColourReset}")
|
||||||
|
SET(TD_TAOS_TOOLS FALSE)
|
||||||
|
ELSE ()
|
||||||
|
MESSAGE("")
|
||||||
|
MESSAGE("${Green} Will build taos_tools! ${ColourReset}")
|
||||||
|
MESSAGE("")
|
||||||
|
SET(TD_TAOS_TOOLS TRUE)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (TD_WINDOWS)
|
||||||
|
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
||||||
|
SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE)
|
||||||
|
SET(COMMON_FLAGS "/nologo /WX /wd4018 /wd4999 /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-")
|
||||||
|
|
||||||
|
IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
||||||
|
SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
ELSE ()
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -fPIC -gdwarf-2 -msse4.2 -mfma -g3")
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fPIC -gdwarf-2 -msse4.2 -mfma -g3")
|
||||||
|
|
||||||
|
ENDIF ()
|
|
@ -1,12 +1,35 @@
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Deps options
|
# Deps options
|
||||||
# =========================================================
|
# =========================================================
|
||||||
|
|
||||||
|
IF(${TD_WINDOWS})
|
||||||
|
|
||||||
|
MESSAGE("build pthread Win32")
|
||||||
|
option(
|
||||||
|
BUILD_PTHREAD
|
||||||
|
"If build pthread on Windows"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
|
MESSAGE("build gnu regex for Windows")
|
||||||
|
option(
|
||||||
|
BUILD_GNUREGEX
|
||||||
|
"If build gnu regex on Windows"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
IF(${TD_LINUX} MATCHES TRUE)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_TEST
|
BUILD_TEST
|
||||||
"If build unit tests using googletest"
|
"If build unit tests using googletest"
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_LEVELDB
|
BUILD_WITH_LEVELDB
|
||||||
"If build with leveldb"
|
"If build with leveldb"
|
||||||
|
@ -25,12 +48,17 @@ option(
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IF(${TD_WINDOWS})
|
||||||
|
MESSAGE("Not build BDB on Windows")
|
||||||
|
ELSE ()
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_BDB
|
BUILD_WITH_BDB
|
||||||
"If build with BerkleyDB"
|
"If build with BerkleyDB"
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_LUCENE
|
BUILD_WITH_LUCENE
|
||||||
"If build with lucene"
|
"If build with lucene"
|
||||||
|
@ -68,12 +96,16 @@ option(
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IF(${TD_LINUX} MATCHES TRUE)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_DEPENDENCY_TESTS
|
BUILD_DEPENDENCY_TESTS
|
||||||
"If build dependency tests"
|
"If build dependency tests"
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_DOCS
|
BUILD_DOCS
|
||||||
"If use doxygen build documents"
|
"If use doxygen build documents"
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
MESSAGE("Current system is ${CMAKE_SYSTEM_NAME}")
|
||||||
|
|
||||||
|
# init
|
||||||
|
SET(TD_LINUX FALSE)
|
||||||
|
SET(TD_WINDOWS FALSE)
|
||||||
|
SET(TD_DARWIN FALSE)
|
||||||
|
|
||||||
|
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
|
|
||||||
|
SET(TD_LINUX TRUE)
|
||||||
|
SET(OSTYPE "Linux")
|
||||||
|
ADD_DEFINITIONS("-DLINUX")
|
||||||
|
|
||||||
|
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
||||||
|
SET(TD_LINUX_64 TRUE)
|
||||||
|
ELSE ()
|
||||||
|
SET(TD_LINUX_32 TRUE)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
|
|
||||||
|
SET(TD_DARWIN TRUE)
|
||||||
|
SET(OSTYPE "macOS")
|
||||||
|
ADD_DEFINITIONS("-DDARWIN")
|
||||||
|
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64")
|
||||||
|
MESSAGE("Current system arch is arm64")
|
||||||
|
SET(TD_DARWIN_64 TRUE)
|
||||||
|
ADD_DEFINITIONS("-D_TD_DARWIN_64")
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
ADD_DEFINITIONS("-DHAVE_UNISTD_H")
|
||||||
|
|
||||||
|
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||||
|
|
||||||
|
SET(TD_WINDOWS TRUE)
|
||||||
|
SET(OSTYPE "Windows")
|
||||||
|
ADD_DEFINITIONS("-DWINDOWS")
|
||||||
|
|
||||||
|
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
||||||
|
SET(TD_WINDOWS_64 TRUE)
|
||||||
|
ADD_DEFINITIONS("-D_TD_WINDOWS_64")
|
||||||
|
ELSE ()
|
||||||
|
SET(TD_WINDOWS_32 TRUE)
|
||||||
|
ADD_DEFINITIONS("-D_TD_WINDOWS_32")
|
||||||
|
ENDIF ()
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
MESSAGE("C Compiler ID: ${CMAKE_C_COMPILER_ID}")
|
||||||
|
MESSAGE("CXX Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
# gnuregex
|
||||||
|
ExternalProject_Add(gnuregex
|
||||||
|
URL https://launchpad.net/gnuregex/trunk/2.9/+download/libgnurx-src-2.9.zip
|
||||||
|
DOWNLOAD_NAME libgnurx-src.zip
|
||||||
|
SOURCE_DIR "${CMAKE_CONTRIB_DIR}/gnuregex"
|
||||||
|
BINARY_DIR ""
|
||||||
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
TEST_COMMAND ""
|
||||||
|
)
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
# pthread
|
||||||
|
ExternalProject_Add(pthread
|
||||||
|
GIT_REPOSITORY https://github.com/GerHobbelt/pthread-win32
|
||||||
|
GIT_TAG v3.0.3.1
|
||||||
|
SOURCE_DIR "${CMAKE_CONTRIB_DIR}/pthread-win32"
|
||||||
|
BINARY_DIR ""
|
||||||
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
TEST_COMMAND ""
|
||||||
|
)
|
|
@ -9,6 +9,16 @@ endfunction(cat IN_FILE OUT_FILE)
|
||||||
set(CONTRIB_TMP_FILE "${CMAKE_BINARY_DIR}/deps_tmp_CMakeLists.txt.in")
|
set(CONTRIB_TMP_FILE "${CMAKE_BINARY_DIR}/deps_tmp_CMakeLists.txt.in")
|
||||||
configure_file("${CMAKE_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
configure_file("${CMAKE_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
|
||||||
|
# pthread
|
||||||
|
if(${BUILD_PTHREAD})
|
||||||
|
cat("${CMAKE_SUPPORT_DIR}/pthread_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# gnu regex
|
||||||
|
if(${BUILD_GNUREGEX})
|
||||||
|
cat("${CMAKE_SUPPORT_DIR}/gnuregex_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
endif()
|
||||||
|
|
||||||
# googletest
|
# googletest
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
cat("${CMAKE_SUPPORT_DIR}/gtest_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${CMAKE_SUPPORT_DIR}/gtest_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
@ -193,7 +203,10 @@ endif(${BUILD_WITH_TRAFT})
|
||||||
|
|
||||||
# LIBUV
|
# LIBUV
|
||||||
if(${BUILD_WITH_UV})
|
if(${BUILD_WITH_UV})
|
||||||
|
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||||
|
MESSAGE("Windows need set no-sign-compare")
|
||||||
add_compile_options(-Wno-sign-compare)
|
add_compile_options(-Wno-sign-compare)
|
||||||
|
endif ()
|
||||||
add_subdirectory(libuv)
|
add_subdirectory(libuv)
|
||||||
endif(${BUILD_WITH_UV})
|
endif(${BUILD_WITH_UV})
|
||||||
|
|
||||||
|
@ -224,6 +237,7 @@ if(${BUILD_WITH_SQLITE})
|
||||||
)
|
)
|
||||||
endif(${BUILD_WITH_SQLITE})
|
endif(${BUILD_WITH_SQLITE})
|
||||||
|
|
||||||
|
# pthread
|
||||||
|
|
||||||
|
|
||||||
# ================================================================================================
|
# ================================================================================================
|
||||||
|
|
|
@ -39,19 +39,19 @@ typedef void **TAOS_ROW;
|
||||||
#define TSDB_DATA_TYPE_BIGINT 5 // 8 bytes
|
#define TSDB_DATA_TYPE_BIGINT 5 // 8 bytes
|
||||||
#define TSDB_DATA_TYPE_FLOAT 6 // 4 bytes
|
#define TSDB_DATA_TYPE_FLOAT 6 // 4 bytes
|
||||||
#define TSDB_DATA_TYPE_DOUBLE 7 // 8 bytes
|
#define TSDB_DATA_TYPE_DOUBLE 7 // 8 bytes
|
||||||
#define TSDB_DATA_TYPE_BINARY 8 // string, alias for varchar
|
#define TSDB_DATA_TYPE_VARCHAR 8 // string, alias for varchar
|
||||||
#define TSDB_DATA_TYPE_TIMESTAMP 9 // 8 bytes
|
#define TSDB_DATA_TYPE_TIMESTAMP 9 // 8 bytes
|
||||||
#define TSDB_DATA_TYPE_NCHAR 10 // unicode string
|
#define TSDB_DATA_TYPE_NCHAR 10 // unicode string
|
||||||
#define TSDB_DATA_TYPE_UTINYINT 11 // 1 byte
|
#define TSDB_DATA_TYPE_UTINYINT 11 // 1 byte
|
||||||
#define TSDB_DATA_TYPE_USMALLINT 12 // 2 bytes
|
#define TSDB_DATA_TYPE_USMALLINT 12 // 2 bytes
|
||||||
#define TSDB_DATA_TYPE_UINT 13 // 4 bytes
|
#define TSDB_DATA_TYPE_UINT 13 // 4 bytes
|
||||||
#define TSDB_DATA_TYPE_UBIGINT 14 // 8 bytes
|
#define TSDB_DATA_TYPE_UBIGINT 14 // 8 bytes
|
||||||
#define TSDB_DATA_TYPE_VARCHAR 15 // string
|
#define TSDB_DATA_TYPE_JSON 15 // json string
|
||||||
#define TSDB_DATA_TYPE_VARBINARY 16 // binary
|
#define TSDB_DATA_TYPE_VARBINARY 16 // binary
|
||||||
#define TSDB_DATA_TYPE_JSON 17 // json
|
#define TSDB_DATA_TYPE_DECIMAL 17 // decimal
|
||||||
#define TSDB_DATA_TYPE_DECIMAL 18 // decimal
|
#define TSDB_DATA_TYPE_BLOB 18 // binary
|
||||||
#define TSDB_DATA_TYPE_BLOB 19 // binary
|
#define TSDB_DATA_TYPE_MEDIUMBLOB 19
|
||||||
#define TSDB_DATA_TYPE_MEDIUMBLOB 20
|
#define TSDB_DATA_TYPE_BINARY TSDB_DATA_TYPE_VARCHAR // string
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_OPTION_LOCALE,
|
TSDB_OPTION_LOCALE,
|
||||||
|
|
|
@ -51,7 +51,12 @@ typedef enum {
|
||||||
TSDB_CHECK_ITEM_MAX
|
TSDB_CHECK_ITEM_MAX
|
||||||
} ECheckItemType;
|
} ECheckItemType;
|
||||||
|
|
||||||
typedef enum { TD_ROW_DISCARD_UPDATE = 0, TD_ROW_OVERWRITE_UPDATE = 1, TD_ROW_PARTIAL_UPDATE = 2 } TDUpdateConfig;
|
typedef enum {
|
||||||
|
TD_ROW_DISCARD_UPDATE = 0,
|
||||||
|
TD_ROW_OVERWRITE_UPDATE = 1,
|
||||||
|
TD_ROW_PARTIAL_UPDATE = 2,
|
||||||
|
} TDUpdateConfig;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_STATIS_OK = 0, // statis part exist and load successfully
|
TSDB_STATIS_OK = 0, // statis part exist and load successfully
|
||||||
TSDB_STATIS_NONE = 1, // statis part not exist
|
TSDB_STATIS_NONE = 1, // statis part not exist
|
||||||
|
@ -62,6 +67,12 @@ typedef enum {
|
||||||
TSDB_SMA_STAT_EXPIRED = 1, // not ready or expired
|
TSDB_SMA_STAT_EXPIRED = 1, // not ready or expired
|
||||||
} ETsdbSmaStat;
|
} ETsdbSmaStat;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TSDB_SMA_TYPE_BLOCK = 0, // Block-wise SMA
|
||||||
|
TSDB_SMA_TYPE_TIME_RANGE = 1, // Time-range-wise SMA
|
||||||
|
TSDB_SMA_TYPE_ROLLUP = 2, // Rollup SMA
|
||||||
|
} ETsdbSmaType;
|
||||||
|
|
||||||
extern char *qtypeStr[];
|
extern char *qtypeStr[];
|
||||||
|
|
||||||
#define TSDB_PORT_HTTP 11
|
#define TSDB_PORT_HTTP 11
|
||||||
|
|
|
@ -136,6 +136,23 @@ static FORCE_INLINE void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock)
|
||||||
return (void*)buf;
|
return (void*)buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void tDeleteSSDataBlock(SSDataBlock* pBlock) {
|
||||||
|
if (pBlock == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// int32_t numOfOutput = pBlock->info.numOfCols;
|
||||||
|
int32_t sz = taosArrayGetSize(pBlock->pDataBlock);
|
||||||
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
|
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
tfree(pColInfoData->pData);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pBlock->pDataBlock);
|
||||||
|
tfree(pBlock->pBlockAgg);
|
||||||
|
// tfree(pBlock);
|
||||||
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSMqPollRsp(void** buf, const SMqPollRsp* pRsp) {
|
static FORCE_INLINE int32_t tEncodeSMqPollRsp(void** buf, const SMqPollRsp* pRsp) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
int32_t sz = 0;
|
int32_t sz = 0;
|
||||||
|
@ -178,23 +195,6 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void tDeleteSSDataBlock(SSDataBlock* pBlock) {
|
|
||||||
if (pBlock == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// int32_t numOfOutput = pBlock->info.numOfCols;
|
|
||||||
int32_t sz = taosArrayGetSize(pBlock->pDataBlock);
|
|
||||||
for (int32_t i = 0; i < sz; ++i) {
|
|
||||||
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
|
||||||
tfree(pColInfoData->pData);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayDestroy(pBlock->pDataBlock);
|
|
||||||
tfree(pBlock->pBlockAgg);
|
|
||||||
// tfree(pBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void tDeleteSMqConsumeRsp(SMqPollRsp* pRsp) {
|
static FORCE_INLINE void tDeleteSMqConsumeRsp(SMqPollRsp* pRsp) {
|
||||||
if (pRsp->schemas) {
|
if (pRsp->schemas) {
|
||||||
if (pRsp->schemas->nCols) {
|
if (pRsp->schemas->nCols) {
|
||||||
|
@ -204,10 +204,6 @@ static FORCE_INLINE void tDeleteSMqConsumeRsp(SMqPollRsp* pRsp) {
|
||||||
}
|
}
|
||||||
taosArrayDestroyEx(pRsp->pBlockData, (void (*)(void*))tDeleteSSDataBlock);
|
taosArrayDestroyEx(pRsp->pBlockData, (void (*)(void*))tDeleteSSDataBlock);
|
||||||
pRsp->pBlockData = NULL;
|
pRsp->pBlockData = NULL;
|
||||||
// for (int32_t i = 0; i < taosArrayGetSize(pRsp->pBlockData); i++) {
|
|
||||||
// SSDataBlock* pDataBlock = (SSDataBlock*)taosArrayGet(pRsp->pBlockData, i);
|
|
||||||
// tDeleteSSDataBlock(pDataBlock);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//======================================================================================================================
|
//======================================================================================================================
|
||||||
|
|
|
@ -460,7 +460,6 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
SName tableName;
|
|
||||||
} SQueryTableRsp;
|
} SQueryTableRsp;
|
||||||
|
|
||||||
int32_t tSerializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp);
|
int32_t tSerializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp);
|
||||||
|
@ -1158,6 +1157,17 @@ int32_t tSerializeSCMCreateStreamReq(void* buf, int32_t bufLen, const SCMCreateS
|
||||||
int32_t tDeserializeSCMCreateStreamReq(void* buf, int32_t bufLen, SCMCreateStreamReq* pReq);
|
int32_t tDeserializeSCMCreateStreamReq(void* buf, int32_t bufLen, SCMCreateStreamReq* pReq);
|
||||||
void tFreeSCMCreateStreamReq(SCMCreateStreamReq* pReq);
|
void tFreeSCMCreateStreamReq(SCMCreateStreamReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char name[TSDB_TOPIC_FNAME_LEN];
|
||||||
|
int64_t streamId;
|
||||||
|
char* sql;
|
||||||
|
char* executorMsg;
|
||||||
|
} SMVCreateStreamReq, SMSCreateStreamReq;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int64_t streamId;
|
||||||
|
} SMVCreateStreamRsp, SMSCreateStreamRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TOPIC_FNAME_LEN];
|
char name[TSDB_TOPIC_FNAME_LEN];
|
||||||
int8_t igExists;
|
int8_t igExists;
|
||||||
|
@ -1351,6 +1361,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct SVCreateTbReq {
|
typedef struct SVCreateTbReq {
|
||||||
int64_t ver; // use a general definition
|
int64_t ver; // use a general definition
|
||||||
|
char* dbFName;
|
||||||
char* name;
|
char* name;
|
||||||
uint32_t ttl;
|
uint32_t ttl;
|
||||||
uint32_t keep;
|
uint32_t keep;
|
||||||
|
@ -1376,7 +1387,7 @@ typedef struct SVCreateTbReq {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
SName tableName;
|
int tmp; // TODO: to avoid compile error
|
||||||
} SVCreateTbRsp, SVUpdateTbRsp;
|
} SVCreateTbRsp, SVUpdateTbRsp;
|
||||||
|
|
||||||
int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq);
|
int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq);
|
||||||
|
@ -1387,12 +1398,18 @@ typedef struct {
|
||||||
SArray* pArray;
|
SArray* pArray;
|
||||||
} SVCreateTbBatchReq;
|
} SVCreateTbBatchReq;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
} SVCreateTbBatchRsp;
|
|
||||||
|
|
||||||
int32_t tSerializeSVCreateTbBatchReq(void** buf, SVCreateTbBatchReq* pReq);
|
int32_t tSerializeSVCreateTbBatchReq(void** buf, SVCreateTbBatchReq* pReq);
|
||||||
void* tDeserializeSVCreateTbBatchReq(void* buf, SVCreateTbBatchReq* pReq);
|
void* tDeserializeSVCreateTbBatchReq(void* buf, SVCreateTbBatchReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SArray* rspList; // SArray<SVCreateTbRsp>
|
||||||
|
int tmp; // TODO: to avoid compile error
|
||||||
|
} SVCreateTbBatchRsp;
|
||||||
|
|
||||||
|
int32_t tSerializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatchRsp *pRsp);
|
||||||
|
int32_t tDeserializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatchRsp *pRsp);
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t ver;
|
int64_t ver;
|
||||||
char* name;
|
char* name;
|
||||||
|
@ -1401,6 +1418,7 @@ typedef struct {
|
||||||
} SVDropTbReq;
|
} SVDropTbReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
int tmp; // TODO: to avoid compile error
|
||||||
} SVDropTbRsp;
|
} SVDropTbRsp;
|
||||||
|
|
||||||
int32_t tSerializeSVDropTbReq(void** buf, SVDropTbReq* pReq);
|
int32_t tSerializeSVDropTbReq(void** buf, SVDropTbReq* pReq);
|
||||||
|
@ -1916,23 +1934,18 @@ typedef enum {
|
||||||
} ETDTimeUnit;
|
} ETDTimeUnit;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t funcId;
|
int8_t version; // for compatibility(default 0)
|
||||||
uint16_t nColIds;
|
int8_t intervalUnit;
|
||||||
col_id_t* colIds; // sorted colIds
|
int8_t slidingUnit;
|
||||||
} SFuncColIds;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t version; // for compatibility
|
|
||||||
uint8_t intervalUnit;
|
|
||||||
uint8_t slidingUnit;
|
|
||||||
char indexName[TSDB_INDEX_NAME_LEN];
|
char indexName[TSDB_INDEX_NAME_LEN];
|
||||||
char timezone[TD_TIMEZONE_LEN];
|
char timezone[TD_TIMEZONE_LEN]; // sma data is invalid if timezone change.
|
||||||
uint16_t nFuncColIds;
|
uint16_t exprLen;
|
||||||
uint16_t tagsFilterLen;
|
uint16_t tagsFilterLen;
|
||||||
tb_uid_t tableUid; // super/common table uid
|
int64_t indexUid;
|
||||||
|
tb_uid_t tableUid; // super/child/common table uid
|
||||||
int64_t interval;
|
int64_t interval;
|
||||||
int64_t sliding;
|
int64_t sliding;
|
||||||
SFuncColIds* funcColIds; // sorted funcIds
|
char* expr; // sma expression
|
||||||
char* tagsFilter;
|
char* tagsFilter;
|
||||||
} STSma; // Time-range-wise SMA
|
} STSma; // Time-range-wise SMA
|
||||||
|
|
||||||
|
@ -1951,7 +1964,9 @@ typedef struct {
|
||||||
int64_t ver; // use a general definition
|
int64_t ver; // use a general definition
|
||||||
char indexName[TSDB_INDEX_NAME_LEN];
|
char indexName[TSDB_INDEX_NAME_LEN];
|
||||||
} SVDropTSmaReq;
|
} SVDropTSmaReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
int tmp; // TODO: to avoid compile error
|
||||||
} SVCreateTSmaRsp, SVDropTSmaRsp;
|
} SVCreateTSmaRsp, SVDropTSmaRsp;
|
||||||
|
|
||||||
int32_t tSerializeSVCreateTSmaReq(void** buf, SVCreateTSmaReq* pReq);
|
int32_t tSerializeSVCreateTSmaReq(void** buf, SVCreateTSmaReq* pReq);
|
||||||
|
@ -1960,24 +1975,30 @@ int32_t tSerializeSVDropTSmaReq(void** buf, SVDropTSmaReq* pReq);
|
||||||
void* tDeserializeSVDropTSmaReq(void* buf, SVDropTSmaReq* pReq);
|
void* tDeserializeSVDropTSmaReq(void* buf, SVDropTSmaReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
STimeWindow tsWindow; // [skey, ekey]
|
col_id_t colId;
|
||||||
uint64_t tableUid; // sub/common table uid
|
uint16_t blockSize; // sma data block size
|
||||||
int32_t numOfBlocks; // number of sma blocks for each column, total number is numOfBlocks*numOfColId
|
char data[];
|
||||||
int32_t dataLen; // total data length
|
} STSmaColData;
|
||||||
col_id_t* colIds; // e.g. 2,4,9,10
|
|
||||||
col_id_t numOfColIds; // e.g. 4
|
|
||||||
char data[]; // the sma blocks
|
|
||||||
} STSmaData;
|
|
||||||
|
|
||||||
// TODO: move to the final location afte schema of STSma/STSmaData defined
|
typedef struct {
|
||||||
static FORCE_INLINE void tdDestroySmaData(STSmaData* pSmaData) {
|
tb_uid_t tableUid; // super/child/normal table uid
|
||||||
if (pSmaData) {
|
int32_t dataLen; // not including head
|
||||||
if (pSmaData->colIds) {
|
char data[];
|
||||||
tfree(pSmaData->colIds);
|
} STSmaTbData;
|
||||||
}
|
|
||||||
tfree(pSmaData);
|
typedef struct {
|
||||||
}
|
int64_t indexUid;
|
||||||
}
|
TSKEY skey; // startTS of one interval/sliding
|
||||||
|
int64_t interval;
|
||||||
|
int32_t dataLen; // not including head
|
||||||
|
int8_t intervalUnit;
|
||||||
|
char data[];
|
||||||
|
} STSmaDataWrapper; // sma data for a interval/sliding window
|
||||||
|
|
||||||
|
// interval/sliding => window
|
||||||
|
|
||||||
|
// => window->table->colId
|
||||||
|
// => 当一个window下所有的表均计算完成时,流计算告知tsdb清除window的过期标记
|
||||||
|
|
||||||
// RSma: Rollup SMA
|
// RSma: Rollup SMA
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -2000,13 +2021,7 @@ typedef struct {
|
||||||
|
|
||||||
static FORCE_INLINE void tdDestroyTSma(STSma* pSma) {
|
static FORCE_INLINE void tdDestroyTSma(STSma* pSma) {
|
||||||
if (pSma) {
|
if (pSma) {
|
||||||
if (pSma->funcColIds != NULL) {
|
tfree(pSma->expr);
|
||||||
for (uint16_t i = 0; i < pSma->nFuncColIds; ++i) {
|
|
||||||
tfree((pSma->funcColIds + i)->colIds);
|
|
||||||
}
|
|
||||||
tfree(pSma->funcColIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
tfree(pSma->tagsFilter);
|
tfree(pSma->tagsFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2025,24 +2040,20 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) {
|
||||||
static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) {
|
static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
|
|
||||||
tlen += taosEncodeFixedU8(buf, pSma->version);
|
tlen += taosEncodeFixedI8(buf, pSma->version);
|
||||||
tlen += taosEncodeFixedU8(buf, pSma->intervalUnit);
|
tlen += taosEncodeFixedI8(buf, pSma->intervalUnit);
|
||||||
tlen += taosEncodeFixedU8(buf, pSma->slidingUnit);
|
tlen += taosEncodeFixedI8(buf, pSma->slidingUnit);
|
||||||
tlen += taosEncodeString(buf, pSma->indexName);
|
tlen += taosEncodeString(buf, pSma->indexName);
|
||||||
tlen += taosEncodeString(buf, pSma->timezone);
|
tlen += taosEncodeString(buf, pSma->timezone);
|
||||||
tlen += taosEncodeFixedU16(buf, pSma->nFuncColIds);
|
tlen += taosEncodeFixedU16(buf, pSma->exprLen);
|
||||||
tlen += taosEncodeFixedU16(buf, pSma->tagsFilterLen);
|
tlen += taosEncodeFixedU16(buf, pSma->tagsFilterLen);
|
||||||
|
tlen += taosEncodeFixedI64(buf, pSma->indexUid);
|
||||||
tlen += taosEncodeFixedI64(buf, pSma->tableUid);
|
tlen += taosEncodeFixedI64(buf, pSma->tableUid);
|
||||||
tlen += taosEncodeFixedI64(buf, pSma->interval);
|
tlen += taosEncodeFixedI64(buf, pSma->interval);
|
||||||
tlen += taosEncodeFixedI64(buf, pSma->sliding);
|
tlen += taosEncodeFixedI64(buf, pSma->sliding);
|
||||||
|
|
||||||
for (uint16_t i = 0; i < pSma->nFuncColIds; ++i) {
|
if (pSma->exprLen > 0) {
|
||||||
SFuncColIds* funcColIds = pSma->funcColIds + i;
|
tlen += taosEncodeString(buf, pSma->expr);
|
||||||
tlen += taosEncodeFixedU16(buf, funcColIds->funcId);
|
|
||||||
tlen += taosEncodeFixedU16(buf, funcColIds->nColIds);
|
|
||||||
for (uint16_t j = 0; j < funcColIds->nColIds; ++j) {
|
|
||||||
tlen += taosEncodeFixedU16(buf, *(funcColIds->colIds + j));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSma->tagsFilterLen > 0) {
|
if (pSma->tagsFilterLen > 0) {
|
||||||
|
@ -2063,43 +2074,30 @@ static FORCE_INLINE int32_t tEncodeTSmaWrapper(void** buf, const STSmaWrapper* p
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) {
|
static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) {
|
||||||
buf = taosDecodeFixedU8(buf, &pSma->version);
|
buf = taosDecodeFixedI8(buf, &pSma->version);
|
||||||
buf = taosDecodeFixedU8(buf, &pSma->intervalUnit);
|
buf = taosDecodeFixedI8(buf, &pSma->intervalUnit);
|
||||||
buf = taosDecodeFixedU8(buf, &pSma->slidingUnit);
|
buf = taosDecodeFixedI8(buf, &pSma->slidingUnit);
|
||||||
buf = taosDecodeStringTo(buf, pSma->indexName);
|
buf = taosDecodeStringTo(buf, pSma->indexName);
|
||||||
buf = taosDecodeStringTo(buf, pSma->timezone);
|
buf = taosDecodeStringTo(buf, pSma->timezone);
|
||||||
buf = taosDecodeFixedU16(buf, &pSma->nFuncColIds);
|
buf = taosDecodeFixedU16(buf, &pSma->exprLen);
|
||||||
buf = taosDecodeFixedU16(buf, &pSma->tagsFilterLen);
|
buf = taosDecodeFixedU16(buf, &pSma->tagsFilterLen);
|
||||||
|
buf = taosDecodeFixedI64(buf, &pSma->indexUid);
|
||||||
buf = taosDecodeFixedI64(buf, &pSma->tableUid);
|
buf = taosDecodeFixedI64(buf, &pSma->tableUid);
|
||||||
buf = taosDecodeFixedI64(buf, &pSma->interval);
|
buf = taosDecodeFixedI64(buf, &pSma->interval);
|
||||||
buf = taosDecodeFixedI64(buf, &pSma->sliding);
|
buf = taosDecodeFixedI64(buf, &pSma->sliding);
|
||||||
|
|
||||||
if (pSma->nFuncColIds > 0) {
|
|
||||||
pSma->funcColIds = (SFuncColIds*)calloc(pSma->nFuncColIds, sizeof(SFuncColIds));
|
if (pSma->exprLen > 0) {
|
||||||
if (pSma->funcColIds == NULL) {
|
pSma->expr = (char*)calloc(pSma->exprLen, 1);
|
||||||
tdDestroyTSma(pSma);
|
if (pSma->expr != NULL) {
|
||||||
return NULL;
|
buf = taosDecodeStringTo(buf, pSma->expr);
|
||||||
}
|
|
||||||
for (uint16_t i = 0; i < pSma->nFuncColIds; ++i) {
|
|
||||||
SFuncColIds* funcColIds = pSma->funcColIds + i;
|
|
||||||
buf = taosDecodeFixedU16(buf, &funcColIds->funcId);
|
|
||||||
buf = taosDecodeFixedU16(buf, &funcColIds->nColIds);
|
|
||||||
if (funcColIds->nColIds > 0) {
|
|
||||||
funcColIds->colIds = (col_id_t*)calloc(funcColIds->nColIds, sizeof(col_id_t));
|
|
||||||
if (funcColIds->colIds != NULL) {
|
|
||||||
for (uint16_t j = 0; j < funcColIds->nColIds; ++j) {
|
|
||||||
buf = taosDecodeFixedU16(buf, funcColIds->colIds + j);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
tdDestroyTSma(pSma);
|
tdDestroyTSma(pSma);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
funcColIds->colIds = NULL;
|
pSma->expr = NULL;
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pSma->funcColIds = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSma->tagsFilterLen > 0) {
|
if (pSma->tagsFilterLen > 0) {
|
||||||
|
|
|
@ -103,6 +103,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// TODO
|
// TODO
|
||||||
|
int tmp; // TODO: to avoid compile error
|
||||||
} STpRow; // tuple
|
} STpRow; // tuple
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|
|
@ -80,6 +80,10 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad);
|
||||||
*/
|
*/
|
||||||
int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||||
|
|
||||||
|
int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg);
|
||||||
|
|
||||||
|
int32_t sndProcessSMsg(SSnode *pSnode, SRpcMsg *pMsg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Drop a snode.
|
* @brief Drop a snode.
|
||||||
*
|
*
|
||||||
|
|
|
@ -112,6 +112,8 @@ int32_t catalogUpdateDBVgInfo(SCatalog* pCatalog, const char* dbName, uint64_t d
|
||||||
|
|
||||||
int32_t catalogRemoveDB(SCatalog* pCatalog, const char* dbName, uint64_t dbId);
|
int32_t catalogRemoveDB(SCatalog* pCatalog, const char* dbName, uint64_t dbId);
|
||||||
|
|
||||||
|
int32_t catalogRemoveTableMeta(SCatalog* pCtg, SName* pTableName);
|
||||||
|
|
||||||
int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, const char* stbName, uint64_t suid);
|
int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, const char* stbName, uint64_t suid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,7 +41,6 @@ int32_t dsDataSinkMgtInit(SDataSinkMgtCfg *cfg);
|
||||||
|
|
||||||
typedef struct SInputData {
|
typedef struct SInputData {
|
||||||
const struct SSDataBlock* pData;
|
const struct SSDataBlock* pData;
|
||||||
SHashObj* pTableRetrieveTsMap;
|
|
||||||
} SInputData;
|
} SInputData;
|
||||||
|
|
||||||
typedef struct SOutputData {
|
typedef struct SOutputData {
|
||||||
|
|
|
@ -69,7 +69,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, SArray* tableIdList, bool isA
|
||||||
* @param qId
|
* @param qId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, struct SSubplan* pPlan, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, SQueryErrorInfo *errInfo);
|
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, struct SSubplan* pPlan, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main task execution function, including query on both table and multiple tables,
|
* The main task execution function, including query on both table and multiple tables,
|
||||||
|
|
|
@ -106,6 +106,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_LOGIC_PLAN_PROJECT,
|
QUERY_NODE_LOGIC_PLAN_PROJECT,
|
||||||
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF,
|
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF,
|
||||||
QUERY_NODE_LOGIC_PLAN_EXCHANGE,
|
QUERY_NODE_LOGIC_PLAN_EXCHANGE,
|
||||||
|
QUERY_NODE_LOGIC_PLAN_WINDOW,
|
||||||
QUERY_NODE_LOGIC_SUBPLAN,
|
QUERY_NODE_LOGIC_SUBPLAN,
|
||||||
QUERY_NODE_LOGIC_PLAN,
|
QUERY_NODE_LOGIC_PLAN,
|
||||||
|
|
||||||
|
@ -120,6 +121,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_AGG,
|
QUERY_NODE_PHYSICAL_PLAN_AGG,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE,
|
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_SORT,
|
QUERY_NODE_PHYSICAL_PLAN_SORT,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_INTERVAL,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_DISPATCH,
|
QUERY_NODE_PHYSICAL_PLAN_DISPATCH,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_INSERT,
|
QUERY_NODE_PHYSICAL_PLAN_INSERT,
|
||||||
QUERY_NODE_PHYSICAL_SUBPLAN,
|
QUERY_NODE_PHYSICAL_SUBPLAN,
|
||||||
|
|
|
@ -80,6 +80,22 @@ typedef struct SExchangeLogicNode {
|
||||||
int32_t srcGroupId;
|
int32_t srcGroupId;
|
||||||
} SExchangeLogicNode;
|
} SExchangeLogicNode;
|
||||||
|
|
||||||
|
typedef enum EWindowType {
|
||||||
|
WINDOW_TYPE_INTERVAL = 1,
|
||||||
|
WINDOW_TYPE_SESSION,
|
||||||
|
WINDOW_TYPE_STATE
|
||||||
|
} EWindowType;
|
||||||
|
|
||||||
|
typedef struct SWindowLogicNode {
|
||||||
|
SLogicNode node;
|
||||||
|
EWindowType winType;
|
||||||
|
SNodeList* pFuncs;
|
||||||
|
int64_t interval;
|
||||||
|
int64_t offset;
|
||||||
|
int64_t sliding;
|
||||||
|
SFillNode* pFill;
|
||||||
|
} SWindowLogicNode;
|
||||||
|
|
||||||
typedef enum ESubplanType {
|
typedef enum ESubplanType {
|
||||||
SUBPLAN_TYPE_MERGE = 1,
|
SUBPLAN_TYPE_MERGE = 1,
|
||||||
SUBPLAN_TYPE_PARTIAL,
|
SUBPLAN_TYPE_PARTIAL,
|
||||||
|
@ -195,6 +211,16 @@ typedef struct SExchangePhysiNode {
|
||||||
SNodeList* pSrcEndPoints; // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
|
SNodeList* pSrcEndPoints; // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
|
||||||
} SExchangePhysiNode;
|
} SExchangePhysiNode;
|
||||||
|
|
||||||
|
typedef struct SIntervalPhysiNode {
|
||||||
|
SPhysiNode node;
|
||||||
|
SNodeList* pExprs; // these are expression list of parameter expression of function
|
||||||
|
SNodeList* pFuncs;
|
||||||
|
int64_t interval;
|
||||||
|
int64_t offset;
|
||||||
|
int64_t sliding;
|
||||||
|
SFillNode* pFill;
|
||||||
|
} SIntervalPhysiNode;
|
||||||
|
|
||||||
typedef struct SDataSinkNode {
|
typedef struct SDataSinkNode {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
SDataBlockDescNode* pInputDataBlockDesc;
|
SDataBlockDescNode* pInputDataBlockDesc;
|
||||||
|
|
|
@ -134,11 +134,6 @@ typedef struct SQueryNodeStat {
|
||||||
int32_t tableNum; // vg table number, unit is TSDB_TABLE_NUM_UNIT
|
int32_t tableNum; // vg table number, unit is TSDB_TABLE_NUM_UNIT
|
||||||
} SQueryNodeStat;
|
} SQueryNodeStat;
|
||||||
|
|
||||||
typedef struct SQueryErrorInfo {
|
|
||||||
int32_t code;
|
|
||||||
SName tableName;
|
|
||||||
} SQueryErrorInfo;
|
|
||||||
|
|
||||||
int32_t initTaskQueue();
|
int32_t initTaskQueue();
|
||||||
int32_t cleanupTaskQueue();
|
int32_t cleanupTaskQueue();
|
||||||
|
|
||||||
|
@ -170,6 +165,7 @@ const SSchema* tGetTbnameColumnSchema();
|
||||||
bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags);
|
bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags);
|
||||||
|
|
||||||
int32_t queryCreateTableMetaFromMsg(STableMetaRsp* msg, bool isSuperTable, STableMeta** pMeta);
|
int32_t queryCreateTableMetaFromMsg(STableMetaRsp* msg, bool isSuperTable, STableMeta** pMeta);
|
||||||
|
char *jobTaskStatusStr(int32_t status);
|
||||||
|
|
||||||
SSchema createSchema(uint8_t type, int32_t bytes, int32_t colId, const char* name);
|
SSchema createSchema(uint8_t type, int32_t bytes, int32_t colId, const char* name);
|
||||||
|
|
||||||
|
@ -181,8 +177,14 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
||||||
#define SET_META_TYPE_TABLE(t) (t) = META_TYPE_TABLE
|
#define SET_META_TYPE_TABLE(t) (t) = META_TYPE_TABLE
|
||||||
#define SET_META_TYPE_BOTH_TABLE(t) (t) = META_TYPE_BOTH_TABLE
|
#define SET_META_TYPE_BOTH_TABLE(t) (t) = META_TYPE_BOTH_TABLE
|
||||||
|
|
||||||
#define IS_CLIENT_RETRY_ERROR(_code) ((_code) == TSDB_CODE_VND_HASH_MISMATCH)
|
#define NEED_CLIENT_RM_TBLMETA_ERROR(_code) ((_code) == TSDB_CODE_TDB_INVALID_TABLE_ID || (_code) == TSDB_CODE_VND_TB_NOT_EXIST)
|
||||||
#define IS_SCHEDULER_RETRY_ERROR(_code) ((_code) == TSDB_CODE_RPC_REDIRECT)
|
#define NEED_CLIENT_REFRESH_VG_ERROR(_code) ((_code) == TSDB_CODE_VND_HASH_MISMATCH || (_code) == TSDB_CODE_VND_INVALID_VGROUP_ID)
|
||||||
|
#define NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code) ((_code) == TSDB_CODE_TDB_TABLE_RECREATED)
|
||||||
|
#define NEED_CLIENT_HANDLE_ERROR(_code) (NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code))
|
||||||
|
|
||||||
|
#define NEED_SCHEDULER_RETRY_ERROR(_code) ((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
|
||||||
|
|
||||||
|
#define REQUEST_MAX_TRY_TIMES 5
|
||||||
|
|
||||||
#define qFatal(...) \
|
#define qFatal(...) \
|
||||||
do { \
|
do { \
|
||||||
|
|
|
@ -53,7 +53,6 @@ typedef struct SQueryProfileSummary {
|
||||||
|
|
||||||
typedef struct SQueryResult {
|
typedef struct SQueryResult {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
SArray *errList; // SArray<SQueryErrorInfo>
|
|
||||||
uint64_t numOfRows;
|
uint64_t numOfRows;
|
||||||
int32_t msgSize;
|
int32_t msgSize;
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
|
@ -29,7 +29,6 @@ extern "C" {
|
||||||
|
|
||||||
extern int tsRpcHeadSize;
|
extern int tsRpcHeadSize;
|
||||||
|
|
||||||
typedef struct SRpcPush SRpcPush;
|
|
||||||
|
|
||||||
typedef struct SRpcConnInfo {
|
typedef struct SRpcConnInfo {
|
||||||
uint32_t clientIp;
|
uint32_t clientIp;
|
||||||
|
@ -45,16 +44,8 @@ typedef struct SRpcMsg {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
void * handle; // rpc handle returned to app
|
void * handle; // rpc handle returned to app
|
||||||
void * ahandle; // app handle set by client
|
void * ahandle; // app handle set by client
|
||||||
int persist; // keep handle or not, default 0
|
|
||||||
|
|
||||||
SRpcPush *push;
|
|
||||||
|
|
||||||
} SRpcMsg;
|
} SRpcMsg;
|
||||||
|
|
||||||
typedef struct SRpcPush {
|
|
||||||
void *arg;
|
|
||||||
int (*callback)(void *arg, SRpcMsg *rpcMsg);
|
|
||||||
} SRpcPush;
|
|
||||||
|
|
||||||
typedef struct SRpcInit {
|
typedef struct SRpcInit {
|
||||||
uint16_t localPort; // local port
|
uint16_t localPort; // local port
|
||||||
|
@ -64,7 +55,6 @@ typedef struct SRpcInit {
|
||||||
int8_t connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
|
int8_t connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
|
||||||
int idleTime; // milliseconds, 0 means idle timer is disabled
|
int idleTime; // milliseconds, 0 means idle timer is disabled
|
||||||
|
|
||||||
bool noPool; // create conn pool or not
|
|
||||||
// the following is for client app ecurity only
|
// the following is for client app ecurity only
|
||||||
char *user; // user name
|
char *user; // user name
|
||||||
char spi; // security parameter index
|
char spi; // security parameter index
|
||||||
|
@ -81,6 +71,10 @@ typedef struct SRpcInit {
|
||||||
// call back to keep conn or not
|
// call back to keep conn or not
|
||||||
bool (*pfp)(void *parent, tmsg_t msgType);
|
bool (*pfp)(void *parent, tmsg_t msgType);
|
||||||
|
|
||||||
|
// to support Send messages multiple times on a link
|
||||||
|
//
|
||||||
|
void* (*mfp)(void *parent, tmsg_t msgType);
|
||||||
|
|
||||||
void *parent;
|
void *parent;
|
||||||
} SRpcInit;
|
} SRpcInit;
|
||||||
|
|
||||||
|
@ -99,6 +93,12 @@ void rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp)
|
||||||
int rpcReportProgress(void *pConn, char *pCont, int contLen);
|
int rpcReportProgress(void *pConn, char *pCont, int contLen);
|
||||||
void rpcCancelRequest(int64_t rid);
|
void rpcCancelRequest(int64_t rid);
|
||||||
|
|
||||||
|
// just release client conn to rpc instance, no close sock
|
||||||
|
void rpcReleaseHandle(void *handle);
|
||||||
|
|
||||||
|
void rpcRefHandle(void *handle, int8_t type);
|
||||||
|
void rpcUnrefHandle(void *handle, int8_t type);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,7 +22,22 @@ extern "C" {
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#if !defined(WINDOWS)
|
||||||
|
#include <unistd.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <regex.h>
|
||||||
|
#include <sched.h>
|
||||||
|
#include <wordexp.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
@ -30,8 +45,6 @@ extern "C" {
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <regex.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -43,16 +56,9 @@ extern "C" {
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/utsname.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#include <wordexp.h>
|
|
||||||
#include <libgen.h>
|
|
||||||
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/prctl.h>
|
|
||||||
|
|
||||||
#include "osAtomic.h"
|
#include "osAtomic.h"
|
||||||
#include "osDef.h"
|
#include "osDef.h"
|
||||||
|
|
|
@ -49,7 +49,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(WINDOWS)
|
||||||
char *stpcpy (char *dest, const char *src);
|
char *stpcpy (char *dest, const char *src);
|
||||||
char *stpncpy (char *dest, const char *src, size_t n);
|
char *stpncpy (char *dest, const char *src, size_t n);
|
||||||
|
|
||||||
|
@ -63,16 +63,46 @@ extern "C" {
|
||||||
#define strtok_r strtok_s
|
#define strtok_r strtok_s
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#define in_addr_t unsigned long
|
#define in_addr_t unsigned long
|
||||||
#define socklen_t int
|
// #define socklen_t int
|
||||||
|
|
||||||
struct tm *localtime_r(const time_t *timep, struct tm *result);
|
|
||||||
char * strptime(const char *buf, const char *fmt, struct tm *tm);
|
|
||||||
char * strsep(char **stringp, const char *delim);
|
char * strsep(char **stringp, const char *delim);
|
||||||
char * getpass(const char *prefix);
|
char * getpass(const char *prefix);
|
||||||
char * strndup(const char *s, size_t n);
|
char * strndup(const char *s, size_t n);
|
||||||
|
int gettimeofday(struct timeval *ptv, void *pTimeZone);
|
||||||
|
|
||||||
|
// for send function in tsocket.c
|
||||||
|
#define MSG_NOSIGNAL 0
|
||||||
|
#define SO_NO_CHECK 0x1234
|
||||||
|
#define SOL_TCP 0x1234
|
||||||
|
|
||||||
|
#define SHUT_RDWR SD_BOTH
|
||||||
|
#define SHUT_RD SD_RECEIVE
|
||||||
|
#define SHUT_WR SD_SEND
|
||||||
|
|
||||||
|
#define LOCK_EX 1
|
||||||
|
#define LOCK_NB 2
|
||||||
|
#define LOCK_UN 3
|
||||||
|
|
||||||
|
#ifndef PATH_MAX
|
||||||
|
#define PATH_MAX 256
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int we_wordc;
|
||||||
|
char *we_wordv[1];
|
||||||
|
int we_offs;
|
||||||
|
char wordPos[1025];
|
||||||
|
} wordexp_t;
|
||||||
|
int wordexp(char *words, wordexp_t *pwordexp, int flags);
|
||||||
|
void wordfree(wordexp_t *pwordexp);
|
||||||
|
|
||||||
|
#define openlog(a, b, c)
|
||||||
|
#define closelog()
|
||||||
|
#define LOG_ERR 0
|
||||||
|
#define LOG_INFO 1
|
||||||
|
void syslog(int unused, const char *format, ...);
|
||||||
|
#endif // WINDOWS
|
||||||
|
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
#ifndef O_BINARY
|
#ifndef O_BINARY
|
||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
|
@ -166,7 +196,7 @@ extern "C" {
|
||||||
#define PRIzu "zu"
|
#define PRIzu "zu"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_TD_LINUX_64) || defined(_TD_LINUX_32) || defined(_TD_MIPS_64) || defined(_TD_ARM_32) || defined(_TD_ARM_64) || defined(_TD_DARWIN_64)
|
#if !defined(WINDOWS)
|
||||||
#if defined(_TD_DARWIN_64)
|
#if defined(_TD_DARWIN_64)
|
||||||
// MacOS
|
// MacOS
|
||||||
#if !defined(_GNU_SOURCE)
|
#if !defined(_GNU_SOURCE)
|
||||||
|
@ -181,8 +211,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
// Windows
|
// Windows
|
||||||
// #define setThreadName(name)
|
#define setThreadName(name)
|
||||||
#define setThreadName(name) do { prctl(PR_SET_NAME, (name)); } while (0)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
|
@ -22,6 +22,15 @@ extern "C" {
|
||||||
|
|
||||||
#include "osSocket.h"
|
#include "osSocket.h"
|
||||||
|
|
||||||
|
#if defined(WINDOWS)
|
||||||
|
typedef int32_t FileFd;
|
||||||
|
typedef SOCKET SocketFd;
|
||||||
|
#else
|
||||||
|
typedef int32_t FileFd;
|
||||||
|
typedef int32_t SocketFd;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int64_t taosRead(FileFd fd, void *buf, int64_t count);
|
||||||
// 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.
|
||||||
#ifndef ALLOW_FORBID_FUNC
|
#ifndef ALLOW_FORBID_FUNC
|
||||||
#define open OPEN_FUNC_TAOS_FORBID
|
#define open OPEN_FUNC_TAOS_FORBID
|
||||||
|
@ -76,7 +85,13 @@ int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count);
|
||||||
int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset);
|
int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset);
|
||||||
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count);
|
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count);
|
||||||
void taosFprintfFile(TdFilePtr pFile, const char *format, ...);
|
void taosFprintfFile(TdFilePtr pFile, const char *format, ...);
|
||||||
|
|
||||||
|
#if defined(WINDOWS)
|
||||||
|
#define __restrict__
|
||||||
|
#endif // WINDOWS
|
||||||
|
|
||||||
int64_t taosGetLineFile(TdFilePtr pFile, char ** __restrict__ ptrBuf);
|
int64_t taosGetLineFile(TdFilePtr pFile, char ** __restrict__ ptrBuf);
|
||||||
|
|
||||||
int32_t taosEOFFile(TdFilePtr pFile);
|
int32_t taosEOFFile(TdFilePtr pFile);
|
||||||
|
|
||||||
int64_t taosCloseFile(TdFilePtr *ppFile);
|
int64_t taosCloseFile(TdFilePtr *ppFile);
|
||||||
|
|
|
@ -17,12 +17,16 @@
|
||||||
#define _TD_OS_LOCALE_H_
|
#define _TD_OS_LOCALE_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "osString.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||||
|
#ifndef ALLOW_FORBID_FUNC
|
||||||
|
#define setlocale SETLOCALE_FUNC_TAOS_FORBID
|
||||||
|
#endif
|
||||||
|
|
||||||
char *taosCharsetReplace(char *charsetstr);
|
char *taosCharsetReplace(char *charsetstr);
|
||||||
void taosGetSystemLocale(char *outLocale, char *outCharset);
|
void taosGetSystemLocale(char *outLocale, char *outCharset);
|
||||||
void taosSetSystemLocale(const char *inLocale, const char *inCharSet);
|
void taosSetSystemLocale(const char *inLocale, const char *inCharSet);
|
||||||
|
|
|
@ -16,12 +16,13 @@
|
||||||
#ifndef _TD_OS_SEMPHONE_H_
|
#ifndef _TD_OS_SEMPHONE_H_
|
||||||
#define _TD_OS_SEMPHONE_H_
|
#define _TD_OS_SEMPHONE_H_
|
||||||
|
|
||||||
#include <semaphore.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <semaphore.h>
|
||||||
|
|
||||||
#if defined (_TD_DARWIN_64)
|
#if defined (_TD_DARWIN_64)
|
||||||
typedef struct tsem_s *tsem_t;
|
typedef struct tsem_s *tsem_t;
|
||||||
int tsem_init(tsem_t *sem, int pshared, unsigned int value);
|
int tsem_init(tsem_t *sem, int pshared, unsigned int value);
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#define epoll_wait EPOLL_WAIT_FUNC_TAOS_FORBID
|
#define epoll_wait EPOLL_WAIT_FUNC_TAOS_FORBID
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(WINDOWS)
|
||||||
#include "winsock2.h"
|
#include "winsock2.h"
|
||||||
#include <WS2tcpip.h>
|
#include <WS2tcpip.h>
|
||||||
#include <winbase.h>
|
#include <winbase.h>
|
||||||
|
|
|
@ -52,6 +52,13 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen);
|
||||||
char *taosGetCmdlineByPID(int32_t pid);
|
char *taosGetCmdlineByPID(int32_t pid);
|
||||||
void taosSetCoreDump(bool enable);
|
void taosSetCoreDump(bool enable);
|
||||||
|
|
||||||
|
#if defined(WINDOWS)
|
||||||
|
|
||||||
|
#define _UTSNAME_LENGTH 65
|
||||||
|
#define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH
|
||||||
|
|
||||||
|
#endif // WINDOWS
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char sysname[_UTSNAME_MACHINE_LENGTH];
|
char sysname[_UTSNAME_MACHINE_LENGTH];
|
||||||
char nodename[_UTSNAME_MACHINE_LENGTH];
|
char nodename[_UTSNAME_MACHINE_LENGTH];
|
||||||
|
|
|
@ -20,7 +20,19 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||||
|
#ifndef ALLOW_FORBID_FUNC
|
||||||
|
#define strptime STRPTIME_FUNC_TAOS_FORBID
|
||||||
|
#define gettimeofday GETTIMEOFDAY_FUNC_TAOS_FORBID
|
||||||
|
#define localtime_s LOCALTIMES_FUNC_TAOS_FORBID
|
||||||
|
#define localtime_r LOCALTIMER_FUNC_TAOS_FORBID
|
||||||
|
#define time TIME_FUNC_TAOS_FORBID
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
|
|
||||||
|
#define CLOCK_REALTIME 0
|
||||||
|
|
||||||
#ifdef _TD_GO_DLL_
|
#ifdef _TD_GO_DLL_
|
||||||
#define MILLISECOND_PER_SECOND (1000LL)
|
#define MILLISECOND_PER_SECOND (1000LL)
|
||||||
#else
|
#else
|
||||||
|
@ -61,6 +73,9 @@ static FORCE_INLINE int64_t taosGetTimestampNs() {
|
||||||
return (int64_t)systemTime.tv_sec * 1000000000L + (int64_t)systemTime.tv_nsec;
|
return (int64_t)systemTime.tv_sec * 1000000000L + (int64_t)systemTime.tv_nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *taosStrpTime(const char *buf, const char *fmt, struct tm *tm);
|
||||||
|
struct tm *taosLocalTime(const time_t *timep, struct tm *result);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,6 +20,15 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||||
|
#ifndef ALLOW_FORBID_FUNC
|
||||||
|
#define timer_create TIMER_CREATE_FUNC_TAOS_FORBID
|
||||||
|
#define timer_settime TIMER_SETTIME_FUNC_TAOS_FORBID
|
||||||
|
#define timer_delete TIMER_DELETE_FUNC_TAOS_FORBID
|
||||||
|
#define timeSetEvent TIMESETEVENT_SETTIME_FUNC_TAOS_FORBID
|
||||||
|
#define timeKillEvent TIMEKILLEVENT_SETTIME_FUNC_TAOS_FORBID
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MSECONDS_PER_TICK 5
|
#define MSECONDS_PER_TICK 5
|
||||||
|
|
||||||
int32_t taosInitTimer(void (*callback)(int32_t), int32_t ms);
|
int32_t taosInitTimer(void (*callback)(int32_t), int32_t ms);
|
||||||
|
|
|
@ -354,6 +354,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614)
|
#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614)
|
||||||
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615)
|
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615)
|
||||||
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616)
|
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616)
|
||||||
|
#define TSDB_CODE_TDB_TABLE_RECREATED TAOS_DEF_ERROR_CODE(0, 0x0617)
|
||||||
|
#define TSDB_CODE_TDB_NO_SMA_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x0618)
|
||||||
|
|
||||||
// query
|
// query
|
||||||
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
||||||
|
@ -457,9 +459,10 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_CTG_OUT_OF_SERVICE TAOS_DEF_ERROR_CODE(0, 0x2406)
|
#define TSDB_CODE_CTG_OUT_OF_SERVICE TAOS_DEF_ERROR_CODE(0, 0x2406)
|
||||||
#define TSDB_CODE_CTG_VG_META_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x2407)
|
#define TSDB_CODE_CTG_VG_META_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x2407)
|
||||||
|
|
||||||
//scheduler
|
//scheduler&qworker
|
||||||
#define TSDB_CODE_SCH_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x2501)
|
#define TSDB_CODE_SCH_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x2501)
|
||||||
#define TSDB_CODE_SCH_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2502)
|
#define TSDB_CODE_SCH_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2502)
|
||||||
|
#define TSDB_CODE_QW_MSG_ERROR TAOS_DEF_ERROR_CODE(0, 0x2503)
|
||||||
|
|
||||||
//parser
|
//parser
|
||||||
#define TSDB_CODE_PAR_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x2600)
|
#define TSDB_CODE_PAR_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x2600)
|
||||||
|
|
|
@ -183,7 +183,8 @@ typedef struct SRequestObj {
|
||||||
char* msgBuf;
|
char* msgBuf;
|
||||||
void* pInfo; // sql parse info, generated by parser module
|
void* pInfo; // sql parse info, generated by parser module
|
||||||
int32_t code;
|
int32_t code;
|
||||||
SArray* errList; // SArray<SQueryErrorInfo>
|
SArray* dbList;
|
||||||
|
SArray* tableList;
|
||||||
SQueryExecMetric metric;
|
SQueryExecMetric metric;
|
||||||
SRequestSendRecvBody body;
|
SRequestSendRecvBody body;
|
||||||
} SRequestObj;
|
} SRequestObj;
|
||||||
|
|
|
@ -72,8 +72,6 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
||||||
taosReleaseRef(clientConnRefPool, pTscObj->id);
|
taosReleaseRef(clientConnRefPool, pTscObj->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// todo close the transporter properly
|
// todo close the transporter properly
|
||||||
void closeTransporter(STscObj *pTscObj) {
|
void closeTransporter(STscObj *pTscObj) {
|
||||||
if (pTscObj == NULL || pTscObj->pAppInfo->pTransporter == NULL) {
|
if (pTscObj == NULL || pTscObj->pAppInfo->pTransporter == NULL) {
|
||||||
|
@ -241,6 +239,7 @@ void taos_init_imp(void) {
|
||||||
clientConnRefPool = taosOpenRef(200, destroyTscObj);
|
clientConnRefPool = taosOpenRef(200, destroyTscObj);
|
||||||
clientReqRefPool = taosOpenRef(40960, doDestroyRequest);
|
clientReqRefPool = taosOpenRef(40960, doDestroyRequest);
|
||||||
|
|
||||||
|
// transDestroyBuffer(&conn->readBuf);
|
||||||
taosGetAppName(appInfo.appName, NULL);
|
taosGetAppName(appInfo.appName, NULL);
|
||||||
pthread_mutex_init(&appInfo.mutex, NULL);
|
pthread_mutex_init(&appInfo.mutex, NULL);
|
||||||
|
|
||||||
|
|
|
@ -220,8 +220,10 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) {
|
int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) {
|
||||||
void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter;
|
void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter;
|
||||||
|
|
||||||
SQueryResult res = {.code = 0, .numOfRows = 0, .msgSize = ERROR_MSG_BUF_DEFAULT_SIZE, .msg = pRequest->msgBuf};
|
SQueryResult res = {.code = 0, .numOfRows = 0, .msgSize = ERROR_MSG_BUF_DEFAULT_SIZE, .msg = pRequest->msgBuf};
|
||||||
int32_t code = schedulerExecJob(pTransporter, pNodeList, pDag, &pRequest->body.queryJob, pRequest->sqlstr, &res);
|
int32_t code = schedulerExecJob(pTransporter, pNodeList, pDag, &pRequest->body.queryJob, pRequest->sqlstr, &res);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -229,8 +231,8 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
|
||||||
schedulerFreeJob(pRequest->body.queryJob);
|
schedulerFreeJob(pRequest->body.queryJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
pRequest->errList = res.errList;
|
|
||||||
pRequest->code = code;
|
pRequest->code = code;
|
||||||
|
terrno = code;
|
||||||
return pRequest->code;
|
return pRequest->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,8 +244,8 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pRequest->errList = res.errList;
|
|
||||||
pRequest->code = res.code;
|
pRequest->code = res.code;
|
||||||
|
terrno = res.code;
|
||||||
return pRequest->code;
|
return pRequest->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,81 +275,61 @@ _return:
|
||||||
return pRequest;
|
return pRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t clientProcessErrorList(SArray **pList) {
|
int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest) {
|
||||||
SArray *errList = *pList;
|
SCatalog *pCatalog = NULL;
|
||||||
int32_t errNum = (int32_t)taosArrayGetSize(errList);
|
int32_t code = 0;
|
||||||
|
int32_t dbNum = taosArrayGetSize(pRequest->dbList);
|
||||||
|
int32_t tblNum = taosArrayGetSize(pRequest->tableList);
|
||||||
|
|
||||||
for (int32_t i = 0; i < errNum; ++i) {
|
if (dbNum <= 0 && tblNum <= 0) {
|
||||||
SQueryErrorInfo *errInfo = taosArrayGet(errList, i);
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
if (TSDB_CODE_VND_HASH_MISMATCH == errInfo->code) {
|
|
||||||
if (i == (errNum - 1)) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO REMOVE SAME DB ERROR
|
code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||||
} else {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
taosArrayRemove(errList, i);
|
return code;
|
||||||
--i;
|
}
|
||||||
--errNum;
|
|
||||||
|
SEpSet epset = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < dbNum; ++i) {
|
||||||
|
char *dbFName = taosArrayGet(pRequest->dbList, i);
|
||||||
|
|
||||||
|
code = catalogRefreshDBVgInfo(pCatalog, pTscObj->pAppInfo->pTransporter, &epset, dbFName);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == errNum) {
|
for (int32_t i = 0; i < tblNum; ++i) {
|
||||||
taosArrayDestroy(*pList);
|
SName *tableName = taosArrayGet(pRequest->tableList, i);
|
||||||
*pList = NULL;
|
|
||||||
|
code = catalogRefreshTableMeta(pCatalog, pTscObj->pAppInfo->pTransporter, &epset, tableName, -1);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
|
SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
|
||||||
SRequestObj* pRequest = NULL;
|
SRequestObj* pRequest = NULL;
|
||||||
|
int32_t retryNum = 0;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
bool quit = false;
|
|
||||||
|
|
||||||
while (!quit) {
|
while (retryNum++ < REQUEST_MAX_TRY_TIMES) {
|
||||||
pRequest = execQueryImpl(pTscObj, sql, sqlLen);
|
pRequest = execQueryImpl(pTscObj, sql, sqlLen);
|
||||||
if (TSDB_CODE_SUCCESS == pRequest->code || NULL == pRequest->errList) {
|
if (TSDB_CODE_SUCCESS == pRequest->code || !NEED_CLIENT_HANDLE_ERROR(pRequest->code)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = clientProcessErrorList(&pRequest->errList);
|
code = refreshMeta(pTscObj, pRequest);
|
||||||
if (code != TSDB_CODE_SUCCESS || NULL == pRequest->errList) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t errNum = (int32_t)taosArrayGetSize(pRequest->errList);
|
|
||||||
for (int32_t i = 0; i < errNum; ++i) {
|
|
||||||
SQueryErrorInfo *errInfo = taosArrayGet(pRequest->errList, i);
|
|
||||||
|
|
||||||
if (TSDB_CODE_VND_HASH_MISMATCH == errInfo->code) {
|
|
||||||
SCatalog *pCatalog = NULL;
|
|
||||||
code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
quit = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SEpSet epset = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
|
||||||
|
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
|
||||||
tNameGetFullDbName(&errInfo->tableName, dbFName);
|
|
||||||
|
|
||||||
code = catalogRefreshDBVgInfo(pCatalog, pTscObj->pAppInfo->pTransporter, &epset, dbFName);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
quit = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!quit) {
|
|
||||||
destroyRequest(pRequest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
pRequest->code = code;
|
pRequest->code = code;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pRequest;
|
return pRequest;
|
||||||
|
|
|
@ -4,6 +4,10 @@ target_include_directories(
|
||||||
common
|
common
|
||||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/common"
|
PUBLIC "${CMAKE_SOURCE_DIR}/include/common"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
|
IF(${TD_WINDOWS})
|
||||||
|
PRIVATE "${CMAKE_SOURCE_DIR}/contrib/pthread-win32"
|
||||||
|
PRIVATE "${CMAKE_SOURCE_DIR}/contrib/gnuregex"
|
||||||
|
ENDIF ()
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
common
|
common
|
||||||
|
|
|
@ -2634,10 +2634,6 @@ int32_t tSerializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pRsp->code) < 0) return -1;
|
if (tEncodeI32(&encoder, pRsp->code) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pRsp->tableName.type) < 0) return -1;
|
|
||||||
if (tEncodeI32(&encoder, pRsp->tableName.acctId) < 0) return -1;
|
|
||||||
if (tEncodeCStr(&encoder, pRsp->tableName.dbname) < 0) return -1;
|
|
||||||
if (tEncodeCStr(&encoder, pRsp->tableName.tname) < 0) return -1;
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -2651,10 +2647,52 @@ int32_t tDeserializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pR
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pRsp->code) < 0) return -1;
|
if (tDecodeI32(&decoder, &pRsp->code) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pRsp->tableName.type) < 0) return -1;
|
tEndDecode(&decoder);
|
||||||
if (tDecodeI32(&decoder, &pRsp->tableName.acctId) < 0) return -1;
|
|
||||||
if (tDecodeCStrTo(&decoder, pRsp->tableName.dbname) < 0) return -1;
|
tCoderClear(&decoder);
|
||||||
if (tDecodeCStrTo(&decoder, pRsp->tableName.tname) < 0) return -1;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatchRsp *pRsp) {
|
||||||
|
SCoder encoder = {0};
|
||||||
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (pRsp->rspList) {
|
||||||
|
int32_t num = taosArrayGetSize(pRsp->rspList);
|
||||||
|
if (tEncodeI32(&encoder, num) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
SVCreateTbRsp *rsp = taosArrayGet(pRsp->rspList, i);
|
||||||
|
if (tEncodeI32(&encoder, rsp->code) < 0) return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (tEncodeI32(&encoder, 0) < 0) return -1;
|
||||||
|
}
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatchRsp *pRsp) {
|
||||||
|
SCoder decoder = {0};
|
||||||
|
int32_t num = 0;
|
||||||
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &num) < 0) return -1;
|
||||||
|
if (num > 0) {
|
||||||
|
pRsp->rspList = taosArrayInit(num, sizeof(SVCreateTbRsp));
|
||||||
|
if (NULL == pRsp->rspList) return -1;
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
SVCreateTbRsp rsp = {0};
|
||||||
|
if (tDecodeI32(&decoder, &rsp.code) < 0) return -1;
|
||||||
|
if (NULL == taosArrayPush(pRsp->rspList, &rsp)) return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pRsp->rspList = NULL;
|
||||||
|
}
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tCoderClear(&decoder);
|
tCoderClear(&decoder);
|
||||||
|
@ -2705,7 +2743,6 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
||||||
if (tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->physicalPlan) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->physicalPlan) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->logicalPlan) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->logicalPlan) < 0) return -1;
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
|
|
@ -61,7 +61,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
|
||||||
}
|
}
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t t = (time_t)start;
|
time_t t = (time_t)start;
|
||||||
localtime_r(&t, &tm);
|
taosLocalTime(&t, &tm);
|
||||||
tm.tm_sec = 0;
|
tm.tm_sec = 0;
|
||||||
tm.tm_min = 0;
|
tm.tm_min = 0;
|
||||||
tm.tm_hour = 0;
|
tm.tm_hour = 0;
|
||||||
|
|
|
@ -69,7 +69,7 @@ static int64_t m_deltaUtc = 0;
|
||||||
void deltaToUtcInitOnce() {
|
void deltaToUtcInitOnce() {
|
||||||
struct tm tm = {0};
|
struct tm tm = {0};
|
||||||
|
|
||||||
(void)strptime("1970-01-01 00:00:00", (const char*)("%Y-%m-%d %H:%M:%S"), &tm);
|
(void)taosStrpTime("1970-01-01 00:00:00", (const char*)("%Y-%m-%d %H:%M:%S"), &tm);
|
||||||
m_deltaUtc = (int64_t)mktime(&tm);
|
m_deltaUtc = (int64_t)mktime(&tm);
|
||||||
// printf("====delta:%lld\n\n", seconds);
|
// printf("====delta:%lld\n\n", seconds);
|
||||||
}
|
}
|
||||||
|
@ -236,9 +236,9 @@ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, ch
|
||||||
|
|
||||||
char* str;
|
char* str;
|
||||||
if (delim == 'T') {
|
if (delim == 'T') {
|
||||||
str = strptime(timestr, "%Y-%m-%dT%H:%M:%S", &tm);
|
str = taosStrpTime(timestr, "%Y-%m-%dT%H:%M:%S", &tm);
|
||||||
} else if (delim == 0) {
|
} else if (delim == 0) {
|
||||||
str = strptime(timestr, "%Y-%m-%d %H:%M:%S", &tm);
|
str = taosStrpTime(timestr, "%Y-%m-%d %H:%M:%S", &tm);
|
||||||
} else {
|
} else {
|
||||||
str = NULL;
|
str = NULL;
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) {
|
||||||
*time = 0;
|
*time = 0;
|
||||||
struct tm tm = {0};
|
struct tm tm = {0};
|
||||||
|
|
||||||
char* str = strptime(timestr, "%Y-%m-%d %H:%M:%S", &tm);
|
char* str = taosStrpTime(timestr, "%Y-%m-%d %H:%M:%S", &tm);
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ int32_t parseLocaltimeDst(char* timestr, int64_t* time, int32_t timePrec) {
|
||||||
struct tm tm = {0};
|
struct tm tm = {0};
|
||||||
tm.tm_isdst = -1;
|
tm.tm_isdst = -1;
|
||||||
|
|
||||||
char* str = strptime(timestr, "%Y-%m-%d %H:%M:%S", &tm);
|
char* str = taosStrpTime(timestr, "%Y-%m-%d %H:%M:%S", &tm);
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
||||||
|
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||||
localtime_r(&tt, &tm);
|
taosLocalTime(&tt, &tm);
|
||||||
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)duration;
|
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)duration;
|
||||||
tm.tm_year = mon / 12;
|
tm.tm_year = mon / 12;
|
||||||
tm.tm_mon = mon % 12;
|
tm.tm_mon = mon % 12;
|
||||||
|
@ -489,11 +489,11 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char
|
||||||
|
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t t = (time_t)skey;
|
time_t t = (time_t)skey;
|
||||||
localtime_r(&t, &tm);
|
taosLocalTime(&t, &tm);
|
||||||
int32_t smon = tm.tm_year * 12 + tm.tm_mon;
|
int32_t smon = tm.tm_year * 12 + tm.tm_mon;
|
||||||
|
|
||||||
t = (time_t)ekey;
|
t = (time_t)ekey;
|
||||||
localtime_r(&t, &tm);
|
taosLocalTime(&t, &tm);
|
||||||
int32_t emon = tm.tm_year * 12 + tm.tm_mon;
|
int32_t emon = tm.tm_year * 12 + tm.tm_mon;
|
||||||
|
|
||||||
if (unit == 'y') {
|
if (unit == 'y') {
|
||||||
|
@ -514,7 +514,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
|
||||||
start /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
|
start /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t tt = (time_t)start;
|
time_t tt = (time_t)start;
|
||||||
localtime_r(&tt, &tm);
|
taosLocalTime(&tt, &tm);
|
||||||
tm.tm_sec = 0;
|
tm.tm_sec = 0;
|
||||||
tm.tm_min = 0;
|
tm.tm_min = 0;
|
||||||
tm.tm_hour = 0;
|
tm.tm_hour = 0;
|
||||||
|
@ -597,13 +597,13 @@ const char* fmtts(int64_t ts) {
|
||||||
|
|
||||||
if (ts > -62135625943 && ts < 32503651200) {
|
if (ts > -62135625943 && ts < 32503651200) {
|
||||||
time_t t = (time_t)ts;
|
time_t t = (time_t)ts;
|
||||||
localtime_r(&t, &tm);
|
taosLocalTime(&t, &tm);
|
||||||
pos += strftime(buf + pos, sizeof(buf), "s=%Y-%m-%d %H:%M:%S", &tm);
|
pos += strftime(buf + pos, sizeof(buf), "s=%Y-%m-%d %H:%M:%S", &tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ts > -62135625943000 && ts < 32503651200000) {
|
if (ts > -62135625943000 && ts < 32503651200000) {
|
||||||
time_t t = (time_t)(ts / 1000);
|
time_t t = (time_t)(ts / 1000);
|
||||||
localtime_r(&t, &tm);
|
taosLocalTime(&t, &tm);
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
buf[pos++] = ' ';
|
buf[pos++] = ' ';
|
||||||
buf[pos++] = '|';
|
buf[pos++] = '|';
|
||||||
|
@ -615,7 +615,7 @@ const char* fmtts(int64_t ts) {
|
||||||
|
|
||||||
{
|
{
|
||||||
time_t t = (time_t)(ts / 1000000);
|
time_t t = (time_t)(ts / 1000000);
|
||||||
localtime_r(&t, &tm);
|
taosLocalTime(&t, &tm);
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
buf[pos++] = ' ';
|
buf[pos++] = ' ';
|
||||||
buf[pos++] = '|';
|
buf[pos++] = '|';
|
||||||
|
|
|
@ -90,9 +90,11 @@ typedef struct {
|
||||||
int32_t refCount;
|
int32_t refCount;
|
||||||
int8_t deployed;
|
int8_t deployed;
|
||||||
int8_t dropped;
|
int8_t dropped;
|
||||||
|
int8_t uniqueWorkerInUse;
|
||||||
SSnode *pSnode;
|
SSnode *pSnode;
|
||||||
SRWLatch latch;
|
SRWLatch latch;
|
||||||
SDnodeWorker writeWorker;
|
SArray *uniqueWorkers; // SArray<SDnodeWorker*>
|
||||||
|
SDnodeWorker sharedWorker;
|
||||||
} SSnodeMgmt;
|
} SSnodeMgmt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -19,7 +19,20 @@
|
||||||
#include "dndTransport.h"
|
#include "dndTransport.h"
|
||||||
#include "dndWorker.h"
|
#include "dndWorker.h"
|
||||||
|
|
||||||
static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg);
|
typedef struct {
|
||||||
|
int32_t vgId;
|
||||||
|
int32_t refCount;
|
||||||
|
int32_t snVersion;
|
||||||
|
int8_t dropped;
|
||||||
|
char *path;
|
||||||
|
SSnode *pImpl;
|
||||||
|
STaosQueue *pSharedQ;
|
||||||
|
STaosQueue *pUniqueQ;
|
||||||
|
} SSnodeObj;
|
||||||
|
|
||||||
|
static void dndProcessSnodeSharedQueue(SDnode *pDnode, SRpcMsg *pMsg);
|
||||||
|
|
||||||
|
static void dndProcessSnodeUniqueQueue(SDnode *pDnode, STaosQall *qall, int32_t numOfMsgs);
|
||||||
|
|
||||||
static SSnode *dndAcquireSnode(SDnode *pDnode) {
|
static SSnode *dndAcquireSnode(SDnode *pDnode) {
|
||||||
SSnodeMgmt *pMgmt = &pDnode->smgmt;
|
SSnodeMgmt *pMgmt = &pDnode->smgmt;
|
||||||
|
@ -152,8 +165,21 @@ static int32_t dndWriteSnodeFile(SDnode *pDnode) {
|
||||||
|
|
||||||
static int32_t dndStartSnodeWorker(SDnode *pDnode) {
|
static int32_t dndStartSnodeWorker(SDnode *pDnode) {
|
||||||
SSnodeMgmt *pMgmt = &pDnode->smgmt;
|
SSnodeMgmt *pMgmt = &pDnode->smgmt;
|
||||||
if (dndInitWorker(pDnode, &pMgmt->writeWorker, DND_WORKER_SINGLE, "snode-write", 0, 1, dndProcessSnodeQueue) != 0) {
|
pMgmt->uniqueWorkers = taosArrayInit(0, sizeof(void *));
|
||||||
dError("failed to start snode write worker since %s", terrstr());
|
for (int32_t i = 0; i < 2; i++) {
|
||||||
|
SDnodeWorker *pUniqueWorker = malloc(sizeof(SDnodeWorker));
|
||||||
|
if (pUniqueWorker == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (dndInitWorker(pDnode, pUniqueWorker, DND_WORKER_MULTI, "snode-unique", 1, 1, dndProcessSnodeSharedQueue) != 0) {
|
||||||
|
dError("failed to start snode unique worker since %s", terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taosArrayPush(pMgmt->uniqueWorkers, &pUniqueWorker);
|
||||||
|
}
|
||||||
|
if (dndInitWorker(pDnode, &pMgmt->sharedWorker, DND_WORKER_SINGLE, "snode-shared", 4, 4,
|
||||||
|
dndProcessSnodeSharedQueue)) {
|
||||||
|
dError("failed to start snode shared worker since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +197,11 @@ static void dndStopSnodeWorker(SDnode *pDnode) {
|
||||||
taosMsleep(10);
|
taosMsleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
dndCleanupWorker(&pMgmt->writeWorker);
|
for (int32_t i = 0; i < taosArrayGetSize(pMgmt->uniqueWorkers); i++) {
|
||||||
|
SDnodeWorker *worker = taosArrayGetP(pMgmt->uniqueWorkers, i);
|
||||||
|
dndCleanupWorker(worker);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(pMgmt->uniqueWorkers);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndBuildSnodeOption(SDnode *pDnode, SSnodeOpt *pOption) {
|
static void dndBuildSnodeOption(SDnode *pDnode, SSnodeOpt *pOption) {
|
||||||
|
@ -292,17 +322,36 @@ int32_t dndProcessDropSnodeReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
|
static void dndProcessSnodeUniqueQueue(SDnode *pDnode, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
SSnodeMgmt *pMgmt = &pDnode->smgmt;
|
SSnodeMgmt *pMgmt = &pDnode->smgmt;
|
||||||
SRpcMsg *pRsp = NULL;
|
|
||||||
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
|
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
|
||||||
|
|
||||||
SSnode *pSnode = dndAcquireSnode(pDnode);
|
SSnode *pSnode = dndAcquireSnode(pDnode);
|
||||||
if (pSnode != NULL) {
|
if (pSnode != NULL) {
|
||||||
code = sndProcessMsg(pSnode, pMsg, &pRsp);
|
for (int32_t i = 0; i < numOfMsgs; i++) {
|
||||||
|
SRpcMsg *pMsg = NULL;
|
||||||
|
taosGetQitem(qall, (void **)&pMsg);
|
||||||
|
|
||||||
|
sndProcessUMsg(pSnode, pMsg);
|
||||||
|
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
taosFreeQitem(pMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dndReleaseSnode(pDnode, pSnode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dndProcessSnodeSharedQueue(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
|
SSnodeMgmt *pMgmt = &pDnode->smgmt;
|
||||||
|
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
|
||||||
|
|
||||||
|
SSnode *pSnode = dndAcquireSnode(pDnode);
|
||||||
|
if (pSnode != NULL) {
|
||||||
|
code = sndProcessSMsg(pSnode, pMsg);
|
||||||
}
|
}
|
||||||
dndReleaseSnode(pDnode, pSnode);
|
dndReleaseSnode(pDnode, pSnode);
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (pMsg->msgType & 1u) {
|
if (pMsg->msgType & 1u) {
|
||||||
if (pRsp != NULL) {
|
if (pRsp != NULL) {
|
||||||
pRsp->ahandle = pMsg->ahandle;
|
pRsp->ahandle = pMsg->ahandle;
|
||||||
|
@ -314,11 +363,32 @@ static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
rpcSendResponse(&rpcRsp);
|
rpcSendResponse(&rpcRsp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
rpcFreeCont(pMsg->pCont);
|
rpcFreeCont(pMsg->pCont);
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dndWriteSnodeMsgToRandomWorker(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
|
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
|
||||||
|
|
||||||
|
SSnode *pSnode = dndAcquireSnode(pDnode);
|
||||||
|
if (pSnode != NULL) {
|
||||||
|
int32_t index = (pDnode->smgmt.uniqueWorkerInUse + 1) % taosArrayGetSize(pDnode->smgmt.uniqueWorkers);
|
||||||
|
SDnodeWorker *pWorker = taosArrayGet(pDnode->smgmt.uniqueWorkers, index);
|
||||||
|
code = dndWriteMsgToWorker(pWorker, pMsg, sizeof(SRpcMsg));
|
||||||
|
}
|
||||||
|
dndReleaseSnode(pDnode, pSnode);
|
||||||
|
|
||||||
|
if (code != 0) {
|
||||||
|
if (pMsg->msgType & 1u) {
|
||||||
|
SRpcMsg rsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code};
|
||||||
|
rpcSendResponse(&rsp);
|
||||||
|
}
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void dndWriteSnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pMsg) {
|
static void dndWriteSnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pMsg) {
|
||||||
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
|
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
|
||||||
|
|
||||||
|
@ -337,8 +407,13 @@ static void dndWriteSnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndProcessSnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
void dndProcessSnodeUniqueMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
dndWriteSnodeMsgToWorker(pDnode, &pDnode->smgmt.writeWorker, pMsg);
|
// judge from msg to write to unique queue
|
||||||
|
dndWriteSnodeMsgToRandomWorker(pDnode, pMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dndProcessSnodeSharedMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
|
dndWriteSnodeMsgToWorker(pDnode, &pDnode->smgmt.sharedWorker, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndInitSnode(SDnode *pDnode) {
|
int32_t dndInitSnode(SDnode *pDnode) {
|
||||||
|
|
|
@ -195,7 +195,6 @@ static int32_t dndInitClient(SDnode *pDnode) {
|
||||||
rpcInit.ckey = INTERNAL_CKEY;
|
rpcInit.ckey = INTERNAL_CKEY;
|
||||||
rpcInit.spi = 1;
|
rpcInit.spi = 1;
|
||||||
rpcInit.parent = pDnode;
|
rpcInit.parent = pDnode;
|
||||||
rpcInit.noPool = true;
|
|
||||||
|
|
||||||
char pass[TSDB_PASSWORD_LEN + 1] = {0};
|
char pass[TSDB_PASSWORD_LEN + 1] = {0};
|
||||||
taosEncryptPass_c((uint8_t *)(INTERNAL_SECRET), strlen(INTERNAL_SECRET), pass);
|
taosEncryptPass_c((uint8_t *)(INTERNAL_SECRET), strlen(INTERNAL_SECRET), pass);
|
||||||
|
|
|
@ -968,7 +968,7 @@ static int32_t mndProcessUseDbReq(SMnodeMsg *pReq) {
|
||||||
char *p = strchr(usedbReq.db, '.');
|
char *p = strchr(usedbReq.db, '.');
|
||||||
if (p && 0 == strcmp(p + 1, TSDB_INFORMATION_SCHEMA_DB)) {
|
if (p && 0 == strcmp(p + 1, TSDB_INFORMATION_SCHEMA_DB)) {
|
||||||
memcpy(usedbRsp.db, usedbReq.db, TSDB_DB_FNAME_LEN);
|
memcpy(usedbRsp.db, usedbReq.db, TSDB_DB_FNAME_LEN);
|
||||||
int32_t vgVersion = taosGetTimestampSec() / 300;
|
static int32_t vgVersion = 1;
|
||||||
if (usedbReq.vgVersion < vgVersion) {
|
if (usedbReq.vgVersion < vgVersion) {
|
||||||
usedbRsp.pVgroupInfos = taosArrayInit(10, sizeof(SVgroupInfo));
|
usedbRsp.pVgroupInfos = taosArrayInit(10, sizeof(SVgroupInfo));
|
||||||
if (usedbRsp.pVgroupInfos == NULL) {
|
if (usedbRsp.pVgroupInfos == NULL) {
|
||||||
|
@ -977,12 +977,16 @@ static int32_t mndProcessUseDbReq(SMnodeMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mndBuildDBVgroupInfo(NULL, pMnode, usedbRsp.pVgroupInfos);
|
mndBuildDBVgroupInfo(NULL, pMnode, usedbRsp.pVgroupInfos);
|
||||||
usedbRsp.vgVersion = vgVersion;
|
usedbRsp.vgVersion = vgVersion++;
|
||||||
|
|
||||||
|
if (taosArrayGetSize(usedbRsp.pVgroupInfos) <= 0) {
|
||||||
|
terrno = TSDB_CODE_MND_DB_NOT_EXIST;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
usedbRsp.vgVersion = usedbReq.vgVersion;
|
usedbRsp.vgVersion = usedbReq.vgVersion;
|
||||||
|
code = 0;
|
||||||
}
|
}
|
||||||
usedbRsp.vgNum = taosArrayGetSize(usedbRsp.pVgroupInfos);
|
usedbRsp.vgNum = taosArrayGetSize(usedbRsp.pVgroupInfos);
|
||||||
code = 0;
|
|
||||||
} else {
|
} else {
|
||||||
pDb = mndAcquireDb(pMnode, usedbReq.db);
|
pDb = mndAcquireDb(pMnode, usedbReq.db);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndSnode.h"
|
#include "mndSnode.h"
|
||||||
#include "mndStb.h"
|
#include "mndStb.h"
|
||||||
|
#include "mndStream.h"
|
||||||
#include "mndSubscribe.h"
|
#include "mndSubscribe.h"
|
||||||
#include "mndSync.h"
|
#include "mndSync.h"
|
||||||
#include "mndTelem.h"
|
#include "mndTelem.h"
|
||||||
|
@ -220,6 +221,7 @@ static int32_t mndInitSteps(SMnode *pMnode) {
|
||||||
if (mndAllocStep(pMnode, "mnode-user", mndInitUser, mndCleanupUser) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-user", mndInitUser, mndCleanupUser) != 0) return -1;
|
||||||
if (mndAllocStep(pMnode, "mnode-auth", mndInitAuth, mndCleanupAuth) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-auth", mndInitAuth, mndCleanupAuth) != 0) return -1;
|
||||||
if (mndAllocStep(pMnode, "mnode-acct", mndInitAcct, mndCleanupAcct) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-acct", mndInitAcct, mndCleanupAcct) != 0) return -1;
|
||||||
|
if (mndAllocStep(pMnode, "mnode-stream", mndInitStream, mndCleanupStream) != 0) return -1;
|
||||||
if (mndAllocStep(pMnode, "mnode-topic", mndInitTopic, mndCleanupTopic) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-topic", mndInitTopic, mndCleanupTopic) != 0) return -1;
|
||||||
if (mndAllocStep(pMnode, "mnode-consumer", mndInitConsumer, mndCleanupConsumer) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-consumer", mndInitConsumer, mndCleanupConsumer) != 0) return -1;
|
||||||
if (mndAllocStep(pMnode, "mnode-subscribe", mndInitSubscribe, mndCleanupSubscribe) != 0) return -1;
|
if (mndAllocStep(pMnode, "mnode-subscribe", mndInitSubscribe, mndCleanupSubscribe) != 0) return -1;
|
||||||
|
|
|
@ -31,3 +31,15 @@ int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sndDestroy(const char *path) {}
|
void sndDestroy(const char *path) {}
|
||||||
|
|
||||||
|
int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) {
|
||||||
|
// stream deployment
|
||||||
|
// stream stop/resume
|
||||||
|
// operator exec
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t sndProcessSMsg(SSnode *pSnode, SRpcMsg *pMsg) {
|
||||||
|
// operator exec
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -58,9 +58,10 @@ STbCfg * metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid);
|
||||||
STbCfg * metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid);
|
STbCfg * metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid);
|
||||||
SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, bool isinline);
|
SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, bool isinline);
|
||||||
STSchema * metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver);
|
STSchema * metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver);
|
||||||
STSma * metaGetSmaInfoByName(SMeta *pMeta, const char *indexName);
|
STSma * metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid);
|
||||||
STSmaWrapper * metaGetSmaInfoByUid(SMeta *pMeta, tb_uid_t uid);
|
STSmaWrapper * metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid);
|
||||||
SArray * metaGetSmaTbUids(SMeta *pMeta, bool isDup);
|
SArray * metaGetSmaTbUids(SMeta *pMeta, bool isDup);
|
||||||
|
int metaGetTbNum(SMeta *pMeta);
|
||||||
|
|
||||||
SMTbCursor *metaOpenTbCursor(SMeta *pMeta);
|
SMTbCursor *metaOpenTbCursor(SMeta *pMeta);
|
||||||
void metaCloseTbCursor(SMTbCursor *pTbCur);
|
void metaCloseTbCursor(SMTbCursor *pTbCur);
|
||||||
|
|
|
@ -91,21 +91,25 @@ int tsdbCommit(STsdb *pTsdb);
|
||||||
* @brief Insert tSma(Time-range-wise SMA) data from stream computing engine
|
* @brief Insert tSma(Time-range-wise SMA) data from stream computing engine
|
||||||
*
|
*
|
||||||
* @param pTsdb
|
* @param pTsdb
|
||||||
* @param param
|
* @param msg
|
||||||
* @param pData
|
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
int32_t tsdbInsertTSmaData(STsdb *pTsdb, STSma *param, STSmaData *pData);
|
int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg);
|
||||||
|
int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, int8_t smaType, char *msg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Insert RSma(Time-range-wise Rollup SMA) data.
|
* @brief Insert RSma(Time-range-wise Rollup SMA) data.
|
||||||
*
|
*
|
||||||
* @param pTsdb
|
* @param pTsdb
|
||||||
* @param param
|
* @param msg
|
||||||
* @param pData
|
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
int32_t tsdbInsertRSmaData(STsdb *pTsdb, SRSma *param, STSmaData *pData);
|
int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg);
|
||||||
|
|
||||||
|
// TODO: This is the basic params, and should wrap the params to a queryHandle.
|
||||||
|
int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval,
|
||||||
|
int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySkey,
|
||||||
|
int32_t nMaxResult);
|
||||||
|
|
||||||
|
|
||||||
// STsdbCfg
|
// STsdbCfg
|
||||||
|
|
|
@ -193,7 +193,7 @@ void vnodeOptionsInit(SVnodeCfg *pOptions);
|
||||||
*/
|
*/
|
||||||
void vnodeOptionsClear(SVnodeCfg *pOptions);
|
void vnodeOptionsClear(SVnodeCfg *pOptions);
|
||||||
|
|
||||||
int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableName);
|
int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName);
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------ FOR COMPILE ------------------------ */
|
/* ------------------------ FOR COMPILE ------------------------ */
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_TSDB_DB_DEF_H_
|
||||||
|
#define _TD_TSDB_DB_DEF_H_
|
||||||
|
|
||||||
|
#include "db.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct SDBFile SDBFile;
|
||||||
|
typedef DB_ENV* TDBEnv;
|
||||||
|
|
||||||
|
struct SDBFile {
|
||||||
|
DB* pDB;
|
||||||
|
char* path;
|
||||||
|
};
|
||||||
|
|
||||||
|
int32_t tsdbOpenDBF(TDBEnv pEnv, SDBFile* pDBF);
|
||||||
|
void tsdbCloseDBF(SDBFile* pDBF);
|
||||||
|
int32_t tsdbOpenBDBEnv(DB_ENV** ppEnv, const char* path);
|
||||||
|
void tsdbCloseBDBEnv(DB_ENV* pEnv);
|
||||||
|
int32_t tsdbSaveSmaToDB(SDBFile* pDBF, void* key, uint32_t keySize, void* data, uint32_t dataSize);
|
||||||
|
void* tsdbGetSmaDataByKey(SDBFile* pDBF, void* key, uint32_t keySize, uint32_t* valueSize);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_TD_TSDB_DB_DEF_H_*/
|
|
@ -27,6 +27,7 @@
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
#include "tsdbDBDef.h"
|
||||||
#include "tsdbCommit.h"
|
#include "tsdbCommit.h"
|
||||||
#include "tsdbFS.h"
|
#include "tsdbFS.h"
|
||||||
#include "tsdbFile.h"
|
#include "tsdbFile.h"
|
||||||
|
@ -37,12 +38,15 @@
|
||||||
#include "tsdbReadImpl.h"
|
#include "tsdbReadImpl.h"
|
||||||
#include "tsdbSma.h"
|
#include "tsdbSma.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct STsdb {
|
struct STsdb {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
|
bool repoLocked;
|
||||||
|
pthread_mutex_t mutex;
|
||||||
char * path;
|
char * path;
|
||||||
STsdbCfg config;
|
STsdbCfg config;
|
||||||
STsdbMemTable * mem;
|
STsdbMemTable * mem;
|
||||||
|
@ -52,12 +56,17 @@ struct STsdb {
|
||||||
STsdbFS * fs;
|
STsdbFS * fs;
|
||||||
SMeta * pMeta;
|
SMeta * pMeta;
|
||||||
STfs * pTfs;
|
STfs * pTfs;
|
||||||
SSmaStat * pSmaStat;
|
SSmaEnv * pTSmaEnv;
|
||||||
|
SSmaEnv * pRSmaEnv;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define REPO_ID(r) ((r)->vgId)
|
#define REPO_ID(r) ((r)->vgId)
|
||||||
#define REPO_CFG(r) (&(r)->config)
|
#define REPO_CFG(r) (&(r)->config)
|
||||||
#define REPO_FS(r) (r)->fs
|
#define REPO_FS(r) (r)->fs
|
||||||
|
#define IS_REPO_LOCKED(r) (r)->repoLocked
|
||||||
|
|
||||||
|
int tsdbLockRepo(STsdb *pTsdb);
|
||||||
|
int tsdbUnlockRepo(STsdb *pTsdb);
|
||||||
|
|
||||||
static FORCE_INLINE STSchema *tsdbGetTableSchemaImpl(STable *pTable, bool lock, bool copy, int32_t version) {
|
static FORCE_INLINE STSchema *tsdbGetTableSchemaImpl(STable *pTable, bool lock, bool copy, int32_t version) {
|
||||||
return pTable->pSchema;
|
return pTable->pSchema;
|
||||||
|
|
|
@ -42,17 +42,14 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
STsdbFSMeta meta; // FS meta
|
STsdbFSMeta meta; // FS meta
|
||||||
SArray * df; // data file array
|
SArray * df; // data file array
|
||||||
|
SArray * sf; // sma data file array v2(t|r)1900.index_name_1
|
||||||
// SArray * v2t100.index_name
|
|
||||||
|
|
||||||
SArray * smaf; // sma data file array v2t1900.index_name
|
|
||||||
} SFSStatus;
|
} SFSStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Directory structure of .tsma data files.
|
* @brief Directory structure of .tsma data files.
|
||||||
*
|
*
|
||||||
* root@cary /vnode2/tsdb $ tree .tsma/
|
* /vnode2/tsdb $ tree .sma/
|
||||||
* .tsma/
|
* .sma/
|
||||||
* ├── v2t100.index_name_1
|
* ├── v2t100.index_name_1
|
||||||
* ├── v2t101.index_name_1
|
* ├── v2t101.index_name_1
|
||||||
* ├── v2t102.index_name_1
|
* ├── v2t102.index_name_1
|
||||||
|
|
|
@ -335,6 +335,19 @@ typedef struct {
|
||||||
SDFile files[TSDB_FILE_MAX];
|
SDFile files[TSDB_FILE_MAX];
|
||||||
} SDFileSet;
|
} SDFileSet;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int fid;
|
||||||
|
int8_t state;
|
||||||
|
uint8_t ver;
|
||||||
|
uint16_t reserve;
|
||||||
|
#if 0
|
||||||
|
SDFInfo info;
|
||||||
|
#endif
|
||||||
|
STfsFile f;
|
||||||
|
TdFilePtr pFile;
|
||||||
|
|
||||||
|
} SSFile; // files split by days with fid
|
||||||
|
|
||||||
#define TSDB_LATEST_FSET_VER 0
|
#define TSDB_LATEST_FSET_VER 0
|
||||||
|
|
||||||
#define TSDB_FSET_FID(s) ((s)->fid)
|
#define TSDB_FSET_FID(s) ((s)->fid)
|
||||||
|
|
|
@ -17,31 +17,62 @@
|
||||||
#define _TD_TSDB_SMA_H_
|
#define _TD_TSDB_SMA_H_
|
||||||
|
|
||||||
typedef struct SSmaStat SSmaStat;
|
typedef struct SSmaStat SSmaStat;
|
||||||
|
typedef struct SSmaEnv SSmaEnv;
|
||||||
|
|
||||||
// insert/update interface
|
struct SSmaEnv {
|
||||||
int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, STSma *param, STSmaData *pData);
|
pthread_rwlock_t lock;
|
||||||
int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, SRSma *param, STSmaData *pData);
|
TDBEnv dbEnv;
|
||||||
|
char * path;
|
||||||
|
SSmaStat * pStat;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SMA_ENV_LOCK(env) ((env)->lock)
|
||||||
|
#define SMA_ENV_ENV(env) ((env)->dbEnv)
|
||||||
|
#define SMA_ENV_PATH(env) ((env)->path)
|
||||||
|
#define SMA_ENV_STAT(env) ((env)->pStat)
|
||||||
|
#define SMA_ENV_STAT_ITEMS(env) ((env)->pStat->smaStatItems)
|
||||||
|
|
||||||
// query interface
|
void tsdbDestroySmaEnv(SSmaEnv *pSmaEnv);
|
||||||
// TODO: This is the basic params, and should wrap the params to a queryHandle.
|
void *tsdbFreeSmaEnv(SSmaEnv *pSmaEnv);
|
||||||
int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSma *param, STSmaData *pData, STimeWindow *queryWin, int32_t nMaxResult);
|
#if 0
|
||||||
|
|
||||||
// management interface
|
|
||||||
int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, char *msg);
|
|
||||||
int32_t tsdbGetTSmaStatus(STsdb *pTsdb, STSma *param, void *result);
|
int32_t tsdbGetTSmaStatus(STsdb *pTsdb, STSma *param, void *result);
|
||||||
int32_t tsdbRemoveTSmaData(STsdb *pTsdb, STSma *param, STimeWindow *pWin);
|
int32_t tsdbRemoveTSmaData(STsdb *pTsdb, STSma *param, STimeWindow *pWin);
|
||||||
int32_t tsdbDestroySmaState(SSmaStat *pSmaStat);
|
#endif
|
||||||
|
|
||||||
// internal func
|
// internal func
|
||||||
|
static FORCE_INLINE int32_t tsdbEncodeTSmaKey(tb_uid_t tableUid, col_id_t colId, TSKEY tsKey, void **pData) {
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tsdbEncodeTSmaKey(uint64_t tableUid, col_id_t colId, TSKEY tsKey, void **pData) {
|
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
len += taosEncodeFixedU64(pData, tableUid);
|
len += taosEncodeFixedI64(pData, tableUid);
|
||||||
len += taosEncodeFixedU16(pData, colId);
|
len += taosEncodeFixedU16(pData, colId);
|
||||||
len += taosEncodeFixedI64(pData, tsKey);
|
len += taosEncodeFixedI64(pData, tsKey);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int tsdbRLockSma(SSmaEnv *pEnv) {
|
||||||
|
int code = pthread_rwlock_rdlock(&(pEnv->lock));
|
||||||
|
if (code != 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(code);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int tsdbWLockSma(SSmaEnv *pEnv) {
|
||||||
|
int code = pthread_rwlock_wrlock(&(pEnv->lock));
|
||||||
|
if (code != 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(code);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int tsdbUnLockSma(SSmaEnv *pEnv) {
|
||||||
|
int code = pthread_rwlock_unlock(&(pEnv->lock));
|
||||||
|
if (code != 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(code);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _TD_TSDB_SMA_H_ */
|
#endif /* _TD_TSDB_SMA_H_ */
|
|
@ -227,28 +227,35 @@ int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) {
|
int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) {
|
||||||
char buf[512] = {0}; // TODO: may overflow
|
// char buf[512] = {0}; // TODO: may overflow
|
||||||
void *pBuf = NULL;
|
void *pBuf = NULL, *qBuf = NULL;
|
||||||
DBT key1 = {0}, value1 = {0};
|
DBT key1 = {0}, value1 = {0};
|
||||||
|
|
||||||
{
|
|
||||||
// save sma info
|
// save sma info
|
||||||
pBuf = buf;
|
int32_t len = tEncodeTSma(NULL, pSmaCfg);
|
||||||
|
pBuf = calloc(len, 1);
|
||||||
key1.data = pSmaCfg->indexName;
|
if (pBuf == NULL) {
|
||||||
key1.size = strlen(key1.data);
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
tEncodeTSma(&pBuf, pSmaCfg);
|
|
||||||
|
|
||||||
value1.data = buf;
|
|
||||||
value1.size = POINTER_DISTANCE(pBuf, buf);
|
|
||||||
value1.app_data = pSmaCfg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
key1.data = (void *)&pSmaCfg->indexUid;
|
||||||
|
key1.size = sizeof(pSmaCfg->indexUid);
|
||||||
|
|
||||||
|
qBuf = pBuf;
|
||||||
|
tEncodeTSma(&qBuf, pSmaCfg);
|
||||||
|
|
||||||
|
value1.data = pBuf;
|
||||||
|
value1.size = POINTER_DISTANCE(qBuf, pBuf);
|
||||||
|
value1.app_data = pSmaCfg;
|
||||||
|
|
||||||
metaDBWLock(pMeta->pDB);
|
metaDBWLock(pMeta->pDB);
|
||||||
pMeta->pDB->pSmaDB->put(pMeta->pDB->pSmaDB, NULL, &key1, &value1, 0);
|
pMeta->pDB->pSmaDB->put(pMeta->pDB->pSmaDB, NULL, &key1, &value1, 0);
|
||||||
metaDBULock(pMeta->pDB);
|
metaDBULock(pMeta->pDB);
|
||||||
|
|
||||||
|
// release
|
||||||
|
tfree(pBuf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,7 +616,7 @@ STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid) {
|
||||||
return pTbCfg;
|
return pTbCfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
STSma *metaGetSmaInfoByName(SMeta *pMeta, const char *indexName) {
|
STSma *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid) {
|
||||||
STSma * pCfg = NULL;
|
STSma * pCfg = NULL;
|
||||||
SMetaDB *pDB = pMeta->pDB;
|
SMetaDB *pDB = pMeta->pDB;
|
||||||
DBT key = {0};
|
DBT key = {0};
|
||||||
|
@ -617,8 +624,8 @@ STSma *metaGetSmaInfoByName(SMeta *pMeta, const char *indexName) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
// Set key/value
|
// Set key/value
|
||||||
key.data = (void *)indexName;
|
key.data = (void *)&indexUid;
|
||||||
key.size = strlen(indexName);
|
key.size = sizeof(indexUid);
|
||||||
|
|
||||||
// Query
|
// Query
|
||||||
metaDBRLock(pDB);
|
metaDBRLock(pDB);
|
||||||
|
@ -634,7 +641,10 @@ STSma *metaGetSmaInfoByName(SMeta *pMeta, const char *indexName) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tDecodeTSma(value.data, pCfg);
|
if (tDecodeTSma(value.data, pCfg) == NULL) {
|
||||||
|
tfree(pCfg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return pCfg;
|
return pCfg;
|
||||||
}
|
}
|
||||||
|
@ -695,6 +705,18 @@ SMTbCursor *metaOpenTbCursor(SMeta *pMeta) {
|
||||||
return pTbCur;
|
return pTbCur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int metaGetTbNum(SMeta *pMeta) {
|
||||||
|
SMetaDB *pDB = pMeta->pDB;
|
||||||
|
|
||||||
|
DB_BTREE_STAT *sp1;
|
||||||
|
pDB->pTbDB->stat(pDB->pNtbIdx, NULL, &sp1, 0);
|
||||||
|
|
||||||
|
DB_BTREE_STAT *sp2;
|
||||||
|
pDB->pTbDB->stat(pDB->pCtbIdx, NULL, &sp2, 0);
|
||||||
|
|
||||||
|
return sp1->bt_nkeys + sp2->bt_nkeys;
|
||||||
|
}
|
||||||
|
|
||||||
void metaCloseTbCursor(SMTbCursor *pTbCur) {
|
void metaCloseTbCursor(SMTbCursor *pTbCur) {
|
||||||
if (pTbCur) {
|
if (pTbCur) {
|
||||||
if (pTbCur->pCur) {
|
if (pTbCur->pCur) {
|
||||||
|
@ -871,7 +893,7 @@ const char *metaSmaCursorNext(SMSmaCursor *pCur) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STSmaWrapper *metaGetSmaInfoByUid(SMeta *pMeta, tb_uid_t uid) {
|
STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
|
||||||
STSmaWrapper *pSW = NULL;
|
STSmaWrapper *pSW = NULL;
|
||||||
|
|
||||||
pSW = calloc(sizeof(*pSW), 1);
|
pSW = calloc(sizeof(*pSW), 1);
|
||||||
|
|
|
@ -83,8 +83,8 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tqRetrieveDataBlockInfo(STqReadHandle* pHandle, SDataBlockInfo* pBlockInfo) {
|
int tqRetrieveDataBlockInfo(STqReadHandle* pHandle, SDataBlockInfo* pBlockInfo) {
|
||||||
/*int32_t sversion = pHandle->pBlock->sversion;*/
|
// currently only rows are used
|
||||||
/*SSchemaWrapper* pSchema = metaGetTableSchema(pHandle->pMeta, pHandle->pBlock->uid, sversion, false);*/
|
|
||||||
pBlockInfo->numOfCols = taosArrayGetSize(pHandle->pColIdList);
|
pBlockInfo->numOfCols = taosArrayGetSize(pHandle->pColIdList);
|
||||||
pBlockInfo->rows = pHandle->pBlock->numOfRows;
|
pBlockInfo->rows = pHandle->pBlock->numOfRows;
|
||||||
pBlockInfo->uid = pHandle->pBlock->uid;
|
pBlockInfo->uid = pHandle->pBlock->uid;
|
||||||
|
|
|
@ -12,3 +12,162 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define ALLOW_FORBID_FUNC
|
||||||
|
#include "db.h"
|
||||||
|
|
||||||
|
#include "taoserror.h"
|
||||||
|
#include "tcoding.h"
|
||||||
|
#include "thash.h"
|
||||||
|
#include "tsdbDBDef.h"
|
||||||
|
#include "tsdbLog.h"
|
||||||
|
|
||||||
|
#define IMPL_WITH_LOCK 1
|
||||||
|
|
||||||
|
static int tsdbOpenBDBDb(DB **ppDB, DB_ENV *pEnv, const char *pFName, bool isDup);
|
||||||
|
static void tsdbCloseBDBDb(DB *pDB);
|
||||||
|
|
||||||
|
#define BDB_PERR(info, code) fprintf(stderr, "%s:%d " info " reason: %s\n", __FILE__, __LINE__, db_strerror(code))
|
||||||
|
|
||||||
|
int32_t tsdbOpenDBF(TDBEnv pEnv, SDBFile *pDBF) {
|
||||||
|
// TDBEnv is shared by a group of SDBFile
|
||||||
|
if (!pEnv) {
|
||||||
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open DBF
|
||||||
|
if (tsdbOpenBDBDb(&(pDBF->pDB), pEnv, pDBF->path, false) < 0) {
|
||||||
|
terrno = TSDB_CODE_TDB_INIT_FAILED;
|
||||||
|
tsdbCloseBDBDb(pDBF->pDB);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tsdbCloseDBF(SDBFile *pDBF) {
|
||||||
|
if (pDBF->pDB) {
|
||||||
|
tsdbCloseBDBDb(pDBF->pDB);
|
||||||
|
pDBF->pDB = NULL;
|
||||||
|
}
|
||||||
|
tfree(pDBF->path);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tsdbOpenBDBEnv(DB_ENV **ppEnv, const char *path) {
|
||||||
|
int ret = 0;
|
||||||
|
DB_ENV *pEnv = NULL;
|
||||||
|
|
||||||
|
if (path == NULL) return 0;
|
||||||
|
|
||||||
|
ret = db_env_create(&pEnv, 0);
|
||||||
|
if (ret != 0) {
|
||||||
|
BDB_PERR("Failed to create tsdb env", ret);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = pEnv->open(pEnv, path, DB_CREATE | DB_INIT_CDB | DB_INIT_MPOOL, 0);
|
||||||
|
if (ret != 0) {
|
||||||
|
// BDB_PERR("Failed to open tsdb env", ret);
|
||||||
|
tsdbWarn("Failed to open tsdb env for path %s since %d", path ? path : "NULL", ret);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppEnv = pEnv;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tsdbCloseBDBEnv(DB_ENV *pEnv) {
|
||||||
|
if (pEnv) {
|
||||||
|
pEnv->close(pEnv, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tsdbOpenBDBDb(DB **ppDB, DB_ENV *pEnv, const char *pFName, bool isDup) {
|
||||||
|
int ret;
|
||||||
|
DB *pDB;
|
||||||
|
|
||||||
|
ret = db_create(&(pDB), pEnv, 0);
|
||||||
|
if (ret != 0) {
|
||||||
|
BDB_PERR("Failed to create DBP", ret);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDup) {
|
||||||
|
ret = pDB->set_flags(pDB, DB_DUPSORT);
|
||||||
|
if (ret != 0) {
|
||||||
|
BDB_PERR("Failed to set DB flags", ret);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = pDB->open(pDB, NULL, pFName, NULL, DB_BTREE, DB_CREATE, 0);
|
||||||
|
if (ret) {
|
||||||
|
BDB_PERR("Failed to open DBF", ret);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppDB = pDB;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tsdbCloseBDBDb(DB *pDB) {
|
||||||
|
if (pDB) {
|
||||||
|
pDB->close(pDB, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tsdbSaveSmaToDB(SDBFile *pDBF, void *key, uint32_t keySize, void *data, uint32_t dataSize) {
|
||||||
|
int ret;
|
||||||
|
DBT key1 = {0}, value1 = {0};
|
||||||
|
|
||||||
|
key1.data = key;
|
||||||
|
key1.size = keySize;
|
||||||
|
|
||||||
|
value1.data = data;
|
||||||
|
value1.size = dataSize;
|
||||||
|
|
||||||
|
// TODO: lock
|
||||||
|
ret = pDBF->pDB->put(pDBF->pDB, NULL, &key1, &value1, 0);
|
||||||
|
if (ret) {
|
||||||
|
BDB_PERR("Failed to put data to DBF", ret);
|
||||||
|
// TODO: unlock
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
// TODO: unlock
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *tsdbGetSmaDataByKey(SDBFile *pDBF, void* key, uint32_t keySize, uint32_t *valueSize) {
|
||||||
|
void *result = NULL;
|
||||||
|
DBT key1 = {0};
|
||||||
|
DBT value1 = {0};
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
// Set key/value
|
||||||
|
key1.data = key;
|
||||||
|
key1.size = keySize;
|
||||||
|
|
||||||
|
// Query
|
||||||
|
// TODO: lock
|
||||||
|
ret = pDBF->pDB->get(pDBF->pDB, NULL, &key1, &value1, 0);
|
||||||
|
// TODO: unlock
|
||||||
|
if (ret != 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = calloc(1, value1.size);
|
||||||
|
|
||||||
|
if (result == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*valueSize = value1.size;
|
||||||
|
memcpy(result, value1.data, value1.size);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -80,6 +80,8 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg,
|
||||||
pTsdb->pmaf = pMAF;
|
pTsdb->pmaf = pMAF;
|
||||||
pTsdb->pMeta = pMeta;
|
pTsdb->pMeta = pMeta;
|
||||||
pTsdb->pTfs = pTfs;
|
pTsdb->pTfs = pTfs;
|
||||||
|
pTsdb->pTSmaEnv = NULL;
|
||||||
|
pTsdb->pRSmaEnv = NULL;
|
||||||
|
|
||||||
pTsdb->fs = tsdbNewFS(pTsdbCfg);
|
pTsdb->fs = tsdbNewFS(pTsdbCfg);
|
||||||
|
|
||||||
|
@ -88,8 +90,9 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg,
|
||||||
|
|
||||||
static void tsdbFree(STsdb *pTsdb) {
|
static void tsdbFree(STsdb *pTsdb) {
|
||||||
if (pTsdb) {
|
if (pTsdb) {
|
||||||
|
tsdbFreeSmaEnv(pTsdb->pRSmaEnv);
|
||||||
|
tsdbFreeSmaEnv(pTsdb->pTSmaEnv);
|
||||||
tsdbFreeFS(pTsdb->fs);
|
tsdbFreeFS(pTsdb->fs);
|
||||||
tsdbDestroySmaState(pTsdb->pSmaStat);
|
|
||||||
tfree(pTsdb->path);
|
tfree(pTsdb->path);
|
||||||
free(pTsdb);
|
free(pTsdb);
|
||||||
}
|
}
|
||||||
|
@ -105,6 +108,30 @@ static void tsdbCloseImpl(STsdb *pTsdb) {
|
||||||
tsdbCloseFS(pTsdb);
|
tsdbCloseFS(pTsdb);
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tsdbLockRepo(STsdb *pTsdb) {
|
||||||
|
int code = pthread_mutex_lock(&pTsdb->mutex);
|
||||||
|
if (code != 0) {
|
||||||
|
tsdbError("vgId:%d failed to lock tsdb since %s", REPO_ID(pTsdb), strerror(errno));
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(code);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pTsdb->repoLocked = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tsdbUnlockRepo(STsdb *pTsdb) {
|
||||||
|
ASSERT(IS_REPO_LOCKED(pTsdb));
|
||||||
|
pTsdb->repoLocked = false;
|
||||||
|
int code = pthread_mutex_unlock(&pTsdb->mutex);
|
||||||
|
if (code != 0) {
|
||||||
|
tsdbError("vgId:%d failed to unlock tsdb since %s", REPO_ID(pTsdb), strerror(errno));
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(code);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,35 +34,46 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
|
||||||
return tsdbMemTableInsert(pTsdb, pTsdb->mem, pMsg, NULL);
|
return tsdbMemTableInsert(pTsdb, pTsdb->mem, pMsg, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/**
|
/**
|
||||||
* @brief Insert/Update tSma(Time-range-wise SMA) data from stream computing engine
|
* @brief Insert/Update tSma(Time-range-wise SMA) data from stream computing engine
|
||||||
*
|
*
|
||||||
* @param pTsdb
|
* @param pTsdb
|
||||||
* @param param
|
* @param param
|
||||||
* @param pData
|
* @param msg
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
* TODO: Who is responsible for resource allocate and release?
|
* TODO: Who is responsible for resource allocate and release?
|
||||||
*/
|
*/
|
||||||
int32_t tsdbInsertTSmaData(STsdb *pTsdb, STSma *param, STSmaData *pData) {
|
int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if ((code = tsdbInsertTSmaDataImpl(pTsdb, param, pData)) < 0) {
|
if ((code = tsdbInsertTSmaDataImpl(pTsdb, msg)) < 0) {
|
||||||
tsdbWarn("vgId:%d insert tSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
tsdbWarn("vgId:%d insert tSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, int8_t smaType, char *msg) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
if ((code = tsdbUpdateExpiredWindow(pTsdb, smaType, msg)) < 0) {
|
||||||
|
tsdbWarn("vgId:%d update expired sma window failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Insert Time-range-wise Rollup Sma(RSma) data
|
* @brief Insert Time-range-wise Rollup Sma(RSma) data
|
||||||
*
|
*
|
||||||
* @param pTsdb
|
* @param pTsdb
|
||||||
* @param param
|
* @param param
|
||||||
* @param pData
|
* @param msg
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
int32_t tsdbInsertRSmaData(STsdb *pTsdb, SRSma *param, STSmaData *pData) {
|
int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if ((code = tsdbInsertRSmaDataImpl(pTsdb, param, pData)) < 0) {
|
if ((code = tsdbInsertRSmaDataImpl(pTsdb, msg)) < 0) {
|
||||||
tsdbWarn("vgId:%d insert rSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
tsdbWarn("vgId:%d insert rSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -34,19 +34,22 @@ void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc) {
|
||||||
memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeCfg));
|
memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeCfg));
|
||||||
}
|
}
|
||||||
|
|
||||||
int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableName) {
|
int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) {
|
||||||
uint32_t hashValue = 0;
|
uint32_t hashValue = 0;
|
||||||
|
|
||||||
switch (pVnodeOptions->hashMethod) {
|
switch (pVnodeOptions->hashMethod) {
|
||||||
default:
|
default:
|
||||||
hashValue = MurmurHash3_32(tableName, strlen(tableName));
|
hashValue = MurmurHash3_32(tableFName, strlen(tableFName));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO OPEN THIS !!!!!!!
|
||||||
|
#if 0
|
||||||
if (hashValue < pVnodeOptions->hashBegin || hashValue > pVnodeOptions->hashEnd) {
|
if (hashValue < pVnodeOptions->hashBegin || hashValue > pVnodeOptions->hashEnd) {
|
||||||
terrno = TSDB_CODE_VND_HASH_MISMATCH;
|
terrno = TSDB_CODE_VND_HASH_MISMATCH;
|
||||||
return TSDB_CODE_VND_HASH_MISMATCH;
|
return TSDB_CODE_VND_HASH_MISMATCH;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ int32_t vnodeSync(SVnode *pVnode) { return 0; }
|
||||||
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
||||||
pLoad->vgId = pVnode->vgId;
|
pLoad->vgId = pVnode->vgId;
|
||||||
pLoad->role = TAOS_SYNC_STATE_LEADER;
|
pLoad->role = TAOS_SYNC_STATE_LEADER;
|
||||||
pLoad->numOfTables = 500;
|
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
|
||||||
pLoad->numOfTimeSeries = 400;
|
pLoad->numOfTimeSeries = 400;
|
||||||
pLoad->totalStorage = 300;
|
pLoad->totalStorage = 300;
|
||||||
pLoad->compStorage = 200;
|
pLoad->compStorage = 200;
|
||||||
|
|
|
@ -77,10 +77,24 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
}
|
}
|
||||||
case TDMT_VND_CREATE_TABLE: {
|
case TDMT_VND_CREATE_TABLE: {
|
||||||
SVCreateTbBatchReq vCreateTbBatchReq = {0};
|
SVCreateTbBatchReq vCreateTbBatchReq = {0};
|
||||||
|
SVCreateTbBatchRsp vCreateTbBatchRsp = {0};
|
||||||
tDeserializeSVCreateTbBatchReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateTbBatchReq);
|
tDeserializeSVCreateTbBatchReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateTbBatchReq);
|
||||||
for (int i = 0; i < taosArrayGetSize(vCreateTbBatchReq.pArray); i++) {
|
int reqNum = taosArrayGetSize(vCreateTbBatchReq.pArray);
|
||||||
|
for (int i = 0; i < reqNum; i++) {
|
||||||
SVCreateTbReq *pCreateTbReq = taosArrayGet(vCreateTbBatchReq.pArray, i);
|
SVCreateTbReq *pCreateTbReq = taosArrayGet(vCreateTbBatchReq.pArray, i);
|
||||||
|
|
||||||
|
char tableFName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
SMsgHead *pHead = (SMsgHead *)pMsg->pCont;
|
||||||
|
sprintf(tableFName, "%s.%s", pCreateTbReq->dbFName, pCreateTbReq->name);
|
||||||
|
|
||||||
|
int32_t code = vnodeValidateTableHash(&pVnode->config, tableFName);
|
||||||
|
if (code) {
|
||||||
|
SVCreateTbRsp rsp;
|
||||||
|
rsp.code = code;
|
||||||
|
|
||||||
|
taosArrayPush(vCreateTbBatchRsp.rspList, &rsp);
|
||||||
|
}
|
||||||
|
|
||||||
if (metaCreateTable(pVnode->pMeta, pCreateTbReq) < 0) {
|
if (metaCreateTable(pVnode->pMeta, pCreateTbReq) < 0) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
vError("vgId:%d, failed to create table: %s", pVnode->vgId, pCreateTbReq->name);
|
vError("vgId:%d, failed to create table: %s", pVnode->vgId, pCreateTbReq->name);
|
||||||
|
@ -98,6 +112,19 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
|
|
||||||
vTrace("vgId:%d process create %" PRIzu " tables", pVnode->vgId, taosArrayGetSize(vCreateTbBatchReq.pArray));
|
vTrace("vgId:%d process create %" PRIzu " tables", pVnode->vgId, taosArrayGetSize(vCreateTbBatchReq.pArray));
|
||||||
taosArrayDestroy(vCreateTbBatchReq.pArray);
|
taosArrayDestroy(vCreateTbBatchReq.pArray);
|
||||||
|
if (vCreateTbBatchRsp.rspList) {
|
||||||
|
int32_t contLen = tSerializeSVCreateTbBatchRsp(NULL, 0, &vCreateTbBatchRsp);
|
||||||
|
void *msg = rpcMallocCont(contLen);
|
||||||
|
tSerializeSVCreateTbBatchRsp(msg, contLen, &vCreateTbBatchRsp);
|
||||||
|
taosArrayDestroy(vCreateTbBatchRsp.rspList);
|
||||||
|
|
||||||
|
*pRsp = calloc(1, sizeof(SRpcMsg));
|
||||||
|
(*pRsp)->msgType = TDMT_VND_CREATE_TABLE_RSP;
|
||||||
|
(*pRsp)->pCont = msg;
|
||||||
|
(*pRsp)->contLen = contLen;
|
||||||
|
(*pRsp)->handle = pMsg->handle;
|
||||||
|
(*pRsp)->ahandle = pMsg->ahandle;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_ALTER_STB: {
|
case TDMT_VND_ALTER_STB: {
|
||||||
|
|
|
@ -33,7 +33,7 @@ int main(int argc, char **argv) {
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, tSmaEncodeDecodeTest) {
|
TEST(testCase, tSma_Meta_Encode_Decode_Test) {
|
||||||
// encode
|
// encode
|
||||||
STSma tSma = {0};
|
STSma tSma = {0};
|
||||||
tSma.version = 0;
|
tSma.version = 0;
|
||||||
|
@ -43,20 +43,8 @@ TEST(testCase, tSmaEncodeDecodeTest) {
|
||||||
tSma.sliding = 0;
|
tSma.sliding = 0;
|
||||||
tstrncpy(tSma.indexName, "sma_index_test", TSDB_INDEX_NAME_LEN);
|
tstrncpy(tSma.indexName, "sma_index_test", TSDB_INDEX_NAME_LEN);
|
||||||
tstrncpy(tSma.timezone, "Asia/Shanghai", TD_TIMEZONE_LEN);
|
tstrncpy(tSma.timezone, "Asia/Shanghai", TD_TIMEZONE_LEN);
|
||||||
|
tSma.indexUid = 2345678910;
|
||||||
tSma.tableUid = 1234567890;
|
tSma.tableUid = 1234567890;
|
||||||
tSma.nFuncColIds = 5;
|
|
||||||
tSma.funcColIds = (SFuncColIds *)calloc(tSma.nFuncColIds, sizeof(SFuncColIds));
|
|
||||||
ASSERT(tSma.funcColIds != NULL);
|
|
||||||
for (int32_t n = 0; n < tSma.nFuncColIds; ++n) {
|
|
||||||
SFuncColIds *funcColIds = tSma.funcColIds + n;
|
|
||||||
funcColIds->funcId = n;
|
|
||||||
funcColIds->nColIds = 10;
|
|
||||||
funcColIds->colIds = (col_id_t *)calloc(funcColIds->nColIds, sizeof(col_id_t));
|
|
||||||
ASSERT(funcColIds->colIds != NULL);
|
|
||||||
for (int32_t i = 0; i < funcColIds->nColIds; ++i) {
|
|
||||||
*(funcColIds->colIds + i) = (i + PRIMARYKEY_TIMESTAMP_COL_ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
STSmaWrapper tSmaWrapper = {.number = 1, .tSma = &tSma};
|
STSmaWrapper tSmaWrapper = {.number = 1, .tSma = &tSma};
|
||||||
uint32_t bufLen = tEncodeTSmaWrapper(NULL, &tSmaWrapper);
|
uint32_t bufLen = tEncodeTSmaWrapper(NULL, &tSmaWrapper);
|
||||||
|
@ -85,21 +73,14 @@ TEST(testCase, tSmaEncodeDecodeTest) {
|
||||||
EXPECT_EQ(pSma->slidingUnit, qSma->slidingUnit);
|
EXPECT_EQ(pSma->slidingUnit, qSma->slidingUnit);
|
||||||
EXPECT_STRCASEEQ(pSma->indexName, qSma->indexName);
|
EXPECT_STRCASEEQ(pSma->indexName, qSma->indexName);
|
||||||
EXPECT_STRCASEEQ(pSma->timezone, qSma->timezone);
|
EXPECT_STRCASEEQ(pSma->timezone, qSma->timezone);
|
||||||
EXPECT_EQ(pSma->nFuncColIds, qSma->nFuncColIds);
|
EXPECT_EQ(pSma->indexUid, qSma->indexUid);
|
||||||
EXPECT_EQ(pSma->tableUid, qSma->tableUid);
|
EXPECT_EQ(pSma->tableUid, qSma->tableUid);
|
||||||
EXPECT_EQ(pSma->interval, qSma->interval);
|
EXPECT_EQ(pSma->interval, qSma->interval);
|
||||||
EXPECT_EQ(pSma->sliding, qSma->sliding);
|
EXPECT_EQ(pSma->sliding, qSma->sliding);
|
||||||
|
EXPECT_EQ(pSma->exprLen, qSma->exprLen);
|
||||||
|
EXPECT_STRCASEEQ(pSma->expr, qSma->expr);
|
||||||
EXPECT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen);
|
EXPECT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen);
|
||||||
EXPECT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter);
|
EXPECT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter);
|
||||||
for (uint32_t j = 0; j < pSma->nFuncColIds; ++j) {
|
|
||||||
SFuncColIds *pFuncColIds = pSma->funcColIds + j;
|
|
||||||
SFuncColIds *qFuncColIds = qSma->funcColIds + j;
|
|
||||||
EXPECT_EQ(pFuncColIds->funcId, qFuncColIds->funcId);
|
|
||||||
EXPECT_EQ(pFuncColIds->nColIds, qFuncColIds->nColIds);
|
|
||||||
for (uint32_t k = 0; k < pFuncColIds->nColIds; ++k) {
|
|
||||||
EXPECT_EQ(*(pFuncColIds->colIds + k), *(qFuncColIds->colIds + k));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// resource release
|
// resource release
|
||||||
|
@ -107,13 +88,17 @@ TEST(testCase, tSmaEncodeDecodeTest) {
|
||||||
tdDestroyTSmaWrapper(&dstTSmaWrapper);
|
tdDestroyTSmaWrapper(&dstTSmaWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, tSma_DB_Put_Get_Del_Test) {
|
#if 1
|
||||||
|
TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
||||||
const char * smaIndexName1 = "sma_index_test_1";
|
const char * smaIndexName1 = "sma_index_test_1";
|
||||||
const char * smaIndexName2 = "sma_index_test_2";
|
const char * smaIndexName2 = "sma_index_test_2";
|
||||||
const char * timeZone = "Asia/Shanghai";
|
const char * timezone = "Asia/Shanghai";
|
||||||
|
const char * expr = "select count(a,b, top 20), from table interval 1d, sliding 1h;";
|
||||||
const char * tagsFilter = "I'm tags filter";
|
const char * tagsFilter = "I'm tags filter";
|
||||||
const char * smaTestDir = "./smaTest";
|
const char * smaTestDir = "./smaTest";
|
||||||
const uint64_t tbUid = 1234567890;
|
const tb_uid_t tbUid = 1234567890;
|
||||||
|
const int64_t indexUid1 = 2000000001;
|
||||||
|
const int64_t indexUid2 = 2000000002;
|
||||||
const uint32_t nCntTSma = 2;
|
const uint32_t nCntTSma = 2;
|
||||||
// encode
|
// encode
|
||||||
STSma tSma = {0};
|
STSma tSma = {0};
|
||||||
|
@ -122,22 +107,15 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) {
|
||||||
tSma.interval = 1;
|
tSma.interval = 1;
|
||||||
tSma.slidingUnit = TD_TIME_UNIT_HOUR;
|
tSma.slidingUnit = TD_TIME_UNIT_HOUR;
|
||||||
tSma.sliding = 0;
|
tSma.sliding = 0;
|
||||||
|
tSma.indexUid = indexUid1;
|
||||||
tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN);
|
tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN);
|
||||||
tstrncpy(tSma.timezone, timeZone, TD_TIMEZONE_LEN);
|
tstrncpy(tSma.timezone, timezone, TD_TIMEZONE_LEN);
|
||||||
tSma.tableUid = tbUid;
|
tSma.tableUid = tbUid;
|
||||||
tSma.nFuncColIds = 5;
|
|
||||||
tSma.funcColIds = (SFuncColIds *)calloc(tSma.nFuncColIds, sizeof(SFuncColIds));
|
tSma.exprLen = strlen(expr);
|
||||||
ASSERT(tSma.funcColIds != NULL);
|
tSma.expr = (char *)calloc(tSma.exprLen + 1, 1);
|
||||||
for (int32_t n = 0; n < tSma.nFuncColIds; ++n) {
|
tstrncpy(tSma.expr, expr, tSma.exprLen + 1);
|
||||||
SFuncColIds *funcColIds = tSma.funcColIds + n;
|
|
||||||
funcColIds->funcId = n;
|
|
||||||
funcColIds->nColIds = 10;
|
|
||||||
funcColIds->colIds = (col_id_t *)calloc(funcColIds->nColIds, sizeof(col_id_t));
|
|
||||||
ASSERT(funcColIds->colIds != NULL);
|
|
||||||
for (int32_t i = 0; i < funcColIds->nColIds; ++i) {
|
|
||||||
*(funcColIds->colIds + i) = (i + PRIMARYKEY_TIMESTAMP_COL_ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tSma.tagsFilterLen = strlen(tagsFilter);
|
tSma.tagsFilterLen = strlen(tagsFilter);
|
||||||
tSma.tagsFilter = (char *)calloc(tSma.tagsFilterLen + 1, 1);
|
tSma.tagsFilter = (char *)calloc(tSma.tagsFilterLen + 1, 1);
|
||||||
tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1);
|
tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1);
|
||||||
|
@ -151,8 +129,9 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) {
|
||||||
pMeta = metaOpen(smaTestDir, pMetaCfg, NULL);
|
pMeta = metaOpen(smaTestDir, pMetaCfg, NULL);
|
||||||
assert(pMeta != NULL);
|
assert(pMeta != NULL);
|
||||||
// save index 1
|
// save index 1
|
||||||
metaSaveSmaToDB(pMeta, pSmaCfg);
|
EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0);
|
||||||
|
|
||||||
|
pSmaCfg->indexUid = indexUid2;
|
||||||
tstrncpy(pSmaCfg->indexName, smaIndexName2, TSDB_INDEX_NAME_LEN);
|
tstrncpy(pSmaCfg->indexName, smaIndexName2, TSDB_INDEX_NAME_LEN);
|
||||||
pSmaCfg->version = 1;
|
pSmaCfg->version = 1;
|
||||||
pSmaCfg->intervalUnit = TD_TIME_UNIT_HOUR;
|
pSmaCfg->intervalUnit = TD_TIME_UNIT_HOUR;
|
||||||
|
@ -161,24 +140,26 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) {
|
||||||
pSmaCfg->sliding = 5;
|
pSmaCfg->sliding = 5;
|
||||||
|
|
||||||
// save index 2
|
// save index 2
|
||||||
metaSaveSmaToDB(pMeta, pSmaCfg);
|
EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0);
|
||||||
|
|
||||||
// get value by indexName
|
// get value by indexName
|
||||||
STSma *qSmaCfg = NULL;
|
STSma *qSmaCfg = NULL;
|
||||||
qSmaCfg = metaGetSmaInfoByName(pMeta, smaIndexName1);
|
qSmaCfg = metaGetSmaInfoByIndex(pMeta, indexUid1);
|
||||||
assert(qSmaCfg != NULL);
|
assert(qSmaCfg != NULL);
|
||||||
printf("name1 = %s\n", qSmaCfg->indexName);
|
printf("name1 = %s\n", qSmaCfg->indexName);
|
||||||
printf("timezone1 = %s\n", qSmaCfg->timezone);
|
printf("timezone1 = %s\n", qSmaCfg->timezone);
|
||||||
|
printf("expr1 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : "");
|
||||||
printf("tagsFilter1 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : "");
|
printf("tagsFilter1 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : "");
|
||||||
EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1);
|
EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1);
|
||||||
EXPECT_EQ(qSmaCfg->tableUid, tSma.tableUid);
|
EXPECT_EQ(qSmaCfg->tableUid, tSma.tableUid);
|
||||||
tdDestroyTSma(qSmaCfg);
|
tdDestroyTSma(qSmaCfg);
|
||||||
tfree(qSmaCfg);
|
tfree(qSmaCfg);
|
||||||
|
|
||||||
qSmaCfg = metaGetSmaInfoByName(pMeta, smaIndexName2);
|
qSmaCfg = metaGetSmaInfoByIndex(pMeta, indexUid2);
|
||||||
assert(qSmaCfg != NULL);
|
assert(qSmaCfg != NULL);
|
||||||
printf("name2 = %s\n", qSmaCfg->indexName);
|
printf("name2 = %s\n", qSmaCfg->indexName);
|
||||||
printf("timezone2 = %s\n", qSmaCfg->timezone);
|
printf("timezone2 = %s\n", qSmaCfg->timezone);
|
||||||
|
printf("expr2 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : "");
|
||||||
printf("tagsFilter2 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : "");
|
printf("tagsFilter2 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : "");
|
||||||
EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2);
|
EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2);
|
||||||
EXPECT_EQ(qSmaCfg->interval, tSma.interval);
|
EXPECT_EQ(qSmaCfg->interval, tSma.interval);
|
||||||
|
@ -201,17 +182,21 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) {
|
||||||
metaCloseSmaCurosr(pSmaCur);
|
metaCloseSmaCurosr(pSmaCur);
|
||||||
|
|
||||||
// get wrapper by table uid
|
// get wrapper by table uid
|
||||||
STSmaWrapper *pSW = metaGetSmaInfoByUid(pMeta, tbUid);
|
STSmaWrapper *pSW = metaGetSmaInfoByTable(pMeta, tbUid);
|
||||||
assert(pSW != NULL);
|
assert(pSW != NULL);
|
||||||
EXPECT_EQ(pSW->number, nCntTSma);
|
EXPECT_EQ(pSW->number, nCntTSma);
|
||||||
EXPECT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1);
|
EXPECT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1);
|
||||||
EXPECT_STRCASEEQ(pSW->tSma->timezone, timeZone);
|
EXPECT_STRCASEEQ(pSW->tSma->timezone, timezone);
|
||||||
|
EXPECT_STRCASEEQ(pSW->tSma->expr, expr);
|
||||||
EXPECT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter);
|
EXPECT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter);
|
||||||
EXPECT_EQ(pSW->tSma->tableUid, tSma.tableUid);
|
EXPECT_EQ(pSW->tSma->indexUid, indexUid1);
|
||||||
|
EXPECT_EQ(pSW->tSma->tableUid, tbUid);
|
||||||
EXPECT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2);
|
EXPECT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2);
|
||||||
EXPECT_STRCASEEQ((pSW->tSma + 1)->timezone, timeZone);
|
EXPECT_STRCASEEQ((pSW->tSma + 1)->timezone, timezone);
|
||||||
|
EXPECT_STRCASEEQ((pSW->tSma + 1)->expr, expr);
|
||||||
EXPECT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter);
|
EXPECT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter);
|
||||||
EXPECT_EQ((pSW->tSma + 1)->tableUid, tSma.tableUid);
|
EXPECT_EQ((pSW->tSma + 1)->indexUid, indexUid2);
|
||||||
|
EXPECT_EQ((pSW->tSma + 1)->tableUid, tbUid);
|
||||||
|
|
||||||
tdDestroyTSmaWrapper(pSW);
|
tdDestroyTSmaWrapper(pSW);
|
||||||
tfree(pSW);
|
tfree(pSW);
|
||||||
|
@ -233,44 +218,164 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) {
|
||||||
tdDestroyTSma(&tSma);
|
tdDestroyTSma(&tSma);
|
||||||
metaClose(pMeta);
|
metaClose(pMeta);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
TEST(testCase, tSmaInsertTest) {
|
TEST(testCase, tSma_Data_Insert_Query_Test) {
|
||||||
|
// step 1: prepare meta
|
||||||
|
const char * smaIndexName1 = "sma_index_test_1";
|
||||||
|
const char * timezone = "Asia/Shanghai";
|
||||||
|
const char * expr = "select count(a,b, top 20), from table interval 1d, sliding 1h;";
|
||||||
|
const char * tagsFilter = "where tags.location='Beijing' and tags.district='ChaoYang'";
|
||||||
|
const char * smaTestDir = "./smaTest";
|
||||||
|
const tb_uid_t tbUid = 1234567890;
|
||||||
|
const int64_t indexUid1 = 2000000001;
|
||||||
|
const int64_t interval1 = 1;
|
||||||
|
const int8_t intervalUnit1 = TD_TIME_UNIT_DAY;
|
||||||
|
const uint32_t nCntTSma = 2;
|
||||||
|
TSKEY skey1 = 1646987196;
|
||||||
|
const int64_t testSmaData1 = 100;
|
||||||
|
const int64_t testSmaData2 = 200;
|
||||||
|
// encode
|
||||||
STSma tSma = {0};
|
STSma tSma = {0};
|
||||||
STSmaData *pSmaData = NULL;
|
tSma.version = 0;
|
||||||
STsdb tsdb = {0};
|
|
||||||
|
|
||||||
// init
|
|
||||||
tSma.intervalUnit = TD_TIME_UNIT_DAY;
|
tSma.intervalUnit = TD_TIME_UNIT_DAY;
|
||||||
tSma.interval = 1;
|
tSma.interval = 1;
|
||||||
tSma.numOfFuncIds = 5; // sum/min/max/avg/last
|
tSma.slidingUnit = TD_TIME_UNIT_HOUR;
|
||||||
|
tSma.sliding = 0;
|
||||||
|
tSma.indexUid = indexUid1;
|
||||||
|
tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN);
|
||||||
|
tstrncpy(tSma.timezone, timezone, TD_TIMEZONE_LEN);
|
||||||
|
tSma.tableUid = tbUid;
|
||||||
|
|
||||||
int32_t blockSize = tSma.numOfFuncIds * sizeof(int64_t);
|
tSma.exprLen = strlen(expr);
|
||||||
int32_t numOfColIds = 3;
|
tSma.expr = (char *)calloc(tSma.exprLen + 1, 1);
|
||||||
int32_t numOfBlocks = 10;
|
tstrncpy(tSma.expr, expr, tSma.exprLen + 1);
|
||||||
|
|
||||||
int32_t dataLen = numOfColIds * numOfBlocks * blockSize;
|
tSma.tagsFilterLen = strlen(tagsFilter);
|
||||||
|
tSma.tagsFilter = (char *)calloc(tSma.tagsFilterLen + 1, 1);
|
||||||
|
tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1);
|
||||||
|
|
||||||
pSmaData = (STSmaData *)malloc(sizeof(STSmaData) + dataLen);
|
SMeta * pMeta = NULL;
|
||||||
ASSERT_EQ(pSmaData != NULL, true);
|
STSma * pSmaCfg = &tSma;
|
||||||
pSmaData->tableUid = 3232329230;
|
const SMetaCfg *pMetaCfg = &defaultMetaOptions;
|
||||||
pSmaData->numOfColIds = numOfColIds;
|
|
||||||
pSmaData->numOfBlocks = numOfBlocks;
|
|
||||||
pSmaData->dataLen = dataLen;
|
|
||||||
pSmaData->tsWindow.skey = 1640000000;
|
|
||||||
pSmaData->tsWindow.ekey = 1645788649;
|
|
||||||
pSmaData->colIds = (col_id_t *)malloc(sizeof(col_id_t) * numOfColIds);
|
|
||||||
ASSERT_EQ(pSmaData->colIds != NULL, true);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfColIds; ++i) {
|
taosRemoveDir(smaTestDir);
|
||||||
*(pSmaData->colIds + i) = (i + PRIMARYKEY_TIMESTAMP_COL_ID);
|
|
||||||
|
pMeta = metaOpen(smaTestDir, pMetaCfg, NULL);
|
||||||
|
assert(pMeta != NULL);
|
||||||
|
// save index 1
|
||||||
|
EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0);
|
||||||
|
|
||||||
|
// step 2: insert data
|
||||||
|
STSmaDataWrapper *pSmaData = NULL;
|
||||||
|
STsdb tsdb = {0};
|
||||||
|
STsdbCfg * pCfg = &tsdb.config;
|
||||||
|
|
||||||
|
tsdb.pMeta = pMeta;
|
||||||
|
tsdb.vgId = 2;
|
||||||
|
tsdb.config.daysPerFile = 10; // default days is 10
|
||||||
|
tsdb.config.keep1 = 30;
|
||||||
|
tsdb.config.keep2 = 90;
|
||||||
|
tsdb.config.keep = 365;
|
||||||
|
tsdb.config.precision = TSDB_TIME_PRECISION_MILLI;
|
||||||
|
tsdb.config.update = TD_ROW_OVERWRITE_UPDATE;
|
||||||
|
tsdb.config.compression = TWO_STAGE_COMP;
|
||||||
|
|
||||||
|
switch (tsdb.config.precision) {
|
||||||
|
case TSDB_TIME_PRECISION_MILLI:
|
||||||
|
skey1 *= 1e3;
|
||||||
|
break;
|
||||||
|
case TSDB_TIME_PRECISION_MICRO:
|
||||||
|
skey1 *= 1e6;
|
||||||
|
break;
|
||||||
|
case TSDB_TIME_PRECISION_NANO:
|
||||||
|
skey1 *= 1e9;
|
||||||
|
break;
|
||||||
|
default: // ms
|
||||||
|
skey1 *= 1e3;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// execute
|
char *msg = (char *)calloc(100, 1);
|
||||||
EXPECT_EQ(tsdbInsertTSmaData(&tsdb, &tSma, pSmaData), TSDB_CODE_SUCCESS);
|
EXPECT_EQ(tsdbUpdateSmaWindow(&tsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0);
|
||||||
|
|
||||||
// release
|
// init
|
||||||
tdDestroySmaData(pSmaData);
|
int32_t allocCnt = 0;
|
||||||
|
int32_t allocStep = 40960;
|
||||||
|
int32_t buffer = 4096;
|
||||||
|
void * buf = NULL;
|
||||||
|
EXPECT_EQ(tsdbMakeRoom(&buf, allocStep), 0);
|
||||||
|
int32_t bufSize = taosTSizeof(buf);
|
||||||
|
int32_t numOfTables = 10;
|
||||||
|
col_id_t numOfCols = 4096;
|
||||||
|
EXPECT_GT(numOfCols, 0);
|
||||||
|
|
||||||
|
pSmaData = (STSmaDataWrapper *)buf;
|
||||||
|
printf(">> allocate [%d] time to %d and addr is %p\n", ++allocCnt, bufSize, pSmaData);
|
||||||
|
pSmaData->skey = skey1;
|
||||||
|
pSmaData->interval = interval1;
|
||||||
|
pSmaData->intervalUnit = intervalUnit1;
|
||||||
|
pSmaData->indexUid = indexUid1;
|
||||||
|
|
||||||
|
int32_t len = sizeof(STSmaDataWrapper);
|
||||||
|
for (int32_t t = 0; t < numOfTables; ++t) {
|
||||||
|
STSmaTbData *pTbData = (STSmaTbData *)POINTER_SHIFT(pSmaData, len);
|
||||||
|
pTbData->tableUid = tbUid + t;
|
||||||
|
|
||||||
|
int32_t tableDataLen = sizeof(STSmaTbData);
|
||||||
|
for (col_id_t c = 0; c < numOfCols; ++c) {
|
||||||
|
if (bufSize - len - tableDataLen < buffer) {
|
||||||
|
EXPECT_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0);
|
||||||
|
pSmaData = (STSmaDataWrapper *)buf;
|
||||||
|
pTbData = (STSmaTbData *)POINTER_SHIFT(pSmaData, len);
|
||||||
|
bufSize = taosTSizeof(buf);
|
||||||
|
printf(">> allocate [%d] time to %d and addr is %p\n", ++allocCnt, bufSize, pSmaData);
|
||||||
|
}
|
||||||
|
STSmaColData *pColData = (STSmaColData *)POINTER_SHIFT(pSmaData, len + tableDataLen);
|
||||||
|
pColData->colId = c + PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||||
|
|
||||||
|
// TODO: fill col data
|
||||||
|
if ((c & 1) == 0) {
|
||||||
|
pColData->blockSize = 8;
|
||||||
|
memcpy(pColData->data, &testSmaData1, 8);
|
||||||
|
} else {
|
||||||
|
pColData->blockSize = 16;
|
||||||
|
memcpy(pColData->data, &testSmaData1, 8);
|
||||||
|
memcpy(POINTER_SHIFT(pColData->data, 8), &testSmaData2, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
tableDataLen += (sizeof(STSmaColData) + pColData->blockSize);
|
||||||
|
}
|
||||||
|
pTbData->dataLen = (tableDataLen - sizeof(STSmaTbData));
|
||||||
|
len += tableDataLen;
|
||||||
|
// printf("bufSize=%d, len=%d, len of table[%d]=%d\n", bufSize, len, t, tableDataLen);
|
||||||
|
}
|
||||||
|
pSmaData->dataLen = (len - sizeof(STSmaDataWrapper));
|
||||||
|
|
||||||
|
EXPECT_GE(bufSize, pSmaData->dataLen);
|
||||||
|
|
||||||
|
// execute
|
||||||
|
EXPECT_EQ(tsdbInsertTSmaData(&tsdb, (char *)pSmaData), TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
// step 3: query
|
||||||
|
uint32_t checkDataCnt = 0;
|
||||||
|
for (int32_t t = 0; t < numOfTables; ++t) {
|
||||||
|
for (col_id_t c = 0; c < numOfCols; ++c) {
|
||||||
|
EXPECT_EQ(tsdbGetTSmaData(&tsdb, NULL, indexUid1, interval1, intervalUnit1, tbUid + t,
|
||||||
|
c + PRIMARYKEY_TIMESTAMP_COL_ID, skey1, 1),
|
||||||
|
TSDB_CODE_SUCCESS);
|
||||||
|
++checkDataCnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s:%d The sma data check count for insert and query is %" PRIu32 "\n", __FILE__, __LINE__, checkDataCnt);
|
||||||
|
|
||||||
|
// release data
|
||||||
|
taosTZfree(buf);
|
||||||
|
// release meta
|
||||||
|
tdDestroyTSma(&tSma);
|
||||||
|
metaClose(pMeta);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -58,10 +58,10 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct SCtgDebug {
|
typedef struct SCtgDebug {
|
||||||
bool lockDebug;
|
bool lockEnable;
|
||||||
bool cacheDebug;
|
bool cacheEnable;
|
||||||
bool apiDebug;
|
bool apiEnable;
|
||||||
bool metaDebug;
|
bool metaEnable;
|
||||||
uint32_t showCachePeriodSec;
|
uint32_t showCachePeriodSec;
|
||||||
} SCtgDebug;
|
} SCtgDebug;
|
||||||
|
|
||||||
|
@ -242,9 +242,9 @@ typedef struct SCtgAction {
|
||||||
#define ctgDebug(param, ...) qDebug("CTG:%p " param, pCtg, __VA_ARGS__)
|
#define ctgDebug(param, ...) qDebug("CTG:%p " param, pCtg, __VA_ARGS__)
|
||||||
#define ctgTrace(param, ...) qTrace("CTG:%p " param, pCtg, __VA_ARGS__)
|
#define ctgTrace(param, ...) qTrace("CTG:%p " param, pCtg, __VA_ARGS__)
|
||||||
|
|
||||||
#define CTG_LOCK_DEBUG(...) do { if (gCTGDebug.lockDebug) { qDebug(__VA_ARGS__); } } while (0)
|
#define CTG_LOCK_DEBUG(...) do { if (gCTGDebug.lockEnable) { qDebug(__VA_ARGS__); } } while (0)
|
||||||
#define CTG_CACHE_DEBUG(...) do { if (gCTGDebug.cacheDebug) { qDebug(__VA_ARGS__); } } while (0)
|
#define CTG_CACHE_DEBUG(...) do { if (gCTGDebug.cacheEnable) { qDebug(__VA_ARGS__); } } while (0)
|
||||||
#define CTG_API_DEBUG(...) do { if (gCTGDebug.apiDebug) { qDebug(__VA_ARGS__); } } while (0)
|
#define CTG_API_DEBUG(...) do { if (gCTGDebug.apiEnable) { qDebug(__VA_ARGS__); } } while (0)
|
||||||
|
|
||||||
#define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000
|
#define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000
|
||||||
|
|
||||||
|
|
|
@ -55,25 +55,25 @@ SCtgAction gCtgAction[CTG_ACT_MAX] = {{
|
||||||
|
|
||||||
int32_t ctgDbgEnableDebug(char *option) {
|
int32_t ctgDbgEnableDebug(char *option) {
|
||||||
if (0 == strcasecmp(option, "lock")) {
|
if (0 == strcasecmp(option, "lock")) {
|
||||||
gCTGDebug.lockDebug = true;
|
gCTGDebug.lockEnable = true;
|
||||||
qDebug("lock debug enabled");
|
qDebug("lock debug enabled");
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == strcasecmp(option, "cache")) {
|
if (0 == strcasecmp(option, "cache")) {
|
||||||
gCTGDebug.cacheDebug = true;
|
gCTGDebug.cacheEnable = true;
|
||||||
qDebug("cache debug enabled");
|
qDebug("cache debug enabled");
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == strcasecmp(option, "api")) {
|
if (0 == strcasecmp(option, "api")) {
|
||||||
gCTGDebug.apiDebug = true;
|
gCTGDebug.apiEnable = true;
|
||||||
qDebug("api debug enabled");
|
qDebug("api debug enabled");
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == strcasecmp(option, "meta")) {
|
if (0 == strcasecmp(option, "meta")) {
|
||||||
gCTGDebug.metaDebug = true;
|
gCTGDebug.metaEnable = true;
|
||||||
qDebug("api debug enabled");
|
qDebug("api debug enabled");
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ int32_t ctgDbgGetClusterCacheNum(SCatalog* pCtg, int32_t type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctgDbgShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) {
|
void ctgDbgShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) {
|
||||||
if (!gCTGDebug.metaDebug) {
|
if (!gCTGDebug.metaEnable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ void ctgDbgShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctgDbgShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
|
void ctgDbgShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
|
||||||
if (NULL == dbHash || !gCTGDebug.cacheDebug) {
|
if (NULL == dbHash || !gCTGDebug.cacheEnable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ void ctgDbgShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
|
||||||
|
|
||||||
|
|
||||||
void ctgDbgShowClusterCache(SCatalog* pCtg) {
|
void ctgDbgShowClusterCache(SCatalog* pCtg) {
|
||||||
if (!gCTGDebug.cacheDebug || NULL == pCtg) {
|
if (!gCTGDebug.cacheEnable || NULL == pCtg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -851,19 +851,12 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgGetTableTypeFromCache(SCatalog* pCtg, const SName* pTableName, int32_t *tbType, int32_t flag) {
|
int32_t ctgGetTableTypeFromCache(SCatalog* pCtg, const char* dbFName, const char *tableName, int32_t *tbType) {
|
||||||
if (NULL == pCtg->dbCache) {
|
if (NULL == pCtg->dbCache) {
|
||||||
ctgWarn("empty db cache, tbName:%s", pTableName->tname);
|
ctgWarn("empty db cache, dbFName:%s, tbName:%s", dbFName, tableName);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
|
||||||
if (CTG_FLAG_IS_INF_DB(flag)) {
|
|
||||||
strcpy(dbFName, pTableName->dbname);
|
|
||||||
} else {
|
|
||||||
tNameGetFullDbName(pTableName, dbFName);
|
|
||||||
}
|
|
||||||
|
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
ctgAcquireDBCache(pCtg, dbFName, &dbCache);
|
ctgAcquireDBCache(pCtg, dbFName, &dbCache);
|
||||||
if (NULL == dbCache) {
|
if (NULL == dbCache) {
|
||||||
|
@ -871,11 +864,11 @@ int32_t ctgGetTableTypeFromCache(SCatalog* pCtg, const SName* pTableName, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
||||||
STableMeta *pTableMeta = (STableMeta *)taosHashAcquire(dbCache->tbCache.metaCache, pTableName->tname, strlen(pTableName->tname));
|
STableMeta *pTableMeta = (STableMeta *)taosHashAcquire(dbCache->tbCache.metaCache, tableName, strlen(tableName));
|
||||||
|
|
||||||
if (NULL == pTableMeta) {
|
if (NULL == pTableMeta) {
|
||||||
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
||||||
ctgWarn("tbl not in cache, dbFName:%s, tbName:%s", dbFName, pTableName->tname);
|
ctgWarn("tbl not in cache, dbFName:%s, tbName:%s", dbFName, tableName);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -889,7 +882,7 @@ int32_t ctgGetTableTypeFromCache(SCatalog* pCtg, const SName* pTableName, int32_
|
||||||
|
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
|
|
||||||
ctgDebug("Got tbtype from cache, dbFName:%s, tbName:%s, type:%d", dbFName, pTableName->tname, *tbType);
|
ctgDebug("Got tbtype from cache, dbFName:%s, tbName:%s, type:%d", dbFName, tableName, *tbType);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1729,18 +1722,17 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, c
|
||||||
|
|
||||||
if (inCache) {
|
if (inCache) {
|
||||||
input.dbId = dbCache->dbId;
|
input.dbId = dbCache->dbId;
|
||||||
input.vgVersion = dbCache->vgInfo->vgVersion;
|
|
||||||
input.numOfTable = dbCache->vgInfo->numOfTable;
|
|
||||||
|
|
||||||
ctgReleaseVgInfo(dbCache);
|
ctgReleaseVgInfo(dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
} else {
|
|
||||||
input.vgVersion = CTG_DEFAULT_INVALID_VERSION;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input.vgVersion = CTG_DEFAULT_INVALID_VERSION;
|
||||||
|
input.numOfTable = 0;
|
||||||
|
|
||||||
code = ctgGetDBVgInfoFromMnode(pCtg, pRpc, pMgmtEps, &input, &DbOut);
|
code = ctgGetDBVgInfoFromMnode(pCtg, pRpc, pMgmtEps, &input, &DbOut);
|
||||||
if (code) {
|
if (code) {
|
||||||
if (CTG_DB_NOT_EXIST(code) && input.vgVersion > CTG_DEFAULT_INVALID_VERSION) {
|
if (CTG_DB_NOT_EXIST(code) && inCache) {
|
||||||
ctgDebug("db no longer exist, dbFName:%s, dbId:%" PRIx64, input.db, input.dbId);
|
ctgDebug("db no longer exist, dbFName:%s, dbId:%" PRIx64, input.db, input.dbId);
|
||||||
ctgPushRmDBMsgInQueue(pCtg, input.db, input.dbId);
|
ctgPushRmDBMsgInQueue(pCtg, input.db, input.dbId);
|
||||||
}
|
}
|
||||||
|
@ -2074,24 +2066,19 @@ int32_t ctgActRemoveStb(SCtgMetaAction *action) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbCache->dbId != msg->dbId) {
|
if (msg->dbId && (dbCache->dbId != msg->dbId)) {
|
||||||
ctgDebug("dbId already modified, dbFName:%s, current:%"PRIx64", dbId:%"PRIx64", stb:%s, suid:%"PRIx64, msg->dbFName, dbCache->dbId, msg->dbId, msg->stbName, msg->suid);
|
ctgDebug("dbId already modified, dbFName:%s, current:%"PRIx64", dbId:%"PRIx64", stb:%s, suid:%"PRIx64, msg->dbFName, dbCache->dbId, msg->dbId, msg->stbName, msg->suid);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_LOCK(CTG_WRITE, &dbCache->tbCache.stbLock);
|
CTG_LOCK(CTG_WRITE, &dbCache->tbCache.stbLock);
|
||||||
if (taosHashRemove(dbCache->tbCache.stbCache, &msg->suid, sizeof(msg->suid))) {
|
if (taosHashRemove(dbCache->tbCache.stbCache, &msg->suid, sizeof(msg->suid))) {
|
||||||
CTG_UNLOCK(CTG_WRITE, &dbCache->tbCache.stbLock);
|
|
||||||
ctgDebug("stb not exist in stbCache, may be removed, dbFName:%s, stb:%s, suid:%"PRIx64, msg->dbFName, msg->stbName, msg->suid);
|
ctgDebug("stb not exist in stbCache, may be removed, dbFName:%s, stb:%s, suid:%"PRIx64, msg->dbFName, msg->stbName, msg->suid);
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
||||||
if (taosHashRemove(dbCache->tbCache.metaCache, msg->stbName, strlen(msg->stbName))) {
|
if (taosHashRemove(dbCache->tbCache.metaCache, msg->stbName, strlen(msg->stbName))) {
|
||||||
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
|
||||||
CTG_UNLOCK(CTG_WRITE, &dbCache->tbCache.stbLock);
|
|
||||||
ctgError("stb not exist in cache, dbFName:%s, stb:%s, suid:%"PRIx64, msg->dbFName, msg->stbName, msg->suid);
|
ctgError("stb not exist in cache, dbFName:%s, stb:%s, suid:%"PRIx64, msg->dbFName, msg->stbName, msg->suid);
|
||||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
|
||||||
}
|
}
|
||||||
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
||||||
|
|
||||||
|
@ -2543,6 +2530,47 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t catalogRemoveTableMeta(SCatalog* pCtg, SName* pTableName) {
|
||||||
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (NULL == pCtg || NULL == pTableName) {
|
||||||
|
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == pCtg->dbCache) {
|
||||||
|
CTG_API_LEAVE(TSDB_CODE_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
STableMeta *tblMeta = NULL;
|
||||||
|
int32_t exist = 0;
|
||||||
|
uint64_t dbId = 0;
|
||||||
|
CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, pTableName, &tblMeta, &exist, 0, &dbId));
|
||||||
|
|
||||||
|
if (0 == exist) {
|
||||||
|
ctgDebug("table already not in cache, db:%s, tblName:%s", pTableName->dbname, pTableName->tname);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
tNameGetFullDbName(pTableName, dbFName);
|
||||||
|
|
||||||
|
if (TSDB_SUPER_TABLE == tblMeta->tableType) {
|
||||||
|
CTG_ERR_JRET(ctgPushRmStbMsgInQueue(pCtg, dbFName, dbId, pTableName->tname, tblMeta->suid));
|
||||||
|
} else {
|
||||||
|
CTG_ERR_JRET(ctgPushRmTblMsgInQueue(pCtg, dbFName, dbId, pTableName->tname));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
tfree(tblMeta);
|
||||||
|
|
||||||
|
CTG_API_LEAVE(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, const char* stbName, uint64_t suid) {
|
int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, const char* stbName, uint64_t suid) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
@ -2631,7 +2659,7 @@ int32_t catalogRefreshTableMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgm
|
||||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_API_LEAVE(ctgRefreshTblMeta(pCtg, pTrans, pMgmtEps, pTableName, CTG_FLAG_FORCE_UPDATE | CTG_FLAG_MAKE_STB(isSTable), NULL, false));
|
CTG_API_LEAVE(ctgRefreshTblMeta(pCtg, pTrans, pMgmtEps, pTableName, CTG_FLAG_FORCE_UPDATE | CTG_FLAG_MAKE_STB(isSTable), NULL, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t catalogRefreshGetTableMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta, int32_t isSTable) {
|
int32_t catalogRefreshGetTableMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta, int32_t isSTable) {
|
||||||
|
|
|
@ -253,6 +253,11 @@ typedef struct STaskIdInfo {
|
||||||
char* str;
|
char* str;
|
||||||
} STaskIdInfo;
|
} STaskIdInfo;
|
||||||
|
|
||||||
|
typedef struct STaskBufInfo {
|
||||||
|
int32_t bufSize; // total available buffer size in bytes
|
||||||
|
int32_t remainBuf; // remain buffer size
|
||||||
|
} STaskBufInfo;
|
||||||
|
|
||||||
typedef struct SExecTaskInfo {
|
typedef struct SExecTaskInfo {
|
||||||
STaskIdInfo id;
|
STaskIdInfo id;
|
||||||
char* content;
|
char* content;
|
||||||
|
@ -264,7 +269,8 @@ typedef struct SExecTaskInfo {
|
||||||
uint64_t totalRows; // total number of rows
|
uint64_t totalRows; // total number of rows
|
||||||
STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray<STableQueryInfo*> structure
|
STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray<STableQueryInfo*> structure
|
||||||
char* sql; // query sql string
|
char* sql; // query sql string
|
||||||
jmp_buf env; //
|
jmp_buf env; // when error occurs, abort
|
||||||
|
STaskBufInfo bufInfo; // available buffer info this task
|
||||||
struct SOperatorInfo* pRoot;
|
struct SOperatorInfo* pRoot;
|
||||||
} SExecTaskInfo;
|
} SExecTaskInfo;
|
||||||
|
|
||||||
|
@ -307,9 +313,11 @@ typedef struct STaskRuntimeEnv {
|
||||||
} STaskRuntimeEnv;
|
} STaskRuntimeEnv;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
OP_IN_EXECUTING = 1,
|
OP_NOT_OPENED = 0x0,
|
||||||
OP_RES_TO_RETURN = 2,
|
OP_OPENED = 0x1,
|
||||||
OP_EXEC_DONE = 3,
|
OP_IN_EXECUTING = 0x3,
|
||||||
|
OP_RES_TO_RETURN = 0x5,
|
||||||
|
OP_EXEC_DONE = 0x9,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct SOperatorInfo {
|
typedef struct SOperatorInfo {
|
||||||
|
@ -322,12 +330,14 @@ typedef struct SOperatorInfo {
|
||||||
SExprInfo* pExpr;
|
SExprInfo* pExpr;
|
||||||
STaskRuntimeEnv* pRuntimeEnv; // todo remove it
|
STaskRuntimeEnv* pRuntimeEnv; // todo remove it
|
||||||
SExecTaskInfo* pTaskInfo;
|
SExecTaskInfo* pTaskInfo;
|
||||||
|
SOperatorCostInfo cost;
|
||||||
|
|
||||||
struct SOperatorInfo** pDownstream; // downstram pointer list
|
struct SOperatorInfo** pDownstream; // downstram pointer list
|
||||||
int32_t numOfDownstream; // number of downstream. The value is always ONE expect for join operator
|
int32_t numOfDownstream; // number of downstream. The value is always ONE expect for join operator
|
||||||
__optr_open_fn_t openFn;
|
__optr_fn_t getNextFn;
|
||||||
__optr_fn_t nextDataFn;
|
__optr_fn_t cleanupFn;
|
||||||
__optr_close_fn_t closeFn;
|
__optr_close_fn_t closeFn;
|
||||||
|
__optr_open_fn_t _openFn; // DO NOT invoke this function directly
|
||||||
} SOperatorInfo;
|
} SOperatorInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -356,9 +366,9 @@ typedef struct SQInfo {
|
||||||
} SQInfo;
|
} SQInfo;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
DATA_NOT_READY = 0x1,
|
EX_SOURCE_DATA_NOT_READY = 0x1,
|
||||||
DATA_READY = 0x2,
|
EX_SOURCE_DATA_READY = 0x2,
|
||||||
DATA_EXHAUSTED = 0x3,
|
EX_SOURCE_DATA_EXHAUSTED = 0x3,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct SSourceDataInfo {
|
typedef struct SSourceDataInfo {
|
||||||
|
@ -626,6 +636,8 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB
|
||||||
SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream);
|
SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream);
|
||||||
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SInterval* pInterval, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SInterval* pInterval, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
|
SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream);
|
||||||
|
|
||||||
SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
||||||
SExprInfo* pExpr, int32_t numOfOutput);
|
SExprInfo* pExpr, int32_t numOfOutput);
|
||||||
SOperatorInfo* createSWindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr,
|
SOperatorInfo* createSWindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr,
|
||||||
|
@ -670,7 +682,6 @@ void* doDestroyFilterInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFil
|
||||||
void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order);
|
void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order);
|
||||||
void finalizeQueryResult(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SResultRowInfo* pResultRowInfo,
|
void finalizeQueryResult(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SResultRowInfo* pResultRowInfo,
|
||||||
int32_t* rowCellInfoOffset);
|
int32_t* rowCellInfoOffset);
|
||||||
void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t* bufCapacity, int32_t numOfInputRows);
|
|
||||||
void clearOutputBuf(SOptrBasicInfo* pBInfo, int32_t* bufCapacity);
|
void clearOutputBuf(SOptrBasicInfo* pBInfo, int32_t* bufCapacity);
|
||||||
void copyTsColoum(SSDataBlock* pRes, SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
void copyTsColoum(SSDataBlock* pRes, SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
||||||
|
|
||||||
|
@ -701,7 +712,7 @@ int32_t getMaximumIdleDurationSec();
|
||||||
|
|
||||||
void doInvokeUdf(struct SUdfInfo* pUdfInfo, SqlFunctionCtx* pCtx, int32_t idx, int32_t type);
|
void doInvokeUdf(struct SUdfInfo* pUdfInfo, SqlFunctionCtx* pCtx, int32_t idx, int32_t type);
|
||||||
void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status);
|
void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status);
|
||||||
int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, SQueryErrorInfo *errInfo);
|
int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
#include "tqueue.h"
|
#include "tqueue.h"
|
||||||
#include "executorimpl.h"
|
#include "executorimpl.h"
|
||||||
|
|
||||||
#define DATA_META_LENGTH(tables) (sizeof(int32_t) + sizeof(STableIdInfo) * taosHashGetSize(tables) + sizeof(SRetrieveTableRsp))
|
|
||||||
|
|
||||||
typedef struct SDataDispatchBuf {
|
typedef struct SDataDispatchBuf {
|
||||||
int32_t useSize;
|
int32_t useSize;
|
||||||
int32_t allocSize;
|
int32_t allocSize;
|
||||||
|
@ -90,19 +88,6 @@ static void copyData(const SInputData* pInput, const SDataBlockDescNode* pSchema
|
||||||
data += pColRes->info.bytes * pInput->pData->info.rows;
|
data += pColRes->info.bytes * pInput->pData->info.rows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfTables = (int32_t) taosHashGetSize(pInput->pTableRetrieveTsMap);
|
|
||||||
*(int32_t*)data = htonl(numOfTables);
|
|
||||||
data += sizeof(int32_t);
|
|
||||||
|
|
||||||
STableIdInfo* item = taosHashIterate(pInput->pTableRetrieveTsMap, NULL);
|
|
||||||
while (item) {
|
|
||||||
STableIdInfo* pDst = (STableIdInfo*)data;
|
|
||||||
pDst->uid = htobe64(item->uid);
|
|
||||||
pDst->key = htobe64(item->key);
|
|
||||||
data += sizeof(STableIdInfo);
|
|
||||||
item = taosHashIterate(pInput->pTableRetrieveTsMap, item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// data format with compress: SDataCacheEntry | cols_data_offset | col1_data col2_data ... | numOfTables | STableIdInfo STableIdInfo ...
|
// data format with compress: SDataCacheEntry | cols_data_offset | col1_data col2_data ... | numOfTables | STableIdInfo STableIdInfo ...
|
||||||
|
@ -113,7 +98,7 @@ static void toDataCacheEntry(const SDataDispatchHandle* pHandle, const SInputDat
|
||||||
pEntry->numOfRows = pInput->pData->info.rows;
|
pEntry->numOfRows = pInput->pData->info.rows;
|
||||||
pEntry->dataLen = 0;
|
pEntry->dataLen = 0;
|
||||||
|
|
||||||
pBuf->useSize = DATA_META_LENGTH(pInput->pTableRetrieveTsMap);
|
pBuf->useSize = sizeof(SRetrieveTableRsp);
|
||||||
copyData(pInput, pHandle->pSchema, pEntry->data, pEntry->compressed, &pEntry->dataLen);
|
copyData(pInput, pHandle->pSchema, pEntry->data, pEntry->compressed, &pEntry->dataLen);
|
||||||
if (0 == pEntry->compressed) {
|
if (0 == pEntry->compressed) {
|
||||||
pEntry->dataLen = pHandle->pSchema->resultRowSize * pInput->pData->info.rows;
|
pEntry->dataLen = pHandle->pSchema->resultRowSize * pInput->pData->info.rows;
|
||||||
|
@ -130,7 +115,7 @@ static bool allocBuf(SDataDispatchHandle* pDispatcher, const SInputData* pInput,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pBuf->allocSize = DATA_META_LENGTH(pInput->pTableRetrieveTsMap) + pDispatcher->pSchema->resultRowSize * pInput->pData->info.rows;
|
pBuf->allocSize = sizeof(SRetrieveTableRsp) + pDispatcher->pSchema->resultRowSize * pInput->pData->info.rows;
|
||||||
pBuf->pData = malloc(pBuf->allocSize);
|
pBuf->pData = malloc(pBuf->allocSize);
|
||||||
if (pBuf->pData == NULL) {
|
if (pBuf->pData == NULL) {
|
||||||
qError("SinkNode failed to malloc memory, size:%d, code:%d", pBuf->allocSize, TAOS_SYSTEM_ERROR(errno));
|
qError("SinkNode failed to malloc memory, size:%d, code:%d", pBuf->allocSize, TAOS_SYSTEM_ERROR(errno));
|
||||||
|
|
|
@ -84,7 +84,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, void* streamReadHandle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
qTaskInfo_t pTaskInfo = NULL;
|
qTaskInfo_t pTaskInfo = NULL;
|
||||||
code = qCreateExecTask(streamReadHandle, 0, 0, plan, &pTaskInfo, NULL, NULL);
|
code = qCreateExecTask(streamReadHandle, 0, 0, plan, &pTaskInfo, NULL);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
// TODO: destroy SSubplan & pTaskInfo
|
// TODO: destroy SSubplan & pTaskInfo
|
||||||
terrno = code;
|
terrno = code;
|
||||||
|
|
|
@ -51,11 +51,11 @@ static void freeqinfoFn(void *qhandle) {
|
||||||
qDestroyTask(*handle);
|
qDestroyTask(*handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SSubplan* pSubplan, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, SQueryErrorInfo *errInfo) {
|
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SSubplan* pSubplan, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle) {
|
||||||
assert(readHandle != NULL && pSubplan != NULL);
|
assert(readHandle != NULL && pSubplan != NULL);
|
||||||
SExecTaskInfo** pTask = (SExecTaskInfo**)pTaskInfo;
|
SExecTaskInfo** pTask = (SExecTaskInfo**)pTaskInfo;
|
||||||
|
|
||||||
int32_t code = createExecTaskInfoImpl(pSubplan, pTask, readHandle, taskId, errInfo);
|
int32_t code = createExecTaskInfoImpl(pSubplan, pTask, readHandle, taskId);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
|
||||||
int64_t st = 0;
|
int64_t st = 0;
|
||||||
|
|
||||||
st = taosGetTimestampUs();
|
st = taosGetTimestampUs();
|
||||||
*pRes = pTaskInfo->pRoot->nextDataFn(pTaskInfo->pRoot, &newgroup);
|
*pRes = pTaskInfo->pRoot->getNextFn(pTaskInfo->pRoot, &newgroup);
|
||||||
|
|
||||||
uint64_t el = (taosGetTimestampUs() - st);
|
uint64_t el = (taosGetTimestampUs() - st);
|
||||||
pTaskInfo->cost.elapsedTime += el;
|
pTaskInfo->cost.elapsedTime += el;
|
||||||
|
|
|
@ -163,7 +163,7 @@ static void getNextTimeWindow(SInterval* pInterval, int32_t precision, int32_t o
|
||||||
|
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t t = (time_t)key;
|
time_t t = (time_t)key;
|
||||||
localtime_r(&t, &tm);
|
taosLocalTime(&t, &tm);
|
||||||
|
|
||||||
int mon = (int)(tm.tm_year * 12 + tm.tm_mon + interval * factor);
|
int mon = (int)(tm.tm_year * 12 + tm.tm_mon + interval * factor);
|
||||||
tm.tm_year = mon / 12;
|
tm.tm_year = mon / 12;
|
||||||
|
@ -211,6 +211,9 @@ static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
static void destroySWindowOperatorInfo(void* param, int32_t numOfOutput);
|
static void destroySWindowOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
static void destroyStateWindowOperatorInfo(void* param, int32_t numOfOutput);
|
static void destroyStateWindowOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
static void destroyAggOperatorInfo(void* param, int32_t numOfOutput);
|
static void destroyAggOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
|
static void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
|
static void destroyConditionOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
|
|
||||||
static void destroyOperatorInfo(SOperatorInfo* pOperator);
|
static void destroyOperatorInfo(SOperatorInfo* pOperator);
|
||||||
static void destroySysTableScannerOperatorInfo(void* param, int32_t numOfOutput);
|
static void destroySysTableScannerOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
|
|
||||||
|
@ -221,6 +224,17 @@ static void doSetOperatorCompleted(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED)
|
||||||
|
#define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED)
|
||||||
|
|
||||||
|
static int32_t operatorDummyOpenFn(void* param) {
|
||||||
|
SOperatorInfo* pOperator = (SOperatorInfo*) param;
|
||||||
|
OPTR_SET_OPENED(pOperator);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void operatorDummyCloseFn(void* param, int32_t numOfCols) {}
|
||||||
|
|
||||||
static int32_t doCopyToSDataBlock(SDiskbasedBuf *pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType, SSDataBlock* pBlock, int32_t rowCapacity);
|
static int32_t doCopyToSDataBlock(SDiskbasedBuf *pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType, SSDataBlock* pBlock, int32_t rowCapacity);
|
||||||
|
|
||||||
static int32_t getGroupbyColumnIndex(SGroupbyExpr *pGroupbyExpr, SSDataBlock* pDataBlock);
|
static int32_t getGroupbyColumnIndex(SGroupbyExpr *pGroupbyExpr, SSDataBlock* pDataBlock);
|
||||||
|
@ -4723,6 +4737,11 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) {
|
||||||
STableScanInfo *pTableScanInfo = pOperator->info;
|
STableScanInfo *pTableScanInfo = pOperator->info;
|
||||||
SExecTaskInfo *pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo *pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
pTaskInfo->code = pOperator->_openFn(pOperator);
|
||||||
|
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// The read handle is not initialized yet, since no qualified tables exists
|
// The read handle is not initialized yet, since no qualified tables exists
|
||||||
if (pTableScanInfo->pTsdbReadHandle == NULL) {
|
if (pTableScanInfo->pTsdbReadHandle == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -4840,6 +4859,11 @@ static SSDataBlock* doStreamBlockScan(void* param, bool* newgroup) {
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
SStreamBlockScanInfo* pInfo = pOperator->info;
|
SStreamBlockScanInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
|
pTaskInfo->code = pOperator->_openFn(pOperator);
|
||||||
|
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SDataBlockInfo* pBlockInfo = &pInfo->pRes->info;
|
SDataBlockInfo* pBlockInfo = &pInfo->pRes->info;
|
||||||
pBlockInfo->rows = 0;
|
pBlockInfo->rows = 0;
|
||||||
|
|
||||||
|
@ -4880,7 +4904,7 @@ int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code)
|
||||||
pRsp->useconds = htobe64(pRsp->useconds);
|
pRsp->useconds = htobe64(pRsp->useconds);
|
||||||
pRsp->compLen = htonl(pRsp->compLen);
|
pRsp->compLen = htonl(pRsp->compLen);
|
||||||
|
|
||||||
pSourceDataInfo->status = DATA_READY;
|
pSourceDataInfo->status = EX_SOURCE_DATA_READY;
|
||||||
tsem_post(&pSourceDataInfo->pEx->ready);
|
tsem_post(&pSourceDataInfo->pEx->ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5010,12 +5034,12 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo *pOperator, SEx
|
||||||
for (int32_t i = 0; i < totalSources; ++i) {
|
for (int32_t i = 0; i < totalSources; ++i) {
|
||||||
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, i);
|
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, i);
|
||||||
|
|
||||||
if (pDataInfo->status == DATA_EXHAUSTED) {
|
if (pDataInfo->status == EX_SOURCE_DATA_EXHAUSTED) {
|
||||||
completed += 1;
|
completed += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDataInfo->status != DATA_READY) {
|
if (pDataInfo->status != EX_SOURCE_DATA_READY) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5028,7 +5052,7 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo *pOperator, SEx
|
||||||
qDebug("%s vgId:%d, taskID:0x%" PRIx64 " index:%d completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 " try next",
|
qDebug("%s vgId:%d, taskID:0x%" PRIx64 " index:%d completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 " try next",
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i + 1, pDataInfo->totalRows,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i + 1, pDataInfo->totalRows,
|
||||||
pExchangeInfo->loadInfo.totalRows);
|
pExchangeInfo->loadInfo.totalRows);
|
||||||
pDataInfo->status = DATA_EXHAUSTED;
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
completed += 1;
|
completed += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -5046,15 +5070,15 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo *pOperator, SEx
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows,
|
||||||
pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize, i + 1,
|
pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize, i + 1,
|
||||||
totalSources);
|
totalSources);
|
||||||
pDataInfo->status = DATA_EXHAUSTED;
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
} else {
|
} else {
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64 ", totalBytes:%" PRIu64,
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64 ", totalBytes:%" PRIu64,
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows, pLoadInfo->totalRows,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows, pLoadInfo->totalRows,
|
||||||
pLoadInfo->totalSize);
|
pLoadInfo->totalSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDataInfo->status != DATA_EXHAUSTED) {
|
if (pDataInfo->status != EX_SOURCE_DATA_EXHAUSTED) {
|
||||||
pDataInfo->status = DATA_NOT_READY;
|
pDataInfo->status = EX_SOURCE_DATA_NOT_READY;
|
||||||
code = doSendFetchDataRequest(pExchangeInfo, pTaskInfo, i);
|
code = doSendFetchDataRequest(pExchangeInfo, pTaskInfo, i);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
|
@ -5074,14 +5098,10 @@ _error:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* concurrentlyLoadRemoteData(SOperatorInfo *pOperator) {
|
static int32_t prepareConcurrentlyLoad(SOperatorInfo *pOperator) {
|
||||||
SExchangeInfo *pExchangeInfo = pOperator->info;
|
SExchangeInfo *pExchangeInfo = pOperator->info;
|
||||||
SExecTaskInfo *pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo *pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
|
||||||
return concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
||||||
int64_t startTs = taosGetTimestampUs();
|
int64_t startTs = taosGetTimestampUs();
|
||||||
|
|
||||||
|
@ -5089,7 +5109,8 @@ static SSDataBlock* concurrentlyLoadRemoteData(SOperatorInfo *pOperator) {
|
||||||
for(int32_t i = 0; i < totalSources; ++i) {
|
for(int32_t i = 0; i < totalSources; ++i) {
|
||||||
int32_t code = doSendFetchDataRequest(pExchangeInfo, pTaskInfo, i);
|
int32_t code = doSendFetchDataRequest(pExchangeInfo, pTaskInfo, i);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return NULL;
|
pTaskInfo->code = code;
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5097,9 +5118,9 @@ static SSDataBlock* concurrentlyLoadRemoteData(SOperatorInfo *pOperator) {
|
||||||
qDebug("%s send all fetch request to %"PRIzu" sources completed, elapsed:%"PRId64, GET_TASKID(pTaskInfo), totalSources, endTs - startTs);
|
qDebug("%s send all fetch request to %"PRIzu" sources completed, elapsed:%"PRId64, GET_TASKID(pTaskInfo), totalSources, endTs - startTs);
|
||||||
|
|
||||||
tsem_wait(&pExchangeInfo->ready);
|
tsem_wait(&pExchangeInfo->ready);
|
||||||
|
pOperator->cost.openCost = taosGetTimestampUs() - startTs;
|
||||||
|
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
return TSDB_CODE_SUCCESS;
|
||||||
return concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* seqLoadRemoteData(SOperatorInfo *pOperator) {
|
static SSDataBlock* seqLoadRemoteData(SOperatorInfo *pOperator) {
|
||||||
|
@ -5129,7 +5150,7 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo *pOperator) {
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pExchangeInfo->current + 1,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pExchangeInfo->current + 1,
|
||||||
pDataInfo->totalRows, pLoadInfo->totalRows);
|
pDataInfo->totalRows, pLoadInfo->totalRows);
|
||||||
|
|
||||||
pDataInfo->status = DATA_EXHAUSTED;
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
pExchangeInfo->current += 1;
|
pExchangeInfo->current += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -5146,7 +5167,7 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo *pOperator) {
|
||||||
pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize, pExchangeInfo->current + 1,
|
pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize, pExchangeInfo->current + 1,
|
||||||
totalSources);
|
totalSources);
|
||||||
|
|
||||||
pDataInfo->status = DATA_EXHAUSTED;
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
pExchangeInfo->current += 1;
|
pExchangeInfo->current += 1;
|
||||||
} else {
|
} else {
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64 ", totalBytes:%" PRIu64,
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64 ", totalBytes:%" PRIu64,
|
||||||
|
@ -5157,6 +5178,26 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo *pOperator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t prepareLoadRemoteData(void* param) {
|
||||||
|
SOperatorInfo *pOperator = (SOperatorInfo*) param;
|
||||||
|
if (OPTR_IS_OPENED(pOperator)) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SExchangeInfo *pExchangeInfo = pOperator->info;
|
||||||
|
if (pExchangeInfo->seqLoadData) {
|
||||||
|
// do nothing for sequentially load data
|
||||||
|
} else {
|
||||||
|
int32_t code = prepareConcurrentlyLoad(pOperator);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OPTR_SET_OPENED(pOperator);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* doLoadRemoteData(void* param, bool* newgroup) {
|
static SSDataBlock* doLoadRemoteData(void* param, bool* newgroup) {
|
||||||
SOperatorInfo *pOperator = (SOperatorInfo*) param;
|
SOperatorInfo *pOperator = (SOperatorInfo*) param;
|
||||||
|
|
||||||
|
@ -5165,7 +5206,6 @@ static SSDataBlock* doLoadRemoteData(void* param, bool* newgroup) {
|
||||||
|
|
||||||
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
||||||
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
||||||
|
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
qDebug("%s all %"PRIzu" source(s) are exhausted, total rows:%"PRIu64" bytes:%"PRIu64", elapsed:%.2f ms", GET_TASKID(pTaskInfo), totalSources,
|
qDebug("%s all %"PRIzu" source(s) are exhausted, total rows:%"PRIu64" bytes:%"PRIu64", elapsed:%.2f ms", GET_TASKID(pTaskInfo), totalSources,
|
||||||
pLoadInfo->totalRows, pLoadInfo->totalSize, pLoadInfo->totalElapsed/1000.0);
|
pLoadInfo->totalRows, pLoadInfo->totalSize, pLoadInfo->totalElapsed/1000.0);
|
||||||
|
@ -5173,11 +5213,10 @@ static SSDataBlock* doLoadRemoteData(void* param, bool* newgroup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
*newgroup = false;
|
*newgroup = false;
|
||||||
|
|
||||||
if (pExchangeInfo->seqLoadData) {
|
if (pExchangeInfo->seqLoadData) {
|
||||||
return seqLoadRemoteData(pOperator);
|
return seqLoadRemoteData(pOperator);
|
||||||
} else {
|
} else {
|
||||||
return concurrentlyLoadRemoteData(pOperator);
|
return concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -5190,16 +5229,35 @@ static SSDataBlock* doLoadRemoteData(void* param, bool* newgroup) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo) {
|
||||||
|
pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo));
|
||||||
|
if (pInfo->pSourceDataInfo == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < numOfSources; ++i) {
|
||||||
|
SSourceDataInfo dataInfo = {0};
|
||||||
|
dataInfo.status = EX_SOURCE_DATA_NOT_READY;
|
||||||
|
dataInfo.pEx = pInfo;
|
||||||
|
dataInfo.index = i;
|
||||||
|
|
||||||
|
void* ret = taosArrayPush(pInfo->pSourceDataInfo, &dataInfo);
|
||||||
|
if (ret == NULL) {
|
||||||
|
taosArrayDestroy(pInfo->pSourceDataInfo);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO handle the error
|
// TODO handle the error
|
||||||
SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
|
SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
|
||||||
SExchangeInfo* pInfo = calloc(1, sizeof(SExchangeInfo));
|
SExchangeInfo* pInfo = calloc(1, sizeof(SExchangeInfo));
|
||||||
SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo));
|
||||||
|
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
tfree(pInfo);
|
goto _error;
|
||||||
tfree(pOperator);
|
|
||||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t numOfSources = LIST_LENGTH(pSources);
|
size_t numOfSources = LIST_LENGTH(pSources);
|
||||||
|
@ -5226,29 +5284,28 @@ SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int32_t i = 0; i < numOfSources; ++i) {
|
int32_t code = initDataSource(numOfSources, pInfo);
|
||||||
SSourceDataInfo dataInfo = {0};
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
dataInfo.status = DATA_NOT_READY;
|
goto _error;
|
||||||
dataInfo.pEx = pInfo;
|
|
||||||
dataInfo.index = i;
|
|
||||||
|
|
||||||
taosArrayPush(pInfo->pSourceDataInfo, &dataInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size = pBlock->info.numOfCols;
|
size_t size = pBlock->info.numOfCols;
|
||||||
pInfo->pResult = pBlock;
|
pInfo->pResult = pBlock;
|
||||||
pInfo->seqLoadData = true;
|
pInfo->seqLoadData = true;
|
||||||
|
|
||||||
|
pInfo->seqLoadData = true; // sequentially load data from the source node
|
||||||
tsem_init(&pInfo->ready, 0, 0);
|
tsem_init(&pInfo->ready, 0, 0);
|
||||||
|
|
||||||
pOperator->name = "ExchangeOperator";
|
pOperator->name = "ExchangeOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_EXCHANGE;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_EXCHANGE;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfOutput = size;
|
pOperator->numOfOutput = size;
|
||||||
pOperator->nextDataFn = doLoadRemoteData;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
pOperator->_openFn = prepareLoadRemoteData; // assign a dummy function.
|
||||||
|
pOperator->getNextFn = doLoadRemoteData;
|
||||||
|
pOperator->closeFn = destroyExchangeOperatorInfo;
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
{ // todo refactor
|
{ // todo refactor
|
||||||
|
@ -5274,6 +5331,16 @@ SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
if (pInfo != NULL) {
|
||||||
|
destroyExchangeOperatorInfo(pInfo, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
tfree(pInfo);
|
||||||
|
tfree(pOperator);
|
||||||
|
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDataBlock* createResultDataBlock(const SArray* pExprInfo) {
|
SSDataBlock* createResultDataBlock(const SArray* pExprInfo) {
|
||||||
|
@ -5324,10 +5391,12 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
|
||||||
pOperator->name = "TableScanOperator";
|
pOperator->name = "TableScanOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->nextDataFn = doTableScan;
|
pOperator->_openFn = operatorDummyOpenFn;
|
||||||
|
pOperator->getNextFn = doTableScan;
|
||||||
|
pOperator->closeFn = operatorDummyCloseFn;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
@ -5348,11 +5417,11 @@ SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntim
|
||||||
pOperator->name = "TableSeqScanOperator";
|
pOperator->name = "TableSeqScanOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfOutput = pRuntimeEnv->pQueryAttr->numOfCols;
|
pOperator->numOfOutput = pRuntimeEnv->pQueryAttr->numOfCols;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
pOperator->pRuntimeEnv = pRuntimeEnv;
|
||||||
pOperator->nextDataFn = doTableScanImpl;
|
pOperator->getNextFn = doTableScanImpl;
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
}
|
}
|
||||||
|
@ -5373,10 +5442,10 @@ SOperatorInfo* createTableBlockInfoScanOperator(void* pTsdbReadHandle, STaskRunt
|
||||||
pOperator->name = "TableBlockInfoScanOperator";
|
pOperator->name = "TableBlockInfoScanOperator";
|
||||||
// pOperator->operatorType = OP_TableBlockInfoScan;
|
// pOperator->operatorType = OP_TableBlockInfoScan;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
// pOperator->numOfOutput = pRuntimeEnv->pQueryAttr->numOfCols;
|
// pOperator->numOfOutput = pRuntimeEnv->pQueryAttr->numOfCols;
|
||||||
pOperator->nextDataFn = doBlockInfoScan;
|
pOperator->getNextFn = doBlockInfoScan;
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
}
|
}
|
||||||
|
@ -5406,10 +5475,13 @@ SOperatorInfo* createStreamScanOperatorInfo(void *streamReadHandle, SSDataBlock*
|
||||||
pOperator->name = "StreamBlockScanOperator";
|
pOperator->name = "StreamBlockScanOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfOutput = pResBlock->info.numOfCols;
|
pOperator->numOfOutput = pResBlock->info.numOfCols;
|
||||||
pOperator->nextDataFn = doStreamBlockScan;
|
pOperator->_openFn = operatorDummyOpenFn;
|
||||||
|
pOperator->getNextFn = doStreamBlockScan;
|
||||||
|
pOperator->closeFn = operatorDummyCloseFn;
|
||||||
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
return pOperator;
|
return pOperator;
|
||||||
}
|
}
|
||||||
|
@ -5568,7 +5640,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_IN_EXECUTING;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfOutput = pResBlock->info.numOfCols;
|
pOperator->numOfOutput = pResBlock->info.numOfCols;
|
||||||
pOperator->nextDataFn = doSysTableScan;
|
pOperator->getNextFn = doSysTableScan;
|
||||||
pOperator->closeFn = destroySysTableScannerOperatorInfo;
|
pOperator->closeFn = destroySysTableScannerOperatorInfo;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
|
@ -5761,7 +5833,7 @@ SSDataBlock* loadNextDataBlock(void* param) {
|
||||||
SOperatorInfo* pOperator = (SOperatorInfo*) param;
|
SOperatorInfo* pOperator = (SOperatorInfo*) param;
|
||||||
bool newgroup = false;
|
bool newgroup = false;
|
||||||
|
|
||||||
return pOperator->nextDataFn(pOperator, &newgroup);
|
return pOperator->getNextFn(pOperator, &newgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool needToMerge(SSDataBlock* pBlock, SArray* groupInfo, char **buf, int32_t rowIndex) {
|
static bool needToMerge(SSDataBlock* pBlock, SArray* groupInfo, char **buf, int32_t rowIndex) {
|
||||||
|
@ -6075,13 +6147,13 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t
|
||||||
pOperator->name = "SortedMerge";
|
pOperator->name = "SortedMerge";
|
||||||
// pOperator->operatorType = OP_SortedMerge;
|
// pOperator->operatorType = OP_SortedMerge;
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blockingOptr = true;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->pExpr = exprArrayDup(pExprInfo);
|
pOperator->pExpr = exprArrayDup(pExprInfo);
|
||||||
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
pOperator->nextDataFn = doSortedMerge;
|
pOperator->getNextFn = doSortedMerge;
|
||||||
pOperator->closeFn = destroySortedMergeOperatorInfo;
|
pOperator->closeFn = destroySortedMergeOperatorInfo;
|
||||||
|
|
||||||
code = appendDownstream(pOperator, downstream, numOfDownstream);
|
code = appendDownstream(pOperator, downstream, numOfDownstream);
|
||||||
|
@ -6173,11 +6245,11 @@ SOperatorInfo *createOrderOperatorInfo(SOperatorInfo* downstream, SArray* pExprI
|
||||||
pOperator->name = "Order";
|
pOperator->name = "Order";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SORT;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SORT;
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blockingOptr = true;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
pOperator->nextDataFn = doSort;
|
pOperator->getNextFn = doSort;
|
||||||
pOperator->closeFn = destroyOrderOperatorInfo;
|
pOperator->closeFn = destroyOrderOperatorInfo;
|
||||||
|
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -6203,7 +6275,7 @@ static SSDataBlock* doAggregate(void* param, bool* newgroup) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = downstream->nextDataFn(downstream, newgroup);
|
SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup);
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -6253,7 +6325,7 @@ static SSDataBlock* doMultiTableAggregate(void* param, bool* newgroup) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = downstream->nextDataFn(downstream, newgroup);
|
SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup);
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -6339,7 +6411,7 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) {
|
||||||
|
|
||||||
// The downstream exec may change the value of the newgroup, so use a local variable instead.
|
// The downstream exec may change the value of the newgroup, so use a local variable instead.
|
||||||
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = pOperator->pDownstream[0]->nextDataFn(pOperator->pDownstream[0], newgroup);
|
SSDataBlock* pBlock = pOperator->pDownstream[0]->getNextFn(pOperator->pDownstream[0], newgroup);
|
||||||
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -6397,7 +6469,7 @@ static SSDataBlock* doLimit(void* param, bool* newgroup) {
|
||||||
SSDataBlock* pBlock = NULL;
|
SSDataBlock* pBlock = NULL;
|
||||||
while (1) {
|
while (1) {
|
||||||
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
pBlock = pOperator->pDownstream[0]->nextDataFn(pOperator->pDownstream[0], newgroup);
|
pBlock = pOperator->pDownstream[0]->getNextFn(pOperator->pDownstream[0], newgroup);
|
||||||
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -6448,7 +6520,7 @@ static SSDataBlock* doFilter(void* param, bool* newgroup) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock *pBlock = pOperator->pDownstream[0]->nextDataFn(pOperator->pDownstream[0], newgroup);
|
SSDataBlock *pBlock = pOperator->pDownstream[0]->getNextFn(pOperator->pDownstream[0], newgroup);
|
||||||
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -6491,7 +6563,7 @@ static SSDataBlock* doIntervalAgg(void* param, bool* newgroup) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = downstream->nextDataFn(downstream, newgroup);
|
SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup);
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -6551,7 +6623,7 @@ static SSDataBlock* doAllIntervalAgg(void* param, bool* newgroup) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = downstream->nextDataFn(downstream, newgroup);
|
SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup);
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -6614,7 +6686,7 @@ static SSDataBlock* doSTableIntervalAgg(void* param, bool* newgroup) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = downstream->nextDataFn(downstream, newgroup);
|
SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup);
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -6669,7 +6741,7 @@ static SSDataBlock* doAllSTableIntervalAgg(void* param, bool* newgroup) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = downstream->nextDataFn(downstream, newgroup);
|
SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup);
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -6804,7 +6876,7 @@ static SSDataBlock* doStateWindowAgg(void *param, bool* newgroup) {
|
||||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||||
while (1) {
|
while (1) {
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = downstream->nextDataFn(downstream, newgroup);
|
SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup);
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -6866,7 +6938,7 @@ static SSDataBlock* doSessionWindowAgg(void* param, bool* newgroup) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = downstream->nextDataFn(downstream, newgroup);
|
SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup);
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
break;
|
break;
|
||||||
|
@ -6919,7 +6991,7 @@ static SSDataBlock* hashGroupbyAggregate(void* param, bool* newgroup) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = downstream->nextDataFn(downstream, newgroup);
|
SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup);
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
break;
|
break;
|
||||||
|
@ -7004,7 +7076,7 @@ static SSDataBlock* doFill(void* param, bool* newgroup) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = pOperator->pDownstream[0]->nextDataFn(pOperator->pDownstream[0], newgroup);
|
SSDataBlock* pBlock = pOperator->pDownstream[0]->getNextFn(pOperator->pDownstream[0], newgroup);
|
||||||
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
||||||
if (*newgroup) {
|
if (*newgroup) {
|
||||||
|
@ -7161,13 +7233,13 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SArray* pE
|
||||||
pOperator->name = "TableAggregate";
|
pOperator->name = "TableAggregate";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_AGG;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_AGG;
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blockingOptr = true;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pExpr = exprArrayDup(pExprInfo);
|
pOperator->pExpr = exprArrayDup(pExprInfo);
|
||||||
pOperator->numOfOutput = taosArrayGetSize(pExprInfo);
|
pOperator->numOfOutput = taosArrayGetSize(pExprInfo);
|
||||||
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
pOperator->nextDataFn = doAggregate;
|
pOperator->getNextFn = doAggregate;
|
||||||
pOperator->closeFn = destroyAggOperatorInfo;
|
pOperator->closeFn = destroyAggOperatorInfo;
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
|
||||||
|
@ -7216,17 +7288,17 @@ static void destroyGroupbyOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
tfree(pInfo->prevData);
|
tfree(pInfo->prevData);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyProjectOperatorInfo(void* param, int32_t numOfOutput) {
|
void destroyProjectOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
SProjectOperatorInfo* pInfo = (SProjectOperatorInfo*) param;
|
SProjectOperatorInfo* pInfo = (SProjectOperatorInfo*) param;
|
||||||
doDestroyBasicInfo(&pInfo->binfo, numOfOutput);
|
doDestroyBasicInfo(&pInfo->binfo, numOfOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyTagScanOperatorInfo(void* param, int32_t numOfOutput) {
|
void destroyTagScanOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
STagScanInfo* pInfo = (STagScanInfo*) param;
|
STagScanInfo* pInfo = (STagScanInfo*) param;
|
||||||
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput) {
|
void destroyOrderOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
SOrderOperatorInfo* pInfo = (SOrderOperatorInfo*) param;
|
SOrderOperatorInfo* pInfo = (SOrderOperatorInfo*) param;
|
||||||
pInfo->pDataBlock = blockDataDestroy(pInfo->pDataBlock);
|
pInfo->pDataBlock = blockDataDestroy(pInfo->pDataBlock);
|
||||||
|
|
||||||
|
@ -7256,6 +7328,17 @@ static void destroySysTableScannerOperatorInfo(void* param, int32_t numOfOutput)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
|
SExchangeInfo* pExInfo = (SExchangeInfo*) param;
|
||||||
|
taosArrayDestroy(pExInfo->pSources);
|
||||||
|
taosArrayDestroy(pExInfo->pSourceDataInfo);
|
||||||
|
if (pExInfo->pResult != NULL) {
|
||||||
|
blockDataDestroy(pExInfo->pResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
tsem_destroy(&pExInfo->ready);
|
||||||
|
}
|
||||||
|
|
||||||
SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo) {
|
SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo) {
|
||||||
SAggOperatorInfo* pInfo = calloc(1, sizeof(SAggOperatorInfo));
|
SAggOperatorInfo* pInfo = calloc(1, sizeof(SAggOperatorInfo));
|
||||||
|
|
||||||
|
@ -7270,13 +7353,13 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SArray
|
||||||
pOperator->name = "MultiTableAggregate";
|
pOperator->name = "MultiTableAggregate";
|
||||||
// pOperator->operatorType = OP_MultiTableAggregate;
|
// pOperator->operatorType = OP_MultiTableAggregate;
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blockingOptr = true;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pExpr = exprArrayDup(pExprInfo);
|
pOperator->pExpr = exprArrayDup(pExprInfo);
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
pOperator->nextDataFn = doMultiTableAggregate;
|
pOperator->getNextFn = doMultiTableAggregate;
|
||||||
pOperator->closeFn = destroyAggOperatorInfo;
|
pOperator->closeFn = destroyAggOperatorInfo;
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
|
||||||
|
@ -7296,12 +7379,12 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SArray* pExp
|
||||||
pOperator->name = "ProjectOperator";
|
pOperator->name = "ProjectOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_PROJECT;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_PROJECT;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pExpr = exprArrayDup(pExprInfo);
|
pOperator->pExpr = exprArrayDup(pExprInfo);
|
||||||
pOperator->numOfOutput = taosArrayGetSize(pExprInfo);
|
pOperator->numOfOutput = taosArrayGetSize(pExprInfo);
|
||||||
|
|
||||||
pOperator->nextDataFn = doProjectOperation;
|
pOperator->getNextFn = doProjectOperation;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
pOperator->closeFn = destroyProjectOperatorInfo;
|
pOperator->closeFn = destroyProjectOperatorInfo;
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -7351,8 +7434,8 @@ SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorIn
|
||||||
pOperator->name = "LimitOperator";
|
pOperator->name = "LimitOperator";
|
||||||
// pOperator->operatorType = OP_Limit;
|
// pOperator->operatorType = OP_Limit;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->nextDataFn = doLimit;
|
pOperator->getNextFn = doLimit;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
pOperator->pRuntimeEnv = pRuntimeEnv;
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -7383,13 +7466,13 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SArray* pEx
|
||||||
pOperator->name = "TimeIntervalAggOperator";
|
pOperator->name = "TimeIntervalAggOperator";
|
||||||
// pOperator->operatorType = OP_TimeWindow;
|
// pOperator->operatorType = OP_TimeWindow;
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blockingOptr = true;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->pExpr = exprArrayDup(pExprInfo);
|
pOperator->pExpr = exprArrayDup(pExprInfo);
|
||||||
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
pOperator->numOfOutput = taosArrayGetSize(pExprInfo);
|
pOperator->numOfOutput = taosArrayGetSize(pExprInfo);
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->nextDataFn = doIntervalAgg;
|
pOperator->getNextFn = doIntervalAgg;
|
||||||
pOperator->closeFn = destroyBasicOperatorInfo;
|
pOperator->closeFn = destroyBasicOperatorInfo;
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -7408,12 +7491,12 @@ SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, S
|
||||||
pOperator->name = "AllTimeIntervalAggOperator";
|
pOperator->name = "AllTimeIntervalAggOperator";
|
||||||
// pOperator->operatorType = OP_AllTimeWindow;
|
// pOperator->operatorType = OP_AllTimeWindow;
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blockingOptr = true;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->pExpr = pExpr;
|
pOperator->pExpr = pExpr;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
pOperator->pRuntimeEnv = pRuntimeEnv;
|
||||||
pOperator->nextDataFn = doAllIntervalAgg;
|
pOperator->getNextFn = doAllIntervalAgg;
|
||||||
pOperator->closeFn = destroyBasicOperatorInfo;
|
pOperator->closeFn = destroyBasicOperatorInfo;
|
||||||
|
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -7432,12 +7515,12 @@ SOperatorInfo* createStatewindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOper
|
||||||
pOperator->name = "StateWindowOperator";
|
pOperator->name = "StateWindowOperator";
|
||||||
// pOperator->operatorType = OP_StateWindow;
|
// pOperator->operatorType = OP_StateWindow;
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blockingOptr = true;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->pExpr = pExpr;
|
pOperator->pExpr = pExpr;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
pOperator->pRuntimeEnv = pRuntimeEnv;
|
||||||
pOperator->nextDataFn = doStateWindowAgg;
|
pOperator->getNextFn = doStateWindowAgg;
|
||||||
pOperator->closeFn = destroyStateWindowOperatorInfo;
|
pOperator->closeFn = destroyStateWindowOperatorInfo;
|
||||||
|
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -7457,12 +7540,12 @@ SOperatorInfo* createSWindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperator
|
||||||
pOperator->name = "SessionWindowAggOperator";
|
pOperator->name = "SessionWindowAggOperator";
|
||||||
// pOperator->operatorType = OP_SessionWindow;
|
// pOperator->operatorType = OP_SessionWindow;
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blockingOptr = true;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->pExpr = pExpr;
|
pOperator->pExpr = pExpr;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
pOperator->pRuntimeEnv = pRuntimeEnv;
|
||||||
pOperator->nextDataFn = doSessionWindowAgg;
|
pOperator->getNextFn = doSessionWindowAgg;
|
||||||
pOperator->closeFn = destroySWindowOperatorInfo;
|
pOperator->closeFn = destroySWindowOperatorInfo;
|
||||||
|
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -7480,13 +7563,13 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim
|
||||||
pOperator->name = "MultiTableTimeIntervalOperator";
|
pOperator->name = "MultiTableTimeIntervalOperator";
|
||||||
// pOperator->operatorType = OP_MultiTableTimeInterval;
|
// pOperator->operatorType = OP_MultiTableTimeInterval;
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blockingOptr = true;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->pExpr = pExpr;
|
pOperator->pExpr = pExpr;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
pOperator->pRuntimeEnv = pRuntimeEnv;
|
||||||
|
|
||||||
pOperator->nextDataFn = doSTableIntervalAgg;
|
pOperator->getNextFn = doSTableIntervalAgg;
|
||||||
pOperator->closeFn = destroyBasicOperatorInfo;
|
pOperator->closeFn = destroyBasicOperatorInfo;
|
||||||
|
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -7504,13 +7587,13 @@ SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRun
|
||||||
pOperator->name = "AllMultiTableTimeIntervalOperator";
|
pOperator->name = "AllMultiTableTimeIntervalOperator";
|
||||||
// pOperator->operatorType = OP_AllMultiTableTimeInterval;
|
// pOperator->operatorType = OP_AllMultiTableTimeInterval;
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blockingOptr = true;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->pExpr = pExpr;
|
pOperator->pExpr = pExpr;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
pOperator->pRuntimeEnv = pRuntimeEnv;
|
||||||
|
|
||||||
pOperator->nextDataFn = doAllSTableIntervalAgg;
|
pOperator->getNextFn = doAllSTableIntervalAgg;
|
||||||
pOperator->closeFn = destroyBasicOperatorInfo;
|
pOperator->closeFn = destroyBasicOperatorInfo;
|
||||||
|
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -7536,13 +7619,13 @@ SOperatorInfo* createGroupbyOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperator
|
||||||
SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo));
|
||||||
pOperator->name = "GroupbyAggOperator";
|
pOperator->name = "GroupbyAggOperator";
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blockingOptr = true;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
// pOperator->operatorType = OP_Groupby;
|
// pOperator->operatorType = OP_Groupby;
|
||||||
pOperator->pExpr = pExpr;
|
pOperator->pExpr = pExpr;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
pOperator->pRuntimeEnv = pRuntimeEnv;
|
||||||
pOperator->nextDataFn = hashGroupbyAggregate;
|
pOperator->getNextFn = hashGroupbyAggregate;
|
||||||
pOperator->closeFn = destroyGroupbyOperatorInfo;
|
pOperator->closeFn = destroyGroupbyOperatorInfo;
|
||||||
|
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -7575,13 +7658,13 @@ SOperatorInfo* createFillOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInf
|
||||||
|
|
||||||
pOperator->name = "FillOperator";
|
pOperator->name = "FillOperator";
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
// pOperator->operatorType = OP_Fill;
|
// pOperator->operatorType = OP_Fill;
|
||||||
pOperator->pExpr = pExpr;
|
pOperator->pExpr = pExpr;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
pOperator->pRuntimeEnv = pRuntimeEnv;
|
||||||
pOperator->nextDataFn = doFill;
|
pOperator->getNextFn = doFill;
|
||||||
pOperator->closeFn = destroySFillOperatorInfo;
|
pOperator->closeFn = destroySFillOperatorInfo;
|
||||||
|
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -7626,10 +7709,9 @@ SOperatorInfo* createSLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorI
|
||||||
pOperator->name = "SLimitOperator";
|
pOperator->name = "SLimitOperator";
|
||||||
// pOperator->operatorType = OP_SLimit;
|
// pOperator->operatorType = OP_SLimit;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
// pOperator->exec = doSLimit;
|
// pOperator->exec = doSLimit;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
|
||||||
pOperator->closeFn = destroySlimitOperatorInfo;
|
pOperator->closeFn = destroySlimitOperatorInfo;
|
||||||
|
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
@ -7766,6 +7848,7 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
|
||||||
return (pRes->info.rows == 0)? NULL:pInfo->pRes;
|
return (pRes->info.rows == 0)? NULL:pInfo->pRes;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createTagScanOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput) {
|
SOperatorInfo* createTagScanOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput) {
|
||||||
|
@ -7782,9 +7865,9 @@ SOperatorInfo* createTagScanOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo
|
||||||
pOperator->name = "SeqTableTagScan";
|
pOperator->name = "SeqTableTagScan";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->nextDataFn = doTagScan;
|
pOperator->getNextFn = doTagScan;
|
||||||
pOperator->pExpr = pExpr;
|
pOperator->pExpr = pExpr;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
pOperator->pRuntimeEnv = pRuntimeEnv;
|
||||||
|
@ -7854,7 +7937,7 @@ static SSDataBlock* hashDistinct(void* param, bool* newgroup) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
pBlock = pOperator->pDownstream[0]->nextDataFn(pOperator->pDownstream[0], newgroup);
|
pBlock = pOperator->pDownstream[0]->getNextFn(pOperator->pDownstream[0], newgroup);
|
||||||
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -7920,13 +8003,13 @@ SOperatorInfo* createDistinctOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperato
|
||||||
SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo));
|
||||||
pOperator->name = "DistinctOperator";
|
pOperator->name = "DistinctOperator";
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
// pOperator->operatorType = OP_Distinct;
|
// pOperator->operatorType = OP_Distinct;
|
||||||
pOperator->pExpr = pExpr;
|
pOperator->pExpr = pExpr;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
pOperator->pRuntimeEnv = pRuntimeEnv;
|
||||||
pOperator->nextDataFn = hashDistinct;
|
pOperator->getNextFn = hashDistinct;
|
||||||
pOperator->pExpr = pExpr;
|
pOperator->pExpr = pExpr;
|
||||||
pOperator->closeFn = destroyDistinctOperatorInfo;
|
pOperator->closeFn = destroyDistinctOperatorInfo;
|
||||||
|
|
||||||
|
@ -8080,7 +8163,7 @@ static int32_t doCreateTableGroup(void* metaHandle, int32_t tableType, uint64_t
|
||||||
static SArray* extractTableIdList(const STableGroupInfo* pTableGroupInfo);
|
static SArray* extractTableIdList(const STableGroupInfo* pTableGroupInfo);
|
||||||
static SArray* extractScanColumnId(SNodeList* pNodeList);
|
static SArray* extractScanColumnId(SNodeList* pNodeList);
|
||||||
|
|
||||||
SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo, SQueryErrorInfo *errInfo) {
|
SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo) {
|
||||||
if (nodeType(pPhyNode) == QUERY_NODE_PHYSICAL_PLAN_PROJECT) { // ignore the project node
|
if (nodeType(pPhyNode) == QUERY_NODE_PHYSICAL_PLAN_PROJECT) { // ignore the project node
|
||||||
pPhyNode = nodesListGetNode(pPhyNode->pChildren, 0);
|
pPhyNode = nodesListGetNode(pPhyNode->pChildren, 0);
|
||||||
}
|
}
|
||||||
|
@ -8089,21 +8172,11 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
|
||||||
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == nodeType(pPhyNode)) {
|
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == nodeType(pPhyNode)) {
|
||||||
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode;
|
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode;
|
||||||
|
|
||||||
if (TSDB_SUPER_TABLE != pScanPhyNode->tableType) {
|
|
||||||
char tableFName[TSDB_TABLE_FNAME_LEN];
|
|
||||||
tNameExtractFullName(&pScanPhyNode->tableName, tableFName);
|
|
||||||
|
|
||||||
int32_t code = vnodeValidateTableHash(pHandle->config, tableFName);
|
|
||||||
if (code) {
|
|
||||||
errInfo->code = code;
|
|
||||||
errInfo->tableName = pScanPhyNode->tableName;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t numOfCols = LIST_LENGTH(pScanPhyNode->pScanCols);
|
size_t numOfCols = LIST_LENGTH(pScanPhyNode->pScanCols);
|
||||||
tsdbReaderT pDataReader = doCreateDataReader((STableScanPhysiNode*)pPhyNode, pHandle, (uint64_t)queryId, taskId);
|
tsdbReaderT pDataReader = doCreateDataReader((STableScanPhysiNode*)pPhyNode, pHandle, (uint64_t)queryId, taskId);
|
||||||
|
if (NULL == pDataReader) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
int32_t code = doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo, queryId, taskId);
|
int32_t code = doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo, queryId, taskId);
|
||||||
return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pScanPhyNode->count,
|
return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pScanPhyNode->count,
|
||||||
pScanPhyNode->reverse, pTaskInfo);
|
pScanPhyNode->reverse, pTaskInfo);
|
||||||
|
@ -8142,10 +8215,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
|
||||||
|
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i);
|
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i);
|
||||||
SOperatorInfo* op = doCreateOperatorTreeNode(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo, errInfo);
|
SOperatorInfo* op = doCreateOperatorTreeNode(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||||
if (errInfo->code) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SArray* pExprInfo = createExprInfo((SAggPhysiNode*)pPhyNode);
|
SArray* pExprInfo = createExprInfo((SAggPhysiNode*)pPhyNode);
|
||||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc);
|
||||||
|
@ -8264,7 +8334,7 @@ tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle*
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, SQueryErrorInfo *errInfo) {
|
int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId) {
|
||||||
uint64_t queryId = pPlan->id.queryId;
|
uint64_t queryId = pPlan->id.queryId;
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -8275,9 +8345,9 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
|
||||||
}
|
}
|
||||||
|
|
||||||
STableGroupInfo group = {0};
|
STableGroupInfo group = {0};
|
||||||
(*pTaskInfo)->pRoot = doCreateOperatorTreeNode(pPlan->pNode, *pTaskInfo, pHandle, queryId, taskId, &group, errInfo);
|
(*pTaskInfo)->pRoot = doCreateOperatorTreeNode(pPlan->pNode, *pTaskInfo, pHandle, queryId, taskId, &group);
|
||||||
if (errInfo->code) {
|
if (NULL == (*pTaskInfo)->pRoot) {
|
||||||
code = errInfo->code;
|
code = terrno;
|
||||||
goto _complete;
|
goto _complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,9 +201,9 @@ SOperatorInfo* createDummyOperator(int32_t startVal, int32_t numOfBlocks, int32_
|
||||||
pOperator->name = "dummyInputOpertor4Test";
|
pOperator->name = "dummyInputOpertor4Test";
|
||||||
|
|
||||||
if (numOfCols == 1) {
|
if (numOfCols == 1) {
|
||||||
pOperator->nextDataFn = getDummyBlock;
|
pOperator->getNextFn = getDummyBlock;
|
||||||
} else {
|
} else {
|
||||||
pOperator->nextDataFn = get2ColsDummyBlock;
|
pOperator->getNextFn = get2ColsDummyBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDummyInputInfo *pInfo = (SDummyInputInfo*) calloc(1, sizeof(SDummyInputInfo));
|
SDummyInputInfo *pInfo = (SDummyInputInfo*) calloc(1, sizeof(SDummyInputInfo));
|
||||||
|
@ -946,7 +946,7 @@ TEST(testCase, build_executor_tree_Test) {
|
||||||
int32_t code = qStringToSubplan(msg, &plan);
|
int32_t code = qStringToSubplan(msg, &plan);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
code = qCreateExecTask(&handle, 2, 1, plan, (void**) &pTaskInfo, &sinkHandle, NULL);
|
code = qCreateExecTask(&handle, 2, 1, plan, (void**) &pTaskInfo, &sinkHandle);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -971,7 +971,7 @@ TEST(testCase, inMem_sort_Test) {
|
||||||
SOperatorInfo* pOperator = createOrderOperatorInfo(createDummyOperator(10000, 5, 1000, data_asc, 1), pExprInfo, pOrderVal, NULL);
|
SOperatorInfo* pOperator = createOrderOperatorInfo(createDummyOperator(10000, 5, 1000, data_asc, 1), pExprInfo, pOrderVal, NULL);
|
||||||
|
|
||||||
bool newgroup = false;
|
bool newgroup = false;
|
||||||
SSDataBlock* pRes = pOperator->nextDataFn(pOperator, &newgroup);
|
SSDataBlock* pRes = pOperator->getNextFn(pOperator, &newgroup);
|
||||||
|
|
||||||
SColumnInfoData* pCol1 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 0));
|
SColumnInfoData* pCol1 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 0));
|
||||||
SColumnInfoData* pCol2 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 1));
|
SColumnInfoData* pCol2 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 1));
|
||||||
|
@ -1019,7 +1019,7 @@ TEST(testCase, external_sort_Test) {
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
|
|
||||||
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
|
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
|
||||||
SOrder o = {0};
|
SOrder o = {0};
|
||||||
|
@ -1049,7 +1049,7 @@ TEST(testCase, external_sort_Test) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
int64_t s = taosGetTimestampUs();
|
int64_t s = taosGetTimestampUs();
|
||||||
pRes = pOperator->nextDataFn(pOperator, &newgroup);
|
pRes = pOperator->getNextFn(pOperator, &newgroup);
|
||||||
|
|
||||||
int64_t e = taosGetTimestampUs();
|
int64_t e = taosGetTimestampUs();
|
||||||
if (t++ == 1) {
|
if (t++ == 1) {
|
||||||
|
@ -1080,7 +1080,7 @@ TEST(testCase, external_sort_Test) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, sorted_merge_Test) {
|
TEST(testCase, sorted_merge_Test) {
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
|
|
||||||
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
|
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
|
||||||
SOrder o = {0};
|
SOrder o = {0};
|
||||||
|
@ -1121,7 +1121,7 @@ TEST(testCase, sorted_merge_Test) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
int64_t s = taosGetTimestampUs();
|
int64_t s = taosGetTimestampUs();
|
||||||
pRes = pOperator->nextDataFn(pOperator, &newgroup);
|
pRes = pOperator->getNextFn(pOperator, &newgroup);
|
||||||
|
|
||||||
int64_t e = taosGetTimestampUs();
|
int64_t e = taosGetTimestampUs();
|
||||||
if (t++ == 1) {
|
if (t++ == 1) {
|
||||||
|
@ -1152,7 +1152,7 @@ TEST(testCase, sorted_merge_Test) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, time_interval_Operator_Test) {
|
TEST(testCase, time_interval_Operator_Test) {
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
|
|
||||||
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
|
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
|
||||||
SOrder o = {0};
|
SOrder o = {0};
|
||||||
|
@ -1199,7 +1199,7 @@ TEST(testCase, time_interval_Operator_Test) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
int64_t s = taosGetTimestampUs();
|
int64_t s = taosGetTimestampUs();
|
||||||
pRes = pOperator->nextDataFn(pOperator, &newgroup);
|
pRes = pOperator->getNextFn(pOperator, &newgroup);
|
||||||
|
|
||||||
int64_t e = taosGetTimestampUs();
|
int64_t e = taosGetTimestampUs();
|
||||||
if (t++ == 1) {
|
if (t++ == 1) {
|
||||||
|
@ -1230,4 +1230,4 @@ TEST(testCase, time_interval_Operator_Test) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnosti
|
|
@ -25,7 +25,7 @@
|
||||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
|
||||||
TEST(testCase, linear_hash_Tests) {
|
TEST(testCase, linear_hash_Tests) {
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
|
|
||||||
_hash_fn_t fn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT);
|
_hash_fn_t fn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT);
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -341,6 +341,8 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
|
||||||
// TODO: iterator mem and tidex
|
// TODO: iterator mem and tidex
|
||||||
STermValueType s = kTypeValue;
|
STermValueType s = kTypeValue;
|
||||||
|
|
||||||
|
int64_t st = taosGetTimestampUs();
|
||||||
|
|
||||||
SIdxTempResult* tr = sIdxTempResultCreate();
|
SIdxTempResult* tr = sIdxTempResultCreate();
|
||||||
if (0 == indexCacheSearch(cache, query, tr, &s)) {
|
if (0 == indexCacheSearch(cache, query, tr, &s)) {
|
||||||
if (s == kTypeDeletion) {
|
if (s == kTypeDeletion) {
|
||||||
|
@ -348,17 +350,23 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
|
||||||
// coloum already drop by other oper, no need to query tindex
|
// coloum already drop by other oper, no need to query tindex
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
st = taosGetTimestampUs();
|
||||||
if (0 != indexTFileSearch(sIdx->tindex, query, tr)) {
|
if (0 != indexTFileSearch(sIdx->tindex, query, tr)) {
|
||||||
indexError("corrupt at index(TFile) col:%s val: %s", term->colName, term->colVal);
|
indexError("corrupt at index(TFile) col:%s val: %s", term->colName, term->colVal);
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
int64_t tfCost = taosGetTimestampUs() - st;
|
||||||
|
indexInfo("tfile search cost: %" PRIu64 "us", tfCost);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
indexError("corrupt at index(cache) col:%s val: %s", term->colName, term->colVal);
|
indexError("corrupt at index(cache) col:%s val: %s", term->colName, term->colVal);
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
int64_t cost = taosGetTimestampUs() - st;
|
||||||
|
indexInfo("search cost: %" PRIu64 "us", cost);
|
||||||
|
|
||||||
sIdxTempResultMergeTo(*result, tr);
|
sIdxTempResultMergeTo(*result, tr);
|
||||||
|
|
||||||
sIdxTempResultDestroy(tr);
|
sIdxTempResultDestroy(tr);
|
||||||
return 0;
|
return 0;
|
||||||
END:
|
END:
|
||||||
|
|
|
@ -276,7 +276,12 @@ static int indexQueryMem(MemTable* mem, CacheTerm* ct, EIndexQueryType qtype, SI
|
||||||
} else if (c->operaType == DEL_VALUE) {
|
} else if (c->operaType == DEL_VALUE) {
|
||||||
INDEX_MERGE_ADD_DEL(tr->added, tr->deled, c->uid)
|
INDEX_MERGE_ADD_DEL(tr->added, tr->deled, c->uid)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (qtype == QUERY_PREFIX) {
|
||||||
|
} else if (qtype == QUERY_SUFFIX) {
|
||||||
|
} else if (qtype == QUERY_RANGE) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,6 +289,7 @@ static int indexQueryMem(MemTable* mem, CacheTerm* ct, EIndexQueryType qtype, SI
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int indexCacheSearch(void* cache, SIndexTermQuery* query, SIdxTempResult* result, STermValueType* s) {
|
int indexCacheSearch(void* cache, SIndexTermQuery* query, SIdxTempResult* result, STermValueType* s) {
|
||||||
|
int64_t st = taosGetTimestampUs();
|
||||||
if (cache == NULL) {
|
if (cache == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -312,12 +318,14 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SIdxTempResult* result
|
||||||
// continue search in imm
|
// continue search in imm
|
||||||
ret = indexQueryMem(imm, &ct, qtype, result, s);
|
ret = indexQueryMem(imm, &ct, qtype, result, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasJson) {
|
if (hasJson) {
|
||||||
tfree(p);
|
tfree(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
indexMemUnRef(mem);
|
indexMemUnRef(mem);
|
||||||
indexMemUnRef(imm);
|
indexMemUnRef(imm);
|
||||||
|
indexInfo("cache search, time cost %" PRIu64 "us", taosGetTimestampUs() - st);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SIdxTempResul
|
||||||
bool hasJson = INDEX_TYPE_CONTAIN_EXTERN_TYPE(term->colType, TSDB_DATA_TYPE_JSON);
|
bool hasJson = INDEX_TYPE_CONTAIN_EXTERN_TYPE(term->colType, TSDB_DATA_TYPE_JSON);
|
||||||
EIndexQueryType qtype = query->qType;
|
EIndexQueryType qtype = query->qType;
|
||||||
|
|
||||||
SArray* result = taosArrayInit(16, sizeof(uint64_t));
|
// SArray* result = taosArrayInit(16, sizeof(uint64_t));
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
// refactor to callback later
|
// refactor to callback later
|
||||||
if (qtype == QUERY_TERM) {
|
if (qtype == QUERY_TERM) {
|
||||||
|
@ -200,11 +200,18 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SIdxTempResul
|
||||||
p = indexPackJsonData(term);
|
p = indexPackJsonData(term);
|
||||||
sz = strlen(p);
|
sz = strlen(p);
|
||||||
}
|
}
|
||||||
|
int64_t st = taosGetTimestampUs();
|
||||||
FstSlice key = fstSliceCreate(p, sz);
|
FstSlice key = fstSliceCreate(p, sz);
|
||||||
if (fstGet(reader->fst, &key, &offset)) {
|
if (fstGet(reader->fst, &key, &offset)) {
|
||||||
indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, found table info in tindex", term->suid, term->colName,
|
int64_t et = taosGetTimestampUs();
|
||||||
term->colVal);
|
int64_t cost = et - st;
|
||||||
ret = tfileReaderLoadTableIds(reader, offset, result);
|
indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, found table info in tindex, time cost: %" PRIu64 "us",
|
||||||
|
term->suid, term->colName, term->colVal, cost);
|
||||||
|
|
||||||
|
ret = tfileReaderLoadTableIds(reader, offset, tr->total);
|
||||||
|
cost = taosGetTimestampUs() - et;
|
||||||
|
indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, load all table info, time cost: %" PRIu64 "us", term->suid,
|
||||||
|
term->colName, term->colVal, cost);
|
||||||
} else {
|
} else {
|
||||||
indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, not found table info in tindex", term->suid, term->colName,
|
indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, not found table info in tindex", term->suid, term->colName,
|
||||||
term->colVal);
|
term->colVal);
|
||||||
|
@ -225,8 +232,8 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SIdxTempResul
|
||||||
}
|
}
|
||||||
tfileReaderUnRef(reader);
|
tfileReaderUnRef(reader);
|
||||||
|
|
||||||
taosArrayAddAll(tr->total, result);
|
// taosArrayAddAll(tr->total, result);
|
||||||
taosArrayDestroy(result);
|
// taosArrayDestroy(result);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -391,6 +398,7 @@ int indexTFileSearch(void* tfile, SIndexTermQuery* query, SIdxTempResult* result
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t st = taosGetTimestampUs();
|
||||||
IndexTFile* pTfile = tfile;
|
IndexTFile* pTfile = tfile;
|
||||||
|
|
||||||
SIndexTerm* term = query->term;
|
SIndexTerm* term = query->term;
|
||||||
|
@ -399,6 +407,8 @@ int indexTFileSearch(void* tfile, SIndexTermQuery* query, SIdxTempResult* result
|
||||||
if (reader == NULL) {
|
if (reader == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int64_t cost = taosGetTimestampUs() - st;
|
||||||
|
indexInfo("index tfile stage 1 cost: %" PRId64 "", cost);
|
||||||
|
|
||||||
return tfileReaderSearch(reader, query, result);
|
return tfileReaderSearch(reader, query, result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,7 +258,7 @@ void checkFstCheckIterator() {
|
||||||
// prefix search
|
// prefix search
|
||||||
std::vector<uint64_t> result;
|
std::vector<uint64_t> result;
|
||||||
|
|
||||||
AutomationCtx* ctx = automCtxCreate((void*)"ab", AUTOMATION_ALWAYS);
|
AutomationCtx* ctx = automCtxCreate((void*)"H", AUTOMATION_PREFIX);
|
||||||
m->Search(ctx, result);
|
m->Search(ctx, result);
|
||||||
std::cout << "size: " << result.size() << std::endl;
|
std::cout << "size: " << result.size() << std::endl;
|
||||||
// assert(result.size() == count);
|
// assert(result.size() == count);
|
||||||
|
@ -328,11 +328,11 @@ void iterTFileReader(char* path, char* uid, char* colName, char* ver) {
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
// tool to check all kind of fst test
|
// tool to check all kind of fst test
|
||||||
// if (argc > 1) { validateTFile(argv[1]); }
|
// if (argc > 1) { validateTFile(argv[1]); }
|
||||||
if (argc > 4) {
|
// if (argc > 4) {
|
||||||
// path suid colName ver
|
// path suid colName ver
|
||||||
iterTFileReader(argv[1], argv[2], argv[3], argv[4]);
|
// iterTFileReader(argv[1], argv[2], argv[3], argv[4]);
|
||||||
}
|
//}
|
||||||
// checkFstCheckIterator();
|
checkFstCheckIterator();
|
||||||
// checkFstLongTerm();
|
// checkFstLongTerm();
|
||||||
// checkFstPrefixSearch();
|
// checkFstPrefixSearch();
|
||||||
|
|
||||||
|
|
|
@ -768,7 +768,7 @@ class IndexObj {
|
||||||
int64_t s = taosGetTimestampUs();
|
int64_t s = taosGetTimestampUs();
|
||||||
if (Search(mq, result) == 0) {
|
if (Search(mq, result) == 0) {
|
||||||
int64_t e = taosGetTimestampUs();
|
int64_t e = taosGetTimestampUs();
|
||||||
std::cout << "search one successfully and time cost:" << e - s << "\tquery col:" << colName
|
std::cout << "search one successfully and time cost:" << e - s << "us\tquery col:" << colName
|
||||||
<< "\t val: " << colVal << "\t size:" << taosArrayGetSize(result) << std::endl;
|
<< "\t val: " << colVal << "\t size:" << taosArrayGetSize(result) << std::endl;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
@ -1106,6 +1106,7 @@ TEST_F(IndexEnv2, testIndex_del) {
|
||||||
}
|
}
|
||||||
index->Del("tag10", "Hello", 12);
|
index->Del("tag10", "Hello", 12);
|
||||||
index->Del("tag10", "Hello", 11);
|
index->Del("tag10", "Hello", 11);
|
||||||
|
EXPECT_EQ(98, index->SearchOne("tag10", "Hello"));
|
||||||
|
|
||||||
index->WriteMultiMillonData("tag10", "xxxxxxxxxxxxxx", 100 * 10000);
|
index->WriteMultiMillonData("tag10", "xxxxxxxxxxxxxx", 100 * 10000);
|
||||||
index->Del("tag10", "Hello", 17);
|
index->Del("tag10", "Hello", 17);
|
||||||
|
|
|
@ -134,7 +134,6 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
COPY_SCALAR_FIELD(datum.d);
|
COPY_SCALAR_FIELD(datum.d);
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY:
|
case TSDB_DATA_TYPE_VARBINARY:
|
||||||
|
@ -187,6 +186,12 @@ static SNode* groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode
|
||||||
return (SNode*)pDst;
|
return (SNode*)pDst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SNode* fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) {
|
||||||
|
COPY_SCALAR_FIELD(mode);
|
||||||
|
CLONE_NODE_FIELD(pValues);
|
||||||
|
return (SNode*)pDst;
|
||||||
|
}
|
||||||
|
|
||||||
static SNode* logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) {
|
static SNode* logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(id);
|
COPY_SCALAR_FIELD(id);
|
||||||
CLONE_NODE_LIST_FIELD(pTargets);
|
CLONE_NODE_LIST_FIELD(pTargets);
|
||||||
|
@ -252,6 +257,17 @@ static SNode* logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNo
|
||||||
return (SNode*)pDst;
|
return (SNode*)pDst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) {
|
||||||
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
|
COPY_SCALAR_FIELD(winType);
|
||||||
|
CLONE_NODE_LIST_FIELD(pFuncs);
|
||||||
|
COPY_SCALAR_FIELD(interval);
|
||||||
|
COPY_SCALAR_FIELD(offset);
|
||||||
|
COPY_SCALAR_FIELD(sliding);
|
||||||
|
CLONE_NODE_FIELD(pFill);
|
||||||
|
return (SNode*)pDst;
|
||||||
|
}
|
||||||
|
|
||||||
static SNode* logicSubplanCopy(const SSubLogicPlan* pSrc, SSubLogicPlan* pDst) {
|
static SNode* logicSubplanCopy(const SSubLogicPlan* pSrc, SSubLogicPlan* pDst) {
|
||||||
CLONE_NODE_FIELD(pNode);
|
CLONE_NODE_FIELD(pNode);
|
||||||
COPY_SCALAR_FIELD(subplanType);
|
COPY_SCALAR_FIELD(subplanType);
|
||||||
|
@ -313,6 +329,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
|
||||||
case QUERY_NODE_ORDER_BY_EXPR:
|
case QUERY_NODE_ORDER_BY_EXPR:
|
||||||
case QUERY_NODE_LIMIT:
|
case QUERY_NODE_LIMIT:
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_FILL:
|
||||||
|
return fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst);
|
||||||
case QUERY_NODE_DATABLOCK_DESC:
|
case QUERY_NODE_DATABLOCK_DESC:
|
||||||
return dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst);
|
return dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst);
|
||||||
case QUERY_NODE_SLOT_DESC:
|
case QUERY_NODE_SLOT_DESC:
|
||||||
|
@ -329,6 +347,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
|
||||||
return logicVnodeModifCopy((const SVnodeModifLogicNode*)pNode, (SVnodeModifLogicNode*)pDst);
|
return logicVnodeModifCopy((const SVnodeModifLogicNode*)pNode, (SVnodeModifLogicNode*)pDst);
|
||||||
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
||||||
return logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst);
|
return logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst);
|
||||||
|
case QUERY_NODE_LOGIC_PLAN_WINDOW:
|
||||||
|
return logicWindowCopy((const SWindowLogicNode*)pNode, (SWindowLogicNode*)pDst);
|
||||||
case QUERY_NODE_LOGIC_SUBPLAN:
|
case QUERY_NODE_LOGIC_SUBPLAN:
|
||||||
return logicSubplanCopy((const SSubLogicPlan*)pNode, (SSubLogicPlan*)pDst);
|
return logicSubplanCopy((const SSubLogicPlan*)pNode, (SSubLogicPlan*)pDst);
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -119,6 +119,8 @@ const char* nodesNodeName(ENodeType type) {
|
||||||
return "PhysiExchange";
|
return "PhysiExchange";
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
||||||
return "PhysiSort";
|
return "PhysiSort";
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:
|
||||||
|
return "PhysiInterval";
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||||
return "PhysiDispatch";
|
return "PhysiDispatch";
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
||||||
|
@ -656,6 +658,65 @@ static int32_t jsonToPhysiExchangeNode(const SJson* pJson, void* pObj) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* jkIntervalPhysiPlanExprs = "Exprs";
|
||||||
|
static const char* jkIntervalPhysiPlanFuncs = "Funcs";
|
||||||
|
static const char* jkIntervalPhysiPlanInterval = "Interval";
|
||||||
|
static const char* jkIntervalPhysiPlanOffset = "Offset";
|
||||||
|
static const char* jkIntervalPhysiPlanSliding = "Sliding";
|
||||||
|
static const char* jkIntervalPhysiPlanFill = "Fill";
|
||||||
|
|
||||||
|
static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
|
const SIntervalPhysiNode* pNode = (const SIntervalPhysiNode*)pObj;
|
||||||
|
|
||||||
|
int32_t code = physicPlanNodeToJson(pObj, pJson);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodeListToJson(pJson, jkIntervalPhysiPlanExprs, pNode->pExprs);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodeListToJson(pJson, jkIntervalPhysiPlanFuncs, pNode->pFuncs);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanInterval, pNode->interval);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanOffset, pNode->offset);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanSliding, pNode->sliding);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddObject(pJson, jkIntervalPhysiPlanFill, nodeToJson, pNode->pFill);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) {
|
||||||
|
SIntervalPhysiNode* pNode = (SIntervalPhysiNode*)pObj;
|
||||||
|
|
||||||
|
int32_t code = jsonToPhysicPlanNode(pJson, pObj);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeList(pJson, jkIntervalPhysiPlanExprs, &pNode->pExprs);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeList(pJson, jkIntervalPhysiPlanFuncs, &pNode->pFuncs);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBigIntValue(pJson, jkIntervalPhysiPlanInterval, &pNode->interval);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBigIntValue(pJson, jkIntervalPhysiPlanOffset, &pNode->offset);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBigIntValue(pJson, jkIntervalPhysiPlanSliding, &pNode->sliding);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeObject(pJson, jkIntervalPhysiPlanFill, (SNode**)&pNode->pFill);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static const char* jkDataSinkInputDataBlockDesc = "InputDataBlockDesc";
|
static const char* jkDataSinkInputDataBlockDesc = "InputDataBlockDesc";
|
||||||
|
|
||||||
static int32_t physicDataSinkNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physicDataSinkNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
|
@ -1036,7 +1097,6 @@ static int32_t datumToJson(const void* pObj, SJson* pJson) {
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
code = tjsonAddDoubleToObject(pJson, jkValueDatum, pNode->datum.d);
|
code = tjsonAddDoubleToObject(pJson, jkValueDatum, pNode->datum.d);
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY:
|
case TSDB_DATA_TYPE_VARBINARY:
|
||||||
|
@ -1100,7 +1160,6 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) {
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
code = tjsonGetDoubleValue(pJson, jkValueDatum, &pNode->datum.d);
|
code = tjsonGetDoubleValue(pJson, jkValueDatum, &pNode->datum.d);
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY: {
|
case TSDB_DATA_TYPE_VARBINARY: {
|
||||||
|
@ -1569,6 +1628,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
return physiExchangeNodeToJson(pObj, pJson);
|
return physiExchangeNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:
|
||||||
|
return physiIntervalNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||||
return physiDispatchNodeToJson(pObj, pJson);
|
return physiDispatchNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
||||||
|
|
|
@ -135,6 +135,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
||||||
return makeNode(type, sizeof(SVnodeModifLogicNode));
|
return makeNode(type, sizeof(SVnodeModifLogicNode));
|
||||||
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
||||||
return makeNode(type, sizeof(SExchangeLogicNode));
|
return makeNode(type, sizeof(SExchangeLogicNode));
|
||||||
|
case QUERY_NODE_LOGIC_PLAN_WINDOW:
|
||||||
|
return makeNode(type, sizeof(SWindowLogicNode));
|
||||||
case QUERY_NODE_LOGIC_SUBPLAN:
|
case QUERY_NODE_LOGIC_SUBPLAN:
|
||||||
return makeNode(type, sizeof(SSubLogicPlan));
|
return makeNode(type, sizeof(SSubLogicPlan));
|
||||||
case QUERY_NODE_LOGIC_PLAN:
|
case QUERY_NODE_LOGIC_PLAN:
|
||||||
|
@ -159,6 +161,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
||||||
return makeNode(type, sizeof(SExchangePhysiNode));
|
return makeNode(type, sizeof(SExchangePhysiNode));
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
||||||
return makeNode(type, sizeof(SNode));
|
return makeNode(type, sizeof(SNode));
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:
|
||||||
|
return makeNode(type, sizeof(SIntervalPhysiNode));
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||||
return makeNode(type, sizeof(SDataDispatcherNode));
|
return makeNode(type, sizeof(SDataDispatcherNode));
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
||||||
|
@ -389,7 +393,6 @@ void* nodesGetValueFromNode(SValueNode *pNode) {
|
||||||
case TSDB_DATA_TYPE_FLOAT:
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
return (void*)&pNode->datum.d;
|
return (void*)&pNode->datum.d;
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY:
|
case TSDB_DATA_TYPE_VARBINARY:
|
||||||
|
|
|
@ -78,6 +78,8 @@ typedef struct STableDataBlocks {
|
||||||
char *pData;
|
char *pData;
|
||||||
bool cloned;
|
bool cloned;
|
||||||
STagData tagData;
|
STagData tagData;
|
||||||
|
char tableName[TSDB_TABLE_NAME_LEN];
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
|
||||||
SParsedDataColInfo boundColumnInfo;
|
SParsedDataColInfo boundColumnInfo;
|
||||||
SRowBuilder rowBuilder;
|
SRowBuilder rowBuilder;
|
||||||
|
@ -115,10 +117,10 @@ static FORCE_INLINE void getMemRowAppendInfo(SSchema *pSchema, uint8_t rowType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t setBlockInfo(SSubmitBlk *pBlocks, const STableMeta *pTableMeta, int32_t numOfRows) {
|
static FORCE_INLINE int32_t setBlockInfo(SSubmitBlk *pBlocks, STableDataBlocks* dataBuf, int32_t numOfRows) {
|
||||||
pBlocks->tid = pTableMeta->suid;
|
pBlocks->tid = dataBuf->pTableMeta->suid;
|
||||||
pBlocks->uid = pTableMeta->uid;
|
pBlocks->uid = dataBuf->pTableMeta->uid;
|
||||||
pBlocks->sversion = pTableMeta->sversion;
|
pBlocks->sversion = dataBuf->pTableMeta->sversion;
|
||||||
|
|
||||||
if (pBlocks->numOfRows + numOfRows >= INT16_MAX) {
|
if (pBlocks->numOfRows + numOfRows >= INT16_MAX) {
|
||||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||||
|
|
|
@ -189,6 +189,7 @@ col_name_list(A) ::= col_name_list(B) NK_COMMA col_name(C).
|
||||||
|
|
||||||
col_name(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); }
|
col_name(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); }
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
/************************************************ show ****************************************************************/
|
/************************************************ show ****************************************************************/
|
||||||
cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); }
|
cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); }
|
||||||
cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL, NULL); }
|
cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL, NULL); }
|
||||||
|
|
|
@ -50,6 +50,8 @@ typedef struct SInsertParseContext {
|
||||||
SParseContext* pComCxt; // input
|
SParseContext* pComCxt; // input
|
||||||
char *pSql; // input
|
char *pSql; // input
|
||||||
SMsgBuf msg; // input
|
SMsgBuf msg; // input
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
char tableName[TSDB_TABLE_NAME_LEN];
|
||||||
STableMeta* pTableMeta; // each table
|
STableMeta* pTableMeta; // each table
|
||||||
SParsedDataColInfo tags; // each table
|
SParsedDataColInfo tags; // each table
|
||||||
SKVRowBuilder tagsBuilder; // each table
|
SKVRowBuilder tagsBuilder; // each table
|
||||||
|
@ -228,6 +230,9 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) {
|
||||||
CHECK_CODE(catalogGetTableHashVgroup(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &vg));
|
CHECK_CODE(catalogGetTableHashVgroup(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &vg));
|
||||||
CHECK_CODE(taosHashPut(pCxt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg)));
|
CHECK_CODE(taosHashPut(pCxt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg)));
|
||||||
pCxt->pTableMeta->vgId = vg.vgId; // todo remove
|
pCxt->pTableMeta->vgId = vg.vgId; // todo remove
|
||||||
|
strcpy(pCxt->tableName, name.tname);
|
||||||
|
tNameGetFullDbName(&name, pCxt->dbFName);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +246,7 @@ static int32_t findCol(SToken* pColname, int32_t start, int32_t end, SSchema* pS
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void buildMsgHeader(SVgDataBlocks* blocks) {
|
static void buildMsgHeader(STableDataBlocks* src, SVgDataBlocks* blocks) {
|
||||||
SSubmitReq* submit = (SSubmitReq*)blocks->pData;
|
SSubmitReq* submit = (SSubmitReq*)blocks->pData;
|
||||||
submit->header.vgId = htonl(blocks->vg.vgId);
|
submit->header.vgId = htonl(blocks->vg.vgId);
|
||||||
submit->header.contLen = htonl(blocks->size);
|
submit->header.contLen = htonl(blocks->size);
|
||||||
|
@ -278,7 +283,7 @@ static int32_t buildOutput(SInsertParseContext* pCxt) {
|
||||||
dst->numOfTables = src->numOfTables;
|
dst->numOfTables = src->numOfTables;
|
||||||
dst->size = src->size;
|
dst->size = src->size;
|
||||||
TSWAP(dst->pData, src->pData, char*);
|
TSWAP(dst->pData, src->pData, char*);
|
||||||
buildMsgHeader(dst);
|
buildMsgHeader(src, dst);
|
||||||
taosArrayPush(pCxt->pOutput->pDataBlocks, &dst);
|
taosArrayPush(pCxt->pOutput->pDataBlocks, &dst);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -893,7 +898,7 @@ static int32_t parseValuesClause(SInsertParseContext* pCxt, STableDataBlocks* da
|
||||||
CHECK_CODE(parseValues(pCxt, dataBuf, maxNumOfRows, &numOfRows));
|
CHECK_CODE(parseValues(pCxt, dataBuf, maxNumOfRows, &numOfRows));
|
||||||
|
|
||||||
SSubmitBlk *pBlocks = (SSubmitBlk *)(dataBuf->pData);
|
SSubmitBlk *pBlocks = (SSubmitBlk *)(dataBuf->pData);
|
||||||
if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, dataBuf->pTableMeta, numOfRows)) {
|
if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, dataBuf, numOfRows)) {
|
||||||
return buildInvalidOperationMsg(&pCxt->msg, "too many rows in sql, total number of rows should be less than 32767");
|
return buildInvalidOperationMsg(&pCxt->msg, "too many rows in sql, total number of rows should be less than 32767");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -970,6 +975,8 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
STableDataBlocks *dataBuf = NULL;
|
STableDataBlocks *dataBuf = NULL;
|
||||||
CHECK_CODE(getDataBlockFromList(pCxt->pTableBlockHashObj, pCxt->pTableMeta->uid, TSDB_DEFAULT_PAYLOAD_SIZE,
|
CHECK_CODE(getDataBlockFromList(pCxt->pTableBlockHashObj, pCxt->pTableMeta->uid, TSDB_DEFAULT_PAYLOAD_SIZE,
|
||||||
sizeof(SSubmitBlk), getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta, &dataBuf, NULL));
|
sizeof(SSubmitBlk), getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta, &dataBuf, NULL));
|
||||||
|
strcpy(dataBuf->tableName, pCxt->tableName);
|
||||||
|
strcpy(dataBuf->dbFName, pCxt->dbFName);
|
||||||
|
|
||||||
if (TK_NK_LP == sToken.type) {
|
if (TK_NK_LP == sToken.type) {
|
||||||
// pSql -> field1_name, ...)
|
// pSql -> field1_name, ...)
|
||||||
|
|
|
@ -342,7 +342,6 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
||||||
pVal->datum.d = strtold(pVal->literal, &endPtr);
|
pVal->datum.d = strtold(pVal->literal, &endPtr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY: {
|
case TSDB_DATA_TYPE_VARBINARY: {
|
||||||
|
@ -677,7 +676,6 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect, bool
|
||||||
static int32_t getPositionValue(const SValueNode* pVal) {
|
static int32_t getPositionValue(const SValueNode* pVal) {
|
||||||
switch (pVal->node.resType.type) {
|
switch (pVal->node.resType.type) {
|
||||||
case TSDB_DATA_TYPE_NULL:
|
case TSDB_DATA_TYPE_NULL:
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
|
@ -784,9 +782,17 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SNodeList* pGroupByList
|
||||||
return translateExprList(pCxt, pGroupByList);
|
return translateExprList(pCxt, pGroupByList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t doTranslateWindow(STranslateContext* pCxt, SNode* pWindow) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateWindow(STranslateContext* pCxt, SNode* pWindow) {
|
static int32_t translateWindow(STranslateContext* pCxt, SNode* pWindow) {
|
||||||
pCxt->currClause = SQL_CLAUSE_WINDOW;
|
pCxt->currClause = SQL_CLAUSE_WINDOW;
|
||||||
return translateExpr(pCxt, pWindow);
|
int32_t code = translateExpr(pCxt, pWindow);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = doTranslateWindow(pCxt, pWindow);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translatePartitionBy(STranslateContext* pCxt, SNodeList* pPartitionByList) {
|
static int32_t translatePartitionBy(STranslateContext* pCxt, SNodeList* pPartitionByList) {
|
||||||
|
@ -1449,6 +1455,7 @@ static int32_t rewriteShow(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
typedef struct SVgroupTablesBatch {
|
typedef struct SVgroupTablesBatch {
|
||||||
SVCreateTbBatchReq req;
|
SVCreateTbBatchReq req;
|
||||||
SVgroupInfo info;
|
SVgroupInfo info;
|
||||||
|
char dbName[TSDB_DB_NAME_LEN];
|
||||||
} SVgroupTablesBatch;
|
} SVgroupTablesBatch;
|
||||||
|
|
||||||
static void toSchema(const SColumnDefNode* pCol, int32_t colId, SSchema* pSchema) {
|
static void toSchema(const SColumnDefNode* pCol, int32_t colId, SSchema* pSchema) {
|
||||||
|
@ -1464,7 +1471,7 @@ static void destroyCreateTbReq(SVCreateTbReq* pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t buildNormalTableBatchReq(
|
static int32_t buildNormalTableBatchReq(
|
||||||
const char* pTableName, const SNodeList* pColumns, const SVgroupInfo* pVgroupInfo, SVgroupTablesBatch* pBatch) {
|
const char* pDbName, const char* pTableName, const SNodeList* pColumns, const SVgroupInfo* pVgroupInfo, SVgroupTablesBatch* pBatch) {
|
||||||
SVCreateTbReq req = {0};
|
SVCreateTbReq req = {0};
|
||||||
req.type = TD_NORMAL_TABLE;
|
req.type = TD_NORMAL_TABLE;
|
||||||
req.name = strdup(pTableName);
|
req.name = strdup(pTableName);
|
||||||
|
@ -1482,6 +1489,7 @@ static int32_t buildNormalTableBatchReq(
|
||||||
}
|
}
|
||||||
|
|
||||||
pBatch->info = *pVgroupInfo;
|
pBatch->info = *pVgroupInfo;
|
||||||
|
strcpy(pBatch->dbName, pDbName);
|
||||||
pBatch->req.pArray = taosArrayInit(1, sizeof(struct SVCreateTbReq));
|
pBatch->req.pArray = taosArrayInit(1, sizeof(struct SVCreateTbReq));
|
||||||
if (NULL == pBatch->req.pArray) {
|
if (NULL == pBatch->req.pArray) {
|
||||||
destroyCreateTbReq(&req);
|
destroyCreateTbReq(&req);
|
||||||
|
@ -1492,7 +1500,7 @@ static int32_t buildNormalTableBatchReq(
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t serializeVgroupTablesBatch(SVgroupTablesBatch* pTbBatch, SArray* pBufArray) {
|
static int32_t serializeVgroupTablesBatch(int32_t acctId, SVgroupTablesBatch* pTbBatch, SArray* pBufArray) {
|
||||||
int tlen = sizeof(SMsgHead) + tSerializeSVCreateTbBatchReq(NULL, &(pTbBatch->req));
|
int tlen = sizeof(SMsgHead) + tSerializeSVCreateTbBatchReq(NULL, &(pTbBatch->req));
|
||||||
void* buf = malloc(tlen);
|
void* buf = malloc(tlen);
|
||||||
if (NULL == buf) {
|
if (NULL == buf) {
|
||||||
|
@ -1554,16 +1562,16 @@ static void destroyCreateTbReqArray(SArray* pArray) {
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t buildCreateTableDataBlock(const SCreateTableStmt* pStmt, const SVgroupInfo* pInfo, SArray** pBufArray) {
|
static int32_t buildCreateTableDataBlock(int32_t acctId, const SCreateTableStmt* pStmt, const SVgroupInfo* pInfo, SArray** pBufArray) {
|
||||||
*pBufArray = taosArrayInit(1, POINTER_BYTES);
|
*pBufArray = taosArrayInit(1, POINTER_BYTES);
|
||||||
if (NULL == *pBufArray) {
|
if (NULL == *pBufArray) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
SVgroupTablesBatch tbatch = {0};
|
SVgroupTablesBatch tbatch = {0};
|
||||||
int32_t code = buildNormalTableBatchReq(pStmt->tableName, pStmt->pCols, pInfo, &tbatch);
|
int32_t code = buildNormalTableBatchReq(pStmt->dbName, pStmt->tableName, pStmt->pCols, pInfo, &tbatch);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = serializeVgroupTablesBatch(&tbatch, *pBufArray);
|
code = serializeVgroupTablesBatch(acctId, &tbatch, *pBufArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyCreateTbReqBatch(&tbatch);
|
destroyCreateTbReqBatch(&tbatch);
|
||||||
|
@ -1580,7 +1588,7 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
int32_t code = getTableHashVgroup(pCxt->pParseCxt, pStmt->dbName, pStmt->tableName, &info);
|
int32_t code = getTableHashVgroup(pCxt->pParseCxt, pStmt->dbName, pStmt->tableName, &info);
|
||||||
SArray* pBufArray = NULL;
|
SArray* pBufArray = NULL;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = buildCreateTableDataBlock(pStmt, &info, &pBufArray);
|
code = buildCreateTableDataBlock(pCxt->pParseCxt->acctId, pStmt, &info, &pBufArray);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = rewriteToVnodeModifOpStmt(pQuery, pBufArray);
|
code = rewriteToVnodeModifOpStmt(pQuery, pBufArray);
|
||||||
|
@ -1592,7 +1600,7 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addCreateTbReqIntoVgroup(SHashObj* pVgroupHashmap, const char* pTableName, SKVRow row, uint64_t suid, SVgroupInfo* pVgInfo) {
|
static void addCreateTbReqIntoVgroup(SHashObj* pVgroupHashmap, const char* pDbName, const char* pTableName, SKVRow row, uint64_t suid, SVgroupInfo* pVgInfo) {
|
||||||
struct SVCreateTbReq req = {0};
|
struct SVCreateTbReq req = {0};
|
||||||
req.type = TD_CHILD_TABLE;
|
req.type = TD_CHILD_TABLE;
|
||||||
req.name = strdup(pTableName);
|
req.name = strdup(pTableName);
|
||||||
|
@ -1603,6 +1611,7 @@ static void addCreateTbReqIntoVgroup(SHashObj* pVgroupHashmap, const char* pTabl
|
||||||
if (pTableBatch == NULL) {
|
if (pTableBatch == NULL) {
|
||||||
SVgroupTablesBatch tBatch = {0};
|
SVgroupTablesBatch tBatch = {0};
|
||||||
tBatch.info = *pVgInfo;
|
tBatch.info = *pVgInfo;
|
||||||
|
strcpy(tBatch.dbName, pDbName);
|
||||||
|
|
||||||
tBatch.req.pArray = taosArrayInit(4, sizeof(struct SVCreateTbReq));
|
tBatch.req.pArray = taosArrayInit(4, sizeof(struct SVCreateTbReq));
|
||||||
taosArrayPush(tBatch.req.pArray, &req);
|
taosArrayPush(tBatch.req.pArray, &req);
|
||||||
|
@ -1639,7 +1648,6 @@ static void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
pVal->d = pNode->datum.d;
|
pVal->d = pNode->datum.d;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY:
|
case TSDB_DATA_TYPE_VARBINARY:
|
||||||
|
@ -1747,7 +1755,7 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
|
||||||
code = getTableHashVgroup(pCxt->pParseCxt, pStmt->dbName, pStmt->tableName, &info);
|
code = getTableHashVgroup(pCxt->pParseCxt, pStmt->dbName, pStmt->tableName, &info);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
addCreateTbReqIntoVgroup(pVgroupHashmap, pStmt->tableName, row, pSuperTableMeta->uid, &info);
|
addCreateTbReqIntoVgroup(pVgroupHashmap, pStmt->dbName, pStmt->tableName, row, pSuperTableMeta->uid, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pSuperTableMeta);
|
tfree(pSuperTableMeta);
|
||||||
|
@ -1755,7 +1763,7 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SArray* serializeVgroupsTablesBatch(SHashObj* pVgroupHashmap) {
|
static SArray* serializeVgroupsTablesBatch(int32_t acctId, SHashObj* pVgroupHashmap) {
|
||||||
SArray* pBufArray = taosArrayInit(taosHashGetSize(pVgroupHashmap), sizeof(void*));
|
SArray* pBufArray = taosArrayInit(taosHashGetSize(pVgroupHashmap), sizeof(void*));
|
||||||
if (NULL == pBufArray) {
|
if (NULL == pBufArray) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1769,7 +1777,7 @@ static SArray* serializeVgroupsTablesBatch(SHashObj* pVgroupHashmap) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
serializeVgroupTablesBatch(pTbBatch, pBufArray);
|
serializeVgroupTablesBatch(acctId, pTbBatch, pBufArray);
|
||||||
destroyCreateTbReqBatch(pTbBatch);
|
destroyCreateTbReqBatch(pTbBatch);
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
|
@ -1794,7 +1802,7 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* pBufArray = serializeVgroupsTablesBatch(pVgroupHashmap);
|
SArray* pBufArray = serializeVgroupsTablesBatch(pCxt->pParseCxt->acctId, pVgroupHashmap);
|
||||||
taosHashCleanup(pVgroupHashmap);
|
taosHashCleanup(pVgroupHashmap);
|
||||||
if (NULL == pBufArray) {
|
if (NULL == pBufArray) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -183,6 +183,13 @@ TEST_F(ParserTest, selectClause) {
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserTest, selectWindow) {
|
||||||
|
setDatabase("root", "test");
|
||||||
|
|
||||||
|
bind("SELECT count(*) FROM t1 interval(10s)");
|
||||||
|
ASSERT_TRUE(run());
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ParserTest, selectSyntaxError) {
|
TEST_F(ParserTest, selectSyntaxError) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
|
|
|
@ -324,6 +324,50 @@ static SLogicNode* createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
|
||||||
return (SLogicNode*)pAgg;
|
return (SLogicNode*)pAgg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SLogicNode* createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SIntervalWindowNode* pInterval, SSelectStmt* pSelect) {
|
||||||
|
SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
||||||
|
CHECK_ALLOC(pWindow, NULL);
|
||||||
|
pWindow->node.id = pCxt->planNodeId++;
|
||||||
|
|
||||||
|
pWindow->winType = WINDOW_TYPE_INTERVAL;
|
||||||
|
pWindow->interval = ((SValueNode*)pInterval->pInterval)->datum.i;
|
||||||
|
pWindow->offset = (NULL != pInterval->pOffset ? ((SValueNode*)pInterval->pOffset)->datum.i : 0);
|
||||||
|
pWindow->sliding = (NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->datum.i : 0);
|
||||||
|
if (NULL != pInterval->pFill) {
|
||||||
|
pWindow->pFill = nodesCloneNode(pInterval->pFill);
|
||||||
|
CHECK_ALLOC(pWindow->pFill, (SLogicNode*)pWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
SNodeList* pFuncs = NULL;
|
||||||
|
CHECK_CODE(nodesCollectFuncs(pSelect, fmIsAggFunc, &pFuncs), NULL);
|
||||||
|
if (NULL != pFuncs) {
|
||||||
|
pWindow->pFuncs = nodesCloneList(pFuncs);
|
||||||
|
CHECK_ALLOC(pWindow->pFuncs, (SLogicNode*)pWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK_CODE(rewriteExpr(pWindow->node.id, 1, pWindow->pFuncs, pSelect, SQL_CLAUSE_WINDOW), (SLogicNode*)pWindow);
|
||||||
|
|
||||||
|
pWindow->node.pTargets = createColumnByRewriteExps(pCxt, pWindow->pFuncs);
|
||||||
|
CHECK_ALLOC(pWindow->node.pTargets, (SLogicNode*)pWindow);
|
||||||
|
|
||||||
|
return (SLogicNode*)pWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SLogicNode* createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect) {
|
||||||
|
if (NULL == pSelect->pWindow) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (nodeType(pSelect->pWindow)) {
|
||||||
|
case QUERY_NODE_INTERVAL_WINDOW:
|
||||||
|
return createWindowLogicNodeByInterval(pCxt, (SIntervalWindowNode*)pSelect->pWindow, pSelect);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static SNodeList* createColumnByProjections(SLogicPlanContext* pCxt, SNodeList* pExprs) {
|
static SNodeList* createColumnByProjections(SLogicPlanContext* pCxt, SNodeList* pExprs) {
|
||||||
SNodeList* pList = nodesMakeList();
|
SNodeList* pList = nodesMakeList();
|
||||||
CHECK_ALLOC(pList, NULL);
|
CHECK_ALLOC(pList, NULL);
|
||||||
|
@ -365,6 +409,9 @@ static SLogicNode* createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
|
||||||
pRoot->pConditions = nodesCloneNode(pSelect->pWhere);
|
pRoot->pConditions = nodesCloneNode(pSelect->pWhere);
|
||||||
CHECK_ALLOC(pRoot->pConditions, pRoot);
|
CHECK_ALLOC(pRoot->pConditions, pRoot);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||||
|
pRoot = pushLogicNode(pCxt, pRoot, createWindowLogicNode(pCxt, pSelect));
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||||
pRoot = pushLogicNode(pCxt, pRoot, createAggLogicNode(pCxt, pSelect));
|
pRoot = pushLogicNode(pCxt, pRoot, createAggLogicNode(pCxt, pSelect));
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,6 +263,8 @@ static SPhysiNode* createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* p
|
||||||
pTableScan->scanRange = pScanLogicNode->scanRange;
|
pTableScan->scanRange = pScanLogicNode->scanRange;
|
||||||
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode);
|
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode);
|
||||||
taosArrayPush(pCxt->pExecNodeList, &pSubplan->execNode);
|
taosArrayPush(pCxt->pExecNodeList, &pSubplan->execNode);
|
||||||
|
pSubplan->execNodeStat.tableNum = pScanLogicNode->pVgroupList->vgroups[0].numOfTable;
|
||||||
|
tNameGetFullDbName(&pScanLogicNode->tableName, pSubplan->dbFName);
|
||||||
return (SPhysiNode*)pTableScan;
|
return (SPhysiNode*)pTableScan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,6 +283,7 @@ static SPhysiNode* createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pScan->mgmtEpSet = pCxt->pPlanCxt->mgmtEpSet;
|
pScan->mgmtEpSet = pCxt->pPlanCxt->mgmtEpSet;
|
||||||
|
tNameGetFullDbName(&pScanLogicNode->tableName, pSubplan->dbFName);
|
||||||
return (SPhysiNode*)pScan;
|
return (SPhysiNode*)pScan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,14 +502,58 @@ static SPhysiNode* createExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLog
|
||||||
return (SPhysiNode*)pExchange;
|
return (SPhysiNode*)pExchange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SPhysiNode* createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode) {
|
||||||
|
SIntervalPhysiNode* pInterval = (SIntervalPhysiNode*)makePhysiNode(pCxt, QUERY_NODE_PHYSICAL_PLAN_INTERVAL);
|
||||||
|
CHECK_ALLOC(pInterval, NULL);
|
||||||
|
|
||||||
|
pInterval->interval = pWindowLogicNode->interval;
|
||||||
|
pInterval->offset = pWindowLogicNode->offset;
|
||||||
|
pInterval->sliding = pWindowLogicNode->sliding;
|
||||||
|
pInterval->pFill = nodesCloneNode(pWindowLogicNode->pFill);
|
||||||
|
|
||||||
|
SNodeList* pPrecalcExprs = NULL;
|
||||||
|
SNodeList* pFuncs = NULL;
|
||||||
|
CHECK_CODE(rewritePrecalcExprs(pCxt, pWindowLogicNode->pFuncs, &pPrecalcExprs, &pFuncs), (SPhysiNode*)pInterval);
|
||||||
|
|
||||||
|
SDataBlockDescNode* pChildTupe = (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc);
|
||||||
|
// push down expression to pOutputDataBlockDesc of child node
|
||||||
|
if (NULL != pPrecalcExprs) {
|
||||||
|
pInterval->pExprs = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pPrecalcExprs);
|
||||||
|
CHECK_ALLOC(pInterval->pExprs, (SPhysiNode*)pInterval);
|
||||||
|
CHECK_CODE(addDataBlockDesc(pCxt, pInterval->pExprs, pChildTupe), (SPhysiNode*)pInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL != pFuncs) {
|
||||||
|
pInterval->pFuncs = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pFuncs);
|
||||||
|
CHECK_ALLOC(pInterval->pFuncs, (SPhysiNode*)pInterval);
|
||||||
|
CHECK_CODE(addDataBlockDesc(pCxt, pInterval->pFuncs, pInterval->node.pOutputDataBlockDesc), (SPhysiNode*)pInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK_CODE(setSlotOutput(pCxt, pWindowLogicNode->node.pTargets, pInterval->node.pOutputDataBlockDesc), (SPhysiNode*)pInterval);
|
||||||
|
|
||||||
|
return (SPhysiNode*)pInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SPhysiNode* createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode) {
|
||||||
|
switch (pWindowLogicNode->winType) {
|
||||||
|
case WINDOW_TYPE_INTERVAL:
|
||||||
|
return createIntervalPhysiNode(pCxt, pChildren, pWindowLogicNode);
|
||||||
|
case WINDOW_TYPE_SESSION:
|
||||||
|
case WINDOW_TYPE_STATE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static SPhysiNode* createPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SLogicNode* pLogicPlan) {
|
static SPhysiNode* createPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SLogicNode* pLogicPlan) {
|
||||||
SNodeList* pChildren = nodesMakeList();
|
SNodeList* pChildren = nodesMakeList();
|
||||||
CHECK_ALLOC(pChildren, NULL);
|
CHECK_ALLOC(pChildren, NULL);
|
||||||
|
|
||||||
SNode* pLogicChild;
|
SNode* pLogicChild;
|
||||||
FOREACH(pLogicChild, pLogicPlan->pChildren) {
|
FOREACH(pLogicChild, pLogicPlan->pChildren) {
|
||||||
SNode* pChildPhyNode = (SNode*)createPhysiNode(pCxt, pSubplan, (SLogicNode*)pLogicChild);
|
if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pChildren, createPhysiNode(pCxt, pSubplan, (SLogicNode*)pLogicChild))) {
|
||||||
if (TSDB_CODE_SUCCESS != nodesListAppend(pChildren, pChildPhyNode)) {
|
|
||||||
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
nodesDestroyList(pChildren);
|
nodesDestroyList(pChildren);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -530,6 +577,9 @@ static SPhysiNode* createPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan,
|
||||||
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
||||||
pPhyNode = createExchangePhysiNode(pCxt, (SExchangeLogicNode*)pLogicPlan);
|
pPhyNode = createExchangePhysiNode(pCxt, (SExchangeLogicNode*)pLogicPlan);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_LOGIC_PLAN_WINDOW:
|
||||||
|
pPhyNode = createWindowPhysiNode(pCxt, pChildren, (SWindowLogicNode*)pLogicPlan);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,6 +167,13 @@ TEST_F(PlannerTest, subquery) {
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PlannerTest, interval) {
|
||||||
|
setDatabase("root", "test");
|
||||||
|
|
||||||
|
bind("SELECT count(*) FROM t1 interval(10s)");
|
||||||
|
ASSERT_TRUE(run());
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, showTables) {
|
TEST_F(PlannerTest, showTables) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,32 @@ int32_t asyncSendMsgToServer(void* pTransporter, SEpSet* epSet, int64_t* pTransp
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *jobTaskStatusStr(int32_t status) {
|
||||||
|
switch (status) {
|
||||||
|
case JOB_TASK_STATUS_NULL:
|
||||||
|
return "NULL";
|
||||||
|
case JOB_TASK_STATUS_NOT_START:
|
||||||
|
return "NOT_START";
|
||||||
|
case JOB_TASK_STATUS_EXECUTING:
|
||||||
|
return "EXECUTING";
|
||||||
|
case JOB_TASK_STATUS_PARTIAL_SUCCEED:
|
||||||
|
return "PARTIAL_SUCCEED";
|
||||||
|
case JOB_TASK_STATUS_SUCCEED:
|
||||||
|
return "SUCCEED";
|
||||||
|
case JOB_TASK_STATUS_FAILED:
|
||||||
|
return "FAILED";
|
||||||
|
case JOB_TASK_STATUS_CANCELLING:
|
||||||
|
return "CANCELLING";
|
||||||
|
case JOB_TASK_STATUS_CANCELLED:
|
||||||
|
return "CANCELLED";
|
||||||
|
case JOB_TASK_STATUS_DROPPING:
|
||||||
|
return "DROPPING";
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
|
||||||
SSchema createSchema(uint8_t type, int32_t bytes, int32_t colId, const char* name) {
|
SSchema createSchema(uint8_t type, int32_t bytes, int32_t colId, const char* name) {
|
||||||
SSchema s = {0};
|
SSchema s = {0};
|
||||||
|
|
|
@ -59,23 +59,15 @@ enum {
|
||||||
QW_WRITE,
|
QW_WRITE,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
|
||||||
QW_EXIST_ACQUIRE = 1,
|
|
||||||
QW_EXIST_RET_ERR,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
QW_NOT_EXIST_RET_ERR = 1,
|
QW_NOT_EXIST_RET_ERR = 1,
|
||||||
QW_NOT_EXIST_ADD,
|
QW_NOT_EXIST_ADD,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
|
||||||
QW_ADD_RET_ERR = 1,
|
|
||||||
QW_ADD_ACQUIRE,
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct SQWDebug {
|
typedef struct SQWDebug {
|
||||||
int32_t lockDebug;
|
bool lockEnable;
|
||||||
|
bool statusEnable;
|
||||||
} SQWDebug;
|
} SQWDebug;
|
||||||
|
|
||||||
typedef struct SQWMsg {
|
typedef struct SQWMsg {
|
||||||
|
@ -91,14 +83,10 @@ typedef struct SQWHbInfo {
|
||||||
} SQWHbInfo;
|
} SQWHbInfo;
|
||||||
|
|
||||||
typedef struct SQWPhaseInput {
|
typedef struct SQWPhaseInput {
|
||||||
int8_t taskStatus;
|
|
||||||
int8_t taskType;
|
|
||||||
int32_t code;
|
int32_t code;
|
||||||
} SQWPhaseInput;
|
} SQWPhaseInput;
|
||||||
|
|
||||||
typedef struct SQWPhaseOutput {
|
typedef struct SQWPhaseOutput {
|
||||||
int32_t rspCode;
|
|
||||||
bool needStop;
|
|
||||||
} SQWPhaseOutput;
|
} SQWPhaseOutput;
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,9 +106,10 @@ typedef struct SQWTaskCtx {
|
||||||
void *cancelConnection;
|
void *cancelConnection;
|
||||||
|
|
||||||
bool emptyRes;
|
bool emptyRes;
|
||||||
bool multiExec;
|
bool queryFetched;
|
||||||
int8_t queryContinue;
|
bool queryEnd;
|
||||||
int8_t queryInQueue;
|
bool queryContinue;
|
||||||
|
bool queryInQueue;
|
||||||
int32_t rspCode;
|
int32_t rspCode;
|
||||||
|
|
||||||
int8_t events[QW_EVENT_MAX];
|
int8_t events[QW_EVENT_MAX];
|
||||||
|
@ -145,7 +134,6 @@ typedef struct SQWorkerMgmt {
|
||||||
void *timer;
|
void *timer;
|
||||||
tmr_h hbTimer;
|
tmr_h hbTimer;
|
||||||
SRWLatch schLock;
|
SRWLatch schLock;
|
||||||
//SRWLatch ctxLock;
|
|
||||||
SHashObj *schHash; //key: schedulerId, value: SQWSchStatus
|
SHashObj *schHash; //key: schedulerId, value: SQWSchStatus
|
||||||
SHashObj *ctxHash; //key: queryId+taskId, value: SQWTaskCtx
|
SHashObj *ctxHash; //key: queryId+taskId, value: SQWTaskCtx
|
||||||
void *nodeObj;
|
void *nodeObj;
|
||||||
|
@ -199,7 +187,7 @@ typedef struct SQWorkerMgmt {
|
||||||
#define QW_SCH_TASK_WLOG(param, ...) qWarn("QW:%p SID:0x%"PRIx64",QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, sId, qId, tId, __VA_ARGS__)
|
#define QW_SCH_TASK_WLOG(param, ...) qWarn("QW:%p SID:0x%"PRIx64",QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, sId, qId, tId, __VA_ARGS__)
|
||||||
#define QW_SCH_TASK_DLOG(param, ...) qDebug("QW:%p SID:0x%"PRIx64",QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, sId, qId, tId, __VA_ARGS__)
|
#define QW_SCH_TASK_DLOG(param, ...) qDebug("QW:%p SID:0x%"PRIx64",QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, sId, qId, tId, __VA_ARGS__)
|
||||||
|
|
||||||
#define QW_LOCK_DEBUG(...) do { if (gQWDebug.lockDebug) { qDebug(__VA_ARGS__); } } while (0)
|
#define QW_LOCK_DEBUG(...) do { if (gQWDebug.lockEnable) { qDebug(__VA_ARGS__); } } while (0)
|
||||||
|
|
||||||
#define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000
|
#define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ int32_t qwBuildAndSendFetchRsp(void *connection, SRetrieveTableRsp *pRsp, int32_
|
||||||
void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete);
|
void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete);
|
||||||
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, void *connection);
|
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, void *connection);
|
||||||
int32_t qwBuildAndSendReadyRsp(void *connection, int32_t code);
|
int32_t qwBuildAndSendReadyRsp(void *connection, int32_t code);
|
||||||
int32_t qwBuildAndSendQueryRsp(void *connection, int32_t code, SQueryErrorInfo *errInfo);
|
int32_t qwBuildAndSendQueryRsp(void *connection, int32_t code);
|
||||||
void qwFreeFetchRsp(void *msg);
|
void qwFreeFetchRsp(void *msg);
|
||||||
int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp);
|
int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp);
|
||||||
int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t sId, SSchedulerStatusRsp **rsp);
|
int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t sId, SSchedulerStatusRsp **rsp);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -44,12 +44,9 @@ void qwFreeFetchRsp(void *msg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwBuildAndSendQueryRsp(void *connection, int32_t code, SQueryErrorInfo *errInfo) {
|
int32_t qwBuildAndSendQueryRsp(void *connection, int32_t code) {
|
||||||
SRpcMsg *pMsg = (SRpcMsg *)connection;
|
SRpcMsg *pMsg = (SRpcMsg *)connection;
|
||||||
SQueryTableRsp rsp = {.code = code};
|
SQueryTableRsp rsp = {.code = code};
|
||||||
if (errInfo && errInfo->code) {
|
|
||||||
rsp.tableName = errInfo->tableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t contLen = tSerializeSQueryTableRsp(NULL, 0, &rsp);
|
int32_t contLen = tSerializeSQueryTableRsp(NULL, 0, &rsp);
|
||||||
void *msg = rpcMallocCont(contLen);
|
void *msg = rpcMallocCont(contLen);
|
||||||
|
@ -266,7 +263,7 @@ int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, void *connection) {
|
||||||
QW_ERR_RET(code);
|
QW_ERR_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
QW_SCH_TASK_DLOG("put task continue exec msg to query queue, vgId:%d", mgmt->nodeId);
|
QW_SCH_TASK_DLOG("query continue msg put to queue, vgId:%d", mgmt->nodeId);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -303,7 +300,7 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
|
||||||
QW_SCH_TASK_DLOG("processQuery start, node:%p, sql:%s", node, sql);
|
QW_SCH_TASK_DLOG("processQuery start, node:%p, sql:%s", node, sql);
|
||||||
tfree(sql);
|
tfree(sql);
|
||||||
|
|
||||||
QW_RET(qwProcessQuery(QW_FPARAMS(), &qwMsg, msg->taskType));
|
QW_ERR_RET(qwProcessQuery(QW_FPARAMS(), &qwMsg, msg->taskType));
|
||||||
|
|
||||||
QW_SCH_TASK_DLOG("processQuery end, node:%p", node);
|
QW_SCH_TASK_DLOG("processQuery end, node:%p", node);
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,8 @@ namespace {
|
||||||
#define qwtTestQueryQueueSize 1000000
|
#define qwtTestQueryQueueSize 1000000
|
||||||
#define qwtTestFetchQueueSize 1000000
|
#define qwtTestFetchQueueSize 1000000
|
||||||
|
|
||||||
|
bool qwtEnableLog = true;
|
||||||
|
|
||||||
int32_t qwtTestMaxExecTaskUsec = 2;
|
int32_t qwtTestMaxExecTaskUsec = 2;
|
||||||
int32_t qwtTestReqMaxDelayUsec = 2;
|
int32_t qwtTestReqMaxDelayUsec = 2;
|
||||||
|
|
||||||
|
@ -54,10 +56,10 @@ uint64_t qwtTestQueryId = 0;
|
||||||
bool qwtTestEnableSleep = true;
|
bool qwtTestEnableSleep = true;
|
||||||
bool qwtTestStop = false;
|
bool qwtTestStop = false;
|
||||||
bool qwtTestDeadLoop = false;
|
bool qwtTestDeadLoop = false;
|
||||||
int32_t qwtTestMTRunSec = 60;
|
int32_t qwtTestMTRunSec = 2;
|
||||||
int32_t qwtTestPrintNum = 100000;
|
int32_t qwtTestPrintNum = 10000;
|
||||||
int32_t qwtTestCaseIdx = 0;
|
uint64_t qwtTestCaseIdx = 0;
|
||||||
int32_t qwtTestCaseNum = 4;
|
uint64_t qwtTestCaseNum = 4;
|
||||||
bool qwtTestCaseFinished = false;
|
bool qwtTestCaseFinished = false;
|
||||||
tsem_t qwtTestQuerySem;
|
tsem_t qwtTestQuerySem;
|
||||||
tsem_t qwtTestFetchSem;
|
tsem_t qwtTestFetchSem;
|
||||||
|
@ -95,11 +97,15 @@ SSchTasksStatusReq qwtstatusMsg = {0};
|
||||||
|
|
||||||
|
|
||||||
void qwtInitLogFile() {
|
void qwtInitLogFile() {
|
||||||
|
if (!qwtEnableLog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const char *defaultLogFileNamePrefix = "taosdlog";
|
const char *defaultLogFileNamePrefix = "taosdlog";
|
||||||
const int32_t maxLogFileNum = 10;
|
const int32_t maxLogFileNum = 10;
|
||||||
|
|
||||||
tsAsyncLog = 0;
|
tsAsyncLog = 0;
|
||||||
qDebugFlag = 159;
|
qDebugFlag = 159;
|
||||||
|
strcpy(tsLogDir, "/var/log/taos");
|
||||||
|
|
||||||
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
||||||
printf("failed to open log file in directory:%s\n", tsLogDir);
|
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||||
|
@ -202,6 +208,9 @@ int32_t qwtPutReqToQueue(void *node, struct SRpcMsg *pMsg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qwtSendReqToDnode(void* pVnode, struct SEpSet* epSet, struct SRpcMsg* pReq) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void qwtRpcSendResponse(const SRpcMsg *pRsp) {
|
void qwtRpcSendResponse(const SRpcMsg *pRsp) {
|
||||||
|
@ -240,6 +249,7 @@ void qwtRpcSendResponse(const SRpcMsg *pRsp) {
|
||||||
if (0 == pRsp->code && 0 == rsp->completed) {
|
if (0 == pRsp->code && 0 == rsp->completed) {
|
||||||
qwtBuildFetchReqMsg(&qwtfetchMsg, &qwtfetchRpc);
|
qwtBuildFetchReqMsg(&qwtfetchMsg, &qwtfetchRpc);
|
||||||
qwtPutReqToFetchQueue((void *)0x1, &qwtfetchRpc);
|
qwtPutReqToFetchQueue((void *)0x1, &qwtfetchRpc);
|
||||||
|
rpcFreeCont(rsp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,26 +272,15 @@ void qwtRpcSendResponse(const SRpcMsg *pRsp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwtCreateExecTask(void* tsdb, int32_t vgId, struct SSubplan* pPlan, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, SQueryErrorInfo *errInfo) {
|
int32_t qwtCreateExecTask(void* tsdb, int32_t vgId, uint64_t taskId, struct SSubplan* pPlan, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle) {
|
||||||
int32_t idx = abs((++qwtTestCaseIdx) % qwtTestCaseNum);
|
|
||||||
|
|
||||||
qwtTestSinkBlockNum = 0;
|
qwtTestSinkBlockNum = 0;
|
||||||
qwtTestSinkMaxBlockNum = taosRand() % 100 + 1;
|
qwtTestSinkMaxBlockNum = taosRand() % 100 + 1;
|
||||||
qwtTestSinkQueryEnd = false;
|
qwtTestSinkQueryEnd = false;
|
||||||
|
|
||||||
if (0 == idx) {
|
*pTaskInfo = (qTaskInfo_t)qwtTestCaseIdx+1;
|
||||||
*pTaskInfo = (qTaskInfo_t)qwtTestCaseIdx;
|
*handle = (DataSinkHandle)qwtTestCaseIdx+2;
|
||||||
*handle = (DataSinkHandle)qwtTestCaseIdx+1;
|
|
||||||
} else if (1 == idx) {
|
++qwtTestCaseIdx;
|
||||||
*pTaskInfo = NULL;
|
|
||||||
*handle = NULL;
|
|
||||||
} else if (2 == idx) {
|
|
||||||
*pTaskInfo = (qTaskInfo_t)qwtTestCaseIdx;
|
|
||||||
*handle = NULL;
|
|
||||||
} else if (3 == idx) {
|
|
||||||
*pTaskInfo = NULL;
|
|
||||||
*handle = (DataSinkHandle)qwtTestCaseIdx;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -314,7 +313,7 @@ int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
|
||||||
|
|
||||||
if (endExec) {
|
if (endExec) {
|
||||||
*pRes = (SSDataBlock*)calloc(1, sizeof(SSDataBlock));
|
*pRes = (SSDataBlock*)calloc(1, sizeof(SSDataBlock));
|
||||||
(*pRes)->info.rows = taosRand() % 1000;
|
(*pRes)->info.rows = taosRand() % 1000 + 1;
|
||||||
} else {
|
} else {
|
||||||
*pRes = NULL;
|
*pRes = NULL;
|
||||||
*useconds = taosRand() % 10;
|
*useconds = taosRand() % 10;
|
||||||
|
@ -849,7 +848,6 @@ void *fetchQueueThread(void *param) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
TEST(seqTest, normalCase) {
|
TEST(seqTest, normalCase) {
|
||||||
void *mgmt = NULL;
|
void *mgmt = NULL;
|
||||||
|
@ -880,7 +878,7 @@ TEST(seqTest, normalCase) {
|
||||||
stubSetPutDataBlock();
|
stubSetPutDataBlock();
|
||||||
stubSetGetDataBlock();
|
stubSetGetDataBlock();
|
||||||
|
|
||||||
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
|
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue, (sendReqToDnodeFp)qwtSendReqToDnode);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);
|
code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);
|
||||||
|
@ -919,7 +917,7 @@ TEST(seqTest, cancelFirst) {
|
||||||
stubSetStringToPlan();
|
stubSetStringToPlan();
|
||||||
stubSetRpcSendResponse();
|
stubSetRpcSendResponse();
|
||||||
|
|
||||||
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
|
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue, (sendReqToDnodeFp)qwtSendReqToDnode);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
qwtBuildStatusReqMsg(&qwtstatusMsg, &statusRpc);
|
qwtBuildStatusReqMsg(&qwtstatusMsg, &statusRpc);
|
||||||
|
@ -963,9 +961,9 @@ TEST(seqTest, randCase) {
|
||||||
stubSetRpcSendResponse();
|
stubSetRpcSendResponse();
|
||||||
stubSetCreateExecTask();
|
stubSetCreateExecTask();
|
||||||
|
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
|
|
||||||
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
|
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue, (sendReqToDnodeFp)qwtSendReqToDnode);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
int32_t t = 0;
|
int32_t t = 0;
|
||||||
|
@ -1024,21 +1022,31 @@ TEST(seqTest, multithreadRand) {
|
||||||
|
|
||||||
stubSetStringToPlan();
|
stubSetStringToPlan();
|
||||||
stubSetRpcSendResponse();
|
stubSetRpcSendResponse();
|
||||||
|
stubSetExecTask();
|
||||||
|
stubSetCreateExecTask();
|
||||||
|
stubSetAsyncKillTask();
|
||||||
|
stubSetDestroyTask();
|
||||||
|
stubSetDestroyDataSinker();
|
||||||
|
stubSetGetDataLength();
|
||||||
|
stubSetEndPut();
|
||||||
|
stubSetPutDataBlock();
|
||||||
|
stubSetGetDataBlock();
|
||||||
|
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
|
|
||||||
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
|
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue, (sendReqToDnodeFp)qwtSendReqToDnode);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
pthread_attr_t thattr;
|
pthread_attr_t thattr;
|
||||||
pthread_attr_init(&thattr);
|
pthread_attr_init(&thattr);
|
||||||
|
|
||||||
pthread_t t1,t2,t3,t4,t5;
|
pthread_t t1,t2,t3,t4,t5,t6;
|
||||||
pthread_create(&(t1), &thattr, queryThread, mgmt);
|
pthread_create(&(t1), &thattr, queryThread, mgmt);
|
||||||
pthread_create(&(t2), &thattr, readyThread, NULL);
|
pthread_create(&(t2), &thattr, readyThread, NULL);
|
||||||
pthread_create(&(t3), &thattr, fetchThread, NULL);
|
pthread_create(&(t3), &thattr, fetchThread, NULL);
|
||||||
pthread_create(&(t4), &thattr, dropThread, NULL);
|
pthread_create(&(t4), &thattr, dropThread, NULL);
|
||||||
pthread_create(&(t5), &thattr, statusThread, NULL);
|
pthread_create(&(t5), &thattr, statusThread, NULL);
|
||||||
|
pthread_create(&(t6), &thattr, fetchQueueThread, mgmt);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (qwtTestDeadLoop) {
|
if (qwtTestDeadLoop) {
|
||||||
|
@ -1052,11 +1060,18 @@ TEST(seqTest, multithreadRand) {
|
||||||
qwtTestStop = true;
|
qwtTestStop = true;
|
||||||
taosSsleep(3);
|
taosSsleep(3);
|
||||||
|
|
||||||
|
qwtTestQueryQueueNum = 0;
|
||||||
|
qwtTestQueryQueueRIdx = 0;
|
||||||
|
qwtTestQueryQueueWIdx = 0;
|
||||||
|
qwtTestQueryQueueLock = 0;
|
||||||
|
qwtTestFetchQueueNum = 0;
|
||||||
|
qwtTestFetchQueueRIdx = 0;
|
||||||
|
qwtTestFetchQueueWIdx = 0;
|
||||||
|
qwtTestFetchQueueLock = 0;
|
||||||
|
|
||||||
qWorkerDestroy(&mgmt);
|
qWorkerDestroy(&mgmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TEST(rcTest, shortExecshortDelay) {
|
TEST(rcTest, shortExecshortDelay) {
|
||||||
void *mgmt = NULL;
|
void *mgmt = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -1076,11 +1091,11 @@ TEST(rcTest, shortExecshortDelay) {
|
||||||
stubSetPutDataBlock();
|
stubSetPutDataBlock();
|
||||||
stubSetGetDataBlock();
|
stubSetGetDataBlock();
|
||||||
|
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
qwtTestStop = false;
|
qwtTestStop = false;
|
||||||
qwtTestQuitThreadNum = 0;
|
qwtTestQuitThreadNum = 0;
|
||||||
|
|
||||||
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue, NULL);
|
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue, (sendReqToDnodeFp)qwtSendReqToDnode);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
qwtTestMaxExecTaskUsec = 0;
|
qwtTestMaxExecTaskUsec = 0;
|
||||||
|
@ -1157,11 +1172,11 @@ TEST(rcTest, longExecshortDelay) {
|
||||||
stubSetPutDataBlock();
|
stubSetPutDataBlock();
|
||||||
stubSetGetDataBlock();
|
stubSetGetDataBlock();
|
||||||
|
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
qwtTestStop = false;
|
qwtTestStop = false;
|
||||||
qwtTestQuitThreadNum = 0;
|
qwtTestQuitThreadNum = 0;
|
||||||
|
|
||||||
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue, NULL);
|
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue, (sendReqToDnodeFp)qwtSendReqToDnode);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
qwtTestMaxExecTaskUsec = 1000000;
|
qwtTestMaxExecTaskUsec = 1000000;
|
||||||
|
@ -1240,11 +1255,11 @@ TEST(rcTest, shortExeclongDelay) {
|
||||||
stubSetPutDataBlock();
|
stubSetPutDataBlock();
|
||||||
stubSetGetDataBlock();
|
stubSetGetDataBlock();
|
||||||
|
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
qwtTestStop = false;
|
qwtTestStop = false;
|
||||||
qwtTestQuitThreadNum = 0;
|
qwtTestQuitThreadNum = 0;
|
||||||
|
|
||||||
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue, NULL);
|
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue, (sendReqToDnodeFp)qwtSendReqToDnode);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
qwtTestMaxExecTaskUsec = 0;
|
qwtTestMaxExecTaskUsec = 0;
|
||||||
|
@ -1304,7 +1319,6 @@ TEST(rcTest, shortExeclongDelay) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
TEST(rcTest, dropTest) {
|
TEST(rcTest, dropTest) {
|
||||||
void *mgmt = NULL;
|
void *mgmt = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -1324,9 +1338,9 @@ TEST(rcTest, dropTest) {
|
||||||
stubSetPutDataBlock();
|
stubSetPutDataBlock();
|
||||||
stubSetGetDataBlock();
|
stubSetGetDataBlock();
|
||||||
|
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
|
|
||||||
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
|
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue, (sendReqToDnodeFp)qwtSendReqToDnode);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
tsem_init(&qwtTestQuerySem, 0, 0);
|
tsem_init(&qwtTestQuerySem, 0, 0);
|
||||||
|
@ -1336,7 +1350,7 @@ TEST(rcTest, dropTest) {
|
||||||
pthread_attr_init(&thattr);
|
pthread_attr_init(&thattr);
|
||||||
|
|
||||||
pthread_t t1,t2,t3,t4,t5;
|
pthread_t t1,t2,t3,t4,t5;
|
||||||
pthread_create(&(t1), &thattr, clientThread, mgmt);
|
pthread_create(&(t1), &thattr, qwtclientThread, mgmt);
|
||||||
pthread_create(&(t2), &thattr, queryQueueThread, mgmt);
|
pthread_create(&(t2), &thattr, queryQueueThread, mgmt);
|
||||||
pthread_create(&(t3), &thattr, fetchQueueThread, mgmt);
|
pthread_create(&(t3), &thattr, fetchQueueThread, mgmt);
|
||||||
|
|
||||||
|
@ -1354,11 +1368,10 @@ TEST(rcTest, dropTest) {
|
||||||
|
|
||||||
qWorkerDestroy(&mgmt);
|
qWorkerDestroy(&mgmt);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,27 +411,26 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t gConvertTypes[TSDB_DATA_TYPE_BLOB+1][TSDB_DATA_TYPE_BLOB+1] = {
|
int8_t gConvertTypes[TSDB_DATA_TYPE_BLOB+1][TSDB_DATA_TYPE_BLOB+1] = {
|
||||||
/* NULL BOOL TINY SMAL INT BIG FLOA DOUB BINA TIME NCHA UTIN USMA UINT UBIG VARC VARB JSON DECI BLOB */
|
/* NULL BOOL TINY SMAL INT BIG FLOA DOUB VARC TIME NCHA UTIN USMA UINT UBIG VARB JSON DECI BLOB */
|
||||||
/*NULL*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
/*NULL*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
/*BOOL*/ 0, 0, 0, 3, 4, 5, 6, 7, 7, 9, 7, 0, 12, 13, 14, 7, 7, 0, 0, 0,
|
/*BOOL*/ 0, 0, 0, 3, 4, 5, 6, 7, 7, 9, 7, 0, 12, 13, 14, 7, 0, 0, 0,
|
||||||
/*TINY*/ 0, 0, 0, 3, 4, 5, 6, 7, 7, 9, 7, 3, 4, 5, 7, 7, 7, 0, 0, 0,
|
/*TINY*/ 0, 0, 0, 3, 4, 5, 6, 7, 7, 9, 7, 3, 4, 5, 7, 7, 0, 0, 0,
|
||||||
/*SMAL*/ 0, 0, 0, 0, 4, 5, 6, 7, 7, 9, 7, 3, 4, 5, 7, 7, 7, 0, 0, 0,
|
/*SMAL*/ 0, 0, 0, 0, 4, 5, 6, 7, 7, 9, 7, 3, 4, 5, 7, 7, 0, 0, 0,
|
||||||
/*INT */ 0, 0, 0, 0, 0, 5, 6, 7, 7, 9, 7, 4, 4, 5, 7, 7, 7, 0, 0, 0,
|
/*INT */ 0, 0, 0, 0, 0, 5, 6, 7, 7, 9, 7, 4, 4, 5, 7, 7, 0, 0, 0,
|
||||||
/*BIGI*/ 0, 0, 0, 0, 0, 0, 6, 7, 7, 0, 7, 5, 5, 5, 7, 7, 7, 0, 0, 0,
|
/*BIGI*/ 0, 0, 0, 0, 0, 0, 6, 7, 7, 0, 7, 5, 5, 5, 7, 7, 0, 0, 0,
|
||||||
/*FLOA*/ 0, 0, 0, 0, 0, 0, 0, 7, 7, 6, 7, 6, 6, 6, 6, 7, 7, 0, 0, 0,
|
/*FLOA*/ 0, 0, 0, 0, 0, 0, 0, 7, 7, 6, 7, 6, 6, 6, 6, 7, 0, 0, 0,
|
||||||
/*DOUB*/ 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0,
|
/*DOUB*/ 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0,
|
||||||
/*BINA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0,
|
/*VARC*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 7, 7, 7, 0, 0, 0, 0,
|
||||||
/*TIME*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 9, 7, 7, 7, 0, 0, 0,
|
/*TIME*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 9, 7, 7, 0, 0, 0,
|
||||||
/*NCHA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0,
|
/*NCHA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0,
|
||||||
/*UTIN*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 7, 7, 0, 0, 0,
|
/*UTIN*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 7, 0, 0, 0,
|
||||||
/*USMA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 7, 7, 0, 0, 0,
|
/*USMA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 7, 0, 0, 0,
|
||||||
/*UINT*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 7, 7, 0, 0, 0,
|
/*UINT*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 7, 0, 0, 0,
|
||||||
/*UBIG*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0,
|
/*UBIG*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
|
||||||
/*VARC*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
/*VARB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
/*VARB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
/*JSON*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
/*JSON*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
/*DECI*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
/*DECI*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
/*BLOB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
/*BLOB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t vectorGetConvertType(int32_t type1, int32_t type2) {
|
int32_t vectorGetConvertType(int32_t type1, int32_t type2) {
|
||||||
|
|
|
@ -1286,7 +1286,7 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) {
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1435,7 +1435,7 @@ TEST(columnTest, greater_and_lower) {
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,7 @@ extern "C" {
|
||||||
|
|
||||||
#define SCHEDULE_DEFAULT_MAX_JOB_NUM 1000
|
#define SCHEDULE_DEFAULT_MAX_JOB_NUM 1000
|
||||||
#define SCHEDULE_DEFAULT_MAX_TASK_NUM 1000
|
#define SCHEDULE_DEFAULT_MAX_TASK_NUM 1000
|
||||||
#define SCHEDULE_DEFAULT_MAX_NODE_TABLE_NUM 20 // unit is TSDB_TABLE_NUM_UNIT
|
#define SCHEDULE_DEFAULT_MAX_NODE_TABLE_NUM 200 // unit is TSDB_TABLE_NUM_UNIT
|
||||||
|
|
||||||
|
|
||||||
#define SCH_MAX_CANDIDATE_EP_NUM TSDB_MAX_REPLICA
|
#define SCH_MAX_CANDIDATE_EP_NUM TSDB_MAX_REPLICA
|
||||||
|
|
||||||
|
@ -113,6 +112,7 @@ typedef struct SSchTask {
|
||||||
int32_t msgLen; // msg length
|
int32_t msgLen; // msg length
|
||||||
int8_t status; // task status
|
int8_t status; // task status
|
||||||
int32_t lastMsgType; // last sent msg type
|
int32_t lastMsgType; // last sent msg type
|
||||||
|
int32_t tryTimes; // task already tried times
|
||||||
SQueryNodeAddr succeedAddr; // task executed success node address
|
SQueryNodeAddr succeedAddr; // task executed success node address
|
||||||
int8_t candidateIdx; // current try condidation index
|
int8_t candidateIdx; // current try condidation index
|
||||||
SArray *candidateAddrs; // condidate node addresses, element is SQueryNodeAddr
|
SArray *candidateAddrs; // condidate node addresses, element is SQueryNodeAddr
|
||||||
|
@ -176,9 +176,12 @@ extern SSchedulerMgmt schMgmt;
|
||||||
|
|
||||||
#define SCH_SET_TASK_STATUS(task, st) atomic_store_8(&(task)->status, st)
|
#define SCH_SET_TASK_STATUS(task, st) atomic_store_8(&(task)->status, st)
|
||||||
#define SCH_GET_TASK_STATUS(task) atomic_load_8(&(task)->status)
|
#define SCH_GET_TASK_STATUS(task) atomic_load_8(&(task)->status)
|
||||||
|
#define SCH_GET_TASK_STATUS_STR(task) jobTaskStatusStr(SCH_GET_TASK_STATUS(task))
|
||||||
|
|
||||||
|
|
||||||
#define SCH_SET_JOB_STATUS(job, st) atomic_store_8(&(job)->status, st)
|
#define SCH_SET_JOB_STATUS(job, st) atomic_store_8(&(job)->status, st)
|
||||||
#define SCH_GET_JOB_STATUS(job) atomic_load_8(&(job)->status)
|
#define SCH_GET_JOB_STATUS(job) atomic_load_8(&(job)->status)
|
||||||
|
#define SCH_GET_JOB_STATUS_STR(job) jobTaskStatusStr(SCH_GET_JOB_STATUS(job))
|
||||||
|
|
||||||
#define SCH_SET_JOB_NEED_FLOW_CTRL(_job) (_job)->attr.needFlowCtrl = true
|
#define SCH_SET_JOB_NEED_FLOW_CTRL(_job) (_job)->attr.needFlowCtrl = true
|
||||||
#define SCH_JOB_NEED_FLOW_CTRL(_job) ((_job)->attr.needFlowCtrl)
|
#define SCH_JOB_NEED_FLOW_CTRL(_job) ((_job)->attr.needFlowCtrl)
|
||||||
|
@ -193,6 +196,7 @@ extern SSchedulerMgmt schMgmt;
|
||||||
#define SCH_IS_LEVEL_UNFINISHED(_level) ((_level)->taskLaunchedNum < (_level)->taskNum)
|
#define SCH_IS_LEVEL_UNFINISHED(_level) ((_level)->taskLaunchedNum < (_level)->taskNum)
|
||||||
#define SCH_GET_CUR_EP(_addr) (&(_addr)->epSet.eps[(_addr)->epSet.inUse])
|
#define SCH_GET_CUR_EP(_addr) (&(_addr)->epSet.eps[(_addr)->epSet.inUse])
|
||||||
#define SCH_SWITCH_EPSET(_addr) ((_addr)->epSet.inUse = ((_addr)->epSet.inUse + 1) % (_addr)->epSet.numOfEps)
|
#define SCH_SWITCH_EPSET(_addr) ((_addr)->epSet.inUse = ((_addr)->epSet.inUse + 1) % (_addr)->epSet.numOfEps)
|
||||||
|
#define SCH_TASK_NUM_OF_EPS(_addr) ((_addr)->epSet.numOfEps)
|
||||||
|
|
||||||
#define SCH_JOB_ELOG(param, ...) qError("QID:0x%" PRIx64 " " param, pJob->queryId, __VA_ARGS__)
|
#define SCH_JOB_ELOG(param, ...) qError("QID:0x%" PRIx64 " " param, pJob->queryId, __VA_ARGS__)
|
||||||
#define SCH_JOB_DLOG(param, ...) qDebug("QID:0x%" PRIx64 " " param, pJob->queryId, __VA_ARGS__)
|
#define SCH_JOB_DLOG(param, ...) qDebug("QID:0x%" PRIx64 " " param, pJob->queryId, __VA_ARGS__)
|
||||||
|
@ -223,7 +227,7 @@ int32_t schCheckIncTaskFlowQuota(SSchJob *pJob, SSchTask *pTask, bool *enough);
|
||||||
int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask);
|
int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask);
|
||||||
int32_t schLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask);
|
int32_t schLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask);
|
||||||
int32_t schFetchFromRemote(SSchJob *pJob);
|
int32_t schFetchFromRemote(SSchJob *pJob);
|
||||||
int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode, SQueryErrorInfo *errInfo);
|
int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -259,7 +259,7 @@ _return:
|
||||||
SCH_UNLOCK(SCH_WRITE, &ctrl->lock);
|
SCH_UNLOCK(SCH_WRITE, &ctrl->lock);
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
code = schProcessOnTaskFailure(pJob, pTask, code, NULL);
|
code = schProcessOnTaskFailure(pJob, pTask, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
|
|
|
@ -105,7 +105,7 @@ static FORCE_INLINE bool schJobNeedToStop(SSchJob *pJob, int8_t *pStatus) {
|
||||||
|
|
||||||
int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgType) {
|
int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgType) {
|
||||||
int32_t lastMsgType = SCH_GET_TASK_LASTMSG_TYPE(pTask);
|
int32_t lastMsgType = SCH_GET_TASK_LASTMSG_TYPE(pTask);
|
||||||
|
int32_t taskStatus = SCH_GET_TASK_STATUS(pTask);
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case TDMT_VND_CREATE_TABLE_RSP:
|
case TDMT_VND_CREATE_TABLE_RSP:
|
||||||
case TDMT_VND_SUBMIT_RSP:
|
case TDMT_VND_SUBMIT_RSP:
|
||||||
|
@ -118,14 +118,14 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SCH_GET_TASK_STATUS(pTask) != JOB_TASK_STATUS_EXECUTING && SCH_GET_TASK_STATUS(pTask) != JOB_TASK_STATUS_PARTIAL_SUCCEED) {
|
if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) {
|
||||||
SCH_TASK_ELOG("rsp msg conflicted with task status, status:%d, rspType:%s", SCH_GET_TASK_STATUS(pTask), TMSG_INFO(msgType));
|
SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType));
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SCH_TASK_ELOG("unknown rsp msg, type:%s, status:%d", TMSG_INFO(msgType), SCH_GET_TASK_STATUS(pTask));
|
SCH_TASK_ELOG("unknown rsp msg, type:%s, status:%s", TMSG_INFO(msgType), jobTaskStatusStr(taskStatus));
|
||||||
|
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ int32_t schCheckAndUpdateJobStatus(SSchJob *pJob, int8_t newStatus) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SCH_JOB_ELOG("invalid job status:%d", oriStatus);
|
SCH_JOB_ELOG("invalid job status:%s", jobTaskStatusStr(oriStatus));
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ int32_t schCheckAndUpdateJobStatus(SSchJob *pJob, int8_t newStatus) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_JOB_DLOG("job status updated from %d to %d", oriStatus, newStatus);
|
SCH_JOB_DLOG("job status updated from %s to %s", jobTaskStatusStr(oriStatus), jobTaskStatusStr(newStatus));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ int32_t schCheckAndUpdateJobStatus(SSchJob *pJob, int8_t newStatus) {
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
SCH_JOB_ELOG("invalid job status update, from %d to %d", oriStatus, newStatus);
|
SCH_JOB_ELOG("invalid job status update, from %s to %s", jobTaskStatusStr(oriStatus), jobTaskStatusStr(newStatus));
|
||||||
|
|
||||||
SCH_ERR_RET(code);
|
SCH_ERR_RET(code);
|
||||||
}
|
}
|
||||||
|
@ -503,7 +503,7 @@ int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
|
||||||
int32_t schMoveTaskToSuccList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
|
int32_t schMoveTaskToSuccList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
|
||||||
if (0 != taosHashRemove(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId))) {
|
if (0 != taosHashRemove(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId))) {
|
||||||
SCH_TASK_WLOG("remove task from execTask list failed, may not exist, status:%d", SCH_GET_TASK_STATUS(pTask));
|
SCH_TASK_WLOG("remove task from execTask list failed, may not exist, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||||
} else {
|
} else {
|
||||||
SCH_TASK_DLOG("task removed from execTask list, numOfTasks:%d", taosHashGetSize(pJob->execTasks));
|
SCH_TASK_DLOG("task removed from execTask list, numOfTasks:%d", taosHashGetSize(pJob->execTasks));
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,7 @@ int32_t schMoveTaskToSuccList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
|
||||||
if (HASH_NODE_EXIST(code)) {
|
if (HASH_NODE_EXIST(code)) {
|
||||||
*moved = true;
|
*moved = true;
|
||||||
|
|
||||||
SCH_TASK_ELOG("task already in succTask list, status:%d", SCH_GET_TASK_STATUS(pTask));
|
SCH_TASK_ELOG("task already in succTask list, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ int32_t schMoveTaskToFailList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
|
||||||
*moved = false;
|
*moved = false;
|
||||||
|
|
||||||
if (0 != taosHashRemove(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId))) {
|
if (0 != taosHashRemove(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId))) {
|
||||||
SCH_TASK_WLOG("remove task from execTask list failed, may not exist, status:%d", SCH_GET_TASK_STATUS(pTask));
|
SCH_TASK_WLOG("remove task from execTask list failed, may not exist, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = taosHashPut(pJob->failTasks, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES);
|
int32_t code = taosHashPut(pJob->failTasks, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES);
|
||||||
|
@ -540,7 +540,7 @@ int32_t schMoveTaskToFailList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
|
||||||
if (HASH_NODE_EXIST(code)) {
|
if (HASH_NODE_EXIST(code)) {
|
||||||
*moved = true;
|
*moved = true;
|
||||||
|
|
||||||
SCH_TASK_WLOG("task already in failTask list, status:%d", SCH_GET_TASK_STATUS(pTask));
|
SCH_TASK_WLOG("task already in failTask list, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ int32_t schMoveTaskToFailList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
|
||||||
|
|
||||||
int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
|
int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
|
||||||
if (0 != taosHashRemove(pJob->succTasks, &pTask->taskId, sizeof(pTask->taskId))) {
|
if (0 != taosHashRemove(pJob->succTasks, &pTask->taskId, sizeof(pTask->taskId))) {
|
||||||
SCH_TASK_WLOG("remove task from succTask list failed, may not exist, status:%d", SCH_GET_TASK_STATUS(pTask));
|
SCH_TASK_WLOG("remove task from succTask list failed, may not exist, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = taosHashPut(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES);
|
int32_t code = taosHashPut(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES);
|
||||||
|
@ -566,7 +566,7 @@ int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
|
||||||
if (HASH_NODE_EXIST(code)) {
|
if (HASH_NODE_EXIST(code)) {
|
||||||
*moved = true;
|
*moved = true;
|
||||||
|
|
||||||
SCH_TASK_ELOG("task already in execTask list, status:%d", SCH_GET_TASK_STATUS(pTask));
|
SCH_TASK_ELOG("task already in execTask list, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,26 +583,48 @@ int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
|
||||||
|
|
||||||
|
|
||||||
int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bool *needRetry) {
|
int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bool *needRetry) {
|
||||||
// TODO set retry or not based on task type/errCode/retry times/job status/available eps...
|
int8_t status = 0;
|
||||||
|
++pTask->tryTimes;
|
||||||
|
|
||||||
|
if (schJobNeedToStop(pJob, &status)) {
|
||||||
*needRetry = false;
|
*needRetry = false;
|
||||||
|
SCH_TASK_DLOG("task no more retry cause of job status, job status:%s", jobTaskStatusStr(status));
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTask->tryTimes >= REQUEST_MAX_TRY_TIMES) {
|
||||||
|
*needRetry = false;
|
||||||
|
SCH_TASK_DLOG("task no more retry since reach max try times, tryTimes:%d", pTask->tryTimes);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NEED_SCHEDULER_RETRY_ERROR(errCode)) {
|
||||||
|
*needRetry = false;
|
||||||
|
SCH_TASK_DLOG("task no more retry cause of errCode, errCode:%x - %s", errCode, tstrerror(errCode));
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO CHECK epList/condidateList
|
//TODO CHECK epList/condidateList
|
||||||
if (SCH_IS_DATA_SRC_QRY_TASK(pTask)) {
|
if (SCH_IS_DATA_SRC_TASK(pTask)) {
|
||||||
|
if (pTask->tryTimes >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) {
|
||||||
|
*needRetry = false;
|
||||||
|
SCH_TASK_DLOG("task no more retry since all ep tried, tryTimes:%d, epNum:%d", pTask->tryTimes, SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode));
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
int32_t candidateNum = taosArrayGetSize(pTask->candidateAddrs);
|
int32_t candidateNum = taosArrayGetSize(pTask->candidateAddrs);
|
||||||
|
|
||||||
if ((pTask->candidateIdx + 1) >= candidateNum) {
|
if ((pTask->candidateIdx + 1) >= candidateNum) {
|
||||||
|
*needRetry = false;
|
||||||
|
SCH_TASK_DLOG("task no more retry since all candiates tried, candidateIdx:%d, candidateNum:%d", pTask->candidateIdx, candidateNum);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
++pTask->candidateIdx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*needRetry = true;
|
||||||
|
SCH_TASK_DLOG("task need the %dth retry, errCode:%x - %s", pTask->tryTimes, errCode, tstrerror(errCode));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) {
|
int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
@ -613,7 +635,7 @@ int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) {
|
||||||
SCH_ERR_RET(schLaunchTasksInFlowCtrlList(pJob, pTask));
|
SCH_ERR_RET(schLaunchTasksInFlowCtrlList(pJob, pTask));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SCH_IS_DATA_SRC_QRY_TASK(pTask)) {
|
if (SCH_IS_DATA_SRC_TASK(pTask)) {
|
||||||
SCH_SWITCH_EPSET(&pTask->plan->execNode);
|
SCH_SWITCH_EPSET(&pTask->plan->execNode);
|
||||||
} else {
|
} else {
|
||||||
++pTask->candidateIdx;
|
++pTask->candidateIdx;
|
||||||
|
@ -671,13 +693,41 @@ int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchHbTrans *trans) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void schUpdateJobErrCode(SSchJob *pJob, int32_t errCode) {
|
||||||
|
if (TSDB_CODE_SUCCESS == errCode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t origCode = atomic_load_32(&pJob->errCode);
|
||||||
|
if (TSDB_CODE_SUCCESS == origCode) {
|
||||||
|
if (origCode == atomic_val_compare_exchange_32(&pJob->errCode, origCode, errCode)) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
origCode = atomic_load_32(&pJob->errCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NEED_CLIENT_HANDLE_ERROR(origCode)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NEED_CLIENT_HANDLE_ERROR(errCode)) {
|
||||||
|
atomic_store_32(&pJob->errCode, errCode);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
SCH_JOB_DLOG("job errCode updated to %x - %s", errCode, tstrerror(errCode));
|
||||||
|
}
|
||||||
|
|
||||||
int32_t schProcessOnJobFailureImpl(SSchJob *pJob, int32_t status, int32_t errCode) {
|
int32_t schProcessOnJobFailureImpl(SSchJob *pJob, int32_t status, int32_t errCode) {
|
||||||
// if already FAILED, no more processing
|
// if already FAILED, no more processing
|
||||||
SCH_ERR_RET(schCheckAndUpdateJobStatus(pJob, status));
|
SCH_ERR_RET(schCheckAndUpdateJobStatus(pJob, status));
|
||||||
|
|
||||||
if (errCode) {
|
schUpdateJobErrCode(pJob, errCode);
|
||||||
atomic_store_32(&pJob->errCode, errCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (atomic_load_8(&pJob->userFetch) || pJob->attr.syncSchedule) {
|
if (atomic_load_8(&pJob->userFetch) || pJob->attr.syncSchedule) {
|
||||||
tsem_post(&pJob->rspSem);
|
tsem_post(&pJob->rspSem);
|
||||||
|
@ -729,37 +779,12 @@ int32_t schProcessOnDataFetched(SSchJob *job) {
|
||||||
tsem_post(&job->rspSem);
|
tsem_post(&job->rspSem);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schPushToErrInfoList(SSchJob *pJob, SSchTask *pTask, SQueryErrorInfo *errInfo) {
|
|
||||||
if (NULL == errInfo || !SCH_IS_DATA_SRC_TASK(pTask) || !IS_CLIENT_RETRY_ERROR(errInfo->code)) {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL == pJob->errList) {
|
|
||||||
SSchLevel *level = taosArrayGetLast(pJob->levels);
|
|
||||||
|
|
||||||
pJob->errList = taosArrayInit(level->taskNum, sizeof(SQueryErrorInfo));
|
|
||||||
if (NULL == pJob->errList) {
|
|
||||||
SCH_TASK_ELOG("taosArrayInit %d errInfofailed", pJob->taskNum);
|
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL == taosArrayPush(pJob->errList, errInfo)) {
|
|
||||||
SCH_TASK_ELOG("taosArrayPush errInfo to list failed, errCode:%x", errInfo->code);
|
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Note: no more task error processing, handled in function internal
|
// Note: no more task error processing, handled in function internal
|
||||||
int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode, SQueryErrorInfo *errInfo) {
|
int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode) {
|
||||||
int8_t status = 0;
|
int8_t status = 0;
|
||||||
|
|
||||||
if (schJobNeedToStop(pJob, &status)) {
|
if (schJobNeedToStop(pJob, &status)) {
|
||||||
SCH_TASK_DLOG("task failed not processed cause of job status, job status:%d", status);
|
SCH_TASK_DLOG("task failed not processed cause of job status, job status:%s", jobTaskStatusStr(status));
|
||||||
|
|
||||||
SCH_RET(atomic_load_32(&pJob->errCode));
|
SCH_RET(atomic_load_32(&pJob->errCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -778,25 +803,23 @@ int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode,
|
||||||
if (SCH_GET_TASK_STATUS(pTask) == JOB_TASK_STATUS_EXECUTING) {
|
if (SCH_GET_TASK_STATUS(pTask) == JOB_TASK_STATUS_EXECUTING) {
|
||||||
SCH_ERR_JRET(schMoveTaskToFailList(pJob, pTask, &moved));
|
SCH_ERR_JRET(schMoveTaskToFailList(pJob, pTask, &moved));
|
||||||
} else {
|
} else {
|
||||||
SCH_TASK_ELOG("task not in executing list, status:%d", SCH_GET_TASK_STATUS(pTask));
|
SCH_TASK_ELOG("task not in executing list, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||||
SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_FAILED);
|
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_FAILED);
|
||||||
|
|
||||||
SCH_ERR_JRET(schPushToErrInfoList(pJob, pTask, errInfo));
|
|
||||||
|
|
||||||
if (SCH_IS_WAIT_ALL_JOB(pJob)) {
|
if (SCH_IS_WAIT_ALL_JOB(pJob)) {
|
||||||
SCH_LOCK(SCH_WRITE, &pTask->level->lock);
|
SCH_LOCK(SCH_WRITE, &pTask->level->lock);
|
||||||
pTask->level->taskFailed++;
|
pTask->level->taskFailed++;
|
||||||
taskDone = pTask->level->taskSucceed + pTask->level->taskFailed;
|
taskDone = pTask->level->taskSucceed + pTask->level->taskFailed;
|
||||||
SCH_UNLOCK(SCH_WRITE, &pTask->level->lock);
|
SCH_UNLOCK(SCH_WRITE, &pTask->level->lock);
|
||||||
|
|
||||||
atomic_store_32(&pJob->errCode, errCode);
|
schUpdateJobErrCode(pJob, errCode);
|
||||||
|
|
||||||
if (taskDone < pTask->level->taskNum) {
|
if (taskDone < pTask->level->taskNum) {
|
||||||
SCH_TASK_DLOG("not all tasks done, done:%d, all:%d", taskDone, pTask->level->taskNum);
|
SCH_TASK_DLOG("need to wait other tasks, doneNum:%d, allNum:%d", taskDone, pTask->level->taskNum);
|
||||||
SCH_ERR_RET(errCode);
|
SCH_RET(errCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -815,7 +838,7 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
|
||||||
bool moved = false;
|
bool moved = false;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
SCH_TASK_DLOG("taskOnSuccess, status:%d", SCH_GET_TASK_STATUS(pTask));
|
SCH_TASK_DLOG("taskOnSuccess, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||||
|
|
||||||
SCH_ERR_JRET(schMoveTaskToSuccList(pJob, pTask, &moved));
|
SCH_ERR_JRET(schMoveTaskToSuccList(pJob, pTask, &moved));
|
||||||
|
|
||||||
|
@ -914,7 +937,7 @@ _return:
|
||||||
|
|
||||||
atomic_val_compare_exchange_32(&pJob->remoteFetch, 1, 0);
|
atomic_val_compare_exchange_32(&pJob->remoteFetch, 1, 0);
|
||||||
|
|
||||||
SCH_RET(schProcessOnTaskFailure(pJob, pJob->fetchTask, code, NULL));
|
SCH_RET(schProcessOnTaskFailure(pJob, pJob->fetchTask, code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -922,11 +945,9 @@ _return:
|
||||||
int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, char *msg, int32_t msgSize, int32_t rspCode) {
|
int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, char *msg, int32_t msgSize, int32_t rspCode) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int8_t status = 0;
|
int8_t status = 0;
|
||||||
bool errInfoGot = false;
|
|
||||||
SQueryErrorInfo errInfo = {0};
|
|
||||||
|
|
||||||
if (schJobNeedToStop(pJob, &status)) {
|
if (schJobNeedToStop(pJob, &status)) {
|
||||||
SCH_TASK_ELOG("rsp not processed cause of job status, job status:%d", status);
|
SCH_TASK_ELOG("rsp not processed cause of job status, job status:%s, rspCode:0x%x", jobTaskStatusStr(status), rspCode);
|
||||||
|
|
||||||
SCH_RET(atomic_load_32(&pJob->errCode));
|
SCH_RET(atomic_load_32(&pJob->errCode));
|
||||||
}
|
}
|
||||||
|
@ -935,28 +956,38 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
||||||
|
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case TDMT_VND_CREATE_TABLE_RSP: {
|
case TDMT_VND_CREATE_TABLE_RSP: {
|
||||||
|
SVCreateTbBatchRsp batchRsp = {0};
|
||||||
|
if (msg) {
|
||||||
|
tDeserializeSVCreateTbBatchRsp(msg, msgSize, &batchRsp);
|
||||||
|
if (batchRsp.rspList) {
|
||||||
|
int32_t num = taosArrayGetSize(batchRsp.rspList);
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
SVCreateTbRsp *rsp = taosArrayGet(batchRsp.rspList, i);
|
||||||
|
if (NEED_CLIENT_HANDLE_ERROR(rsp->code)) {
|
||||||
|
taosArrayDestroy(batchRsp.rspList);
|
||||||
|
SCH_ERR_JRET(rsp->code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(batchRsp.rspList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SCH_ERR_JRET(rspCode);
|
SCH_ERR_JRET(rspCode);
|
||||||
SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask));
|
SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_SUBMIT_RSP: {
|
case TDMT_VND_SUBMIT_RSP: {
|
||||||
#if 0 //TODO OPEN THIS
|
if (msg) {
|
||||||
SShellSubmitRspMsg *rsp = (SShellSubmitRspMsg *)msg;
|
|
||||||
|
|
||||||
if (rspCode != TSDB_CODE_SUCCESS || NULL == msg || rsp->code != TSDB_CODE_SUCCESS) {
|
|
||||||
SCH_ERR_RET(schProcessOnTaskFailure(pJob, pTask, rspCode));
|
|
||||||
}
|
|
||||||
|
|
||||||
pJob->resNumOfRows += rsp->affectedRows;
|
|
||||||
#else
|
|
||||||
SCH_ERR_JRET(rspCode);
|
|
||||||
|
|
||||||
SSubmitRsp *rsp = (SSubmitRsp *)msg;
|
SSubmitRsp *rsp = (SSubmitRsp *)msg;
|
||||||
if (rsp) {
|
|
||||||
|
SCH_ERR_JRET(rsp->code);
|
||||||
|
|
||||||
pJob->resNumOfRows += rsp->affectedRows;
|
pJob->resNumOfRows += rsp->affectedRows;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
SCH_ERR_JRET(rspCode);
|
||||||
|
|
||||||
SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask));
|
SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask));
|
||||||
|
|
||||||
|
@ -966,12 +997,6 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
||||||
SQueryTableRsp rsp = {0};
|
SQueryTableRsp rsp = {0};
|
||||||
if (msg) {
|
if (msg) {
|
||||||
tDeserializeSQueryTableRsp(msg, msgSize, &rsp);
|
tDeserializeSQueryTableRsp(msg, msgSize, &rsp);
|
||||||
if (rsp.code) {
|
|
||||||
errInfo.code = rsp.code;
|
|
||||||
errInfo.tableName = rsp.tableName;
|
|
||||||
errInfoGot = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SCH_ERR_JRET(rsp.code);
|
SCH_ERR_JRET(rsp.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1031,7 +1056,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
SCH_TASK_ELOG("unknown rsp msg, type:%d, status:%d", msgType, SCH_GET_TASK_STATUS(pTask));
|
SCH_TASK_ELOG("unknown rsp msg, type:%d, status:%s", msgType, SCH_GET_TASK_STATUS_STR(pTask));
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1039,7 +1064,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
SCH_RET(schProcessOnTaskFailure(pJob, pTask, code, errInfoGot ? &errInfo : NULL));
|
SCH_RET(schProcessOnTaskFailure(pJob, pTask, code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1285,6 +1310,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
|
|
||||||
memcpy(pMsg->msg, pJob->sql, len);
|
memcpy(pMsg->msg, pJob->sql, len);
|
||||||
memcpy(pMsg->msg + len, pTask->msg, pTask->msgLen);
|
memcpy(pMsg->msg + len, pTask->msg, pTask->msgLen);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1410,7 +1436,7 @@ int32_t schLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) {
|
||||||
atomic_add_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
atomic_add_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
||||||
|
|
||||||
if (schJobNeedToStop(pJob, &status)) {
|
if (schJobNeedToStop(pJob, &status)) {
|
||||||
SCH_TASK_DLOG("no need to launch task cause of job status, job status:%d", status);
|
SCH_TASK_DLOG("no need to launch task cause of job status, job status:%s", jobTaskStatusStr(status));
|
||||||
|
|
||||||
SCH_RET(atomic_load_32(&pJob->errCode));
|
SCH_RET(atomic_load_32(&pJob->errCode));
|
||||||
}
|
}
|
||||||
|
@ -1463,7 +1489,7 @@ int32_t schLaunchTask(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
SCH_RET(schProcessOnTaskFailure(pJob, pTask, code, NULL));
|
SCH_RET(schProcessOnTaskFailure(pJob, pTask, code));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schLaunchLevelTasks(SSchJob *pJob, SSchLevel *level) {
|
int32_t schLaunchLevelTasks(SSchJob *pJob, SSchLevel *level) {
|
||||||
|
@ -1492,14 +1518,14 @@ int32_t schLaunchJob(SSchJob *pJob) {
|
||||||
|
|
||||||
void schDropTaskOnExecutedNode(SSchJob *pJob, SSchTask *pTask) {
|
void schDropTaskOnExecutedNode(SSchJob *pJob, SSchTask *pTask) {
|
||||||
if (NULL == pTask->execAddrs) {
|
if (NULL == pTask->execAddrs) {
|
||||||
SCH_TASK_DLOG("no exec address, status:%d", SCH_GET_TASK_STATUS(pTask));
|
SCH_TASK_DLOG("no exec address, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t size = (int32_t)taosArrayGetSize(pTask->execAddrs);
|
int32_t size = (int32_t)taosArrayGetSize(pTask->execAddrs);
|
||||||
|
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
SCH_TASK_DLOG("task has no exec address, no need to drop it, status:%d", SCH_GET_TASK_STATUS(pTask));
|
SCH_TASK_DLOG("task has no exec address, no need to drop it, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1579,7 +1605,6 @@ void schFreeJobImpl(void *job) {
|
||||||
|
|
||||||
taosArrayDestroy(pJob->levels);
|
taosArrayDestroy(pJob->levels);
|
||||||
taosArrayDestroy(pJob->nodeList);
|
taosArrayDestroy(pJob->nodeList);
|
||||||
taosArrayDestroy(pJob->errList);
|
|
||||||
|
|
||||||
tfree(pJob->resData);
|
tfree(pJob->resData);
|
||||||
|
|
||||||
|
@ -1649,11 +1674,11 @@ static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan* pD
|
||||||
*job = pJob->refId;
|
*job = pJob->refId;
|
||||||
|
|
||||||
if (syncSchedule) {
|
if (syncSchedule) {
|
||||||
SCH_JOB_DLOG("will wait for rsp now, job status:%d", SCH_GET_JOB_STATUS(pJob));
|
SCH_JOB_DLOG("will wait for rsp now, job status:%s", SCH_GET_JOB_STATUS_STR(pJob));
|
||||||
tsem_wait(&pJob->rspSem);
|
tsem_wait(&pJob->rspSem);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_JOB_DLOG("job exec done, job status:%d", SCH_GET_JOB_STATUS(pJob));
|
SCH_JOB_DLOG("job exec done, job status:%s", SCH_GET_JOB_STATUS_STR(pJob));
|
||||||
|
|
||||||
schReleaseJob(pJob->refId);
|
schReleaseJob(pJob->refId);
|
||||||
|
|
||||||
|
@ -1719,8 +1744,6 @@ int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryPlan* pDag, in
|
||||||
|
|
||||||
pRes->code = atomic_load_32(&job->errCode);
|
pRes->code = atomic_load_32(&job->errCode);
|
||||||
pRes->numOfRows = job->resNumOfRows;
|
pRes->numOfRows = job->resNumOfRows;
|
||||||
pRes->errList = job->errList;
|
|
||||||
job->errList = NULL;
|
|
||||||
|
|
||||||
schReleaseJob(*pJob);
|
schReleaseJob(*pJob);
|
||||||
|
|
||||||
|
@ -1873,13 +1896,13 @@ int32_t schedulerFetchRows(int64_t job, void** pData) {
|
||||||
|
|
||||||
int8_t status = SCH_GET_JOB_STATUS(pJob);
|
int8_t status = SCH_GET_JOB_STATUS(pJob);
|
||||||
if (status == JOB_TASK_STATUS_DROPPING) {
|
if (status == JOB_TASK_STATUS_DROPPING) {
|
||||||
SCH_JOB_ELOG("job is dropping, status:%d", status);
|
SCH_JOB_ELOG("job is dropping, status:%s", jobTaskStatusStr(status));
|
||||||
schReleaseJob(job);
|
schReleaseJob(job);
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SCH_JOB_NEED_FETCH(pJob)) {
|
if (!SCH_JOB_NEED_FETCH(pJob)) {
|
||||||
SCH_JOB_ELOG("no need to fetch data, status:%d", SCH_GET_JOB_STATUS(pJob));
|
SCH_JOB_ELOG("no need to fetch data, status:%s", SCH_GET_JOB_STATUS_STR(pJob));
|
||||||
schReleaseJob(job);
|
schReleaseJob(job);
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -1891,10 +1914,10 @@ int32_t schedulerFetchRows(int64_t job, void** pData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JOB_TASK_STATUS_FAILED == status || JOB_TASK_STATUS_DROPPING == status) {
|
if (JOB_TASK_STATUS_FAILED == status || JOB_TASK_STATUS_DROPPING == status) {
|
||||||
SCH_JOB_ELOG("job failed or dropping, status:%d", status);
|
SCH_JOB_ELOG("job failed or dropping, status:%s", jobTaskStatusStr(status));
|
||||||
SCH_ERR_JRET(atomic_load_32(&pJob->errCode));
|
SCH_ERR_JRET(atomic_load_32(&pJob->errCode));
|
||||||
} else if (status == JOB_TASK_STATUS_SUCCEED) {
|
} else if (status == JOB_TASK_STATUS_SUCCEED) {
|
||||||
SCH_JOB_DLOG("job already succeed, status:%d", status);
|
SCH_JOB_DLOG("job already succeed, status:%s", jobTaskStatusStr(status));
|
||||||
goto _return;
|
goto _return;
|
||||||
} else if (status == JOB_TASK_STATUS_PARTIAL_SUCCEED) {
|
} else if (status == JOB_TASK_STATUS_PARTIAL_SUCCEED) {
|
||||||
SCH_ERR_JRET(schFetchFromRemote(pJob));
|
SCH_ERR_JRET(schFetchFromRemote(pJob));
|
||||||
|
@ -1905,7 +1928,7 @@ int32_t schedulerFetchRows(int64_t job, void** pData) {
|
||||||
status = SCH_GET_JOB_STATUS(pJob);
|
status = SCH_GET_JOB_STATUS(pJob);
|
||||||
|
|
||||||
if (JOB_TASK_STATUS_FAILED == status || JOB_TASK_STATUS_DROPPING == status) {
|
if (JOB_TASK_STATUS_FAILED == status || JOB_TASK_STATUS_DROPPING == status) {
|
||||||
SCH_JOB_ELOG("job failed or dropping, status:%d", status);
|
SCH_JOB_ELOG("job failed or dropping, status:%s", jobTaskStatusStr(status));
|
||||||
SCH_ERR_JRET(atomic_load_32(&pJob->errCode));
|
SCH_ERR_JRET(atomic_load_32(&pJob->errCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -724,7 +724,7 @@ TEST(queryTest, flowCtrlCase) {
|
||||||
|
|
||||||
schtInitLogFile();
|
schtInitLogFile();
|
||||||
|
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
|
|
||||||
SArray *qnodeList = taosArrayInit(1, sizeof(SEp));
|
SArray *qnodeList = taosArrayInit(1, sizeof(SEp));
|
||||||
|
|
||||||
|
@ -873,7 +873,7 @@ TEST(multiThread, forceFree) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
taosSeedRand(time(NULL));
|
taosSeedRand(taosGetTimestampSec());
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue