Merge branch '3.0' into test/jcy
This commit is contained in:
commit
a3d7e07f3e
|
@ -1,5 +1,7 @@
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
|
|
||||||
#set output directory
|
#set output directory
|
||||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
|
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
|
||||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
|
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
|
||||||
|
@ -43,11 +45,14 @@ ENDIF ()
|
||||||
IF (TD_WINDOWS)
|
IF (TD_WINDOWS)
|
||||||
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
||||||
SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE)
|
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-")
|
SET(COMMON_FLAGS "/W3 /D_WIN32")
|
||||||
|
|
||||||
IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
||||||
SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
# SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
||||||
ENDIF ()
|
# ENDIF ()
|
||||||
|
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")
|
||||||
|
|
||||||
ELSE ()
|
ELSE ()
|
||||||
IF (${SANITIZER} MATCHES "true")
|
IF (${SANITIZER} MATCHES "true")
|
||||||
|
|
|
@ -25,9 +25,28 @@ IF(${TD_WINDOWS})
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
ENDIF ()
|
MESSAGE("build msvcregex Win32")
|
||||||
|
option(
|
||||||
|
BUILD_MSVCREGEX
|
||||||
|
"If build msvcregex on Windows"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
IF(${TD_LINUX} MATCHES TRUE)
|
MESSAGE("build wcwidth Win32")
|
||||||
|
option(
|
||||||
|
BUILD_WCWIDTH
|
||||||
|
"If build wcwidth on Windows"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
|
MESSAGE("build wingetopt Win32")
|
||||||
|
option(
|
||||||
|
BUILD_WINGETOPT
|
||||||
|
"If build wingetopt on Windows"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_TEST
|
BUILD_TEST
|
||||||
|
@ -35,8 +54,6 @@ option(
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_LEVELDB
|
BUILD_WITH_LEVELDB
|
||||||
"If build with leveldb"
|
"If build with leveldb"
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
# msvcregex
|
||||||
|
ExternalProject_Add(msvcregex
|
||||||
|
GIT_REPOSITORY https://gitee.com/l0km/libgnurx-msvc.git
|
||||||
|
GIT_TAG master
|
||||||
|
SOURCE_DIR "${TD_CONTRIB_DIR}/msvcregex"
|
||||||
|
BINARY_DIR ""
|
||||||
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
TEST_COMMAND ""
|
||||||
|
)
|
|
@ -3,7 +3,7 @@
|
||||||
ExternalProject_Add(pthread
|
ExternalProject_Add(pthread
|
||||||
GIT_REPOSITORY https://github.com/GerHobbelt/pthread-win32
|
GIT_REPOSITORY https://github.com/GerHobbelt/pthread-win32
|
||||||
GIT_TAG v3.0.3.1
|
GIT_TAG v3.0.3.1
|
||||||
SOURCE_DIR "${TD_CONTRIB_DIR}/pthread-win32"
|
SOURCE_DIR "${TD_CONTRIB_DIR}/pthread"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
CONFIGURE_COMMAND ""
|
CONFIGURE_COMMAND ""
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
# wcwidth
|
||||||
|
ExternalProject_Add(wcwidth
|
||||||
|
GIT_REPOSITORY https://github.com/fumiyas/wcwidth-cjk.git
|
||||||
|
GIT_TAG master
|
||||||
|
SOURCE_DIR "${TD_CONTRIB_DIR}/wcwidth"
|
||||||
|
BINARY_DIR ""
|
||||||
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
TEST_COMMAND ""
|
||||||
|
)
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
# wingetopt
|
||||||
|
ExternalProject_Add(wingetopt
|
||||||
|
GIT_REPOSITORY https://github.com/alex85k/wingetopt.git
|
||||||
|
GIT_TAG master
|
||||||
|
SOURCE_DIR "${TD_CONTRIB_DIR}/wingetopt"
|
||||||
|
BINARY_DIR ""
|
||||||
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
TEST_COMMAND ""
|
||||||
|
)
|
|
@ -14,9 +14,24 @@ if(${BUILD_PTHREAD})
|
||||||
cat("${TD_SUPPORT_DIR}/pthread_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/pthread_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# gnu regex
|
# iconv
|
||||||
if(${BUILD_GNUREGEX})
|
if(${BUILD_WITH_ICONV})
|
||||||
cat("${TD_SUPPORT_DIR}/gnuregex_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/iconv_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# msvc regex
|
||||||
|
if(${BUILD_MSVCREGEX})
|
||||||
|
cat("${TD_SUPPORT_DIR}/msvcregex_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# wcwidth
|
||||||
|
if(${BUILD_WCWIDTH})
|
||||||
|
cat("${TD_SUPPORT_DIR}/wcwidth_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# wingetopt
|
||||||
|
if(${BUILD_WINGETOPT})
|
||||||
|
cat("${TD_SUPPORT_DIR}/wingetopt_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# googletest
|
# googletest
|
||||||
|
@ -99,8 +114,27 @@ if(${BUILD_TEST})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
gtest
|
gtest
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src>
|
||||||
|
)
|
||||||
|
if(${TD_WINDOWS})
|
||||||
|
target_include_directories(
|
||||||
|
gtest
|
||||||
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_win>
|
||||||
|
)
|
||||||
|
endif(${TD_WINDOWS})
|
||||||
|
if(${TD_LINUX})
|
||||||
|
target_include_directories(
|
||||||
|
gtest
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_linux>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_linux>
|
||||||
)
|
)
|
||||||
|
endif(${TD_LINUX})
|
||||||
|
if(${TD_DARWIN})
|
||||||
|
target_include_directories(
|
||||||
|
gtest
|
||||||
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_darwin>
|
||||||
|
)
|
||||||
|
endif(${TD_DARWIN})
|
||||||
|
|
||||||
|
|
||||||
endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
||||||
|
|
||||||
# cJson
|
# cJson
|
||||||
|
@ -182,6 +216,53 @@ if(${BUILD_WITH_NURAFT})
|
||||||
add_subdirectory(nuraft)
|
add_subdirectory(nuraft)
|
||||||
endif(${BUILD_WITH_NURAFT})
|
endif(${BUILD_WITH_NURAFT})
|
||||||
|
|
||||||
|
# pthread
|
||||||
|
if(${BUILD_PTHREAD})
|
||||||
|
set(CMAKE_BUILD_TYPE release)
|
||||||
|
add_definitions(-DPTW32_STATIC_LIB)
|
||||||
|
add_subdirectory(pthread)
|
||||||
|
set_target_properties(libpthreadVC3 PROPERTIES OUTPUT_NAME pthread)
|
||||||
|
add_library(pthread STATIC IMPORTED GLOBAL)
|
||||||
|
SET_PROPERTY(TARGET pthread PROPERTY IMPORTED_LOCATION ${LIBRARY_OUTPUT_PATH}/pthread.lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# iconv
|
||||||
|
if(${BUILD_WITH_ICONV})
|
||||||
|
add_subdirectory(iconv)
|
||||||
|
endif(${BUILD_WITH_ICONV})
|
||||||
|
|
||||||
|
# wingetopt
|
||||||
|
if(${BUILD_WINGETOPT})
|
||||||
|
add_subdirectory(wingetopt)
|
||||||
|
endif(${BUILD_WINGETOPT})
|
||||||
|
|
||||||
|
# msvcregex
|
||||||
|
if(${BUILD_MSVCREGEX})
|
||||||
|
add_library(msvcregex STATIC "")
|
||||||
|
target_sources(msvcregex
|
||||||
|
PRIVATE "msvcregex/regex.c"
|
||||||
|
)
|
||||||
|
target_include_directories(msvcregex
|
||||||
|
PRIVATE "msvcregex"
|
||||||
|
)
|
||||||
|
target_link_libraries(msvcregex
|
||||||
|
INTERFACE Shell32
|
||||||
|
)
|
||||||
|
SET_TARGET_PROPERTIES(msvcregex PROPERTIES OUTPUT_NAME msvcregex)
|
||||||
|
endif(${BUILD_MSVCREGEX})
|
||||||
|
|
||||||
|
# msvcregex
|
||||||
|
if(${BUILD_WCWIDTH})
|
||||||
|
add_library(wcwidth STATIC "")
|
||||||
|
target_sources(wcwidth
|
||||||
|
PRIVATE "wcwidth/wcwidth.c"
|
||||||
|
)
|
||||||
|
target_include_directories(wcwidth
|
||||||
|
PRIVATE "wcwidth"
|
||||||
|
)
|
||||||
|
SET_TARGET_PROPERTIES(wcwidth PROPERTIES OUTPUT_NAME wcwidth)
|
||||||
|
endif(${BUILD_WCWIDTH})
|
||||||
|
|
||||||
# CRAFT
|
# CRAFT
|
||||||
if(${BUILD_WITH_CRAFT})
|
if(${BUILD_WITH_CRAFT})
|
||||||
add_library(craft STATIC IMPORTED GLOBAL)
|
add_library(craft STATIC IMPORTED GLOBAL)
|
||||||
|
@ -238,8 +319,12 @@ if(${BUILD_WITH_SQLITE})
|
||||||
target_link_libraries(sqlite
|
target_link_libraries(sqlite
|
||||||
INTERFACE m
|
INTERFACE m
|
||||||
INTERFACE pthread
|
INTERFACE pthread
|
||||||
|
)
|
||||||
|
if(NOT TD_WINDOWS)
|
||||||
|
target_link_libraries(sqlite
|
||||||
INTERFACE dl
|
INTERFACE dl
|
||||||
)
|
)
|
||||||
|
endif(NOT TD_WINDOWS)
|
||||||
endif(${BUILD_WITH_SQLITE})
|
endif(${BUILD_WITH_SQLITE})
|
||||||
|
|
||||||
# pthread
|
# pthread
|
||||||
|
|
|
@ -1,2 +1,9 @@
|
||||||
add_executable(simulate_vnode "simulate_vnode.c")
|
add_executable(simulate_vnode "simulate_vnode.c")
|
||||||
target_link_libraries(simulate_vnode PUBLIC craft lz4 uv_a)
|
target_link_libraries(simulate_vnode PUBLIC craft lz4 uv_a)
|
||||||
|
if(${BUILD_WINGETOPT})
|
||||||
|
target_link_libraries(simulate_vnode PUBLIC wingetopt)
|
||||||
|
target_include_directories(
|
||||||
|
simulate_vnode
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/contrib/wingetopt/src"
|
||||||
|
)
|
||||||
|
endif()
|
|
@ -6,43 +6,39 @@
|
||||||
#define POINTER_SHIFT(ptr, s) ((void *)(((char *)ptr) + (s)))
|
#define POINTER_SHIFT(ptr, s) ((void *)(((char *)ptr) + (s)))
|
||||||
#define POINTER_DISTANCE(pa, pb) ((char *)(pb) - (char *)(pa))
|
#define POINTER_DISTANCE(pa, pb) ((char *)(pb) - (char *)(pa))
|
||||||
|
|
||||||
#define tPutA(buf, val) \
|
static inline void tPutA(void **buf, uint64_t val) {
|
||||||
({ \
|
memcpy(buf, &val, sizeof(val));
|
||||||
memcpy(buf, &val, sizeof(val)); \
|
*buf = POINTER_SHIFT(buf, sizeof(val));
|
||||||
POINTER_SHIFT(buf, sizeof(val)); \
|
}
|
||||||
})
|
|
||||||
|
|
||||||
#define tPutB(buf, val) \
|
static inline void tPutB(void **buf, uint64_t val) {
|
||||||
({ \
|
((uint8_t *)buf)[7] = ((val) >> 56) & 0xff;
|
||||||
((uint8_t *)buf)[7] = ((val) >> 56) & 0xff; \
|
((uint8_t *)buf)[6] = ((val) >> 48) & 0xff;
|
||||||
((uint8_t *)buf)[6] = ((val) >> 48) & 0xff; \
|
((uint8_t *)buf)[5] = ((val) >> 40) & 0xff;
|
||||||
((uint8_t *)buf)[5] = ((val) >> 40) & 0xff; \
|
((uint8_t *)buf)[4] = ((val) >> 32) & 0xff;
|
||||||
((uint8_t *)buf)[4] = ((val) >> 32) & 0xff; \
|
((uint8_t *)buf)[3] = ((val) >> 24) & 0xff;
|
||||||
((uint8_t *)buf)[3] = ((val) >> 24) & 0xff; \
|
((uint8_t *)buf)[2] = ((val) >> 16) & 0xff;
|
||||||
((uint8_t *)buf)[2] = ((val) >> 16) & 0xff; \
|
((uint8_t *)buf)[1] = ((val) >> 8) & 0xff;
|
||||||
((uint8_t *)buf)[1] = ((val) >> 8) & 0xff; \
|
((uint8_t *)buf)[0] = (val)&0xff;
|
||||||
((uint8_t *)buf)[0] = (val)&0xff; \
|
*buf = POINTER_SHIFT(buf, sizeof(val));
|
||||||
POINTER_SHIFT(buf, sizeof(val)); \
|
}
|
||||||
})
|
|
||||||
|
|
||||||
#define tPutC(buf, val) \
|
static inline void tPutC(void **buf, uint64_t val) {
|
||||||
({ \
|
if (buf) {
|
||||||
if (buf) { \
|
((uint64_t *)buf)[0] = (val);
|
||||||
((uint64_t *)buf)[0] = (val); \
|
POINTER_SHIFT(buf, sizeof(val));
|
||||||
POINTER_SHIFT(buf, sizeof(val)); \
|
}
|
||||||
} \
|
*buf = NULL;
|
||||||
NULL; \
|
}
|
||||||
})
|
|
||||||
|
|
||||||
#define tPutD(buf, val) \
|
static inline void tPutD(void **buf, uint64_t val) {
|
||||||
({ \
|
uint64_t tmp = val;
|
||||||
uint64_t tmp = val; \
|
for (size_t i = 0; i < sizeof(val); i++) {
|
||||||
for (size_t i = 0; i < sizeof(val); i++) { \
|
((uint8_t *)buf)[i] = tmp & 0xff;
|
||||||
((uint8_t *)buf)[i] = tmp & 0xff; \
|
tmp >>= 8;
|
||||||
tmp >>= 8; \
|
}
|
||||||
} \
|
*buf = POINTER_SHIFT(buf, sizeof(val));
|
||||||
POINTER_SHIFT(buf, sizeof(val)); \
|
}
|
||||||
})
|
|
||||||
|
|
||||||
static inline void tPutE(void **buf, uint64_t val) {
|
static inline void tPutE(void **buf, uint64_t val) {
|
||||||
if (buf) {
|
if (buf) {
|
||||||
|
@ -61,7 +57,7 @@ static void func(T t) {
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case A:
|
case A:
|
||||||
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
||||||
pBuf = tPutA(pBuf, val);
|
tPutA(pBuf, val);
|
||||||
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
||||||
pBuf = buf;
|
pBuf = buf;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +65,7 @@ static void func(T t) {
|
||||||
break;
|
break;
|
||||||
case B:
|
case B:
|
||||||
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
||||||
pBuf = tPutB(pBuf, val);
|
tPutB(pBuf, val);
|
||||||
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
||||||
pBuf = buf;
|
pBuf = buf;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +73,7 @@ static void func(T t) {
|
||||||
break;
|
break;
|
||||||
case C:
|
case C:
|
||||||
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
||||||
pBuf = tPutC(pBuf, val);
|
tPutC(pBuf, val);
|
||||||
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
||||||
pBuf = buf;
|
pBuf = buf;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +81,7 @@ static void func(T t) {
|
||||||
break;
|
break;
|
||||||
case D:
|
case D:
|
||||||
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
||||||
pBuf = tPutD(pBuf, val);
|
tPutD(pBuf, val);
|
||||||
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
||||||
pBuf = buf;
|
pBuf = buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ target_include_directories(tstream
|
||||||
|
|
||||||
target_include_directories(demoapi
|
target_include_directories(demoapi
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/os"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
// #include <unistd.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#ifndef WINDOWS
|
||||||
#include <argp.h>
|
#include <argp.h>
|
||||||
|
#endif
|
||||||
|
#include "osSleep.h"
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
|
|
||||||
#define debugPrint(fmt, ...) \
|
#define debugPrint(fmt, ...) \
|
||||||
|
@ -32,6 +34,7 @@
|
||||||
int64_t g_num_of_tb = 2;
|
int64_t g_num_of_tb = 2;
|
||||||
int64_t g_num_of_rec = 3;
|
int64_t g_num_of_rec = 3;
|
||||||
|
|
||||||
|
#ifndef WINDOWS
|
||||||
static struct argp_option options[] = {
|
static struct argp_option options[] = {
|
||||||
{"tables", 't', "NUMBER", 0, "Number of child tables, default is 10000."},
|
{"tables", 't', "NUMBER", 0, "Number of child tables, default is 10000."},
|
||||||
{"records", 'n', "NUMBER", 0,
|
{"records", 'n', "NUMBER", 0,
|
||||||
|
@ -61,16 +64,16 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct argp argp = {options, parse_opt, "", ""};
|
static struct argp argp = {options, parse_opt, "", ""};
|
||||||
|
#endif
|
||||||
static void prepare_data(TAOS* taos) {
|
static void prepare_data(TAOS* taos) {
|
||||||
TAOS_RES *res;
|
TAOS_RES *res;
|
||||||
res = taos_query(taos, "drop database if exists test;");
|
res = taos_query(taos, "drop database if exists test;");
|
||||||
taos_free_result(res);
|
taos_free_result(res);
|
||||||
usleep(100000);
|
taosMsleep(100);
|
||||||
|
|
||||||
res = taos_query(taos, "create database test;");
|
res = taos_query(taos, "create database test;");
|
||||||
taos_free_result(res);
|
taos_free_result(res);
|
||||||
usleep(100000);
|
taosMsleep(100);
|
||||||
taos_select_db(taos, "test");
|
taos_select_db(taos, "test");
|
||||||
|
|
||||||
char command[1024] = {0};
|
char command[1024] = {0};
|
||||||
|
@ -87,18 +90,17 @@ static void prepare_data(TAOS* taos) {
|
||||||
taos_free_result(res);
|
taos_free_result(res);
|
||||||
|
|
||||||
for (int64_t i = 0; i < g_num_of_tb; i ++) {
|
for (int64_t i = 0; i < g_num_of_tb; i ++) {
|
||||||
|
// sprintf(command, "create table t%"PRId64" using meters "
|
||||||
|
// "tags(%"PRId64", '%s', '%s', '%s');",
|
||||||
|
// i, i, (i%2)?"beijing":"shanghai",
|
||||||
|
// (i%2)?"朝阳区":"黄浦区",
|
||||||
|
// (i%2)?"长安街":"中山路");
|
||||||
sprintf(command, "create table t%"PRId64" using meters "
|
sprintf(command, "create table t%"PRId64" using meters "
|
||||||
"tags(%"PRId64", '%s', '%s', '%s');",
|
|
||||||
i, i, (i%2)?"beijing":"shanghai",
|
|
||||||
(i%2)?"朝阳区":"黄浦区",
|
|
||||||
(i%2)?"长安街":"中山路");
|
|
||||||
/* sprintf(command, "create table t%"PRId64" using meters "
|
|
||||||
"tags(%"PRId64", '%s', '%s', '%s');",
|
"tags(%"PRId64", '%s', '%s', '%s');",
|
||||||
i, i,
|
i, i,
|
||||||
(i%2)?"beijing":"shanghai",
|
(i%2)?"beijing":"shanghai",
|
||||||
(i%2)?"chaoyang":"huangpu",
|
(i%2)?"chaoyang":"huangpu",
|
||||||
(i%2?"changan street":"jianguo rd"));
|
(i%2?"changan street":"jianguo rd"));
|
||||||
*/
|
|
||||||
res = taos_query(taos, command);
|
res = taos_query(taos, command);
|
||||||
if ((res) && (0 == taos_errno(res))) {
|
if ((res) && (0 == taos_errno(res))) {
|
||||||
okPrint("t%" PRId64 " created\n", i);
|
okPrint("t%" PRId64 " created\n", i);
|
||||||
|
@ -117,7 +119,8 @@ static void prepare_data(TAOS* taos) {
|
||||||
"'%c%d', '%s%c%d', '%c%d')",
|
"'%c%d', '%s%c%d', '%c%d')",
|
||||||
i, 1650000000000+j, (float)j, j,
|
i, 1650000000000+j, (float)j, j,
|
||||||
'a'+(int)j%25, rand(),
|
'a'+(int)j%25, rand(),
|
||||||
"涛思", 'z' - (int)j%25, rand(),
|
// "涛思", 'z' - (int)j%25, rand(),
|
||||||
|
"TAOS", 'z' - (int)j%25, rand(),
|
||||||
'b' - (int)j%25, rand()
|
'b' - (int)j%25, rand()
|
||||||
);
|
);
|
||||||
res = taos_query(taos, command);
|
res = taos_query(taos, command);
|
||||||
|
@ -196,7 +199,7 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
||||||
printf("col%d, row: %"PRId64", "
|
printf("col%d, row: %"PRId64", "
|
||||||
"value: %"PRId64"\n",
|
"value: %"PRId64"\n",
|
||||||
f, c,
|
f, c,
|
||||||
*(int64_t*)(row[f]+c*sizeof(int64_t)));
|
*(int64_t*)((char*)(row[f])+c*sizeof(int64_t)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -208,7 +211,7 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
||||||
printf("col%d, row: %"PRId64", "
|
printf("col%d, row: %"PRId64", "
|
||||||
"value: %d\n",
|
"value: %d\n",
|
||||||
f, c,
|
f, c,
|
||||||
*(int32_t*)(row[f]+c*sizeof(int32_t)));
|
*(int32_t*)((char*)(row[f])+c*sizeof(int32_t)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -220,7 +223,7 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
||||||
printf("col%d, row: %"PRId64", "
|
printf("col%d, row: %"PRId64", "
|
||||||
"value: %f\n",
|
"value: %f\n",
|
||||||
f, c,
|
f, c,
|
||||||
*(float*)(row[f]+c*sizeof(float)));
|
*(float*)((char*)(row[f])+c*sizeof(float)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -235,9 +238,9 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
||||||
if (offsets) {
|
if (offsets) {
|
||||||
for (int c = 0; c < rows; c++) {
|
for (int c = 0; c < rows; c++) {
|
||||||
if (offsets[c] != -1) {
|
if (offsets[c] != -1) {
|
||||||
int length = *(int16_t*)(row[f] + offsets[c]);
|
int length = *(int16_t*)((char*)(row[f]) + offsets[c]);
|
||||||
char *buf = calloc(1, length + 1);
|
char *buf = calloc(1, length + 1);
|
||||||
strncpy(buf, (char *)(row[f] + offsets[c] + 2), length);
|
strncpy(buf, (char *)((char*)(row[f]) + offsets[c] + 2), length);
|
||||||
printf("row: %d, col: %d, offset: %d, length: %d, content: %s\n",
|
printf("row: %d, col: %d, offset: %d, length: %d, content: %s\n",
|
||||||
c, f, offsets[c], length, buf);
|
c, f, offsets[c], length, buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
@ -314,8 +317,9 @@ int main(int argc, char *argv[]) {
|
||||||
const char* host = "127.0.0.1";
|
const char* host = "127.0.0.1";
|
||||||
const char* user = "root";
|
const char* user = "root";
|
||||||
const char* passwd = "taosdata";
|
const char* passwd = "taosdata";
|
||||||
|
#ifndef WINDOWS
|
||||||
argp_parse(&argp, argc, argv, 0, 0, NULL);
|
argp_parse(&argp, argc, argv, 0, 0, NULL);
|
||||||
|
#endif
|
||||||
TAOS* taos = taos_connect(host, user, passwd, "", 0);
|
TAOS* taos = taos_connect(host, user, passwd, "", 0);
|
||||||
if (taos == NULL) {
|
if (taos == NULL) {
|
||||||
printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos));
|
printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos));
|
||||||
|
|
|
@ -216,7 +216,6 @@ typedef struct tmq_topic_vgroup_list_t tmq_topic_vgroup_list_t;
|
||||||
|
|
||||||
typedef struct tmq_conf_t tmq_conf_t;
|
typedef struct tmq_conf_t tmq_conf_t;
|
||||||
typedef struct tmq_list_t tmq_list_t;
|
typedef struct tmq_list_t tmq_list_t;
|
||||||
// typedef struct tmq_message_t tmq_message_t;
|
|
||||||
|
|
||||||
typedef void(tmq_commit_cb(tmq_t *, tmq_resp_err_t, tmq_topic_vgroup_list_t *));
|
typedef void(tmq_commit_cb(tmq_t *, tmq_resp_err_t, tmq_topic_vgroup_list_t *));
|
||||||
|
|
||||||
|
@ -262,12 +261,6 @@ DLL_EXPORT tmq_conf_res_t tmq_conf_set(tmq_conf_t *conf, const char *key, const
|
||||||
DLL_EXPORT void tmq_conf_destroy(tmq_conf_t *conf);
|
DLL_EXPORT void tmq_conf_destroy(tmq_conf_t *conf);
|
||||||
DLL_EXPORT void tmq_conf_set_offset_commit_cb(tmq_conf_t *conf, tmq_commit_cb *cb);
|
DLL_EXPORT void tmq_conf_set_offset_commit_cb(tmq_conf_t *conf, tmq_commit_cb *cb);
|
||||||
|
|
||||||
#if 0
|
|
||||||
// temporary used function for demo only
|
|
||||||
void tmqShowMsg(tmq_message_t *tmq_message);
|
|
||||||
int32_t tmqGetSkipLogNum(tmq_message_t *tmq_message);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
|
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
|
||||||
|
|
||||||
DLL_EXPORT char *tmq_get_topic_name(TAOS_RES *res);
|
DLL_EXPORT char *tmq_get_topic_name(TAOS_RES *res);
|
||||||
|
@ -278,12 +271,8 @@ DLL_EXPORT char *tmq_get_block_table_name(TAOS_RES *res);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
DLL_EXPORT TAOS_ROW tmq_get_row(tmq_message_t *message);
|
|
||||||
DLL_EXPORT int64_t tmq_get_request_offset(tmq_message_t *message);
|
DLL_EXPORT int64_t tmq_get_request_offset(tmq_message_t *message);
|
||||||
DLL_EXPORT int64_t tmq_get_response_offset(tmq_message_t *message);
|
DLL_EXPORT int64_t tmq_get_response_offset(tmq_message_t *message);
|
||||||
DLL_EXPORT TAOS_FIELD *tmq_get_fields(tmq_t *tmq, const char *topic);
|
|
||||||
DLL_EXPORT int32_t tmq_field_count(tmq_t *tmq, const char *topic);
|
|
||||||
DLL_EXPORT void tmq_message_destroy(TAOS_RES *res);
|
|
||||||
#endif
|
#endif
|
||||||
/* --------------------TMPORARY INTERFACE FOR TESTING--------------------- */
|
/* --------------------TMPORARY INTERFACE FOR TESTING--------------------- */
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -1359,7 +1359,7 @@ static void tdSRowPrint(STSRow *row, STSchema *pSchema) {
|
||||||
printf(">>>");
|
printf(">>>");
|
||||||
for (int i = 0; i < pSchema->numOfCols; ++i) {
|
for (int i = 0; i < pSchema->numOfCols; ++i) {
|
||||||
STColumn *stCol = pSchema->columns + i;
|
STColumn *stCol = pSchema->columns + i;
|
||||||
SCellVal sVal = {.valType = 255, .val = NULL};
|
SCellVal sVal = { 255, NULL};
|
||||||
if (!tdSTSRowIterNext(&iter, stCol->colId, stCol->type, &sVal)) {
|
if (!tdSTSRowIterNext(&iter, stCol->colId, stCol->type, &sVal)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,9 @@ extern "C" {
|
||||||
typedef struct SBnode SBnode;
|
typedef struct SBnode SBnode;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
size_t avoidCompilationErrors;
|
||||||
|
#endif
|
||||||
} SBnodeLoad;
|
} SBnodeLoad;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -51,6 +51,10 @@ typedef struct STableComInfo {
|
||||||
|
|
||||||
typedef struct SIndexMeta {
|
typedef struct SIndexMeta {
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
size_t avoidCompilationErrors;
|
||||||
|
#endif
|
||||||
|
|
||||||
} SIndexMeta;
|
} SIndexMeta;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ extern "C" {
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <semaphore.h>
|
|
||||||
|
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
|
||||||
|
@ -51,6 +50,15 @@ extern "C" {
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#include <argp.h>
|
#include <argp.h>
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#ifndef TD_USE_WINSOCK
|
||||||
|
#include <winsock2.h>
|
||||||
|
#else
|
||||||
|
#include <winsock.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -63,22 +63,22 @@ int8_t atomic_add_fetch_8(int8_t volatile *ptr, int8_t val);
|
||||||
int16_t atomic_add_fetch_16(int16_t volatile *ptr, int16_t val);
|
int16_t atomic_add_fetch_16(int16_t volatile *ptr, int16_t val);
|
||||||
int32_t atomic_add_fetch_32(int32_t volatile *ptr, int32_t val);
|
int32_t atomic_add_fetch_32(int32_t volatile *ptr, int32_t val);
|
||||||
int64_t atomic_add_fetch_64(int64_t volatile *ptr, int64_t val);
|
int64_t atomic_add_fetch_64(int64_t volatile *ptr, int64_t val);
|
||||||
void* atomic_add_fetch_ptr(void *ptr, int32_t val);
|
void* atomic_add_fetch_ptr(void *ptr, void *val);
|
||||||
int8_t atomic_fetch_add_8(int8_t volatile *ptr, int8_t val);
|
int8_t atomic_fetch_add_8(int8_t volatile *ptr, int8_t val);
|
||||||
int16_t atomic_fetch_add_16(int16_t volatile *ptr, int16_t val);
|
int16_t atomic_fetch_add_16(int16_t volatile *ptr, int16_t val);
|
||||||
int32_t atomic_fetch_add_32(int32_t volatile *ptr, int32_t val);
|
int32_t atomic_fetch_add_32(int32_t volatile *ptr, int32_t val);
|
||||||
int64_t atomic_fetch_add_64(int64_t volatile *ptr, int64_t val);
|
int64_t atomic_fetch_add_64(int64_t volatile *ptr, int64_t val);
|
||||||
void* atomic_fetch_add_ptr(void *ptr, int32_t val);
|
void* atomic_fetch_add_ptr(void *ptr, void *val);
|
||||||
int8_t atomic_sub_fetch_8(int8_t volatile *ptr, int8_t val);
|
int8_t atomic_sub_fetch_8(int8_t volatile *ptr, int8_t val);
|
||||||
int16_t atomic_sub_fetch_16(int16_t volatile *ptr, int16_t val);
|
int16_t atomic_sub_fetch_16(int16_t volatile *ptr, int16_t val);
|
||||||
int32_t atomic_sub_fetch_32(int32_t volatile *ptr, int32_t val);
|
int32_t atomic_sub_fetch_32(int32_t volatile *ptr, int32_t val);
|
||||||
int64_t atomic_sub_fetch_64(int64_t volatile *ptr, int64_t val);
|
int64_t atomic_sub_fetch_64(int64_t volatile *ptr, int64_t val);
|
||||||
void* atomic_sub_fetch_ptr(void *ptr, int32_t val);
|
void* atomic_sub_fetch_ptr(void *ptr, void *val);
|
||||||
int8_t atomic_fetch_sub_8(int8_t volatile *ptr, int8_t val);
|
int8_t atomic_fetch_sub_8(int8_t volatile *ptr, int8_t val);
|
||||||
int16_t atomic_fetch_sub_16(int16_t volatile *ptr, int16_t val);
|
int16_t atomic_fetch_sub_16(int16_t volatile *ptr, int16_t val);
|
||||||
int32_t atomic_fetch_sub_32(int32_t volatile *ptr, int32_t val);
|
int32_t atomic_fetch_sub_32(int32_t volatile *ptr, int32_t val);
|
||||||
int64_t atomic_fetch_sub_64(int64_t volatile *ptr, int64_t val);
|
int64_t atomic_fetch_sub_64(int64_t volatile *ptr, int64_t val);
|
||||||
void* atomic_fetch_sub_ptr(void *ptr, int32_t val);
|
void* atomic_fetch_sub_ptr(void *ptr, void *val);
|
||||||
int8_t atomic_and_fetch_8(int8_t volatile *ptr, int8_t val);
|
int8_t atomic_and_fetch_8(int8_t volatile *ptr, int8_t val);
|
||||||
int16_t atomic_and_fetch_16(int16_t volatile *ptr, int16_t val);
|
int16_t atomic_and_fetch_16(int16_t volatile *ptr, int16_t val);
|
||||||
int32_t atomic_and_fetch_32(int32_t volatile *ptr, int32_t val);
|
int32_t atomic_and_fetch_32(int32_t volatile *ptr, int32_t val);
|
||||||
|
|
|
@ -191,7 +191,7 @@ extern "C" {
|
||||||
#define threadlocal __declspec( thread )
|
#define threadlocal __declspec( thread )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
#define PRIzu "ld"
|
#define PRIzu "ld"
|
||||||
#else
|
#else
|
||||||
#define PRIzu "zu"
|
#define PRIzu "zu"
|
||||||
|
|
|
@ -36,12 +36,12 @@ typedef struct TdDirEntry *TdDirEntryPtr;
|
||||||
|
|
||||||
|
|
||||||
void taosRemoveDir(const char *dirname);
|
void taosRemoveDir(const char *dirname);
|
||||||
bool taosDirExist(char *dirname);
|
bool taosDirExist(const char *dirname);
|
||||||
int32_t taosMkDir(const char *dirname);
|
int32_t taosMkDir(const char *dirname);
|
||||||
int32_t taosMulMkDir(const char *dirname);
|
int32_t taosMulMkDir(const char *dirname);
|
||||||
void taosRemoveOldFiles(const char *dirname, int32_t keepDays);
|
void taosRemoveOldFiles(const char *dirname, int32_t keepDays);
|
||||||
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
|
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
|
||||||
int32_t taosRealPath(char *dirname, int32_t maxlen);
|
int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen);
|
||||||
bool taosIsDir(const char *dirname);
|
bool taosIsDir(const char *dirname);
|
||||||
char* taosDirName(char *dirname);
|
char* taosDirName(char *dirname);
|
||||||
char* taosDirEntryBaseName(char *dirname);
|
char* taosDirEntryBaseName(char *dirname);
|
||||||
|
@ -50,7 +50,7 @@ TdDirPtr taosOpenDir(const char *dirname);
|
||||||
TdDirEntryPtr taosReadDir(TdDirPtr pDir);
|
TdDirEntryPtr taosReadDir(TdDirPtr pDir);
|
||||||
bool taosDirEntryIsDir(TdDirEntryPtr pDirEntry);
|
bool taosDirEntryIsDir(TdDirEntryPtr pDirEntry);
|
||||||
char* taosGetDirEntryName(TdDirEntryPtr pDirEntry);
|
char* taosGetDirEntryName(TdDirEntryPtr pDirEntry);
|
||||||
int32_t taosCloseDir(TdDirPtr pDir);
|
int32_t taosCloseDir(TdDirPtr *ppDir);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,6 @@ void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix,
|
||||||
|
|
||||||
int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size);
|
int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size);
|
||||||
|
|
||||||
void *taosMmapReadOnlyFile(TdFilePtr pFile, int64_t length);
|
|
||||||
bool taosValidFile(TdFilePtr pFile);
|
bool taosValidFile(TdFilePtr pFile);
|
||||||
|
|
||||||
int32_t taosGetErrorFile(TdFilePtr pFile);
|
int32_t taosGetErrorFile(TdFilePtr pFile);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
int32_t BUILDIN_CLZL(uint64_t val);
|
int32_t BUILDIN_CLZL(uint64_t val);
|
||||||
int32_t BUILDIN_CLZ(uint32_t val);
|
int32_t BUILDIN_CLZ(uint32_t val);
|
||||||
int32_t BUILDIN_CTZL(uint64_t val);
|
int32_t BUILDIN_CTZL(uint64_t val);
|
||||||
|
|
|
@ -23,7 +23,7 @@ extern "C" {
|
||||||
#define TPOW2(x) ((x) * (x))
|
#define TPOW2(x) ((x) * (x))
|
||||||
#define TABS(x) ((x) > 0 ? (x) : -(x))
|
#define TABS(x) ((x) > 0 ? (x) : -(x))
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
|
|
||||||
#define TSWAP(a, b, c) \
|
#define TSWAP(a, b, c) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -33,6 +33,7 @@ extern "C" {
|
||||||
} while (0)
|
} while (0)
|
||||||
#define TMAX(a, b) (((a) > (b)) ? (a) : (b))
|
#define TMAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||||
#define TMIN(a, b) (((a) < (b)) ? (a) : (b))
|
#define TMIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||||
|
#define TRANGE(aa, bb, cc) ((aa) = TMAX((aa), (bb)),(aa) = TMIN((aa), (cc)))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,31 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
#include "winsock2.h"
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||||
#include <WS2tcpip.h>
|
#include <stdlib.h>
|
||||||
#include <winbase.h>
|
#define htobe16(x) _byteswap_ushort(x)
|
||||||
#include <Winsock2.h>
|
#define htole16(x) (x)
|
||||||
|
#define be16toh(x) _byteswap_ushort(x)
|
||||||
|
#define le16toh(x) (x)
|
||||||
|
|
||||||
|
#define htobe32(x) _byteswap_ulong(x)
|
||||||
|
#define htole32(x) (x)
|
||||||
|
#define be32toh(x) _byteswap_ulong(x)
|
||||||
|
#define le32toh(x) (x)
|
||||||
|
|
||||||
|
#define htobe64(x) _byteswap_uint64(x)
|
||||||
|
#define htole64(x) (x)
|
||||||
|
#define be64toh(x) _byteswap_uint64(x)
|
||||||
|
#define le64toh(x) (x)
|
||||||
|
#else
|
||||||
|
#error byte order not supported
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define __BYTE_ORDER BYTE_ORDER
|
||||||
|
#define __BIG_ENDIAN BIG_ENDIAN
|
||||||
|
#define __LITTLE_ENDIAN LITTLE_ENDIAN
|
||||||
|
#define __PDP_ENDIAN PDP_ENDIAN
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
@ -52,14 +73,10 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
#define htobe64 htonll
|
typedef int socklen_t;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
|
||||||
#define TAOS_EPOLL_WAIT_TIME 100
|
#define TAOS_EPOLL_WAIT_TIME 100
|
||||||
typedef SOCKET eventfd_t;
|
typedef SOCKET eventfd_t;
|
||||||
#define eventfd(a, b) -1
|
#define eventfd(a, b) -1
|
||||||
typedef SOCKET EpollFd;
|
|
||||||
#define EpollClose(pollFd) epoll_close(pollFd)
|
#define EpollClose(pollFd) epoll_close(pollFd)
|
||||||
#ifndef EPOLLWAKEUP
|
#ifndef EPOLLWAKEUP
|
||||||
#define EPOLLWAKEUP (1u << 29)
|
#define EPOLLWAKEUP (1u << 29)
|
||||||
|
@ -102,8 +119,6 @@ extern "C" {
|
||||||
#define __PDP_ENDIAN PDP_ENDIAN
|
#define __PDP_ENDIAN PDP_ENDIAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TAOS_EPOLL_WAIT_TIME 500
|
|
||||||
|
|
||||||
typedef int32_t SocketFd;
|
typedef int32_t SocketFd;
|
||||||
typedef SocketFd EpollFd;
|
typedef SocketFd EpollFd;
|
||||||
|
|
||||||
|
@ -122,7 +137,7 @@ typedef struct TdEpoll *TdEpollPtr;
|
||||||
int32_t taosSendto(TdSocketPtr pSocket, void * msg, int len, unsigned int flags, const struct sockaddr * to, int tolen);
|
int32_t taosSendto(TdSocketPtr pSocket, void * msg, int len, unsigned int flags, const struct sockaddr * to, int tolen);
|
||||||
int32_t taosWriteSocket(TdSocketPtr pSocket, void *msg, int len);
|
int32_t taosWriteSocket(TdSocketPtr pSocket, void *msg, int len);
|
||||||
int32_t taosReadSocket(TdSocketPtr pSocket, void *msg, int len);
|
int32_t taosReadSocket(TdSocketPtr pSocket, void *msg, int len);
|
||||||
int32_t taosReadFromSocket(TdSocketPtr pSocket, void *buf, int32_t len, int32_t flags, struct sockaddr *destAddr, socklen_t *addrLen);
|
int32_t taosReadFromSocket(TdSocketPtr pSocket, void *buf, int32_t len, int32_t flags, struct sockaddr *destAddr, int *addrLen);
|
||||||
int32_t taosCloseSocketNoCheck1(SocketFd fd);
|
int32_t taosCloseSocketNoCheck1(SocketFd fd);
|
||||||
int32_t taosCloseSocket(TdSocketPtr *ppSocket);
|
int32_t taosCloseSocket(TdSocketPtr *ppSocket);
|
||||||
int32_t taosCloseSocketServer(TdSocketServerPtr *ppSocketServer);
|
int32_t taosCloseSocketServer(TdSocketServerPtr *ppSocketServer);
|
||||||
|
@ -139,14 +154,15 @@ int32_t taosWriteMsg(TdSocketPtr pSocket, void *ptr, int32_t nbytes);
|
||||||
int32_t taosReadMsg(TdSocketPtr pSocket, void *ptr, int32_t nbytes);
|
int32_t taosReadMsg(TdSocketPtr pSocket, void *ptr, int32_t nbytes);
|
||||||
int32_t taosNonblockwrite(TdSocketPtr pSocket, char *ptr, int32_t nbytes);
|
int32_t taosNonblockwrite(TdSocketPtr pSocket, char *ptr, int32_t nbytes);
|
||||||
int64_t taosCopyFds(TdSocketPtr pSrcSocket, TdSocketPtr pDestSocket, int64_t len);
|
int64_t taosCopyFds(TdSocketPtr pSrcSocket, TdSocketPtr pDestSocket, int64_t len);
|
||||||
|
void taosWinSocketInit();
|
||||||
|
|
||||||
TdSocketPtr taosOpenUdpSocket(uint32_t localIp, uint16_t localPort);
|
TdSocketPtr taosOpenUdpSocket(uint32_t localIp, uint16_t localPort);
|
||||||
TdSocketPtr taosOpenTcpClientSocket(uint32_t ip, uint16_t port, uint32_t localIp);
|
TdSocketPtr taosOpenTcpClientSocket(uint32_t ip, uint16_t port, uint32_t localIp);
|
||||||
TdSocketServerPtr taosOpenTcpServerSocket(uint32_t ip, uint16_t port);
|
TdSocketServerPtr taosOpenTcpServerSocket(uint32_t ip, uint16_t port);
|
||||||
int32_t taosKeepTcpAlive(TdSocketPtr pSocket);
|
int32_t taosKeepTcpAlive(TdSocketPtr pSocket);
|
||||||
TdSocketPtr taosAcceptTcpConnectSocket(TdSocketServerPtr pServerSocket, struct sockaddr *destAddr, socklen_t *addrLen);
|
TdSocketPtr taosAcceptTcpConnectSocket(TdSocketServerPtr pServerSocket, struct sockaddr *destAddr, int *addrLen);
|
||||||
|
|
||||||
int32_t taosGetSocketName(TdSocketPtr pSocket,struct sockaddr *destAddr, socklen_t *addrLen);
|
int32_t taosGetSocketName(TdSocketPtr pSocket,struct sockaddr *destAddr, int *addrLen);
|
||||||
|
|
||||||
void taosBlockSIGPIPE();
|
void taosBlockSIGPIPE();
|
||||||
uint32_t taosGetIpv4FromFqdn(const char *);
|
uint32_t taosGetIpv4FromFqdn(const char *);
|
||||||
|
|
|
@ -39,7 +39,7 @@ typedef int32_t TdUcs4;
|
||||||
#define wchar_t WCHAR_T_TYPE_TAOS_FORBID
|
#define wchar_t WCHAR_T_TYPE_TAOS_FORBID
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
#define tstrdup(str) _strdup(str)
|
#define tstrdup(str) _strdup(str)
|
||||||
#else
|
#else
|
||||||
#define tstrdup(str) strdup(str)
|
#define tstrdup(str) strdup(str)
|
||||||
|
|
|
@ -22,9 +22,12 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef WINDOWS
|
||||||
#ifndef __USE_XOPEN2K
|
#ifndef __USE_XOPEN2K
|
||||||
|
#define TD_USE_SPINLOCK_AS_MUTEX
|
||||||
typedef pthread_mutex_t pthread_spinlock_t;
|
typedef pthread_mutex_t pthread_spinlock_t;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef pthread_t TdThread;
|
typedef pthread_t TdThread;
|
||||||
typedef pthread_spinlock_t TdThreadSpinlock;
|
typedef pthread_spinlock_t TdThreadSpinlock;
|
||||||
|
@ -41,6 +44,13 @@ typedef pthread_key_t TdThreadKey;
|
||||||
#define taosThreadCleanupPush pthread_cleanup_push
|
#define taosThreadCleanupPush pthread_cleanup_push
|
||||||
#define taosThreadCleanupPop pthread_cleanup_pop
|
#define taosThreadCleanupPop pthread_cleanup_pop
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#define TD_PTHREAD_MUTEX_INITIALIZER (TdThreadMutex)(-1)
|
||||||
|
#else
|
||||||
|
#define TD_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||||
|
#endif
|
||||||
|
|
||||||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||||
// When you want to use this feature, you should find or add the same function in the following section.
|
// When you want to use this feature, you should find or add the same function in the following section.
|
||||||
#ifndef ALLOW_FORBID_FUNC
|
#ifndef ALLOW_FORBID_FUNC
|
||||||
|
@ -218,8 +228,7 @@ int32_t taosThreadSpinLock(TdThreadSpinlock * lock);
|
||||||
int32_t taosThreadSpinTrylock(TdThreadSpinlock * lock);
|
int32_t taosThreadSpinTrylock(TdThreadSpinlock * lock);
|
||||||
int32_t taosThreadSpinUnlock(TdThreadSpinlock * lock);
|
int32_t taosThreadSpinUnlock(TdThreadSpinlock * lock);
|
||||||
void taosThreadTestCancel(void);
|
void taosThreadTestCancel(void);
|
||||||
int32_t taosThreadSigMask(int32_t how, sigset_t const *set, sigset_t * oset);
|
void taosThreadClear(TdThread *thread);
|
||||||
int32_t taosThreadSigWait(const sigset_t * set, int32_t *sig);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||||
// When you want to use this feature, you should find or add the same function in the following section.
|
// When you want to use this feature, you should find or add the same function in the following section.
|
||||||
#ifndef ALLOW_FORBID_FUNC
|
#ifndef ALLOW_FORBID_FUNC
|
||||||
|
@ -34,7 +32,7 @@ extern "C" {
|
||||||
#define mktime MKTIME_FUNC_TAOS_FORBID
|
#define mktime MKTIME_FUNC_TAOS_FORBID
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
|
|
||||||
#define CLOCK_REALTIME 0
|
#define CLOCK_REALTIME 0
|
||||||
|
|
||||||
|
@ -58,6 +56,8 @@ extern "C" {
|
||||||
|
|
||||||
int32_t taosGetTimeOfDay(struct timeval *tv);
|
int32_t taosGetTimeOfDay(struct timeval *tv);
|
||||||
|
|
||||||
|
int32_t taosClockGetTime(int clock_id, struct timespec *pTS);
|
||||||
|
|
||||||
//@return timestamp in second
|
//@return timestamp in second
|
||||||
int32_t taosGetTimestampSec();
|
int32_t taosGetTimestampSec();
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ static FORCE_INLINE int64_t taosGetTimestampUs() {
|
||||||
//@return timestamp in nanosecond
|
//@return timestamp in nanosecond
|
||||||
static FORCE_INLINE int64_t taosGetTimestampNs() {
|
static FORCE_INLINE int64_t taosGetTimestampNs() {
|
||||||
struct timespec systemTime = {0};
|
struct timespec systemTime = {0};
|
||||||
clock_gettime(CLOCK_REALTIME, &systemTime);
|
taosClockGetTime(CLOCK_REALTIME, &systemTime);
|
||||||
return (int64_t)systemTime.tv_sec * 1000000000L + (int64_t)systemTime.tv_nsec;
|
return (int64_t)systemTime.tv_sec * 1000000000L + (int64_t)systemTime.tv_nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -236,7 +236,8 @@ static FORCE_INLINE int32_t tEncodeFloat(SCoder* pEncoder, float val) {
|
||||||
union {
|
union {
|
||||||
uint32_t ui;
|
uint32_t ui;
|
||||||
float f;
|
float f;
|
||||||
} v = {.f = val};
|
} v;
|
||||||
|
v.f = val;
|
||||||
|
|
||||||
return tEncodeU32(pEncoder, v.ui);
|
return tEncodeU32(pEncoder, v.ui);
|
||||||
}
|
}
|
||||||
|
@ -245,7 +246,8 @@ static FORCE_INLINE int32_t tEncodeDouble(SCoder* pEncoder, double val) {
|
||||||
union {
|
union {
|
||||||
uint64_t ui;
|
uint64_t ui;
|
||||||
double d;
|
double d;
|
||||||
} v = {.d = val};
|
} v;
|
||||||
|
v.d = val;
|
||||||
|
|
||||||
return tEncodeU64(pEncoder, v.ui);
|
return tEncodeU64(pEncoder, v.ui);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#define tjsonGetNumberValue(pJson, pName, val) -1
|
||||||
|
#else
|
||||||
#define tjsonGetNumberValue(pJson, pName, val) \
|
#define tjsonGetNumberValue(pJson, pName, val) \
|
||||||
({ \
|
({ \
|
||||||
uint64_t _tmp = 0; \
|
uint64_t _tmp = 0; \
|
||||||
|
@ -29,6 +32,7 @@ extern "C" {
|
||||||
val = _tmp; \
|
val = _tmp; \
|
||||||
_code; \
|
_code; \
|
||||||
})
|
})
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef void SJson;
|
typedef void SJson;
|
||||||
|
|
||||||
|
|
|
@ -24,16 +24,6 @@
|
||||||
#include "tqueue.h"
|
#include "tqueue.h"
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
|
|
||||||
#if 0
|
|
||||||
struct tmq_message_t {
|
|
||||||
SMqPollRsp msg;
|
|
||||||
char* topic;
|
|
||||||
SArray* res; // SArray<SReqResultInfo>
|
|
||||||
int32_t vgId;
|
|
||||||
int32_t resIter;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t tmqRspType;
|
int8_t tmqRspType;
|
||||||
int32_t epoch;
|
int32_t epoch;
|
||||||
|
@ -770,105 +760,12 @@ _return:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
|
||||||
time_t tt;
|
|
||||||
int32_t ms = 0;
|
|
||||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
|
||||||
tt = (time_t)(val / 1000000000);
|
|
||||||
ms = val % 1000000000;
|
|
||||||
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
|
||||||
tt = (time_t)(val / 1000000);
|
|
||||||
ms = val % 1000000;
|
|
||||||
} else {
|
|
||||||
tt = (time_t)(val / 1000);
|
|
||||||
ms = val % 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* comment out as it make testcases like select_with_tags.sim fail.
|
|
||||||
but in windows, this may cause the call to localtime crash if tt < 0,
|
|
||||||
need to find a better solution.
|
|
||||||
if (tt < 0) {
|
|
||||||
tt = 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef WINDOWS
|
|
||||||
if (tt < 0) tt = 0;
|
|
||||||
#endif
|
|
||||||
if (tt <= 0 && ms < 0) {
|
|
||||||
tt--;
|
|
||||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
|
||||||
ms += 1000000000;
|
|
||||||
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
|
||||||
ms += 1000000;
|
|
||||||
} else {
|
|
||||||
ms += 1000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct tm* ptm = taosLocalTime(&tt, NULL);
|
|
||||||
size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", ptm);
|
|
||||||
|
|
||||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
|
||||||
sprintf(buf + pos, ".%09d", ms);
|
|
||||||
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
|
||||||
sprintf(buf + pos, ".%06d", ms);
|
|
||||||
} else {
|
|
||||||
sprintf(buf + pos, ".%03d", ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
#if 0
|
#if 0
|
||||||
int32_t tmqGetSkipLogNum(tmq_message_t* tmq_message) {
|
int32_t tmqGetSkipLogNum(tmq_message_t* tmq_message) {
|
||||||
if (tmq_message == NULL) return 0;
|
if (tmq_message == NULL) return 0;
|
||||||
SMqPollRsp* pRsp = &tmq_message->msg;
|
SMqPollRsp* pRsp = &tmq_message->msg;
|
||||||
return pRsp->skipLogNum;
|
return pRsp->skipLogNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmqShowMsg(tmq_message_t* tmq_message) {
|
|
||||||
if (tmq_message == NULL) return;
|
|
||||||
|
|
||||||
static bool noPrintSchema;
|
|
||||||
char pBuf[128];
|
|
||||||
SMqPollRsp* pRsp = &tmq_message->msg;
|
|
||||||
int32_t colNum = 2;
|
|
||||||
if (!noPrintSchema) {
|
|
||||||
printf("|");
|
|
||||||
for (int32_t i = 0; i < colNum; i++) {
|
|
||||||
if (i == 0)
|
|
||||||
printf(" %25s |", pRsp->schema->pSchema[i].name);
|
|
||||||
else
|
|
||||||
printf(" %15s |", pRsp->schema->pSchema[i].name);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
printf("===============================================\n");
|
|
||||||
noPrintSchema = true;
|
|
||||||
}
|
|
||||||
int32_t sz = taosArrayGetSize(pRsp->pBlockData);
|
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
|
||||||
SSDataBlock* pDataBlock = taosArrayGet(pRsp->pBlockData, i);
|
|
||||||
int32_t rows = pDataBlock->info.rows;
|
|
||||||
for (int32_t j = 0; j < rows; j++) {
|
|
||||||
printf("|");
|
|
||||||
for (int32_t k = 0; k < colNum; k++) {
|
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
|
||||||
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
|
||||||
switch (pColInfoData->info.type) {
|
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
|
||||||
formatTimestamp(pBuf, *(uint64_t*)var, TSDB_TIME_PRECISION_MILLI);
|
|
||||||
printf(" %25s |", pBuf);
|
|
||||||
break;
|
|
||||||
case TSDB_DATA_TYPE_INT:
|
|
||||||
case TSDB_DATA_TYPE_UINT:
|
|
||||||
printf(" %15u |", *(uint32_t*)var);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
|
@ -1049,7 +946,6 @@ int32_t tmqAskEpCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
tDeleteSMqCMGetSubEpRsp(&rsp);
|
tDeleteSMqCMGetSubEpRsp(&rsp);
|
||||||
} else {
|
} else {
|
||||||
/*SMqCMGetSubEpRsp* pRsp = taosAllocateQitem(sizeof(SMqCMGetSubEpRsp));*/
|
|
||||||
SMqAskEpRspWrapper* pWrapper = taosAllocateQitem(sizeof(SMqAskEpRspWrapper));
|
SMqAskEpRspWrapper* pWrapper = taosAllocateQitem(sizeof(SMqAskEpRspWrapper));
|
||||||
if (pWrapper == NULL) {
|
if (pWrapper == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -1208,7 +1104,6 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
||||||
pRspObj->resIter = -1;
|
pRspObj->resIter = -1;
|
||||||
memcpy(&pRspObj->rsp, &pWrapper->msg, sizeof(SMqDataBlkRsp));
|
memcpy(&pRspObj->rsp, &pWrapper->msg, sizeof(SMqDataBlkRsp));
|
||||||
|
|
||||||
/*SRetrieveTableRsp* pRetrieve = taosArrayGetP(pWrapper->msg.blockData, 0);*/
|
|
||||||
pRspObj->resInfo.totalRows = 0;
|
pRspObj->resInfo.totalRows = 0;
|
||||||
pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI;
|
pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI;
|
||||||
setResSchemaInfo(&pRspObj->resInfo, pWrapper->topicHandle->schema.pSchema, pWrapper->topicHandle->schema.nCols);
|
setResSchemaInfo(&pRspObj->resInfo, pWrapper->topicHandle->schema.pSchema, pWrapper->topicHandle->schema.nCols);
|
||||||
|
@ -1355,31 +1250,6 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t blockingTime, bool pollIfReset) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
tmq_message_t* tmq_consumer_poll_v1(tmq_t* tmq, int64_t blocking_time) {
|
|
||||||
tmq_message_t* rspMsg = NULL;
|
|
||||||
int64_t startTime = taosGetTimestampMs();
|
|
||||||
|
|
||||||
int64_t status = atomic_load_64(&tmq->status);
|
|
||||||
tmqAskEp(tmq, status == TMQ_CONSUMER_STATUS__INIT);
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
rspMsg = tmqSyncPollImpl(tmq, blocking_time);
|
|
||||||
if (rspMsg && rspMsg->consumeRsp.numOfTopics) {
|
|
||||||
return rspMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blocking_time != 0) {
|
|
||||||
int64_t endTime = taosGetTimestampMs();
|
|
||||||
if (endTime - startTime > blocking_time) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
|
TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
|
||||||
SMqRspObj* rspObj;
|
SMqRspObj* rspObj;
|
||||||
int64_t startTime = taosGetTimestampMs();
|
int64_t startTime = taosGetTimestampMs();
|
||||||
|
@ -1417,138 +1287,11 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
tmq_resp_err_t tmq_consumer_close(tmq_t* tmq) {
|
||||||
|
|
||||||
if (blocking_time <= 0) blocking_time = 1;
|
|
||||||
if (blocking_time > 1000) blocking_time = 1000;
|
|
||||||
/*blocking_time = 1;*/
|
|
||||||
|
|
||||||
if (taosArrayGetSize(tmq->clientTopics) == 0) {
|
|
||||||
tscDebug("consumer:%ld poll but not assigned", tmq->consumerId);
|
|
||||||
/*printf("over1\n");*/
|
|
||||||
taosMsleep(blocking_time);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, tmq->nextTopicIdx);
|
|
||||||
if (taosArrayGetSize(pTopic->vgs) == 0) {
|
|
||||||
/*printf("over2\n");*/
|
|
||||||
taosMsleep(blocking_time);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmq->nextTopicIdx = (tmq->nextTopicIdx + 1) % taosArrayGetSize(tmq->clientTopics);
|
|
||||||
int32_t beginVgIdx = pTopic->nextVgIdx;
|
|
||||||
while (1) {
|
|
||||||
pTopic->nextVgIdx = (pTopic->nextVgIdx + 1) % taosArrayGetSize(pTopic->vgs);
|
|
||||||
SMqClientVg* pVg = taosArrayGet(pTopic->vgs, pTopic->nextVgIdx);
|
|
||||||
/*printf("consume vg %d, offset %ld\n", pVg->vgId, pVg->currentOffset);*/
|
|
||||||
SMqConsumeReq* pReq = tmqBuildConsumeReqImpl(tmq, blocking_time, pTopic, pVg);
|
|
||||||
if (pReq == NULL) {
|
|
||||||
ASSERT(false);
|
|
||||||
taosMsleep(blocking_time);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SMqPollCbParam* param = taosMemoryMalloc(sizeof(SMqPollCbParam));
|
|
||||||
if (param == NULL) {
|
|
||||||
ASSERT(false);
|
|
||||||
taosMsleep(blocking_time);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
param->tmq = tmq;
|
|
||||||
param->retMsg = &tmq_message;
|
|
||||||
param->pVg = pVg;
|
|
||||||
tsem_init(¶m->rspSem, 0, 0);
|
|
||||||
|
|
||||||
SRequestObj* pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_VND_CONSUME);
|
|
||||||
pRequest->body.requestMsg = (SDataBuf){
|
|
||||||
.pData = pReq,
|
|
||||||
.len = sizeof(SMqConsumeReq),
|
|
||||||
.handle = NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
SMsgSendInfo* sendInfo = buildMsgInfoImpl(pRequest);
|
|
||||||
sendInfo->requestObjRefId = 0;
|
|
||||||
sendInfo->param = param;
|
|
||||||
sendInfo->fp = tmqPollCb;
|
|
||||||
|
|
||||||
/*printf("req offset: %ld\n", pReq->offset);*/
|
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
|
||||||
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo);
|
|
||||||
tmq->pollCnt++;
|
|
||||||
|
|
||||||
tsem_wait(¶m->rspSem);
|
|
||||||
tsem_destroy(¶m->rspSem);
|
|
||||||
taosMemoryFree(param);
|
|
||||||
|
|
||||||
if (tmq_message == NULL) {
|
|
||||||
if (beginVgIdx == pTopic->nextVgIdx) {
|
|
||||||
taosMsleep(blocking_time);
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmq_message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*tsem_wait(&pRequest->body.rspSem);*/
|
|
||||||
|
|
||||||
/*if (body != NULL) {*/
|
|
||||||
/*destroySendMsgInfo(body);*/
|
|
||||||
/*}*/
|
|
||||||
|
|
||||||
/*if (pRequest != NULL && terrno != TSDB_CODE_SUCCESS) {*/
|
|
||||||
/*pRequest->code = terrno;*/
|
|
||||||
/*}*/
|
|
||||||
|
|
||||||
/*return pRequest;*/
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* tmq_topic_vgroup_list, int32_t async) {
|
|
||||||
if (tmq_topic_vgroup_list != NULL) {
|
|
||||||
// TODO
|
// TODO
|
||||||
|
return TMQ_RESP_ERR__SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: change semaphore to gate
|
|
||||||
for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
|
||||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
|
||||||
for (int j = 0; j < taosArrayGetSize(pTopic->vgs); j++) {
|
|
||||||
SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j);
|
|
||||||
SMqConsumeReq* pReq = tmqBuildConsumeReqImpl(tmq, 0, pTopic, pVg);
|
|
||||||
|
|
||||||
SRequestObj* pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_VND_CONSUME);
|
|
||||||
pRequest->body.requestMsg = (SDataBuf){.pData = pReq, .len = sizeof(SMqConsumeReq)};
|
|
||||||
SMqCommitCbParam* pParam = taosMemoryMalloc(sizeof(SMqCommitCbParam));
|
|
||||||
if (pParam == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
pParam->tmq = tmq;
|
|
||||||
pParam->pVg = pVg;
|
|
||||||
pParam->async = async;
|
|
||||||
if (!async) tsem_init(&pParam->rspSem, 0, 0);
|
|
||||||
|
|
||||||
SMsgSendInfo* sendInfo = buildMsgInfoImpl(pRequest);
|
|
||||||
sendInfo->requestObjRefId = 0;
|
|
||||||
sendInfo->param = pParam;
|
|
||||||
sendInfo->fp = tmqCommitCb;
|
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
|
||||||
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo);
|
|
||||||
|
|
||||||
if (!async) tsem_wait(&pParam->rspSem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
tmq_resp_err_t tmq_consumer_close(tmq_t* tmq) { return TMQ_RESP_ERR__SUCCESS; }
|
|
||||||
|
|
||||||
const char* tmq_err2str(tmq_resp_err_t err) {
|
const char* tmq_err2str(tmq_resp_err_t err) {
|
||||||
if (err == TMQ_RESP_ERR__SUCCESS) {
|
if (err == TMQ_RESP_ERR__SUCCESS) {
|
||||||
return "success";
|
return "success";
|
||||||
|
@ -1573,10 +1316,3 @@ int32_t tmq_get_vgroup_id(TAOS_RES* res) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmq_message_destroy(TAOS_RES* res) {
|
|
||||||
if (res == NULL) return;
|
|
||||||
if (TD_RES_TMQ(res)) {
|
|
||||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ target_include_directories(
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/common"
|
PUBLIC "${TD_SOURCE_DIR}/include/common"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
IF(${TD_WINDOWS})
|
IF(${TD_WINDOWS})
|
||||||
PRIVATE "${TD_SOURCE_DIR}/contrib/pthread-win32"
|
PRIVATE "${TD_SOURCE_DIR}/contrib/pthread"
|
||||||
PRIVATE "${TD_SOURCE_DIR}/contrib/gnuregex"
|
PRIVATE "${TD_SOURCE_DIR}/contrib/msvcregex"
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
|
|
|
@ -167,7 +167,7 @@ TEST(testCase, Datablock_test) {
|
||||||
printf("the second row of binary:%s, length:%d\n", (char*)varDataVal(pData), varDataLen(pData));
|
printf("the second row of binary:%s, length:%d\n", (char*)varDataVal(pData), varDataLen(pData));
|
||||||
|
|
||||||
SArray* pOrderInfo = taosArrayInit(3, sizeof(SBlockOrderInfo));
|
SArray* pOrderInfo = taosArrayInit(3, sizeof(SBlockOrderInfo));
|
||||||
SBlockOrderInfo order = {.nullFirst = true, .order = TSDB_ORDER_ASC, .slotId = 0};
|
SBlockOrderInfo order = { true, TSDB_ORDER_ASC, 0, NULL };
|
||||||
taosArrayPush(pOrderInfo, &order);
|
taosArrayPush(pOrderInfo, &order);
|
||||||
|
|
||||||
blockDataSort(b, pOrderInfo);
|
blockDataSort(b, pOrderInfo);
|
||||||
|
|
|
@ -40,10 +40,12 @@ static void dmSetSignalHandle() {
|
||||||
taosSetSignal(SIGTERM, dmStopDnode);
|
taosSetSignal(SIGTERM, dmStopDnode);
|
||||||
taosSetSignal(SIGHUP, dmStopDnode);
|
taosSetSignal(SIGHUP, dmStopDnode);
|
||||||
taosSetSignal(SIGINT, dmStopDnode);
|
taosSetSignal(SIGINT, dmStopDnode);
|
||||||
taosSetSignal(SIGTSTP, dmStopDnode);
|
|
||||||
taosSetSignal(SIGABRT, dmStopDnode);
|
taosSetSignal(SIGABRT, dmStopDnode);
|
||||||
taosSetSignal(SIGBREAK, dmStopDnode);
|
taosSetSignal(SIGBREAK, dmStopDnode);
|
||||||
|
#ifndef WINDOWS
|
||||||
|
taosSetSignal(SIGTSTP, dmStopDnode);
|
||||||
taosSetSignal(SIGQUIT, dmStopDnode);
|
taosSetSignal(SIGQUIT, dmStopDnode);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!tsMultiProcess) {
|
if (!tsMultiProcess) {
|
||||||
} else if (global.ntype == DNODE || global.ntype == NODE_END) {
|
} else if (global.ntype == DNODE || global.ntype == NODE_END) {
|
||||||
|
|
|
@ -307,11 +307,11 @@ int32_t dmStartUdfd(SDnode *pDnode) {
|
||||||
dInfo("dnode-mgmt start udfd already called");
|
dInfo("dnode-mgmt start udfd already called");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
pData->startCalled = true;
|
||||||
uv_barrier_init(&pData->barrier, 2);
|
uv_barrier_init(&pData->barrier, 2);
|
||||||
pData->stopping = 0;
|
pData->stopping = 0;
|
||||||
uv_thread_create(&pData->thread, dmWatchUdfd, pDnode);
|
uv_thread_create(&pData->thread, dmWatchUdfd, pDnode);
|
||||||
uv_barrier_wait(&pData->barrier);
|
uv_barrier_wait(&pData->barrier);
|
||||||
pData->startCalled = true;
|
|
||||||
pData->needCleanUp = true;
|
pData->needCleanUp = true;
|
||||||
return pData->spawnErr;
|
return pData->spawnErr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,8 @@ int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList
|
||||||
int tqReadHandleAddTbUidList(STqReadHandle *pHandle, const SArray *tbUidList);
|
int tqReadHandleAddTbUidList(STqReadHandle *pHandle, const SArray *tbUidList);
|
||||||
int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver);
|
int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver);
|
||||||
bool tqNextDataBlock(STqReadHandle *pHandle);
|
bool tqNextDataBlock(STqReadHandle *pHandle);
|
||||||
int32_t tqRetrieveDataBlock(SArray **ppCols, STqReadHandle *pHandle, uint64_t *pGroupId, int32_t *pNumOfRows);
|
int32_t tqRetrieveDataBlock(SArray **ppCols, STqReadHandle *pHandle, uint64_t *pGroupId, int32_t *pNumOfRows,
|
||||||
|
int16_t *pNumOfCols);
|
||||||
|
|
||||||
// need to reposition
|
// need to reposition
|
||||||
|
|
||||||
|
|
|
@ -88,22 +88,12 @@ struct STqReadHandle {
|
||||||
SSubmitMsgIter msgIter;
|
SSubmitMsgIter msgIter;
|
||||||
SSubmitBlkIter blkIter;
|
SSubmitBlkIter blkIter;
|
||||||
SMeta* pVnodeMeta;
|
SMeta* pVnodeMeta;
|
||||||
SArray* pColIdList; // SArray<int32_t>
|
SArray* pColIdList; // SArray<int16_t>
|
||||||
int32_t sver;
|
int32_t sver;
|
||||||
SSchemaWrapper* pSchemaWrapper;
|
SSchemaWrapper* pSchemaWrapper;
|
||||||
STSchema* pSchema;
|
STSchema* pSchema;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int8_t type;
|
|
||||||
int8_t reserved[7];
|
|
||||||
union {
|
|
||||||
void* data;
|
|
||||||
int64_t wmTs;
|
|
||||||
int64_t checkpointId;
|
|
||||||
};
|
|
||||||
} STqStreamToken;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int16_t ver;
|
int16_t ver;
|
||||||
int16_t action;
|
int16_t action;
|
||||||
|
@ -155,24 +145,26 @@ typedef struct {
|
||||||
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
|
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
|
||||||
int64_t consumerId;
|
int64_t consumerId;
|
||||||
int32_t epoch;
|
int32_t epoch;
|
||||||
|
int8_t subType;
|
||||||
|
int8_t withTbName;
|
||||||
|
int8_t withSchema;
|
||||||
|
int8_t withTag;
|
||||||
|
int8_t withTagSchema;
|
||||||
char* qmsg;
|
char* qmsg;
|
||||||
// SRWLatch lock;
|
// SRWLatch lock;
|
||||||
SWalReadHandle* pReadHandle;
|
SWalReadHandle* pWalReader;
|
||||||
// number should be identical to fetch thread num
|
// number should be identical to fetch thread num
|
||||||
|
STqReadHandle* pStreamReader[4];
|
||||||
qTaskInfo_t task[4];
|
qTaskInfo_t task[4];
|
||||||
} STqExec;
|
} STqExec;
|
||||||
|
|
||||||
struct STQ {
|
struct STQ {
|
||||||
// the collection of groups
|
|
||||||
// the handle of meta kvstore
|
|
||||||
bool writeTrigger;
|
|
||||||
char* path;
|
char* path;
|
||||||
STqMetaStore* tqMeta;
|
// STqMetaStore* tqMeta;
|
||||||
SHashObj* tqMetaNew; // subKey -> tqExec
|
SHashObj* execs; // subKey -> tqExec
|
||||||
SHashObj* pStreamTasks;
|
SHashObj* pStreamTasks;
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
SWal* pWal;
|
SWal* pWal;
|
||||||
SMeta* pVnodeMeta;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -252,7 +244,7 @@ int tqInit();
|
||||||
void tqCleanUp();
|
void tqCleanUp();
|
||||||
|
|
||||||
// open in each vnode
|
// open in each vnode
|
||||||
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pMeta, SMemAllocatorFactory* allocFac);
|
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal);
|
||||||
void tqClose(STQ*);
|
void tqClose(STQ*);
|
||||||
// required by vnode
|
// required by vnode
|
||||||
int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t version);
|
int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t version);
|
||||||
|
|
|
@ -23,6 +23,9 @@ struct SMetaIdx {
|
||||||
SIndex *pIdx;
|
SIndex *pIdx;
|
||||||
#endif
|
#endif
|
||||||
/* data */
|
/* data */
|
||||||
|
#ifdef WINDOWS
|
||||||
|
size_t avoidCompilationErrors;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
int metaOpenIdx(SMeta *pMeta) {
|
int metaOpenIdx(SMeta *pMeta) {
|
||||||
|
|
|
@ -45,10 +45,12 @@ struct SMetaDB {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct __attribute__((__packed__)) {
|
#pragma pack(push,1)
|
||||||
|
typedef struct {
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
int32_t sver;
|
int32_t sver;
|
||||||
} SSchemaDbKey;
|
} SSchemaDbKey;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
|
|
|
@ -19,7 +19,7 @@ int32_t tqInit() { return tqPushMgrInit(); }
|
||||||
|
|
||||||
void tqCleanUp() { tqPushMgrCleanUp(); }
|
void tqCleanUp() { tqPushMgrCleanUp(); }
|
||||||
|
|
||||||
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, SMemAllocatorFactory* allocFac) {
|
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) {
|
||||||
STQ* pTq = taosMemoryMalloc(sizeof(STQ));
|
STQ* pTq = taosMemoryMalloc(sizeof(STQ));
|
||||||
if (pTq == NULL) {
|
if (pTq == NULL) {
|
||||||
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
||||||
|
@ -28,15 +28,16 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, SMe
|
||||||
pTq->path = strdup(path);
|
pTq->path = strdup(path);
|
||||||
pTq->pVnode = pVnode;
|
pTq->pVnode = pVnode;
|
||||||
pTq->pWal = pWal;
|
pTq->pWal = pWal;
|
||||||
pTq->pVnodeMeta = pVnodeMeta;
|
#if 0
|
||||||
pTq->tqMeta = tqStoreOpen(pTq, path, (FTqSerialize)tqSerializeConsumer, (FTqDeserialize)tqDeserializeConsumer,
|
pTq->tqMeta = tqStoreOpen(pTq, path, (FTqSerialize)tqSerializeConsumer, (FTqDeserialize)tqDeserializeConsumer,
|
||||||
(FTqDelete)taosMemoryFree, 0);
|
(FTqDelete)taosMemoryFree, 0);
|
||||||
if (pTq->tqMeta == NULL) {
|
if (pTq->tqMeta == NULL) {
|
||||||
taosMemoryFree(pTq);
|
taosMemoryFree(pTq);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
pTq->tqMetaNew = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
pTq->execs = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||||
|
|
||||||
pTq->pStreamTasks = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
pTq->pStreamTasks = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||||
|
|
||||||
|
@ -104,7 +105,11 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t versi
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tqCommit(STQ* pTq) { return tqStorePersist(pTq->tqMeta); }
|
int tqCommit(STQ* pTq) {
|
||||||
|
// do nothing
|
||||||
|
/*return tqStorePersist(pTq->tqMeta);*/
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tqGetTopicHandleSize(const STqTopic* pTopic) {
|
int32_t tqGetTopicHandleSize(const STqTopic* pTopic) {
|
||||||
return strlen(pTopic->topicName) + strlen(pTopic->sql) + strlen(pTopic->physicalPlan) + strlen(pTopic->qmsg) +
|
return strlen(pTopic->topicName) + strlen(pTopic->sql) + strlen(pTopic->physicalPlan) + strlen(pTopic->qmsg) +
|
||||||
|
@ -219,10 +224,10 @@ int32_t tqDeserializeConsumer(STQ* pTq, const STqSerializedHead* pHead, STqConsu
|
||||||
}
|
}
|
||||||
for (int j = 0; j < TQ_BUFFER_SIZE; j++) {
|
for (int j = 0; j < TQ_BUFFER_SIZE; j++) {
|
||||||
pTopic->buffer.output[j].status = 0;
|
pTopic->buffer.output[j].status = 0;
|
||||||
STqReadHandle* pReadHandle = tqInitSubmitMsgScanner(pTq->pVnodeMeta);
|
STqReadHandle* pReadHandle = tqInitSubmitMsgScanner(pTq->pVnode->pMeta);
|
||||||
SReadHandle handle = {
|
SReadHandle handle = {
|
||||||
.reader = pReadHandle,
|
.reader = pReadHandle,
|
||||||
.meta = pTq->pVnodeMeta,
|
.meta = pTq->pVnode->pMeta,
|
||||||
};
|
};
|
||||||
pTopic->buffer.output[j].pReadHandle = pReadHandle;
|
pTopic->buffer.output[j].pReadHandle = pReadHandle;
|
||||||
pTopic->buffer.output[j].task = qCreateStreamExecTaskInfo(pTopic->qmsg, &handle);
|
pTopic->buffer.output[j].task = qCreateStreamExecTaskInfo(pTopic->qmsg, &handle);
|
||||||
|
@ -238,6 +243,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
int32_t reqEpoch = pReq->epoch;
|
int32_t reqEpoch = pReq->epoch;
|
||||||
int64_t fetchOffset;
|
int64_t fetchOffset;
|
||||||
|
|
||||||
|
// get offset to fetch message
|
||||||
if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__EARLIEAST) {
|
if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__EARLIEAST) {
|
||||||
fetchOffset = walGetFirstVer(pTq->pWal);
|
fetchOffset = walGetFirstVer(pTq->pWal);
|
||||||
} else if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__LATEST) {
|
} else if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__LATEST) {
|
||||||
|
@ -249,7 +255,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
vDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld", consumerId, pReq->epoch,
|
vDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld", consumerId, pReq->epoch,
|
||||||
TD_VID(pTq->pVnode), pReq->currentOffset, fetchOffset);
|
TD_VID(pTq->pVnode), pReq->currentOffset, fetchOffset);
|
||||||
|
|
||||||
STqExec* pExec = taosHashGet(pTq->tqMetaNew, pReq->subKey, strlen(pReq->subKey));
|
STqExec* pExec = taosHashGet(pTq->execs, pReq->subKey, strlen(pReq->subKey));
|
||||||
ASSERT(pExec);
|
ASSERT(pExec);
|
||||||
|
|
||||||
int32_t consumerEpoch = atomic_load_32(&pExec->epoch);
|
int32_t consumerEpoch = atomic_load_32(&pExec->epoch);
|
||||||
|
@ -271,7 +277,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SWalReadHead* pHead;
|
SWalReadHead* pHead;
|
||||||
if (walReadWithHandle_s(pExec->pReadHandle, fetchOffset, &pHead) < 0) {
|
if (walReadWithHandle_s(pExec->pWalReader, fetchOffset, &pHead) < 0) {
|
||||||
// TODO: no more log, set timer to wait blocking time
|
// TODO: no more log, set timer to wait blocking time
|
||||||
// if data inserted during waiting, launch query and
|
// if data inserted during waiting, launch query and
|
||||||
// response to user
|
// response to user
|
||||||
|
@ -285,6 +291,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
|
|
||||||
if (pHead->msgType == TDMT_VND_SUBMIT) {
|
if (pHead->msgType == TDMT_VND_SUBMIT) {
|
||||||
SSubmitReq* pCont = (SSubmitReq*)&pHead->body;
|
SSubmitReq* pCont = (SSubmitReq*)&pHead->body;
|
||||||
|
if (pExec->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
qTaskInfo_t task = pExec->task[workerId];
|
qTaskInfo_t task = pExec->task[workerId];
|
||||||
ASSERT(task);
|
ASSERT(task);
|
||||||
qSetStreamInput(task, pCont, STREAM_DATA_TYPE_SUBMIT_BLOCK);
|
qSetStreamInput(task, pCont, STREAM_DATA_TYPE_SUBMIT_BLOCK);
|
||||||
|
@ -317,9 +324,40 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
taosArrayPush(rsp.blockData, &buf);
|
taosArrayPush(rsp.blockData, &buf);
|
||||||
rsp.blockNum++;
|
rsp.blockNum++;
|
||||||
}
|
}
|
||||||
|
} else if (pExec->subType == TOPIC_SUB_TYPE__DB) {
|
||||||
|
STqReadHandle* pReader = pExec->pStreamReader[workerId];
|
||||||
|
tqReadHandleSetMsg(pReader, pCont, 0);
|
||||||
|
while (tqNextDataBlock(pReader)) {
|
||||||
|
SSDataBlock block = {0};
|
||||||
|
if (tqRetrieveDataBlock(&block.pDataBlock, pReader, &block.info.groupId, &block.info.rows,
|
||||||
|
&block.info.numOfCols) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(&block);
|
||||||
|
void* buf = taosMemoryCalloc(1, dataStrLen);
|
||||||
|
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)buf;
|
||||||
|
/*pRetrieve->useconds = 0;*/
|
||||||
|
pRetrieve->precision = TSDB_DEFAULT_PRECISION;
|
||||||
|
pRetrieve->compressed = 0;
|
||||||
|
pRetrieve->completed = 1;
|
||||||
|
pRetrieve->numOfRows = htonl(block.info.rows);
|
||||||
|
|
||||||
|
// TODO enable compress
|
||||||
|
int32_t actualLen = 0;
|
||||||
|
blockCompressEncode(&block, pRetrieve->data, &actualLen, block.info.numOfCols, false);
|
||||||
|
actualLen += sizeof(SRetrieveTableRsp);
|
||||||
|
ASSERT(actualLen <= dataStrLen);
|
||||||
|
taosArrayPush(rsp.blockDataLen, &actualLen);
|
||||||
|
taosArrayPush(rsp.blockData, &buf);
|
||||||
|
rsp.blockNum++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO batch optimization
|
// TODO batch optimization:
|
||||||
|
// TODO continue scan until meeting batch requirement
|
||||||
if (rsp.blockNum != 0) break;
|
if (rsp.blockNum != 0) break;
|
||||||
rsp.skipLogNum++;
|
rsp.skipLogNum++;
|
||||||
fetchOffset++;
|
fetchOffset++;
|
||||||
|
@ -572,10 +610,10 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
|
|
||||||
// TODO: persist meta into tdb
|
// TODO: persist meta into tdb
|
||||||
int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
SMqRebVgReq req;
|
SMqRebVgReq req = {0};
|
||||||
tDecodeSMqRebVgReq(msg, &req);
|
tDecodeSMqRebVgReq(msg, &req);
|
||||||
// todo lock
|
// todo lock
|
||||||
STqExec* pExec = taosHashGet(pTq->tqMetaNew, req.subKey, strlen(req.subKey));
|
STqExec* pExec = taosHashGet(pTq->execs, req.subKey, strlen(req.subKey));
|
||||||
if (pExec == NULL) {
|
if (pExec == NULL) {
|
||||||
ASSERT(req.oldConsumerId == -1);
|
ASSERT(req.oldConsumerId == -1);
|
||||||
ASSERT(req.newConsumerId != -1);
|
ASSERT(req.newConsumerId != -1);
|
||||||
|
@ -586,19 +624,27 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
memcpy(pExec->subKey, req.subKey, TSDB_SUBSCRIBE_KEY_LEN);
|
memcpy(pExec->subKey, req.subKey, TSDB_SUBSCRIBE_KEY_LEN);
|
||||||
pExec->consumerId = req.newConsumerId;
|
pExec->consumerId = req.newConsumerId;
|
||||||
pExec->epoch = -1;
|
pExec->epoch = -1;
|
||||||
|
|
||||||
|
pExec->subType = req.subType;
|
||||||
|
pExec->withTbName = req.withTbName;
|
||||||
|
pExec->withSchema = req.withSchema;
|
||||||
|
pExec->withTag = req.withTag;
|
||||||
|
pExec->withTagSchema = req.withTagSchema;
|
||||||
|
|
||||||
pExec->qmsg = req.qmsg;
|
pExec->qmsg = req.qmsg;
|
||||||
req.qmsg = NULL;
|
req.qmsg = NULL;
|
||||||
pExec->pReadHandle = walOpenReadHandle(pTq->pVnode->pWal);
|
|
||||||
|
pExec->pWalReader = walOpenReadHandle(pTq->pVnode->pWal);
|
||||||
for (int32_t i = 0; i < 4; i++) {
|
for (int32_t i = 0; i < 4; i++) {
|
||||||
STqReadHandle* pReadHandle = tqInitSubmitMsgScanner(pTq->pVnodeMeta);
|
pExec->pStreamReader[i] = tqInitSubmitMsgScanner(pTq->pVnode->pMeta);
|
||||||
SReadHandle handle = {
|
SReadHandle handle = {
|
||||||
.reader = pReadHandle,
|
.reader = pExec->pStreamReader[i],
|
||||||
.meta = pTq->pVnodeMeta,
|
.meta = pTq->pVnode->pMeta,
|
||||||
};
|
};
|
||||||
pExec->task[i] = qCreateStreamExecTaskInfo(pExec->qmsg, &handle);
|
pExec->task[i] = qCreateStreamExecTaskInfo(pExec->qmsg, &handle);
|
||||||
ASSERT(pExec->task[i]);
|
ASSERT(pExec->task[i]);
|
||||||
}
|
}
|
||||||
taosHashPut(pTq->tqMetaNew, req.subKey, strlen(req.subKey), pExec, sizeof(STqExec));
|
taosHashPut(pTq->execs, req.subKey, strlen(req.subKey), pExec, sizeof(STqExec));
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
/*if (req.newConsumerId != -1) {*/
|
/*if (req.newConsumerId != -1) {*/
|
||||||
|
@ -627,12 +673,12 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int32_t parallel) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (int32_t i = 0; i < parallel; i++) {
|
for (int32_t i = 0; i < parallel; i++) {
|
||||||
STqReadHandle* pReadHandle = tqInitSubmitMsgScanner(pTq->pVnodeMeta);
|
STqReadHandle* pStreamReader = tqInitSubmitMsgScanner(pTq->pVnode->pMeta);
|
||||||
SReadHandle handle = {
|
SReadHandle handle = {
|
||||||
.reader = pReadHandle,
|
.reader = pStreamReader,
|
||||||
.meta = pTq->pVnodeMeta,
|
.meta = pTq->pVnode->pMeta,
|
||||||
};
|
};
|
||||||
pTask->exec.runners[i].inputHandle = pReadHandle;
|
pTask->exec.runners[i].inputHandle = pStreamReader;
|
||||||
pTask->exec.runners[i].executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle);
|
pTask->exec.runners[i].executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle);
|
||||||
ASSERT(pTask->exec.runners[i].executor);
|
ASSERT(pTask->exec.runners[i].executor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
||||||
}
|
}
|
||||||
strcpy(pMeta->dirPath, path);
|
strcpy(pMeta->dirPath, path);
|
||||||
|
|
||||||
char name[pathLen + 10];
|
char *name = taosMemoryMalloc(pathLen + 10) ;
|
||||||
|
|
||||||
strcpy(name, path);
|
strcpy(name, path);
|
||||||
if (!taosDirExist(name) && taosMkDir(name) != 0) {
|
if (!taosDirExist(name) && taosMkDir(name) != 0) {
|
||||||
|
@ -99,6 +99,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
tqError("failed to open file:%s since %s ", name, terrstr());
|
tqError("failed to open file:%s since %s ", name, terrstr());
|
||||||
// free memory
|
// free memory
|
||||||
|
taosMemoryFree(name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +107,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
||||||
pMeta->unpersistHead = taosMemoryCalloc(1, sizeof(STqMetaList));
|
pMeta->unpersistHead = taosMemoryCalloc(1, sizeof(STqMetaList));
|
||||||
if (pMeta->unpersistHead == NULL) {
|
if (pMeta->unpersistHead == NULL) {
|
||||||
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
||||||
|
taosMemoryFree(name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pMeta->unpersistHead->unpersistNext = pMeta->unpersistHead->unpersistPrev = pMeta->unpersistHead;
|
pMeta->unpersistHead->unpersistNext = pMeta->unpersistHead->unpersistPrev = pMeta->unpersistHead;
|
||||||
|
@ -116,8 +118,10 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
tqError("failed to open file:%s since %s", name, terrstr());
|
tqError("failed to open file:%s since %s", name, terrstr());
|
||||||
|
taosMemoryFree(name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
taosMemoryFree(name);
|
||||||
|
|
||||||
pMeta->pFile = pFile;
|
pMeta->pFile = pFile;
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,8 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* pGroupId, int32_t* pNumOfRows) {
|
int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* pGroupId, int32_t* pNumOfRows,
|
||||||
|
int16_t* pNumOfCols) {
|
||||||
/*int32_t sversion = pHandle->pBlock->sversion;*/
|
/*int32_t sversion = pHandle->pBlock->sversion;*/
|
||||||
// TODO set to real sversion
|
// TODO set to real sversion
|
||||||
int32_t sversion = 0;
|
int32_t sversion = 0;
|
||||||
|
@ -104,7 +105,6 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
|
||||||
SSchemaWrapper* pSchemaWrapper = pHandle->pSchemaWrapper;
|
SSchemaWrapper* pSchemaWrapper = pHandle->pSchemaWrapper;
|
||||||
|
|
||||||
*pNumOfRows = pHandle->pBlock->numOfRows;
|
*pNumOfRows = pHandle->pBlock->numOfRows;
|
||||||
/*int32_t numOfCols = pHandle->pSchema->numOfCols;*/
|
|
||||||
int32_t colNumNeed = taosArrayGetSize(pHandle->pColIdList);
|
int32_t colNumNeed = taosArrayGetSize(pHandle->pColIdList);
|
||||||
|
|
||||||
if (colNumNeed > pSchemaWrapper->nCols) {
|
if (colNumNeed > pSchemaWrapper->nCols) {
|
||||||
|
@ -142,6 +142,7 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t colActual = taosArrayGetSize(*ppCols);
|
int32_t colActual = taosArrayGetSize(*ppCols);
|
||||||
|
*pNumOfCols = colActual;
|
||||||
|
|
||||||
// TODO in stream shuffle case, fetch groupId
|
// TODO in stream shuffle case, fetch groupId
|
||||||
*pGroupId = 0;
|
*pGroupId = 0;
|
||||||
|
|
|
@ -112,7 +112,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
|
|
||||||
// open tq
|
// open tq
|
||||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
||||||
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal, pVnode->pMeta, vBufPoolGetMAF(pVnode));
|
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal);
|
||||||
if (pVnode->pTq == NULL) {
|
if (pVnode->pTq == NULL) {
|
||||||
vError("vgId: %d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId: %d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
|
@ -104,6 +104,10 @@ typedef struct SCatalog {
|
||||||
|
|
||||||
typedef struct SCtgApiStat {
|
typedef struct SCtgApiStat {
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
size_t avoidCompilationErrors;
|
||||||
|
#endif
|
||||||
|
|
||||||
} SCtgApiStat;
|
} SCtgApiStat;
|
||||||
|
|
||||||
typedef struct SCtgRuntimeStat {
|
typedef struct SCtgRuntimeStat {
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
#pragma GCC diagnostic ignored "-Wformat"
|
#pragma GCC diagnostic ignored "-Wformat"
|
||||||
#include <addr_any.h>
|
#include <addr_any.h>
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#define TD_USE_WINSOCK
|
||||||
|
#endif
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
|
@ -155,11 +158,11 @@ int32_t ctgTestGetVgNumFromVgVersion(int32_t vgVersion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
|
void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
|
||||||
SName cn = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName cn = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(cn.dbname, "db1");
|
strcpy(cn.dbname, "db1");
|
||||||
strcpy(cn.tname, ctgTestCTablename);
|
strcpy(cn.tname, ctgTestCTablename);
|
||||||
|
|
||||||
SName sn = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName sn = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(sn.dbname, "db1");
|
strcpy(sn.dbname, "db1");
|
||||||
strcpy(sn.tname, ctgTestSTablename);
|
strcpy(sn.tname, ctgTestSTablename);
|
||||||
|
|
||||||
|
@ -577,9 +580,16 @@ void ctgTestSetRspDbVgroups() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(rpcSendRecv, ctgTestRspDbVgroups);
|
stub.set(rpcSendRecv, ctgTestRspDbVgroups);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("rpcSendRecv", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string, void *> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||||
|
#endif
|
||||||
for (const auto &f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, ctgTestRspDbVgroups);
|
stub.set(f.second, ctgTestRspDbVgroups);
|
||||||
}
|
}
|
||||||
|
@ -590,9 +600,16 @@ void ctgTestSetRspTableMeta() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(rpcSendRecv, ctgTestRspTableMeta);
|
stub.set(rpcSendRecv, ctgTestRspTableMeta);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("rpcSendRecv", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string, void *> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||||
|
#endif
|
||||||
for (const auto &f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, ctgTestRspTableMeta);
|
stub.set(f.second, ctgTestRspTableMeta);
|
||||||
}
|
}
|
||||||
|
@ -603,9 +620,16 @@ void ctgTestSetRspCTableMeta() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(rpcSendRecv, ctgTestRspCTableMeta);
|
stub.set(rpcSendRecv, ctgTestRspCTableMeta);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("rpcSendRecv", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string, void *> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||||
|
#endif
|
||||||
for (const auto &f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, ctgTestRspCTableMeta);
|
stub.set(f.second, ctgTestRspCTableMeta);
|
||||||
}
|
}
|
||||||
|
@ -616,9 +640,16 @@ void ctgTestSetRspSTableMeta() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(rpcSendRecv, ctgTestRspSTableMeta);
|
stub.set(rpcSendRecv, ctgTestRspSTableMeta);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("rpcSendRecv", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string, void *> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||||
|
#endif
|
||||||
for (const auto &f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, ctgTestRspSTableMeta);
|
stub.set(f.second, ctgTestRspSTableMeta);
|
||||||
}
|
}
|
||||||
|
@ -629,9 +660,16 @@ void ctgTestSetRspMultiSTableMeta() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(rpcSendRecv, ctgTestRspMultiSTableMeta);
|
stub.set(rpcSendRecv, ctgTestRspMultiSTableMeta);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("rpcSendRecv", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string, void *> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||||
|
#endif
|
||||||
for (const auto &f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, ctgTestRspMultiSTableMeta);
|
stub.set(f.second, ctgTestRspMultiSTableMeta);
|
||||||
}
|
}
|
||||||
|
@ -642,9 +680,16 @@ void ctgTestSetRspByIdx() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(rpcSendRecv, ctgTestRspByIdx);
|
stub.set(rpcSendRecv, ctgTestRspByIdx);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("rpcSendRecv", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string, void *> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||||
|
#endif
|
||||||
for (const auto &f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, ctgTestRspByIdx);
|
stub.set(f.second, ctgTestRspByIdx);
|
||||||
}
|
}
|
||||||
|
@ -656,9 +701,16 @@ void ctgTestSetRspDbVgroupsAndNormalMeta() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndNormalMeta);
|
stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndNormalMeta);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("rpcSendRecv", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string, void *> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||||
|
#endif
|
||||||
for (const auto &f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, ctgTestRspDbVgroupsAndNormalMeta);
|
stub.set(f.second, ctgTestRspDbVgroupsAndNormalMeta);
|
||||||
}
|
}
|
||||||
|
@ -669,9 +721,16 @@ void ctgTestSetRspDbVgroupsAndChildMeta() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndChildMeta);
|
stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndChildMeta);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("rpcSendRecv", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string, void *> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||||
|
#endif
|
||||||
for (const auto &f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, ctgTestRspDbVgroupsAndChildMeta);
|
stub.set(f.second, ctgTestRspDbVgroupsAndChildMeta);
|
||||||
}
|
}
|
||||||
|
@ -682,9 +741,16 @@ void ctgTestSetRspDbVgroupsAndSuperMeta() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndSuperMeta);
|
stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndSuperMeta);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("rpcSendRecv", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string, void *> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||||
|
#endif
|
||||||
for (const auto &f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, ctgTestRspDbVgroupsAndSuperMeta);
|
stub.set(f.second, ctgTestRspDbVgroupsAndSuperMeta);
|
||||||
}
|
}
|
||||||
|
@ -695,9 +761,16 @@ void ctgTestSetRspDbVgroupsAndMultiSuperMeta() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndMultiSuperMeta);
|
stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndMultiSuperMeta);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("rpcSendRecv", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string, void *> result;
|
std::map<std::string, void *> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||||
|
#endif
|
||||||
for (const auto &f : result) {
|
for (const auto &f : result) {
|
||||||
stub.set(f.second, ctgTestRspDbVgroupsAndMultiSuperMeta);
|
stub.set(f.second, ctgTestRspDbVgroupsAndMultiSuperMeta);
|
||||||
}
|
}
|
||||||
|
@ -789,7 +862,7 @@ void *ctgTestGetCtableMetaThread(void *param) {
|
||||||
STableMeta *tbMeta = NULL;
|
STableMeta *tbMeta = NULL;
|
||||||
bool inCache = false;
|
bool inCache = false;
|
||||||
|
|
||||||
SName cn = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName cn = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(cn.dbname, "db1");
|
strcpy(cn.dbname, "db1");
|
||||||
strcpy(cn.tname, ctgTestCTablename);
|
strcpy(cn.tname, ctgTestCTablename);
|
||||||
|
|
||||||
|
@ -871,7 +944,7 @@ TEST(tableMeta, normalTable) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestTablename);
|
strcpy(n.tname, ctgTestTablename);
|
||||||
|
|
||||||
|
@ -978,7 +1051,7 @@ TEST(tableMeta, childTableCase) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestCTablename);
|
strcpy(n.tname, ctgTestCTablename);
|
||||||
|
|
||||||
|
@ -1085,7 +1158,7 @@ TEST(tableMeta, superTableCase) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestSTablename);
|
strcpy(n.tname, ctgTestSTablename);
|
||||||
|
|
||||||
|
@ -1210,7 +1283,7 @@ TEST(tableMeta, rmStbMeta) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestSTablename);
|
strcpy(n.tname, ctgTestSTablename);
|
||||||
|
|
||||||
|
@ -1280,7 +1353,7 @@ TEST(tableMeta, updateStbMeta) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestSTablename);
|
strcpy(n.tname, ctgTestSTablename);
|
||||||
|
|
||||||
|
@ -1378,7 +1451,7 @@ TEST(refreshGetMeta, normal2normal) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestTablename);
|
strcpy(n.tname, ctgTestTablename);
|
||||||
|
|
||||||
|
@ -1457,7 +1530,7 @@ TEST(refreshGetMeta, normal2notexist) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestTablename);
|
strcpy(n.tname, ctgTestTablename);
|
||||||
|
|
||||||
|
@ -1529,7 +1602,7 @@ TEST(refreshGetMeta, normal2child) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestTablename);
|
strcpy(n.tname, ctgTestTablename);
|
||||||
ctgTestCurrentCTableName = ctgTestTablename;
|
ctgTestCurrentCTableName = ctgTestTablename;
|
||||||
|
@ -1613,7 +1686,7 @@ TEST(refreshGetMeta, stable2child) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestTablename);
|
strcpy(n.tname, ctgTestTablename);
|
||||||
ctgTestCurrentSTableName = ctgTestTablename;
|
ctgTestCurrentSTableName = ctgTestTablename;
|
||||||
|
@ -1699,7 +1772,7 @@ TEST(refreshGetMeta, stable2stable) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestTablename);
|
strcpy(n.tname, ctgTestTablename);
|
||||||
ctgTestCurrentSTableName = ctgTestTablename;
|
ctgTestCurrentSTableName = ctgTestTablename;
|
||||||
|
@ -1786,7 +1859,7 @@ TEST(refreshGetMeta, child2stable) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestTablename);
|
strcpy(n.tname, ctgTestTablename);
|
||||||
ctgTestCurrentCTableName = ctgTestTablename;
|
ctgTestCurrentCTableName = ctgTestTablename;
|
||||||
|
@ -1871,7 +1944,7 @@ TEST(tableDistVgroup, normalTable) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestTablename);
|
strcpy(n.tname, ctgTestTablename);
|
||||||
|
|
||||||
|
@ -1913,7 +1986,7 @@ TEST(tableDistVgroup, childTableCase) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestCTablename);
|
strcpy(n.tname, ctgTestCTablename);
|
||||||
|
|
||||||
|
@ -1956,7 +2029,7 @@ TEST(tableDistVgroup, superTableCase) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestSTablename);
|
strcpy(n.tname, ctgTestSTablename);
|
||||||
|
|
||||||
|
@ -2006,7 +2079,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestTablename);
|
strcpy(n.tname, ctgTestTablename);
|
||||||
|
|
||||||
|
@ -2091,7 +2164,7 @@ TEST(multiThread, getSetRmSameDbVgroup) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestTablename);
|
strcpy(n.tname, ctgTestTablename);
|
||||||
|
|
||||||
|
@ -2143,7 +2216,7 @@ TEST(multiThread, getSetRmDiffDbVgroup) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestTablename);
|
strcpy(n.tname, ctgTestTablename);
|
||||||
|
|
||||||
|
@ -2195,7 +2268,7 @@ TEST(multiThread, ctableMeta) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
strcpy(n.tname, ctgTestTablename);
|
strcpy(n.tname, ctgTestTablename);
|
||||||
|
|
||||||
|
@ -2247,7 +2320,7 @@ TEST(rentTest, allRent) {
|
||||||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||||
strcpy(n.dbname, "db1");
|
strcpy(n.dbname, "db1");
|
||||||
|
|
||||||
for (int32_t i = 1; i <= 10; ++i) {
|
for (int32_t i = 1; i <= 10; ++i) {
|
||||||
|
|
|
@ -410,8 +410,8 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
int32_t contentLen = 0;
|
int32_t contentLen = 0;
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||||
int32_t* offset = pPage + startOffset;
|
int32_t* offset = (int32_t*)((char*)pPage + startOffset);
|
||||||
columnLen = pPage + startOffset + sizeof(int32_t) * pInfo->rowCapacity;
|
columnLen = (char*)pPage + startOffset + sizeof(int32_t) * pInfo->rowCapacity;
|
||||||
char* data = (char*)(columnLen + sizeof(int32_t));
|
char* data = (char*)(columnLen + sizeof(int32_t));
|
||||||
|
|
||||||
if (colDataIsNull_s(pColInfoData, j)) {
|
if (colDataIsNull_s(pColInfoData, j)) {
|
||||||
|
@ -424,8 +424,8 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
contentLen = varDataTLen(src);
|
contentLen = varDataTLen(src);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char* bitmap = pPage + startOffset;
|
char* bitmap = (char*)pPage + startOffset;
|
||||||
columnLen = pPage + startOffset + BitmapLen(pInfo->rowCapacity);
|
columnLen = (char*)pPage + startOffset + BitmapLen(pInfo->rowCapacity);
|
||||||
char* data = (char*) columnLen + sizeof(int32_t);
|
char* data = (char*) columnLen + sizeof(int32_t);
|
||||||
|
|
||||||
bool isNull = colDataIsNull_f(pColInfoData->nullbitmap, j);
|
bool isNull = colDataIsNull_f(pColInfoData->nullbitmap, j);
|
||||||
|
|
|
@ -560,7 +560,8 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator, bool* newgroup)
|
||||||
SArray* pCols = NULL;
|
SArray* pCols = NULL;
|
||||||
uint64_t groupId;
|
uint64_t groupId;
|
||||||
int32_t numOfRows;
|
int32_t numOfRows;
|
||||||
int32_t code = tqRetrieveDataBlock(&pCols, pInfo->readerHandle, &groupId, &numOfRows);
|
int16_t outputCol;
|
||||||
|
int32_t code = tqRetrieveDataBlock(&pCols, pInfo->readerHandle, &groupId, &numOfRows, &outputCol);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS || numOfRows == 0) {
|
if (code != TSDB_CODE_SUCCESS || numOfRows == 0) {
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
|
|
|
@ -48,7 +48,7 @@ struct SSHashObj {
|
||||||
};
|
};
|
||||||
|
|
||||||
static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
|
static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
|
||||||
int32_t len = MIN(length, HASH_MAX_CAPACITY);
|
int32_t len = (length < HASH_MAX_CAPACITY ? length : HASH_MAX_CAPACITY);
|
||||||
|
|
||||||
int32_t i = 4;
|
int32_t i = 4;
|
||||||
while (i < len) i = (i << 1u);
|
while (i < len) i = (i << 1u);
|
||||||
|
@ -127,7 +127,7 @@ static void taosHashTableResize(SSHashObj *pHashObj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t inc = newCapacity - pHashObj->capacity;
|
size_t inc = newCapacity - pHashObj->capacity;
|
||||||
memset(pNewEntryList + pHashObj->capacity * sizeof(void*), 0, inc);
|
memset((char*)pNewEntryList + pHashObj->capacity * sizeof(void*), 0, inc);
|
||||||
|
|
||||||
pHashObj->hashList = pNewEntryList;
|
pHashObj->hashList = pNewEntryList;
|
||||||
pHashObj->capacity = newCapacity;
|
pHashObj->capacity = newCapacity;
|
||||||
|
@ -301,7 +301,7 @@ size_t tSimpleHashGetMemSize(const SSHashObj *pHashObj) {
|
||||||
|
|
||||||
void *tSimpleHashGetKey(const SSHashObj* pHashObj, void *data, size_t* keyLen) {
|
void *tSimpleHashGetKey(const SSHashObj* pHashObj, void *data, size_t* keyLen) {
|
||||||
int32_t offset = offsetof(SHNode, data);
|
int32_t offset = offsetof(SHNode, data);
|
||||||
SHNode *node = data - offset;
|
SHNode *node = ((SHNode*)(char*)data - offset);
|
||||||
if (keyLen != NULL) {
|
if (keyLen != NULL) {
|
||||||
*keyLen = pHashObj->keyLen;
|
*keyLen = pHashObj->keyLen;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ SSDataBlock* getDummyBlock(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
} else if (pInfo->type == data_asc) {
|
} else if (pInfo->type == data_asc) {
|
||||||
v = ++pInfo->startVal;
|
v = ++pInfo->startVal;
|
||||||
} else if (pInfo->type == data_rand) {
|
} else if (pInfo->type == data_rand) {
|
||||||
v = random();
|
v = taosRand();
|
||||||
}
|
}
|
||||||
|
|
||||||
colDataAppend(pColInfo, i, reinterpret_cast<const char*>(&v), false);
|
colDataAppend(pColInfo, i, reinterpret_cast<const char*>(&v), false);
|
||||||
|
@ -172,7 +172,7 @@ SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
} else if (pInfo->type == data_asc) {
|
} else if (pInfo->type == data_asc) {
|
||||||
v = ++pInfo->startVal;
|
v = ++pInfo->startVal;
|
||||||
} else if (pInfo->type == data_rand) {
|
} else if (pInfo->type == data_rand) {
|
||||||
v = random();
|
v = taosRand();
|
||||||
}
|
}
|
||||||
|
|
||||||
colDataAppend(pColInfo1, i, reinterpret_cast<const char*>(&v), false);
|
colDataAppend(pColInfo1, i, reinterpret_cast<const char*>(&v), false);
|
||||||
|
@ -938,7 +938,7 @@ TEST(testCase, build_executor_tree_Test) {
|
||||||
|
|
||||||
SExecTaskInfo* pTaskInfo = nullptr;
|
SExecTaskInfo* pTaskInfo = nullptr;
|
||||||
DataSinkHandle sinkHandle = nullptr;
|
DataSinkHandle sinkHandle = nullptr;
|
||||||
SReadHandle handle = {.reader = reinterpret_cast<void*>(0x1), .meta = reinterpret_cast<void*>(0x1)};
|
SReadHandle handle = { reinterpret_cast<void*>(0x1), reinterpret_cast<void*>(0x1), NULL };
|
||||||
|
|
||||||
struct SSubplan *plan = NULL;
|
struct SSubplan *plan = NULL;
|
||||||
int32_t code = qStringToSubplan(msg, &plan);
|
int32_t code = qStringToSubplan(msg, &plan);
|
||||||
|
|
|
@ -47,6 +47,9 @@ target_include_directories(
|
||||||
"${TD_SOURCE_DIR}/include/os"
|
"${TD_SOURCE_DIR}/include/os"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
udf1 PUBLIC os
|
||||||
|
)
|
||||||
|
|
||||||
#SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin)
|
#SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin)
|
||||||
add_executable(udfd src/udfd.c)
|
add_executable(udfd src/udfd.c)
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
|
#include "function.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -118,8 +119,7 @@ int32_t callUdfAggFinalize(UdfcFuncHandle handle, SUdfInterBuf *interBuf, SUdfIn
|
||||||
int32_t callUdfAggMerge(UdfcFuncHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf *interBuf2, SUdfInterBuf *resultBuf);
|
int32_t callUdfAggMerge(UdfcFuncHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf *interBuf2, SUdfInterBuf *resultBuf);
|
||||||
// input: block
|
// input: block
|
||||||
// output: resultData
|
// output: resultData
|
||||||
int32_t callUdfScalaProcess(UdfcFuncHandle handle, SSDataBlock *block, SSDataBlock *resultData);
|
int32_t callUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t numOfCols, SScalarParam *output);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tearn down udf
|
* tearn down udf
|
||||||
* @param handle
|
* @param handle
|
||||||
|
|
|
@ -69,6 +69,9 @@ typedef struct SUdfTeardownRequest {
|
||||||
|
|
||||||
|
|
||||||
typedef struct SUdfTeardownResponse {
|
typedef struct SUdfTeardownResponse {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
size_t avoidCompilationErrors;
|
||||||
|
#endif
|
||||||
} SUdfTeardownResponse;
|
} SUdfTeardownResponse;
|
||||||
|
|
||||||
typedef struct SUdfRequest {
|
typedef struct SUdfRequest {
|
||||||
|
|
|
@ -84,6 +84,9 @@ typedef struct SUdfTeardownRequest {
|
||||||
|
|
||||||
|
|
||||||
typedef struct SUdfTeardownResponse {
|
typedef struct SUdfTeardownResponse {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
size_t avoidCompilationErrors;
|
||||||
|
#endif
|
||||||
} SUdfTeardownResponse;
|
} SUdfTeardownResponse;
|
||||||
|
|
||||||
typedef struct SUdfRequest {
|
typedef struct SUdfRequest {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
#include "uv.h"
|
#include "uv.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "fnLog.h"
|
||||||
#include "tudf.h"
|
#include "tudf.h"
|
||||||
#include "tudfInt.h"
|
#include "tudfInt.h"
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
|
@ -557,6 +558,34 @@ int32_t convertUdfColumnToDataBlock(SUdfColumn *udfCol, SSDataBlock *block) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t convertScalarParamToDataBlock(SScalarParam *input, int32_t numOfCols, SSDataBlock *output) {
|
||||||
|
output->info.rows = input->numOfRows;
|
||||||
|
output->info.numOfCols = numOfCols;
|
||||||
|
bool hasVarCol = false;
|
||||||
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
if (IS_VAR_DATA_TYPE((input+i)->columnData->info.type)) {
|
||||||
|
hasVarCol = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
output->info.hasVarCol = hasVarCol;
|
||||||
|
|
||||||
|
//TODO: free the array output->pDataBlock
|
||||||
|
output->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
||||||
|
taosArrayPush(output->pDataBlock, input->columnData);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t convertDataBlockToScalarParm(SSDataBlock *input, SScalarParam *output) {
|
||||||
|
if (input->info.numOfCols != 1) {
|
||||||
|
fnError("scalar function only support one column");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
output->numOfRows = input->info.rows;
|
||||||
|
//TODO: memory
|
||||||
|
output->columnData = taosArrayGet(input->pDataBlock, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void onUdfcPipeClose(uv_handle_t *handle) {
|
void onUdfcPipeClose(uv_handle_t *handle) {
|
||||||
SClientUvConn *conn = handle->data;
|
SClientUvConn *conn = handle->data;
|
||||||
|
@ -1108,11 +1137,13 @@ int32_t callUdfAggFinalize(UdfcFuncHandle handle, SUdfInterBuf *interBuf, SUdfIn
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// input: block
|
int32_t callUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t numOfCols, SScalarParam* output) {
|
||||||
// output: resultData
|
|
||||||
int32_t callUdfScalaProcess(UdfcFuncHandle handle, SSDataBlock *block, SSDataBlock *resultData) {
|
|
||||||
int8_t callType = TSDB_UDF_CALL_SCALA_PROC;
|
int8_t callType = TSDB_UDF_CALL_SCALA_PROC;
|
||||||
int32_t err = callUdf(handle, callType, block, NULL, NULL, resultData, NULL);
|
SSDataBlock inputBlock = {0};
|
||||||
|
convertScalarParamToDataBlock(input, numOfCols, &inputBlock);
|
||||||
|
SSDataBlock resultBlock = {0};
|
||||||
|
int32_t err = callUdf(handle, callType, &inputBlock, NULL, NULL, &resultBlock, NULL);
|
||||||
|
convertDataBlockToScalarParm(&resultBlock, output);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,12 +55,7 @@ typedef struct SUvUdfWork {
|
||||||
uv_buf_t output;
|
uv_buf_t output;
|
||||||
} SUvUdfWork;
|
} SUvUdfWork;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum { UDF_STATE_INIT = 0, UDF_STATE_LOADING, UDF_STATE_READY, UDF_STATE_UNLOADING } EUdfState;
|
||||||
UDF_STATE_INIT = 0,
|
|
||||||
UDF_STATE_LOADING,
|
|
||||||
UDF_STATE_READY,
|
|
||||||
UDF_STATE_UNLOADING
|
|
||||||
} EUdfState;
|
|
||||||
|
|
||||||
typedef struct SUdf {
|
typedef struct SUdf {
|
||||||
int32_t refCount;
|
int32_t refCount;
|
||||||
|
@ -83,9 +78,13 @@ typedef struct SUdfcFuncHandle {
|
||||||
SUdf *udf;
|
SUdf *udf;
|
||||||
} SUdfcFuncHandle;
|
} SUdfcFuncHandle;
|
||||||
|
|
||||||
int32_t udfdLoadUdf(char* udfName, SUdf* udf) {
|
int32_t udfdFillUdfInfoFromMNode(void *clientRpc, SEpSet *pEpSet, char *udfName, SUdf *udf);
|
||||||
|
|
||||||
|
int32_t udfdLoadUdf(char *udfName, SEpSet *pEpSet, SUdf *udf) {
|
||||||
strcpy(udf->name, udfName);
|
strcpy(udf->name, udfName);
|
||||||
|
|
||||||
|
udfdFillUdfInfoFromMNode(global.clientRpc, pEpSet, udf->name, udf);
|
||||||
|
|
||||||
int err = uv_dlopen(udf->path, &udf->lib);
|
int err = uv_dlopen(udf->path, &udf->lib);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
fnError("can not load library %s. error: %s", udf->path, uv_strerror(err));
|
fnError("can not load library %s. error: %s", udf->path, uv_strerror(err));
|
||||||
|
@ -136,7 +135,7 @@ void udfdProcessRequest(uv_work_t *req) {
|
||||||
uv_mutex_lock(&udf->lock);
|
uv_mutex_lock(&udf->lock);
|
||||||
if (udf->state == UDF_STATE_INIT) {
|
if (udf->state == UDF_STATE_INIT) {
|
||||||
udf->state = UDF_STATE_LOADING;
|
udf->state = UDF_STATE_LOADING;
|
||||||
udfdLoadUdf(setup->udfName, udf);
|
udfdLoadUdf(setup->udfName, &setup->epSet, udf);
|
||||||
udf->state = UDF_STATE_READY;
|
udf->state = UDF_STATE_READY;
|
||||||
uv_cond_broadcast(&udf->condReady);
|
uv_cond_broadcast(&udf->condReady);
|
||||||
uv_mutex_unlock(&udf->lock);
|
uv_mutex_unlock(&udf->lock);
|
||||||
|
@ -168,7 +167,8 @@ void udfdProcessRequest(uv_work_t *req) {
|
||||||
|
|
||||||
case UDF_TASK_CALL: {
|
case UDF_TASK_CALL: {
|
||||||
SUdfCallRequest *call = &request.call;
|
SUdfCallRequest *call = &request.call;
|
||||||
fnDebug("%"PRId64 "call request. call type %d, handle: %"PRIx64, request.seqNum, call->callType, call->udfHandle);
|
fnDebug("%" PRId64 "call request. call type %d, handle: %" PRIx64, request.seqNum, call->callType,
|
||||||
|
call->udfHandle);
|
||||||
SUdfcFuncHandle *handle = (SUdfcFuncHandle *)(call->udfHandle);
|
SUdfcFuncHandle *handle = (SUdfcFuncHandle *)(call->udfHandle);
|
||||||
SUdf *udf = handle->udf;
|
SUdf *udf = handle->udf;
|
||||||
|
|
||||||
|
@ -206,8 +206,8 @@ void udfdProcessRequest(uv_work_t *req) {
|
||||||
}
|
}
|
||||||
case UDF_TASK_TEARDOWN: {
|
case UDF_TASK_TEARDOWN: {
|
||||||
SUdfTeardownRequest *teardown = &request.teardown;
|
SUdfTeardownRequest *teardown = &request.teardown;
|
||||||
fnInfo("teardown. %"PRId64"handle:%"PRIx64, request.seqNum, teardown->udfHandle)
|
fnInfo("teardown. %" PRId64 "handle:%" PRIx64, request.seqNum, teardown->udfHandle) SUdfcFuncHandle *handle =
|
||||||
SUdfcFuncHandle *handle = (SUdfcFuncHandle *)(teardown->udfHandle);
|
(SUdfcFuncHandle *)(teardown->udfHandle);
|
||||||
SUdf *udf = handle->udf;
|
SUdf *udf = handle->udf;
|
||||||
bool unloadUdf = false;
|
bool unloadUdf = false;
|
||||||
uv_mutex_lock(&global.udfsMutex);
|
uv_mutex_lock(&global.udfsMutex);
|
||||||
|
|
|
@ -45,11 +45,14 @@ int main(int argc, char *argv[]) {
|
||||||
taosArrayPush(pBlock->pDataBlock, &colInfo);
|
taosArrayPush(pBlock->pDataBlock, &colInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDataBlock output = {0};
|
SScalarParam input = {0};
|
||||||
callUdfScalaProcess(handle, pBlock, &output);
|
input.numOfRows = pBlock->info.rows;
|
||||||
|
input.columnData = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
SScalarParam output = {0};
|
||||||
|
callUdfScalarFunc(handle, &input, 1 , &output);
|
||||||
|
|
||||||
SColumnInfoData *col = taosArrayGet(output.pDataBlock, 0);
|
SColumnInfoData *col = output.columnData;
|
||||||
for (int32_t i = 0; i < output.info.rows; ++i) {
|
for (int32_t i = 0; i < output.numOfRows; ++i) {
|
||||||
fprintf(stderr, "%d\t%d\n" , i, *(int32_t*)(col->pData + i *sizeof(int32_t)));
|
fprintf(stderr, "%d\t%d\n" , i, *(int32_t*)(col->pData + i *sizeof(int32_t)));
|
||||||
}
|
}
|
||||||
teardownUdf(handle);
|
teardownUdf(handle);
|
||||||
|
|
|
@ -31,6 +31,9 @@ extern "C" {
|
||||||
typedef enum { MATCH, JUMP, SPLIT, RANGE } InstType;
|
typedef enum { MATCH, JUMP, SPLIT, RANGE } InstType;
|
||||||
|
|
||||||
typedef struct MatchValue {
|
typedef struct MatchValue {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
size_t avoidCompilationErrors;
|
||||||
|
#endif
|
||||||
} MatchValue;
|
} MatchValue;
|
||||||
typedef struct JumpValue {
|
typedef struct JumpValue {
|
||||||
uint32_t step;
|
uint32_t step;
|
||||||
|
|
|
@ -748,7 +748,7 @@ static SArray* tfileGetFileList(const char* path) {
|
||||||
sprintf(buf, "%s/%s", path, file);
|
sprintf(buf, "%s/%s", path, file);
|
||||||
taosArrayPush(files, &buf);
|
taosArrayPush(files, &buf);
|
||||||
}
|
}
|
||||||
taosCloseDir(pDir);
|
taosCloseDir(&pDir);
|
||||||
|
|
||||||
taosArraySort(files, tfileCompare);
|
taosArraySort(files, tfileCompare);
|
||||||
tfileRmExpireFile(files);
|
tfileRmExpireFile(files);
|
||||||
|
|
|
@ -485,7 +485,7 @@ TEST_F(IndexTFileEnv, test_tfile_write) {
|
||||||
std::string colVal("ab");
|
std::string colVal("ab");
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
SIndexTermQuery query = {.term = term, .qType = QUERY_TERM};
|
SIndexTermQuery query = { term, QUERY_TERM};
|
||||||
|
|
||||||
SArray* result = (SArray*)taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = (SArray*)taosArrayInit(1, sizeof(uint64_t));
|
||||||
fObj->Get(&query, result);
|
fObj->Get(&query, result);
|
||||||
|
@ -625,7 +625,7 @@ TEST_F(IndexCacheEnv, cache_test) {
|
||||||
std::string colVal("v3");
|
std::string colVal("v3");
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
SIndexTermQuery query = {.term = term, .qType = QUERY_TERM};
|
SIndexTermQuery query = { term, QUERY_TERM };
|
||||||
SArray* ret = (SArray*)taosArrayInit(4, sizeof(suid));
|
SArray* ret = (SArray*)taosArrayInit(4, sizeof(suid));
|
||||||
STermValueType valType;
|
STermValueType valType;
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ TEST_F(IndexCacheEnv, cache_test) {
|
||||||
std::string colVal("v2");
|
std::string colVal("v2");
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
SIndexTermQuery query = {.term = term, .qType = QUERY_TERM};
|
SIndexTermQuery query = { term, QUERY_TERM };
|
||||||
SArray* ret = (SArray*)taosArrayInit(4, sizeof(suid));
|
SArray* ret = (SArray*)taosArrayInit(4, sizeof(suid));
|
||||||
STermValueType valType;
|
STermValueType valType;
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
|
||||||
{
|
{
|
||||||
std::string colName("voltagefdadfa");
|
std::string colName("voltagefdadfa");
|
||||||
std::string colVal("abxxxxxxxxxxxx");
|
std::string colVal("abxxxxxxxxxxxx");
|
||||||
for (uint i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
colVal[i % colVal.size()] = '0' + i % 128;
|
colVal[i % colVal.size()] = '0' + i % 128;
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os.h"
|
|
||||||
#include "ttokendef.h"
|
#include "ttokendef.h"
|
||||||
|
|
||||||
// used to denote the minimum unite in sql parsing
|
// used to denote the minimum unite in sql parsing
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
#include "parInt.h"
|
#include "parInt.h"
|
||||||
|
|
||||||
#include "parAst.h"
|
#include "parAst.h"
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
#include "parInsertData.h"
|
#include "parInsertData.h"
|
||||||
#include "parInt.h"
|
#include "parInt.h"
|
||||||
#include "parToken.h"
|
#include "parToken.h"
|
||||||
|
@ -1408,10 +1409,6 @@ int32_t qBindStmtSingleColValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf,
|
||||||
|
|
||||||
SSchema* pColSchema = &pSchema[spd->boundColumns[colIdx] - 1];
|
SSchema* pColSchema = &pSchema[spd->boundColumns[colIdx] - 1];
|
||||||
|
|
||||||
if (bind->buffer_type != pColSchema->type) {
|
|
||||||
return buildInvalidOperationMsg(&pBuf, "column type mis-match with buffer type");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bind->num != rowNum) {
|
if (bind->num != rowNum) {
|
||||||
return buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same");
|
return buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same");
|
||||||
}
|
}
|
||||||
|
@ -1426,6 +1423,10 @@ int32_t qBindStmtSingleColValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf,
|
||||||
|
|
||||||
CHECK_CODE(MemRowAppend(&pBuf, NULL, 0, ¶m));
|
CHECK_CODE(MemRowAppend(&pBuf, NULL, 0, ¶m));
|
||||||
} else {
|
} else {
|
||||||
|
if (bind->buffer_type != pColSchema->type) {
|
||||||
|
return buildInvalidOperationMsg(&pBuf, "column type mis-match with buffer type");
|
||||||
|
}
|
||||||
|
|
||||||
int32_t colLen = pColSchema->bytes;
|
int32_t colLen = pColSchema->bytes;
|
||||||
if (IS_VAR_DATA_TYPE(pColSchema->type)) {
|
if (IS_VAR_DATA_TYPE(pColSchema->type)) {
|
||||||
colLen = bind->length[r];
|
colLen = bind->length[r];
|
||||||
|
|
|
@ -49,12 +49,14 @@ static bool afterGroupBy(ESqlClause clause) { return clause > SQL_CLAUSE_GROUP_B
|
||||||
|
|
||||||
static bool beforeHaving(ESqlClause clause) { return clause < SQL_CLAUSE_HAVING; }
|
static bool beforeHaving(ESqlClause clause) { return clause < SQL_CLAUSE_HAVING; }
|
||||||
|
|
||||||
#define generateDealNodeErrMsg(pCxt, code, ...) \
|
enum EDealRes generateDealNodeErrMsg(STranslateContext* pCxt, int32_t code, ...) {
|
||||||
({ \
|
va_list ap;
|
||||||
generateSyntaxErrMsg(&pCxt->msgBuf, code, ##__VA_ARGS__); \
|
va_start(ap, code);
|
||||||
pCxt->errCode = code; \
|
generateSyntaxErrMsg(&pCxt->msgBuf, code, ap);
|
||||||
DEAL_RES_ERROR; \
|
va_end(ap);
|
||||||
})
|
pCxt->errCode = code;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t addNamespace(STranslateContext* pCxt, void* pTable) {
|
static int32_t addNamespace(STranslateContext* pCxt, void* pTable) {
|
||||||
size_t currTotalLevel = taosArrayGetSize(pCxt->pNsLevel);
|
size_t currTotalLevel = taosArrayGetSize(pCxt->pNsLevel);
|
||||||
|
@ -564,6 +566,9 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
||||||
TSDB_DATA_TYPE_BLOB == rdt.type) {
|
TSDB_DATA_TYPE_BLOB == rdt.type) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
|
||||||
}
|
}
|
||||||
|
if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) {
|
||||||
|
((SExprNode*)pOp->pRight)->resType = ((SExprNode*)pOp->pLeft)->resType;
|
||||||
|
}
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||||
} else if (nodesIsJsonOp(pOp)){
|
} else if (nodesIsJsonOp(pOp)){
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
#include "parInt.h"
|
#include "parInt.h"
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
#include "parToken.h"
|
#include "parToken.h"
|
||||||
|
|
|
@ -17,3 +17,11 @@ TARGET_LINK_LIBRARIES(
|
||||||
parserTest
|
parserTest
|
||||||
PUBLIC os util common nodes parser catalog transport gtest function planner qcom
|
PUBLIC os util common nodes parser catalog transport gtest function planner qcom
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(${BUILD_WINGETOPT})
|
||||||
|
target_include_directories(
|
||||||
|
parserTest
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/contrib/wingetopt/src"
|
||||||
|
)
|
||||||
|
target_link_libraries(parserTest PUBLIC wingetopt)
|
||||||
|
endif()
|
|
@ -12,7 +12,6 @@
|
||||||
* 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/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
|
|
||||||
|
@ -23,6 +22,9 @@
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#define TD_USE_WINSOCK
|
||||||
|
#endif
|
||||||
#include "mockCatalog.h"
|
#include "mockCatalog.h"
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
|
@ -40,13 +40,11 @@ public:
|
||||||
virtual TableBuilder& setVgid(int16_t vgid) {
|
virtual TableBuilder& setVgid(int16_t vgid) {
|
||||||
schema()->vgId = vgid;
|
schema()->vgId = vgid;
|
||||||
|
|
||||||
SVgroupInfo vgroup = {.vgId = vgid, .hashBegin = 0, .hashEnd = 0, };
|
SVgroupInfo vgroup = { vgid, 0, 0, {0}, 0};
|
||||||
|
addEpIntoEpSet(&vgroup.epSet, "dnode_1", 6030);
|
||||||
vgroup.epSet.eps[0] = (SEp){"dnode_1", 6030};
|
addEpIntoEpSet(&vgroup.epSet, "dnode_2", 6030);
|
||||||
vgroup.epSet.eps[1] = (SEp){"dnode_2", 6030};
|
addEpIntoEpSet(&vgroup.epSet, "dnode_3", 6030);
|
||||||
vgroup.epSet.eps[2] = (SEp){"dnode_3", 6030};
|
|
||||||
vgroup.epSet.inUse = 0;
|
vgroup.epSet.inUse = 0;
|
||||||
vgroup.epSet.numOfEps = 3;
|
|
||||||
|
|
||||||
meta_->vgs.emplace_back(vgroup);
|
meta_->vgs.emplace_back(vgroup);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -148,7 +146,7 @@ public:
|
||||||
meta_[db][tbname]->schema->uid = id_++;
|
meta_[db][tbname]->schema->uid = id_++;
|
||||||
meta_[db][tbname]->schema->tableType = TSDB_CHILD_TABLE;
|
meta_[db][tbname]->schema->tableType = TSDB_CHILD_TABLE;
|
||||||
|
|
||||||
SVgroupInfo vgroup = {.vgId = vgid, .hashBegin = 0, .hashEnd = 0,};
|
SVgroupInfo vgroup = { vgid, 0, 0, {0}, 0};
|
||||||
addEpIntoEpSet(&vgroup.epSet, "dnode_1", 6030);
|
addEpIntoEpSet(&vgroup.epSet, "dnode_1", 6030);
|
||||||
addEpIntoEpSet(&vgroup.epSet, "dnode_2", 6030);
|
addEpIntoEpSet(&vgroup.epSet, "dnode_2", 6030);
|
||||||
addEpIntoEpSet(&vgroup.epSet, "dnode_3", 6030);
|
addEpIntoEpSet(&vgroup.epSet, "dnode_3", 6030);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
#include "parInt.h"
|
#include "parInt.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
@ -14,14 +14,20 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "mockCatalog.h"
|
#ifdef WINDOWS
|
||||||
|
#define TD_USE_WINSOCK
|
||||||
|
#endif
|
||||||
|
#include "os.h"
|
||||||
#include "parserTestUtil.h"
|
#include "parserTestUtil.h"
|
||||||
#include "parToken.h"
|
#include "parToken.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
#include "mockCatalog.h"
|
||||||
|
|
||||||
bool g_isDump = false;
|
bool g_isDump = false;
|
||||||
|
|
||||||
|
|
|
@ -22,3 +22,12 @@ TARGET_INCLUDE_DIRECTORIES(
|
||||||
PRIVATE "${TD_SOURCE_DIR}/source/libs/planner/inc"
|
PRIVATE "${TD_SOURCE_DIR}/source/libs/planner/inc"
|
||||||
PRIVATE "${TD_SOURCE_DIR}/source/libs/parser/test"
|
PRIVATE "${TD_SOURCE_DIR}/source/libs/parser/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if(${BUILD_WINGETOPT})
|
||||||
|
target_include_directories(
|
||||||
|
plannerTest
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/contrib/wingetopt/src"
|
||||||
|
)
|
||||||
|
target_link_libraries(plannerTest PUBLIC wingetopt)
|
||||||
|
endif()
|
|
@ -16,7 +16,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
#include "getopt.h"
|
||||||
#include "mockCatalog.h"
|
#include "mockCatalog.h"
|
||||||
#include "planTestUtil.h"
|
#include "planTestUtil.h"
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include "planTestUtil.h"
|
#include "planTestUtil.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
@ -95,6 +95,9 @@ typedef struct SQWPhaseInput {
|
||||||
} SQWPhaseInput;
|
} SQWPhaseInput;
|
||||||
|
|
||||||
typedef struct SQWPhaseOutput {
|
typedef struct SQWPhaseOutput {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
size_t avoidCompilationErrors;
|
||||||
|
#endif
|
||||||
} SQWPhaseOutput;
|
} SQWPhaseOutput;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
#pragma GCC diagnostic ignored "-Wpointer-arith"
|
#pragma GCC diagnostic ignored "-Wpointer-arith"
|
||||||
#include <addr_any.h>
|
#include <addr_any.h>
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#define TD_USE_WINSOCK
|
||||||
|
#endif
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
@ -277,8 +280,8 @@ int32_t qwtCreateExecTask(void* tsdb, int32_t vgId, uint64_t taskId, struct SSub
|
||||||
qwtTestSinkMaxBlockNum = taosRand() % 100 + 1;
|
qwtTestSinkMaxBlockNum = taosRand() % 100 + 1;
|
||||||
qwtTestSinkQueryEnd = false;
|
qwtTestSinkQueryEnd = false;
|
||||||
|
|
||||||
*pTaskInfo = (qTaskInfo_t)qwtTestCaseIdx+1;
|
*pTaskInfo = (qTaskInfo_t)((char*)qwtTestCaseIdx+1);
|
||||||
*handle = (DataSinkHandle)qwtTestCaseIdx+2;
|
*handle = (DataSinkHandle)((char*)qwtTestCaseIdx+2);
|
||||||
|
|
||||||
++qwtTestCaseIdx;
|
++qwtTestCaseIdx;
|
||||||
|
|
||||||
|
@ -435,9 +438,16 @@ void stubSetStringToPlan() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(qStringToSubplan, qwtStringToPlan);
|
stub.set(qStringToSubplan, qwtStringToPlan);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("qStringToSubplan", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libplanner.so");
|
AddrAny any("libplanner.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^qStringToSubplan$", result);
|
any.get_global_func_addr_dynsym("^qStringToSubplan$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, qwtStringToPlan);
|
stub.set(f.second, qwtStringToPlan);
|
||||||
}
|
}
|
||||||
|
@ -448,9 +458,16 @@ void stubSetExecTask() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(qExecTask, qwtExecTask);
|
stub.set(qExecTask, qwtExecTask);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("qExecTask", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^qExecTask$", result);
|
any.get_global_func_addr_dynsym("^qExecTask$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, qwtExecTask);
|
stub.set(f.second, qwtExecTask);
|
||||||
}
|
}
|
||||||
|
@ -463,9 +480,16 @@ void stubSetCreateExecTask() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(qCreateExecTask, qwtCreateExecTask);
|
stub.set(qCreateExecTask, qwtCreateExecTask);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("qCreateExecTask", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^qCreateExecTask$", result);
|
any.get_global_func_addr_dynsym("^qCreateExecTask$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, qwtCreateExecTask);
|
stub.set(f.second, qwtCreateExecTask);
|
||||||
}
|
}
|
||||||
|
@ -476,9 +500,16 @@ void stubSetAsyncKillTask() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(qAsyncKillTask, qwtKillTask);
|
stub.set(qAsyncKillTask, qwtKillTask);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("qAsyncKillTask", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^qAsyncKillTask$", result);
|
any.get_global_func_addr_dynsym("^qAsyncKillTask$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, qwtKillTask);
|
stub.set(f.second, qwtKillTask);
|
||||||
}
|
}
|
||||||
|
@ -489,9 +520,16 @@ void stubSetDestroyTask() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(qDestroyTask, qwtDestroyTask);
|
stub.set(qDestroyTask, qwtDestroyTask);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("qDestroyTask", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^qDestroyTask$", result);
|
any.get_global_func_addr_dynsym("^qDestroyTask$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, qwtDestroyTask);
|
stub.set(f.second, qwtDestroyTask);
|
||||||
}
|
}
|
||||||
|
@ -503,9 +541,16 @@ void stubSetDestroyDataSinker() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(dsDestroyDataSinker, qwtDestroyDataSinker);
|
stub.set(dsDestroyDataSinker, qwtDestroyDataSinker);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("dsDestroyDataSinker", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^dsDestroyDataSinker$", result);
|
any.get_global_func_addr_dynsym("^dsDestroyDataSinker$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, qwtDestroyDataSinker);
|
stub.set(f.second, qwtDestroyDataSinker);
|
||||||
}
|
}
|
||||||
|
@ -516,9 +561,16 @@ void stubSetGetDataLength() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(dsGetDataLength, qwtGetDataLength);
|
stub.set(dsGetDataLength, qwtGetDataLength);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("dsGetDataLength", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^dsGetDataLength$", result);
|
any.get_global_func_addr_dynsym("^dsGetDataLength$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, qwtGetDataLength);
|
stub.set(f.second, qwtGetDataLength);
|
||||||
}
|
}
|
||||||
|
@ -529,9 +581,16 @@ void stubSetEndPut() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(dsEndPut, qwtEndPut);
|
stub.set(dsEndPut, qwtEndPut);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("dsEndPut", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^dsEndPut$", result);
|
any.get_global_func_addr_dynsym("^dsEndPut$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, qwtEndPut);
|
stub.set(f.second, qwtEndPut);
|
||||||
}
|
}
|
||||||
|
@ -542,9 +601,16 @@ void stubSetPutDataBlock() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(dsPutDataBlock, qwtPutDataBlock);
|
stub.set(dsPutDataBlock, qwtPutDataBlock);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("dsPutDataBlock", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libexecutor.so");
|
AddrAny any("libexecutor.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^dsPutDataBlock$", result);
|
any.get_global_func_addr_dynsym("^dsPutDataBlock$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, qwtPutDataBlock);
|
stub.set(f.second, qwtPutDataBlock);
|
||||||
}
|
}
|
||||||
|
@ -555,9 +621,16 @@ void stubSetRpcSendResponse() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(rpcSendResponse, qwtRpcSendResponse);
|
stub.set(rpcSendResponse, qwtRpcSendResponse);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("rpcSendResponse", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendResponse$", result);
|
any.get_global_func_addr_dynsym("^rpcSendResponse$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, qwtRpcSendResponse);
|
stub.set(f.second, qwtRpcSendResponse);
|
||||||
}
|
}
|
||||||
|
@ -568,9 +641,16 @@ void stubSetGetDataBlock() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(dsGetDataBlock, qwtGetDataBlock);
|
stub.set(dsGetDataBlock, qwtGetDataBlock);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("dsGetDataBlock", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^dsGetDataBlock$", result);
|
any.get_global_func_addr_dynsym("^dsGetDataBlock$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, qwtGetDataBlock);
|
stub.set(f.second, qwtGetDataBlock);
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,9 @@ typedef struct SFilterPCtx {
|
||||||
|
|
||||||
typedef struct SFltTreeStat {
|
typedef struct SFltTreeStat {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
int8_t precision;
|
||||||
bool scalarMode;
|
bool scalarMode;
|
||||||
|
SFilterInfo* info;
|
||||||
} SFltTreeStat;
|
} SFltTreeStat;
|
||||||
|
|
||||||
typedef struct SFltScalarCtx {
|
typedef struct SFltScalarCtx {
|
||||||
|
|
|
@ -3364,6 +3364,12 @@ int32_t filterGetTimeRangeImpl(SFilterInfo *info, STimeWindow *win, bool *
|
||||||
filterGetRangeRes(prev, &tra);
|
filterGetRangeRes(prev, &tra);
|
||||||
win->skey = tra.s;
|
win->skey = tra.s;
|
||||||
win->ekey = tra.e;
|
win->ekey = tra.e;
|
||||||
|
if (FILTER_GET_FLAG(tra.sflag, RANGE_FLG_EXCLUDE)) {
|
||||||
|
win->skey++;
|
||||||
|
}
|
||||||
|
if (FILTER_GET_FLAG(tra.eflag, RANGE_FLG_EXCLUDE)) {
|
||||||
|
win->ekey--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filterFreeRangeCtx(prev);
|
filterFreeRangeCtx(prev);
|
||||||
|
@ -3492,7 +3498,40 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QUERY_NODE_VALUE == nodeType(*pNode) || QUERY_NODE_NODE_LIST == nodeType(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
if (QUERY_NODE_VALUE == nodeType(*pNode)) {
|
||||||
|
if (!FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP)) {
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SValueNode *valueNode = (SValueNode *)*pNode;
|
||||||
|
if (TSDB_DATA_TYPE_BINARY != valueNode->node.resType.type) {
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (stat->precision < 0) {
|
||||||
|
//TODO
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *timeStr = valueNode->datum.p;
|
||||||
|
if (taosParseTime(valueNode->datum.p, &valueNode->datum.i, valueNode->node.resType.bytes, stat->precision, tsDaylight) !=
|
||||||
|
TSDB_CODE_SUCCESS) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
|
}
|
||||||
|
TODO
|
||||||
|
#else
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
|
SColumnNode *colNode = (SColumnNode *)*pNode;
|
||||||
|
stat->precision = colNode->node.resType.precision;
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QUERY_NODE_NODE_LIST == nodeType(*pNode)) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3656,16 +3695,19 @@ int32_t filterInitFromNode(SNode* pNode, SFilterInfo **pInfo, uint32_t options)
|
||||||
info = *pInfo;
|
info = *pInfo;
|
||||||
info->options = options;
|
info->options = options;
|
||||||
|
|
||||||
SFltTreeStat stat1 = {0};
|
SFltTreeStat stat = {0};
|
||||||
FLT_ERR_JRET(fltReviseNodes(info, &pNode, &stat1));
|
stat.precision = -1;
|
||||||
|
stat.info = info;
|
||||||
|
|
||||||
info->scalarMode = stat1.scalarMode;
|
FLT_ERR_JRET(fltReviseNodes(info, &pNode, &stat));
|
||||||
|
|
||||||
|
info->scalarMode = stat.scalarMode;
|
||||||
|
|
||||||
if (!info->scalarMode) {
|
if (!info->scalarMode) {
|
||||||
FLT_ERR_JRET(fltInitFromNode(pNode, info, options));
|
FLT_ERR_JRET(fltInitFromNode(pNode, info, options));
|
||||||
} else {
|
} else {
|
||||||
info->sclCtx.node = pNode;
|
info->sclCtx.node = pNode;
|
||||||
FLT_ERR_JRET(fltOptimizeNodes(info, &info->sclCtx.node, &stat1));
|
FLT_ERR_JRET(fltOptimizeNodes(info, &info->sclCtx.node, &stat));
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -621,13 +621,13 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
||||||
|
|
||||||
if (subPos > 0) {
|
if (subPos > 0) {
|
||||||
startPosBytes = (GET_PARAM_TYPE(pInput) == TSDB_DATA_TYPE_VARCHAR) ? subPos - 1 : (subPos - 1) * TSDB_NCHAR_SIZE;
|
startPosBytes = (GET_PARAM_TYPE(pInput) == TSDB_DATA_TYPE_VARCHAR) ? subPos - 1 : (subPos - 1) * TSDB_NCHAR_SIZE;
|
||||||
startPosBytes = MIN(startPosBytes, len);
|
startPosBytes = TMIN(startPosBytes, len);
|
||||||
} else {
|
} else {
|
||||||
startPosBytes = (GET_PARAM_TYPE(pInput) == TSDB_DATA_TYPE_VARCHAR) ? len + subPos : len + subPos * TSDB_NCHAR_SIZE;
|
startPosBytes = (GET_PARAM_TYPE(pInput) == TSDB_DATA_TYPE_VARCHAR) ? len + subPos : len + subPos * TSDB_NCHAR_SIZE;
|
||||||
startPosBytes = MAX(startPosBytes, 0);
|
startPosBytes = TMAX(startPosBytes, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t resLen = MIN(subLen, len - startPosBytes);
|
int32_t resLen = TMIN(subLen, len - startPosBytes);
|
||||||
if (resLen > 0) {
|
if (resLen > 0) {
|
||||||
memcpy(varDataVal(output), varDataVal(input) + startPosBytes, resLen);
|
memcpy(varDataVal(output), varDataVal(input) + startPosBytes, resLen);
|
||||||
}
|
}
|
||||||
|
@ -716,7 +716,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
||||||
int32_t len = sprintf(varDataVal(output), "%.*s", (int32_t)(outputLen - VARSTR_HEADER_SIZE), *(int8_t *)input ? "true" : "false");
|
int32_t len = sprintf(varDataVal(output), "%.*s", (int32_t)(outputLen - VARSTR_HEADER_SIZE), *(int8_t *)input ? "true" : "false");
|
||||||
varDataSetLen(output, len);
|
varDataSetLen(output, len);
|
||||||
} else if (inputType == TSDB_DATA_TYPE_BINARY) {
|
} else if (inputType == TSDB_DATA_TYPE_BINARY) {
|
||||||
int32_t len = MIN(varDataLen(input), outputLen - VARSTR_HEADER_SIZE);
|
int32_t len = TMIN(varDataLen(input), outputLen - VARSTR_HEADER_SIZE);
|
||||||
len = sprintf(varDataVal(output), "%.*s", len, varDataVal(input));
|
len = sprintf(varDataVal(output), "%.*s", len, varDataVal(input));
|
||||||
varDataSetLen(output, len);
|
varDataSetLen(output, len);
|
||||||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
@ -750,7 +750,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
||||||
}
|
}
|
||||||
varDataSetLen(output, len);
|
varDataSetLen(output, len);
|
||||||
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t len = MIN(outputLen, varDataLen(input) + VARSTR_HEADER_SIZE);
|
int32_t len = TMIN(outputLen, varDataLen(input) + VARSTR_HEADER_SIZE);
|
||||||
memcpy(output, input, len);
|
memcpy(output, input, len);
|
||||||
varDataSetLen(output, len - VARSTR_HEADER_SIZE);
|
varDataSetLen(output, len - VARSTR_HEADER_SIZE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
#pragma GCC diagnostic ignored "-Wpointer-arith"
|
#pragma GCC diagnostic ignored "-Wpointer-arith"
|
||||||
#include <addr_any.h>
|
#include <addr_any.h>
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#define TD_USE_WINSOCK
|
||||||
|
#endif
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
@ -242,7 +245,7 @@ TEST(timerangeTest, greater) {
|
||||||
int32_t code = filterGetTimeRange(opNode1, &win, &isStrict);
|
int32_t code = filterGetTimeRange(opNode1, &win, &isStrict);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(isStrict, true);
|
ASSERT_EQ(isStrict, true);
|
||||||
ASSERT_EQ(win.skey, tsmall);
|
ASSERT_EQ(win.skey, tsmall+1);
|
||||||
ASSERT_EQ(win.ekey, INT64_MAX);
|
ASSERT_EQ(win.ekey, INT64_MAX);
|
||||||
//filterFreeInfo(filter);
|
//filterFreeInfo(filter);
|
||||||
nodesDestroyNode(opNode1);
|
nodesDestroyNode(opNode1);
|
||||||
|
@ -265,6 +268,37 @@ TEST(timerangeTest, greater_and_lower) {
|
||||||
|
|
||||||
flttMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2);
|
flttMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2);
|
||||||
|
|
||||||
|
//SFilterInfo *filter = NULL;
|
||||||
|
//int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP);
|
||||||
|
//ASSERT_EQ(code, 0);
|
||||||
|
STimeWindow win = {0};
|
||||||
|
bool isStrict = false;
|
||||||
|
int32_t code = filterGetTimeRange(logicNode, &win, &isStrict);
|
||||||
|
ASSERT_EQ(isStrict, true);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
ASSERT_EQ(win.skey, tsmall+1);
|
||||||
|
ASSERT_EQ(win.ekey, tbig-1);
|
||||||
|
//filterFreeInfo(filter);
|
||||||
|
nodesDestroyNode(logicNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(timerangeTest, greater_equal_and_lower_equal) {
|
||||||
|
SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL;
|
||||||
|
bool eRes[5] = {false, false, true, true, true};
|
||||||
|
SScalarParam res = {0};
|
||||||
|
int64_t tsmall = 222, tbig = 333;
|
||||||
|
flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL);
|
||||||
|
flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tsmall);
|
||||||
|
flttMakeOpNode(&opNode1, OP_TYPE_GREATER_EQUAL, TSDB_DATA_TYPE_BOOL, pcol, pval);
|
||||||
|
flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL);
|
||||||
|
flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tbig);
|
||||||
|
flttMakeOpNode(&opNode2, OP_TYPE_LOWER_EQUAL, TSDB_DATA_TYPE_BOOL, pcol, pval);
|
||||||
|
SNode *list[2] = {0};
|
||||||
|
list[0] = opNode1;
|
||||||
|
list[1] = opNode2;
|
||||||
|
|
||||||
|
flttMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2);
|
||||||
|
|
||||||
//SFilterInfo *filter = NULL;
|
//SFilterInfo *filter = NULL;
|
||||||
//int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP);
|
//int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP);
|
||||||
//ASSERT_EQ(code, 0);
|
//ASSERT_EQ(code, 0);
|
||||||
|
@ -279,6 +313,7 @@ TEST(timerangeTest, greater_and_lower) {
|
||||||
nodesDestroyNode(logicNode);
|
nodesDestroyNode(logicNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(timerangeTest, greater_and_lower_not_strict) {
|
TEST(timerangeTest, greater_and_lower_not_strict) {
|
||||||
SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode1 = NULL, *logicNode2 = NULL;
|
SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode1 = NULL, *logicNode2 = NULL;
|
||||||
bool eRes[5] = {false, false, true, true, true};
|
bool eRes[5] = {false, false, true, true, true};
|
||||||
|
@ -321,8 +356,8 @@ TEST(timerangeTest, greater_and_lower_not_strict) {
|
||||||
int32_t code = filterGetTimeRange(logicNode1, &win, &isStrict);
|
int32_t code = filterGetTimeRange(logicNode1, &win, &isStrict);
|
||||||
ASSERT_EQ(isStrict, false);
|
ASSERT_EQ(isStrict, false);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(win.skey, tsmall1);
|
ASSERT_EQ(win.skey, tsmall1+1);
|
||||||
ASSERT_EQ(win.ekey, tbig2);
|
ASSERT_EQ(win.ekey, tbig2-1);
|
||||||
//filterFreeInfo(filter);
|
//filterFreeInfo(filter);
|
||||||
nodesDestroyNode(logicNode1);
|
nodesDestroyNode(logicNode1);
|
||||||
}
|
}
|
||||||
|
@ -364,7 +399,7 @@ TEST(columnTest, smallint_column_greater_double_value) {
|
||||||
keep = filterRangeExecute(filter, &stat, 1, rowNum);
|
keep = filterRangeExecute(filter, &stat, 1, rowNum);
|
||||||
ASSERT_EQ(keep, true);
|
ASSERT_EQ(keep, true);
|
||||||
|
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -419,7 +454,7 @@ TEST(columnTest, int_column_greater_smallint_value) {
|
||||||
keep = filterRangeExecute(filter, &stat, 1, rowNum);
|
keep = filterRangeExecute(filter, &stat, 1, rowNum);
|
||||||
ASSERT_EQ(keep, false);
|
ASSERT_EQ(keep, false);
|
||||||
|
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -463,7 +498,7 @@ TEST(columnTest, int_column_in_double_list) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -527,7 +562,7 @@ TEST(columnTest, binary_column_in_binary_list) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -575,7 +610,7 @@ TEST(columnTest, binary_column_like_binary) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -622,7 +657,7 @@ TEST(columnTest, binary_column_is_null) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -669,7 +704,7 @@ TEST(columnTest, binary_column_is_not_null) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -706,7 +741,7 @@ TEST(opTest, smallint_column_greater_int_column) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -744,7 +779,7 @@ TEST(opTest, smallint_value_add_int_column) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -787,7 +822,7 @@ TEST(opTest, bigint_column_multi_binary_column) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -830,7 +865,7 @@ TEST(opTest, smallint_column_and_binary_column) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -868,7 +903,7 @@ TEST(opTest, smallint_column_or_float_column) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -906,7 +941,7 @@ TEST(opTest, smallint_column_or_double_value) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -950,7 +985,7 @@ TEST(opTest, binary_column_is_true) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -1021,7 +1056,7 @@ TEST(filterModelogicTest, diff_columns_and_or_and) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -1090,7 +1125,7 @@ TEST(filterModelogicTest, same_column_and_or_and) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -1159,7 +1194,7 @@ TEST(filterModelogicTest, diff_columns_or_and_or) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -1228,7 +1263,7 @@ TEST(filterModelogicTest, same_column_or_and_or) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -1299,7 +1334,7 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
SColumnDataAgg stat = {0};
|
SColumnDataAgg stat = {0};
|
||||||
SFilterColumnParam param = {.numOfCols= src->info.numOfCols, .pDataBlock = src->pDataBlock};
|
SFilterColumnParam param = { src->info.numOfCols, src->pDataBlock };
|
||||||
code = filterSetDataFromSlotId(filter, ¶m);
|
code = filterSetDataFromSlotId(filter, ¶m);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
#pragma GCC diagnostic ignored "-Wpointer-arith"
|
#pragma GCC diagnostic ignored "-Wpointer-arith"
|
||||||
#include <addr_any.h>
|
#include <addr_any.h>
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#define TD_USE_WINSOCK
|
||||||
|
#endif
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
|
|
@ -52,14 +52,26 @@ typedef struct SSchHbTrans {
|
||||||
|
|
||||||
typedef struct SSchApiStat {
|
typedef struct SSchApiStat {
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
size_t avoidCompilationErrors;
|
||||||
|
#endif
|
||||||
|
|
||||||
} SSchApiStat;
|
} SSchApiStat;
|
||||||
|
|
||||||
typedef struct SSchRuntimeStat {
|
typedef struct SSchRuntimeStat {
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
size_t avoidCompilationErrors;
|
||||||
|
#endif
|
||||||
|
|
||||||
} SSchRuntimeStat;
|
} SSchRuntimeStat;
|
||||||
|
|
||||||
typedef struct SSchJobStat {
|
typedef struct SSchJobStat {
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
size_t avoidCompilationErrors;
|
||||||
|
#endif
|
||||||
|
|
||||||
} SSchJobStat;
|
} SSchJobStat;
|
||||||
|
|
||||||
typedef struct SSchedulerStat {
|
typedef struct SSchedulerStat {
|
||||||
|
|
|
@ -25,7 +25,9 @@
|
||||||
#pragma GCC diagnostic ignored "-Wformat"
|
#pragma GCC diagnostic ignored "-Wformat"
|
||||||
#include <addr_any.h>
|
#include <addr_any.h>
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#define TD_USE_WINSOCK
|
||||||
|
#endif
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
@ -275,9 +277,16 @@ void schtSetPlanToString() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(qSubPlanToString, schtPlanToString);
|
stub.set(qSubPlanToString, schtPlanToString);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("qSubPlanToString", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libplanner.so");
|
AddrAny any("libplanner.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^qSubPlanToString$", result);
|
any.get_global_func_addr_dynsym("^qSubPlanToString$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, schtPlanToString);
|
stub.set(f.second, schtPlanToString);
|
||||||
}
|
}
|
||||||
|
@ -288,9 +297,16 @@ void schtSetExecNode() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(qSetSubplanExecutionNode, schtExecNode);
|
stub.set(qSetSubplanExecutionNode, schtExecNode);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("qSetSubplanExecutionNode", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libplanner.so");
|
AddrAny any("libplanner.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^qSetSubplanExecutionNode$", result);
|
any.get_global_func_addr_dynsym("^qSetSubplanExecutionNode$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, schtExecNode);
|
stub.set(f.second, schtExecNode);
|
||||||
}
|
}
|
||||||
|
@ -301,9 +317,16 @@ void schtSetRpcSendRequest() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(rpcSendRequest, schtRpcSendRequest);
|
stub.set(rpcSendRequest, schtRpcSendRequest);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("rpcSendRequest", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^rpcSendRequest$", result);
|
any.get_global_func_addr_dynsym("^rpcSendRequest$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, schtRpcSendRequest);
|
stub.set(f.second, schtRpcSendRequest);
|
||||||
}
|
}
|
||||||
|
@ -324,9 +347,16 @@ void schtSetAsyncSendMsgToServer() {
|
||||||
static Stub stub;
|
static Stub stub;
|
||||||
stub.set(asyncSendMsgToServer, schtAsyncSendMsgToServer);
|
stub.set(asyncSendMsgToServer, schtAsyncSendMsgToServer);
|
||||||
{
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
AddrAny any;
|
||||||
|
std::map<std::string,void*> result;
|
||||||
|
any.get_func_addr("asyncSendMsgToServer", result);
|
||||||
|
#endif
|
||||||
|
#ifdef LINUX
|
||||||
AddrAny any("libtransport.so");
|
AddrAny any("libtransport.so");
|
||||||
std::map<std::string,void*> result;
|
std::map<std::string,void*> result;
|
||||||
any.get_global_func_addr_dynsym("^asyncSendMsgToServer$", result);
|
any.get_global_func_addr_dynsym("^asyncSendMsgToServer$", result);
|
||||||
|
#endif
|
||||||
for (const auto& f : result) {
|
for (const auto& f : result) {
|
||||||
stub.set(f.second, schtAsyncSendMsgToServer);
|
stub.set(f.second, schtAsyncSendMsgToServer);
|
||||||
}
|
}
|
||||||
|
@ -382,6 +412,7 @@ void *schtCreateFetchRspThread(void *param) {
|
||||||
schReleaseJob(job);
|
schReleaseJob(job);
|
||||||
|
|
||||||
assert(code == 0);
|
assert(code == 0);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -413,6 +444,7 @@ void *schtFetchRspThread(void *aa) {
|
||||||
|
|
||||||
assert(code == 0 || code);
|
assert(code == 0 || code);
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void schtFreeQueryJob(int32_t freeThread) {
|
void schtFreeQueryJob(int32_t freeThread) {
|
||||||
|
@ -595,6 +627,7 @@ void* schtRunJobThread(void *aa) {
|
||||||
|
|
||||||
schedulerDestroy();
|
schedulerDestroy();
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* schtFreeJobThread(void *aa) {
|
void* schtFreeJobThread(void *aa) {
|
||||||
|
@ -602,6 +635,7 @@ void* schtFreeJobThread(void *aa) {
|
||||||
taosUsleep(taosRand() % 100);
|
taosUsleep(taosRand() % 100);
|
||||||
schtFreeQueryJob(1);
|
schtFreeQueryJob(1);
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "syncEnv.h"
|
#include "syncEnv.h"
|
||||||
#include <assert.h>
|
// #include <assert.h>
|
||||||
|
|
||||||
SSyncEnv *gSyncEnv = NULL;
|
SSyncEnv *gSyncEnv = NULL;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# tdb
|
# tdb
|
||||||
add_library(tdb "")
|
add_library(tdb STATIC "")
|
||||||
target_sources(tdb
|
target_sources(tdb
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"src/db/tdbPCache.c"
|
"src/db/tdbPCache.c"
|
||||||
|
|
|
@ -42,14 +42,17 @@ struct SBTree {
|
||||||
ASSERT(TDB_FLAG_IS(flags, TDB_BTREE_ROOT) || TDB_FLAG_IS(flags, TDB_BTREE_LEAF) || \
|
ASSERT(TDB_FLAG_IS(flags, TDB_BTREE_ROOT) || TDB_FLAG_IS(flags, TDB_BTREE_LEAF) || \
|
||||||
TDB_FLAG_IS(flags, TDB_BTREE_ROOT | TDB_BTREE_LEAF) || TDB_FLAG_IS(flags, 0))
|
TDB_FLAG_IS(flags, TDB_BTREE_ROOT | TDB_BTREE_LEAF) || TDB_FLAG_IS(flags, 0))
|
||||||
|
|
||||||
typedef struct __attribute__((__packed__)) {
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct {
|
||||||
TDB_BTREE_PAGE_COMMON_HDR
|
TDB_BTREE_PAGE_COMMON_HDR
|
||||||
} SLeafHdr;
|
} SLeafHdr;
|
||||||
|
|
||||||
typedef struct __attribute__((__packed__)) {
|
typedef struct {
|
||||||
TDB_BTREE_PAGE_COMMON_HDR;
|
TDB_BTREE_PAGE_COMMON_HDR
|
||||||
SPgno pgno; // right-most child
|
SPgno pgno; // right-most child
|
||||||
} SIntHdr;
|
} SIntHdr;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 flags;
|
u8 flags;
|
||||||
|
|
|
@ -28,11 +28,10 @@ struct SPCache {
|
||||||
SPage lru;
|
SPage lru;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PCACHE_PAGE_HASH(pPgid) \
|
static inline int tdbPCachePageHash(const SPgid *pPgid) {
|
||||||
({ \
|
u32 *t = (u32 *)((pPgid)->fileid);
|
||||||
u32 *t = (u32 *)((pPgid)->fileid); \
|
return t[0] + t[1] + t[2] + t[3] + t[4] + t[5] + (pPgid)->pgno;
|
||||||
t[0] + t[1] + t[2] + t[3] + t[4] + t[5] + (pPgid)->pgno; \
|
}
|
||||||
})
|
|
||||||
#define PAGE_IS_PINNED(pPage) ((pPage)->pLruNext == NULL)
|
#define PAGE_IS_PINNED(pPage) ((pPage)->pLruNext == NULL)
|
||||||
|
|
||||||
static int tdbPCacheOpenImpl(SPCache *pCache);
|
static int tdbPCacheOpenImpl(SPCache *pCache);
|
||||||
|
@ -130,7 +129,7 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, TXN *pTxn)
|
||||||
SPage *pPage;
|
SPage *pPage;
|
||||||
|
|
||||||
// 1. Search the hash table
|
// 1. Search the hash table
|
||||||
pPage = pCache->pgHash[PCACHE_PAGE_HASH(pPgid) % pCache->nHash];
|
pPage = pCache->pgHash[tdbPCachePageHash(pPgid) % pCache->nHash];
|
||||||
while (pPage) {
|
while (pPage) {
|
||||||
if (TDB_IS_SAME_PAGE(&(pPage->pgid), pPgid)) break;
|
if (TDB_IS_SAME_PAGE(&(pPage->pgid), pPgid)) break;
|
||||||
pPage = pPage->pHashNext;
|
pPage = pPage->pHashNext;
|
||||||
|
@ -218,7 +217,7 @@ static void tdbPCacheRemovePageFromHash(SPCache *pCache, SPage *pPage) {
|
||||||
SPage **ppPage;
|
SPage **ppPage;
|
||||||
int h;
|
int h;
|
||||||
|
|
||||||
h = PCACHE_PAGE_HASH(&(pPage->pgid));
|
h = tdbPCachePageHash(&(pPage->pgid));
|
||||||
for (ppPage = &(pCache->pgHash[h % pCache->nHash]); *ppPage != pPage; ppPage = &((*ppPage)->pHashNext))
|
for (ppPage = &(pCache->pgHash[h % pCache->nHash]); *ppPage != pPage; ppPage = &((*ppPage)->pHashNext))
|
||||||
;
|
;
|
||||||
ASSERT(*ppPage == pPage);
|
ASSERT(*ppPage == pPage);
|
||||||
|
@ -230,7 +229,7 @@ static void tdbPCacheRemovePageFromHash(SPCache *pCache, SPage *pPage) {
|
||||||
static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage) {
|
static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage) {
|
||||||
int h;
|
int h;
|
||||||
|
|
||||||
h = PCACHE_PAGE_HASH(&(pPage->pgid)) % pCache->nHash;
|
h = tdbPCachePageHash(&(pPage->pgid)) % pCache->nHash;
|
||||||
|
|
||||||
pPage->pHashNext = pCache->pgHash[h];
|
pPage->pHashNext = pCache->pgHash[h];
|
||||||
pCache->pgHash[h] = pPage;
|
pCache->pgHash[h] = pPage;
|
||||||
|
|
|
@ -435,17 +435,20 @@ static int tdbPageDefragment(SPage *pPage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------------- */
|
||||||
typedef struct __attribute__((__packed__)) {
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct {
|
||||||
u16 cellNum;
|
u16 cellNum;
|
||||||
u16 cellBody;
|
u16 cellBody;
|
||||||
u16 cellFree;
|
u16 cellFree;
|
||||||
u16 nFree;
|
u16 nFree;
|
||||||
} SPageHdr;
|
} SPageHdr;
|
||||||
|
|
||||||
typedef struct __attribute__((__packed__)) {
|
typedef struct {
|
||||||
u16 szCell;
|
u16 szCell;
|
||||||
u16 nxOffset;
|
u16 nxOffset;
|
||||||
} SFreeCell;
|
} SFreeCell;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
// cellNum
|
// cellNum
|
||||||
static inline int getPageCellNum(SPage *pPage) { return ((SPageHdr *)(pPage->pPageHdr))[0].cellNum; }
|
static inline int getPageCellNum(SPage *pPage) { return ((SPageHdr *)(pPage->pPageHdr))[0].cellNum; }
|
||||||
|
@ -517,17 +520,19 @@ SPageMethods pageMethods = {
|
||||||
setPageFreeCellInfo // setFreeCellInfo
|
setPageFreeCellInfo // setFreeCellInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct __attribute__((__packed__)) {
|
#pragma pack(push,1)
|
||||||
|
typedef struct {
|
||||||
u8 cellNum[3];
|
u8 cellNum[3];
|
||||||
u8 cellBody[3];
|
u8 cellBody[3];
|
||||||
u8 cellFree[3];
|
u8 cellFree[3];
|
||||||
u8 nFree[3];
|
u8 nFree[3];
|
||||||
} SPageHdrL;
|
} SPageHdrL;
|
||||||
|
|
||||||
typedef struct __attribute__((__packed__)) {
|
typedef struct {
|
||||||
u8 szCell[3];
|
u8 szCell[3];
|
||||||
u8 nxOffset[3];
|
u8 nxOffset[3];
|
||||||
} SFreeCellL;
|
} SFreeCellL;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
// cellNum
|
// cellNum
|
||||||
static inline int getLPageCellNum(SPage *pPage) { return TDB_GET_U24(((SPageHdrL *)(pPage->pPageHdr))[0].cellNum); }
|
static inline int getLPageCellNum(SPage *pPage) { return TDB_GET_U24(((SPageHdrL *)(pPage->pPageHdr))[0].cellNum); }
|
||||||
|
|
|
@ -15,13 +15,15 @@
|
||||||
|
|
||||||
#include "tdbInt.h"
|
#include "tdbInt.h"
|
||||||
|
|
||||||
typedef struct __attribute__((__packed__)) {
|
#pragma pack(push,1)
|
||||||
|
typedef struct {
|
||||||
u8 hdrString[16];
|
u8 hdrString[16];
|
||||||
u16 pageSize;
|
u16 pageSize;
|
||||||
SPgno freePage;
|
SPgno freePage;
|
||||||
u32 nFreePages;
|
u32 nFreePages;
|
||||||
u8 reserved[102];
|
u8 reserved[102];
|
||||||
} SFileHdr;
|
} SFileHdr;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
TDB_STATIC_ASSERT(sizeof(SFileHdr) == 128, "Size of file header is not correct");
|
TDB_STATIC_ASSERT(sizeof(SFileHdr) == 128, "Size of file header is not correct");
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,13 @@ typedef struct {
|
||||||
void (*setFreeCellInfo)(SCell *pCell, int szCell, int nxOffset);
|
void (*setFreeCellInfo)(SCell *pCell, int szCell, int nxOffset);
|
||||||
} SPageMethods;
|
} SPageMethods;
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
|
||||||
// Page footer
|
// Page footer
|
||||||
typedef struct __attribute__((__packed__)) {
|
typedef struct {
|
||||||
u8 cksm[4];
|
u8 cksm[4];
|
||||||
} SPageFtr;
|
} SPageFtr;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
struct SPage {
|
struct SPage {
|
||||||
tdb_spinlock_t lock;
|
tdb_spinlock_t lock;
|
||||||
|
@ -80,22 +83,23 @@ struct SPage {
|
||||||
#define P_LOCK_BUSY 1
|
#define P_LOCK_BUSY 1
|
||||||
#define P_LOCK_FAIL -1
|
#define P_LOCK_FAIL -1
|
||||||
|
|
||||||
|
static inline int tdbTryLockPage(tdb_spinlock_t *pLock) {
|
||||||
|
int ret;
|
||||||
|
if (tdbSpinlockTrylock(pLock) == 0) {
|
||||||
|
ret = P_LOCK_SUCC;
|
||||||
|
} else if (errno == EBUSY) {
|
||||||
|
ret = P_LOCK_BUSY;
|
||||||
|
} else {
|
||||||
|
ret = P_LOCK_FAIL;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#define TDB_INIT_PAGE_LOCK(pPage) tdbSpinlockInit(&((pPage)->lock), 0)
|
#define TDB_INIT_PAGE_LOCK(pPage) tdbSpinlockInit(&((pPage)->lock), 0)
|
||||||
#define TDB_DESTROY_PAGE_LOCK(pPage) tdbSpinlockDestroy(&((pPage)->lock))
|
#define TDB_DESTROY_PAGE_LOCK(pPage) tdbSpinlockDestroy(&((pPage)->lock))
|
||||||
#define TDB_LOCK_PAGE(pPage) tdbSpinlockLock(&((pPage)->lock))
|
#define TDB_LOCK_PAGE(pPage) tdbSpinlockLock(&((pPage)->lock))
|
||||||
#define TDB_UNLOCK_PAGE(pPage) tdbSpinlockUnlock(&((pPage)->lock))
|
#define TDB_UNLOCK_PAGE(pPage) tdbSpinlockUnlock(&((pPage)->lock))
|
||||||
#define TDB_TRY_LOCK_PAGE(pPage) \
|
#define TDB_TRY_LOCK_PAGE(pPage) tdbTryLockPage(&((pPage)->lock))
|
||||||
({ \
|
|
||||||
int ret; \
|
|
||||||
if (tdbSpinlockTrylock(&((pPage)->lock)) == 0) { \
|
|
||||||
ret = P_LOCK_SUCC; \
|
|
||||||
} else if (errno == EBUSY) { \
|
|
||||||
ret = P_LOCK_BUSY; \
|
|
||||||
} else { \
|
|
||||||
ret = P_LOCK_FAIL; \
|
|
||||||
} \
|
|
||||||
ret; \
|
|
||||||
})
|
|
||||||
|
|
||||||
// APIs
|
// APIs
|
||||||
#define TDB_PAGE_TOTAL_CELLS(pPage) ((pPage)->nOverflow + (pPage)->pPageMethods->getCellNum(pPage))
|
#define TDB_PAGE_TOTAL_CELLS(pPage) ((pPage)->nOverflow + (pPage)->pPageMethods->getCellNum(pPage))
|
||||||
|
|
|
@ -31,20 +31,20 @@ extern "C" {
|
||||||
int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique);
|
int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique);
|
||||||
int tdbGetFileSize(tdb_fd_t fd, int szPage, SPgno *size);
|
int tdbGetFileSize(tdb_fd_t fd, int szPage, SPgno *size);
|
||||||
|
|
||||||
#define TDB_REALLOC(PTR, SIZE) \
|
static inline void *tdbRealloc(void *ptr, size_t size) {
|
||||||
({ \
|
void *nPtr;
|
||||||
void *nPtr; \
|
if ((ptr) == NULL || ((int *)(ptr))[-1] < (size)) {
|
||||||
if ((PTR) == NULL || ((int *)(PTR))[-1] < (SIZE)) { \
|
nPtr = tdbOsRealloc((ptr) ? (char *)(ptr) - sizeof(int) : NULL, (size) + sizeof(int));
|
||||||
nPtr = tdbOsRealloc((PTR) ? (char *)(PTR) - sizeof(int) : NULL, (SIZE) + sizeof(int)); \
|
if (nPtr) {
|
||||||
if (nPtr) { \
|
((int *)nPtr)[0] = (size);
|
||||||
((int *)nPtr)[0] = (SIZE); \
|
nPtr = (char *)nPtr + sizeof(int);
|
||||||
nPtr = (char *)nPtr + sizeof(int); \
|
}
|
||||||
} \
|
} else {
|
||||||
} else { \
|
nPtr = (ptr);
|
||||||
nPtr = (PTR); \
|
}
|
||||||
} \
|
return nPtr;
|
||||||
nPtr; \
|
}
|
||||||
})
|
#define TDB_REALLOC(PTR, SIZE) tdbRealloc(PTR, SIZE)
|
||||||
|
|
||||||
#define TDB_FREE(PTR) \
|
#define TDB_FREE(PTR) \
|
||||||
do { \
|
do { \
|
||||||
|
|
|
@ -366,7 +366,7 @@ const STfsFile *tfsReaddir(STfsDir *pTfsDir) {
|
||||||
void tfsClosedir(STfsDir *pTfsDir) {
|
void tfsClosedir(STfsDir *pTfsDir) {
|
||||||
if (pTfsDir) {
|
if (pTfsDir) {
|
||||||
if (pTfsDir->pDir != NULL) {
|
if (pTfsDir->pDir != NULL) {
|
||||||
taosCloseDir(pTfsDir->pDir);
|
taosCloseDir(&pTfsDir->pDir);
|
||||||
pTfsDir->pDir = NULL;
|
pTfsDir->pDir = NULL;
|
||||||
}
|
}
|
||||||
taosMemoryFree(pTfsDir);
|
taosMemoryFree(pTfsDir);
|
||||||
|
@ -455,7 +455,7 @@ static int32_t tfsFormatDir(char *idir, char *odir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char tmp[PATH_MAX] = {0};
|
char tmp[PATH_MAX] = {0};
|
||||||
if (realpath(wep.we_wordv[0], tmp) == NULL) {
|
if (taosRealPath(wep.we_wordv[0], tmp, PATH_MAX) != 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
wordfree(&wep);
|
wordfree(&wep);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -499,7 +499,7 @@ static int32_t tfsOpendirImpl(STfs *pTfs, STfsDir *pTfsDir) {
|
||||||
char adir[TMPNAME_LEN * 2] = "\0";
|
char adir[TMPNAME_LEN * 2] = "\0";
|
||||||
|
|
||||||
if (pTfsDir->pDir != NULL) {
|
if (pTfsDir->pDir != NULL) {
|
||||||
taosCloseDir(pTfsDir->pDir);
|
taosCloseDir(&pTfsDir->pDir);
|
||||||
pTfsDir->pDir = NULL;
|
pTfsDir->pDir = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
* 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/>.
|
||||||
*/
|
*/
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <tdatablock.h>
|
#include <tdatablock.h>
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "rpcLog.h"
|
#include "rpcLog.h"
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
* 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/>.
|
||||||
*/
|
*/
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <tdatablock.h>
|
#include <tdatablock.h>
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "rpcLog.h"
|
#include "rpcLog.h"
|
||||||
|
|
|
@ -156,14 +156,14 @@ TEST_F(TransCtxEnv, mergeTest) {
|
||||||
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
||||||
transCtxInit(src);
|
transCtxInit(src);
|
||||||
{
|
{
|
||||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
STransCtxVal val1 = { NULL, NULL, (void (*)(const void*))taosMemoryFree};
|
||||||
val1.val = taosMemoryMalloc(12);
|
val1.val = taosMemoryMalloc(12);
|
||||||
|
|
||||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||||
key++;
|
key++;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
STransCtxVal val1 = { NULL, NULL, (void (*)(const void*))taosMemoryFree};
|
||||||
val1.val = taosMemoryMalloc(12);
|
val1.val = taosMemoryMalloc(12);
|
||||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||||
key++;
|
key++;
|
||||||
|
@ -176,14 +176,14 @@ TEST_F(TransCtxEnv, mergeTest) {
|
||||||
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
||||||
transCtxInit(src);
|
transCtxInit(src);
|
||||||
{
|
{
|
||||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
STransCtxVal val1 = { NULL, NULL, (void (*)(const void*))taosMemoryFree};
|
||||||
val1.val = taosMemoryMalloc(12);
|
val1.val = taosMemoryMalloc(12);
|
||||||
|
|
||||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||||
key++;
|
key++;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
STransCtxVal val1 = { NULL, NULL, (void (*)(const void*))taosMemoryFree};
|
||||||
val1.val = taosMemoryMalloc(12);
|
val1.val = taosMemoryMalloc(12);
|
||||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||||
key++;
|
key++;
|
||||||
|
@ -198,7 +198,7 @@ TEST_F(TransCtxEnv, mergeTest) {
|
||||||
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
||||||
transCtxInit(src);
|
transCtxInit(src);
|
||||||
{
|
{
|
||||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
STransCtxVal val1 = { NULL, NULL, (void (*)(const void*))taosMemoryFree};
|
||||||
val1.val = taosMemoryCalloc(1, 11);
|
val1.val = taosMemoryCalloc(1, 11);
|
||||||
memcpy(val1.val, val.c_str(), val.size());
|
memcpy(val1.val, val.c_str(), val.size());
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ TEST_F(TransCtxEnv, mergeTest) {
|
||||||
key++;
|
key++;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
STransCtxVal val1 = { NULL, NULL, (void (*)(const void*))taosMemoryFree};
|
||||||
val1.val = taosMemoryCalloc(1, 11);
|
val1.val = taosMemoryCalloc(1, 11);
|
||||||
memcpy(val1.val, val.c_str(), val.size());
|
memcpy(val1.val, val.c_str(), val.size());
|
||||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||||
|
|
|
@ -145,7 +145,7 @@ int walCheckAndRepairMeta(SWal* pWal) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosCloseDir(pDir);
|
taosCloseDir(&pDir);
|
||||||
regfree(&logRegPattern);
|
regfree(&logRegPattern);
|
||||||
regfree(&idxRegPattern);
|
regfree(&idxRegPattern);
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ static int walFindCurMetaVer(SWal* pWal) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosCloseDir(pDir);
|
taosCloseDir(&pDir);
|
||||||
regfree(&walMetaRegexPattern);
|
regfree(&walMetaRegexPattern);
|
||||||
return metaVer;
|
return metaVer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ target_include_directories(
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include"
|
PUBLIC "${TD_SOURCE_DIR}/include"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/util"
|
PUBLIC "${TD_SOURCE_DIR}/include/util"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/contrib/pthread"
|
PUBLIC "${TD_SOURCE_DIR}/contrib/pthread"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/contrib/gnuregex"
|
PUBLIC "${TD_SOURCE_DIR}/contrib/iconv"
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/contrib/msvcregex"
|
||||||
)
|
)
|
||||||
# iconv
|
# iconv
|
||||||
find_path(IconvApiIncludes iconv.h PATHS)
|
find_path(IconvApiIncludes iconv.h PATHS)
|
||||||
|
@ -17,5 +18,14 @@ if(USE_TD_MEMORY)
|
||||||
add_definitions(-DUSE_TD_MEMORY)
|
add_definitions(-DUSE_TD_MEMORY)
|
||||||
endif ()
|
endif ()
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
os pthread dl rt m
|
os pthread
|
||||||
)
|
)
|
||||||
|
if(NOT TD_WINDOWS)
|
||||||
|
target_link_libraries(
|
||||||
|
os dl m rt
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_link_libraries(
|
||||||
|
os ws2_32 iconv msvcregex wcwidth winmm
|
||||||
|
)
|
||||||
|
endif(NOT TD_WINDOWS)
|
||||||
|
|
|
@ -16,78 +16,101 @@
|
||||||
#define ALLOW_FORBID_FUNC
|
#define ALLOW_FORBID_FUNC
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
|
|
||||||
// add
|
// add
|
||||||
char interlocked_add_fetch_8(char volatile* ptr, char val) {
|
int8_t interlocked_add_fetch_8(int8_t volatile* ptr, int8_t val) {
|
||||||
return _InterlockedExchangeAdd8(ptr, val) + val;
|
return _InterlockedExchangeAdd8(ptr, val) + val;
|
||||||
}
|
}
|
||||||
|
|
||||||
short interlocked_add_fetch_16(short volatile* ptr, short val) {
|
int16_t interlocked_add_fetch_16(int16_t volatile* ptr, int16_t val) {
|
||||||
return _InterlockedExchangeAdd16(ptr, val) + val;
|
return _InterlockedExchangeAdd16(ptr, val) + val;
|
||||||
}
|
}
|
||||||
|
|
||||||
long interlocked_add_fetch_32(long volatile* ptr, long val) {
|
int32_t interlocked_add_fetch_32(int32_t volatile* ptr, int32_t val) {
|
||||||
return _InterlockedExchangeAdd(ptr, val) + val;
|
return _InterlockedExchangeAdd(ptr, val) + val;
|
||||||
}
|
}
|
||||||
|
|
||||||
__int64 interlocked_add_fetch_64(__int64 volatile* ptr, __int64 val) {
|
int64_t interlocked_add_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
return InterlockedExchangeAdd64(ptr, val) + val;
|
return InterlockedExchangeAdd64(ptr, val) + val;
|
||||||
}
|
}
|
||||||
|
|
||||||
char interlocked_and_fetch_8(char volatile* ptr, char val) {
|
void* interlocked_add_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
|
#ifdef _TD_WINDOWS_32
|
||||||
|
return (void*)(_InterlockedExchangeAdd((int32_t volatile*)(ptr), (int32_t)val) + (int32_t)val);
|
||||||
|
#else
|
||||||
|
return (void*)(InterlockedExchangeAdd64((int64_t volatile*)(ptr), (int64_t)val) + (int64_t)val);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t interlocked_and_fetch_8(int8_t volatile* ptr, int8_t val) {
|
||||||
return _InterlockedAnd8(ptr, val) & val;
|
return _InterlockedAnd8(ptr, val) & val;
|
||||||
}
|
}
|
||||||
|
|
||||||
short interlocked_and_fetch_16(short volatile* ptr, short val) {
|
int16_t interlocked_and_fetch_16(int16_t volatile* ptr, int16_t val) {
|
||||||
return _InterlockedAnd16(ptr, val) & val;
|
return _InterlockedAnd16(ptr, val) & val;
|
||||||
}
|
}
|
||||||
|
|
||||||
long interlocked_and_fetch_32(long volatile* ptr, long val) {
|
int32_t interlocked_and_fetch_32(int32_t volatile* ptr, int32_t val) {
|
||||||
return _InterlockedAnd(ptr, val) & val;
|
return _InterlockedAnd(ptr, val) & val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t interlocked_and_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
__int64 interlocked_and_fetch_64(__int64 volatile* ptr, __int64 val) {
|
#ifdef _TD_WINDOWS_32
|
||||||
#ifndef _M_IX86
|
int64_t old, res;
|
||||||
return _InterlockedAnd64(ptr, val) & val;
|
|
||||||
#else
|
|
||||||
__int64 old, res;
|
|
||||||
do {
|
do {
|
||||||
old = *ptr;
|
old = *ptr;
|
||||||
res = old & val;
|
res = old & val;
|
||||||
} while (_InterlockedCompareExchange64(ptr, res, old) != old);
|
} while (_InterlockedCompareExchange64(ptr, res, old) != old);
|
||||||
return res;
|
return res;
|
||||||
|
#else
|
||||||
|
return _InterlockedAnd64(ptr, val) & val;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
__int64 interlocked_fetch_and_64(__int64 volatile* ptr, __int64 val) {
|
void* interlocked_and_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
#ifdef _M_IX86
|
#ifdef _TD_WINDOWS_32
|
||||||
__int64 old;
|
return (void*)interlocked_and_fetch_32((int32_t volatile*)ptr, (int32_t)val);
|
||||||
|
#else
|
||||||
|
return (void*)interlocked_and_fetch_64((int64_t volatile*)ptr, (int64_t)val);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t interlocked_fetch_and_64(int64_t volatile* ptr, int64_t val) {
|
||||||
|
#ifdef _TD_WINDOWS_32
|
||||||
|
int64_t old;
|
||||||
do {
|
do {
|
||||||
old = *ptr;
|
old = *ptr;
|
||||||
} while (_InterlockedCompareExchange64(ptr, old & val, old) != old);
|
} while (_InterlockedCompareExchange64(ptr, old & val, old) != old);
|
||||||
return old;
|
return old;
|
||||||
#else
|
#else
|
||||||
return _InterlockedAnd64((__int64 volatile*)(ptr), (__int64)(val));
|
return _InterlockedAnd64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char interlocked_or_fetch_8(char volatile* ptr, char val) {
|
void* interlocked_fetch_and_ptr(void* volatile* ptr, void* val) {
|
||||||
|
#ifdef _TD_WINDOWS_32
|
||||||
|
return (void*)_InterlockedAnd((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
|
#else
|
||||||
|
return (void*)_InterlockedAnd64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t interlocked_or_fetch_8(int8_t volatile* ptr, int8_t val) {
|
||||||
return _InterlockedOr8(ptr, val) | val;
|
return _InterlockedOr8(ptr, val) | val;
|
||||||
}
|
}
|
||||||
|
|
||||||
short interlocked_or_fetch_16(short volatile* ptr, short val) {
|
int16_t interlocked_or_fetch_16(int16_t volatile* ptr, int16_t val) {
|
||||||
return _InterlockedOr16(ptr, val) | val;
|
return _InterlockedOr16(ptr, val) | val;
|
||||||
}
|
}
|
||||||
|
|
||||||
long interlocked_or_fetch_32(long volatile* ptr, long val) {
|
int32_t interlocked_or_fetch_32(int32_t volatile* ptr, int32_t val) {
|
||||||
return _InterlockedOr(ptr, val) | val;
|
return _InterlockedOr(ptr, val) | val;
|
||||||
}
|
}
|
||||||
|
|
||||||
__int64 interlocked_or_fetch_64(__int64 volatile* ptr, __int64 val) {
|
int64_t interlocked_or_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
#ifdef _M_IX86
|
#ifdef _TD_WINDOWS_32
|
||||||
__int64 old, res;
|
int64_t old, res;
|
||||||
do {
|
do {
|
||||||
old = *ptr;
|
old = *ptr;
|
||||||
res = old | val;
|
res = old | val;
|
||||||
|
@ -98,33 +121,49 @@ __int64 interlocked_or_fetch_64(__int64 volatile* ptr, __int64 val) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
__int64 interlocked_fetch_or_64(__int64 volatile* ptr, __int64 val) {
|
void* interlocked_or_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
#ifdef _M_IX86
|
#ifdef _TD_WINDOWS_32
|
||||||
__int64 old;
|
return (void*)interlocked_or_fetch_32((int32_t volatile*)ptr, (int32_t)val);
|
||||||
|
#else
|
||||||
|
return (void*)interlocked_or_fetch_64((int64_t volatile*)ptr, (int64_t)val);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t interlocked_fetch_or_64(int64_t volatile* ptr, int64_t val) {
|
||||||
|
#ifdef _TD_WINDOWS_32
|
||||||
|
int64_t old;
|
||||||
do {
|
do {
|
||||||
old = *ptr;
|
old = *ptr;
|
||||||
} while(_InterlockedCompareExchange64(ptr, old | val, old) != old);
|
} while(_InterlockedCompareExchange64(ptr, old | val, old) != old);
|
||||||
return old;
|
return old;
|
||||||
#else
|
#else
|
||||||
return _InterlockedOr64((__int64 volatile*)(ptr), (__int64)(val));
|
return _InterlockedOr64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char interlocked_xor_fetch_8(char volatile* ptr, char val) {
|
void* interlocked_fetch_or_ptr(void* volatile* ptr, void* val) {
|
||||||
|
#ifdef _TD_WINDOWS_32
|
||||||
|
return (void*)_InterlockedOr((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
|
#else
|
||||||
|
return (void*)interlocked_fetch_or_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t interlocked_xor_fetch_8(int8_t volatile* ptr, int8_t val) {
|
||||||
return _InterlockedXor8(ptr, val) ^ val;
|
return _InterlockedXor8(ptr, val) ^ val;
|
||||||
}
|
}
|
||||||
|
|
||||||
short interlocked_xor_fetch_16(short volatile* ptr, short val) {
|
int16_t interlocked_xor_fetch_16(int16_t volatile* ptr, int16_t val) {
|
||||||
return _InterlockedXor16(ptr, val) ^ val;
|
return _InterlockedXor16(ptr, val) ^ val;
|
||||||
}
|
}
|
||||||
|
|
||||||
long interlocked_xor_fetch_32(long volatile* ptr, long val) {
|
int32_t interlocked_xor_fetch_32(int32_t volatile* ptr, int32_t val) {
|
||||||
return _InterlockedXor(ptr, val) ^ val;
|
return _InterlockedXor(ptr, val) ^ val;
|
||||||
}
|
}
|
||||||
|
|
||||||
__int64 interlocked_xor_fetch_64(__int64 volatile* ptr, __int64 val) {
|
int64_t interlocked_xor_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
#ifdef _M_IX86
|
#ifdef _TD_WINDOWS_32
|
||||||
__int64 old, res;
|
int64_t old, res;
|
||||||
do {
|
do {
|
||||||
old = *ptr;
|
old = *ptr;
|
||||||
res = old ^ val;
|
res = old ^ val;
|
||||||
|
@ -135,15 +174,62 @@ __int64 interlocked_xor_fetch_64(__int64 volatile* ptr, __int64 val) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
__int64 interlocked_fetch_xor_64(__int64 volatile* ptr, __int64 val) {
|
void* interlocked_xor_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
#ifdef _M_IX86
|
#ifdef _TD_WINDOWS_32
|
||||||
__int64 old;
|
return (void*)interlocked_xor_fetch_32((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
|
#else
|
||||||
|
return (void*)interlocked_xor_fetch_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t interlocked_fetch_xor_64(int64_t volatile* ptr, int64_t val) {
|
||||||
|
#ifdef _TD_WINDOWS_32
|
||||||
|
int64_t old;
|
||||||
do {
|
do {
|
||||||
old = *ptr;
|
old = *ptr;
|
||||||
} while (_InterlockedCompareExchange64(ptr, old ^ val, old) != old);
|
} while (_InterlockedCompareExchange64(ptr, old ^ val, old) != old);
|
||||||
return old;
|
return old;
|
||||||
#else
|
#else
|
||||||
return _InterlockedXor64((__int64 volatile*)(ptr), (__int64)(val));
|
return _InterlockedXor64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void* interlocked_fetch_xor_ptr(void* volatile* ptr, void* val) {
|
||||||
|
#ifdef _TD_WINDOWS_32
|
||||||
|
return (void*)_InterlockedXor((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
|
#else
|
||||||
|
return (void*)interlocked_fetch_xor_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t interlocked_sub_fetch_32(int32_t volatile* ptr, int32_t val) {
|
||||||
|
return interlocked_add_fetch_32(ptr, -val);
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t interlocked_sub_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
|
return interlocked_add_fetch_64(ptr, -val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* interlocked_sub_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
|
#ifdef _TD_WINDOWS_32
|
||||||
|
return (void*)interlocked_sub_fetch_32((int32_t volatile*)ptr, (int32_t)val);
|
||||||
|
#else
|
||||||
|
return (void*)interlocked_add_fetch_64((int64_t volatile*)ptr, (int64_t)val);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
int32_t interlocked_fetch_sub_32(int32_t volatile* ptr, int32_t val) {
|
||||||
|
return _InterlockedExchangeAdd(ptr, -val);
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t interlocked_fetch_sub_64(int64_t volatile* ptr, int64_t val) {
|
||||||
|
return _InterlockedExchangeAdd64(ptr, -val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* interlocked_fetch_sub_ptr(void* volatile* ptr, void* val) {
|
||||||
|
#ifdef _TD_WINDOWS_32
|
||||||
|
return (void*)interlocked_fetch_sub_32((int32_t volatile*)ptr, (int32_t)val);
|
||||||
|
#else
|
||||||
|
return (void*)interlocked_fetch_sub_64((int64_t volatile*)ptr, (int64_t)val);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +275,7 @@ int64_t atomic_exchange_64_impl(int64_t* ptr, int64_t val ) {
|
||||||
|
|
||||||
|
|
||||||
int8_t atomic_load_8(int8_t volatile *ptr) {
|
int8_t atomic_load_8(int8_t volatile *ptr) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return (*(int8_t volatile*)(ptr));
|
return (*(int8_t volatile*)(ptr));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_add((ptr), 0);
|
return __sync_fetch_and_add((ptr), 0);
|
||||||
|
@ -199,7 +285,7 @@ int8_t atomic_load_8(int8_t volatile *ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_load_16(int16_t volatile *ptr) {
|
int16_t atomic_load_16(int16_t volatile *ptr) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return (*(int16_t volatile*)(ptr));
|
return (*(int16_t volatile*)(ptr));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_add((ptr), 0);
|
return __sync_fetch_and_add((ptr), 0);
|
||||||
|
@ -209,7 +295,7 @@ int16_t atomic_load_16(int16_t volatile *ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_load_32(int32_t volatile *ptr) {
|
int32_t atomic_load_32(int32_t volatile *ptr) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return (*(int32_t volatile*)(ptr));
|
return (*(int32_t volatile*)(ptr));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_add((ptr), 0);
|
return __sync_fetch_and_add((ptr), 0);
|
||||||
|
@ -219,7 +305,7 @@ int32_t atomic_load_32(int32_t volatile *ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_load_64(int64_t volatile *ptr) {
|
int64_t atomic_load_64(int64_t volatile *ptr) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return (*(int64_t volatile*)(ptr));
|
return (*(int64_t volatile*)(ptr));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_add((ptr), 0);
|
return __sync_fetch_and_add((ptr), 0);
|
||||||
|
@ -229,7 +315,7 @@ int64_t atomic_load_64(int64_t volatile *ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_load_ptr(void *ptr) {
|
void* atomic_load_ptr(void *ptr) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return (*(void* volatile*)(ptr));
|
return (*(void* volatile*)(ptr));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_add((ptr), 0);
|
return __sync_fetch_and_add((ptr), 0);
|
||||||
|
@ -239,7 +325,7 @@ void* atomic_load_ptr(void *ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void atomic_store_8(int8_t volatile *ptr, int8_t val) {
|
void atomic_store_8(int8_t volatile *ptr, int8_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
((*(int8_t volatile*)(ptr)) = (int8_t)(val));
|
((*(int8_t volatile*)(ptr)) = (int8_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
(*(ptr)=(val));
|
(*(ptr)=(val));
|
||||||
|
@ -249,7 +335,7 @@ void atomic_store_8(int8_t volatile *ptr, int8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void atomic_store_16(int16_t volatile *ptr, int16_t val) {
|
void atomic_store_16(int16_t volatile *ptr, int16_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
((*(int16_t volatile*)(ptr)) = (int16_t)(val));
|
((*(int16_t volatile*)(ptr)) = (int16_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
(*(ptr)=(val));
|
(*(ptr)=(val));
|
||||||
|
@ -259,7 +345,7 @@ void atomic_store_16(int16_t volatile *ptr, int16_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void atomic_store_32(int32_t volatile *ptr, int32_t val) {
|
void atomic_store_32(int32_t volatile *ptr, int32_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
((*(int32_t volatile*)(ptr)) = (int32_t)(val));
|
((*(int32_t volatile*)(ptr)) = (int32_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
(*(ptr)=(val));
|
(*(ptr)=(val));
|
||||||
|
@ -269,7 +355,7 @@ void atomic_store_32(int32_t volatile *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void atomic_store_64(int64_t volatile *ptr, int64_t val) {
|
void atomic_store_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
((*(int64_t volatile*)(ptr)) = (int64_t)(val));
|
((*(int64_t volatile*)(ptr)) = (int64_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
(*(ptr)=(val));
|
(*(ptr)=(val));
|
||||||
|
@ -279,7 +365,7 @@ void atomic_store_64(int64_t volatile *ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void atomic_store_ptr(void *ptr, void *val) {
|
void atomic_store_ptr(void *ptr, void *val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
((*(void* volatile*)(ptr)) = (void*)(val));
|
((*(void* volatile*)(ptr)) = (void*)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
(*(ptr)=(val));
|
(*(ptr)=(val));
|
||||||
|
@ -289,7 +375,7 @@ void atomic_store_ptr(void *ptr, void *val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t atomic_exchange_8(int8_t volatile *ptr, int8_t val) {
|
int8_t atomic_exchange_8(int8_t volatile *ptr, int8_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchange8((int8_t volatile*)(ptr), (int8_t)(val));
|
return _InterlockedExchange8((int8_t volatile*)(ptr), (int8_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return atomic_exchange_8_impl((int8_t*)ptr, (int8_t)val);
|
return atomic_exchange_8_impl((int8_t*)ptr, (int8_t)val);
|
||||||
|
@ -299,7 +385,7 @@ int8_t atomic_exchange_8(int8_t volatile *ptr, int8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_exchange_16(int16_t volatile *ptr, int16_t val) {
|
int16_t atomic_exchange_16(int16_t volatile *ptr, int16_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchange16((int16_t volatile*)(ptr), (int16_t)(val));
|
return _InterlockedExchange16((int16_t volatile*)(ptr), (int16_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return atomic_exchange_16_impl((int16_t*)ptr, (int16_t)val);
|
return atomic_exchange_16_impl((int16_t*)ptr, (int16_t)val);
|
||||||
|
@ -309,7 +395,7 @@ int16_t atomic_exchange_16(int16_t volatile *ptr, int16_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_exchange_32(int32_t volatile *ptr, int32_t val) {
|
int32_t atomic_exchange_32(int32_t volatile *ptr, int32_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchange((int32_t volatile*)(ptr), (int32_t)(val));
|
return _InterlockedExchange((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return atomic_exchange_32_impl((int32_t*)ptr, (int32_t)val);
|
return atomic_exchange_32_impl((int32_t*)ptr, (int32_t)val);
|
||||||
|
@ -319,7 +405,7 @@ int32_t atomic_exchange_32(int32_t volatile *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_exchange_64(int64_t volatile *ptr, int64_t val) {
|
int64_t atomic_exchange_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchange64((int64_t volatile*)(ptr), (int64_t)(val));
|
return _InterlockedExchange64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return atomic_exchange_64_impl((int64_t*)ptr, (int64_t)val);
|
return atomic_exchange_64_impl((int64_t*)ptr, (int64_t)val);
|
||||||
|
@ -329,7 +415,7 @@ int64_t atomic_exchange_64(int64_t volatile *ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_exchange_ptr(void *ptr, void *val) {
|
void* atomic_exchange_ptr(void *ptr, void *val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
return _InterlockedExchangePointer((void* volatile*)(ptr), (void*)(val));
|
return _InterlockedExchangePointer((void* volatile*)(ptr), (void*)(val));
|
||||||
#else
|
#else
|
||||||
|
@ -343,7 +429,7 @@ void* atomic_exchange_ptr(void *ptr, void *val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t atomic_val_compare_exchange_8(int8_t volatile *ptr, int8_t oldval, int8_t newval) {
|
int8_t atomic_val_compare_exchange_8(int8_t volatile *ptr, int8_t oldval, int8_t newval) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedCompareExchange8((int8_t volatile*)(ptr), (int8_t)(newval), (int8_t)(oldval));
|
return _InterlockedCompareExchange8((int8_t volatile*)(ptr), (int8_t)(newval), (int8_t)(oldval));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
||||||
|
@ -353,7 +439,7 @@ int8_t atomic_val_compare_exchange_8(int8_t volatile *ptr, int8_t oldval, int8_t
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_val_compare_exchange_16(int16_t volatile *ptr, int16_t oldval, int16_t newval) {
|
int16_t atomic_val_compare_exchange_16(int16_t volatile *ptr, int16_t oldval, int16_t newval) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedCompareExchange16((int16_t volatile*)(ptr), (int16_t)(newval), (int16_t)(oldval));
|
return _InterlockedCompareExchange16((int16_t volatile*)(ptr), (int16_t)(newval), (int16_t)(oldval));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
||||||
|
@ -363,7 +449,7 @@ int16_t atomic_val_compare_exchange_16(int16_t volatile *ptr, int16_t oldval, in
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_val_compare_exchange_32(int32_t volatile *ptr, int32_t oldval, int32_t newval) {
|
int32_t atomic_val_compare_exchange_32(int32_t volatile *ptr, int32_t oldval, int32_t newval) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedCompareExchange((int32_t volatile*)(ptr), (int32_t)(newval), (int32_t)(oldval));
|
return _InterlockedCompareExchange((int32_t volatile*)(ptr), (int32_t)(newval), (int32_t)(oldval));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
||||||
|
@ -373,7 +459,7 @@ int32_t atomic_val_compare_exchange_32(int32_t volatile *ptr, int32_t oldval, in
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_val_compare_exchange_64(int64_t volatile *ptr, int64_t oldval, int64_t newval) {
|
int64_t atomic_val_compare_exchange_64(int64_t volatile *ptr, int64_t oldval, int64_t newval) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedCompareExchange64((int64_t volatile*)(ptr), (int64_t)(newval), (int64_t)(oldval));
|
return _InterlockedCompareExchange64((int64_t volatile*)(ptr), (int64_t)(newval), (int64_t)(oldval));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
||||||
|
@ -383,7 +469,7 @@ int64_t atomic_val_compare_exchange_64(int64_t volatile *ptr, int64_t oldval, in
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_val_compare_exchange_ptr(void *ptr, void *oldval, void *newval) {
|
void* atomic_val_compare_exchange_ptr(void *ptr, void *oldval, void *newval) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedCompareExchangePointer((void* volatile*)(ptr), (void*)(newval), (void*)(oldval));
|
return _InterlockedCompareExchangePointer((void* volatile*)(ptr), (void*)(newval), (void*)(oldval));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
||||||
|
@ -393,7 +479,7 @@ void* atomic_val_compare_exchange_ptr(void *ptr, void *oldval, void *newval) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t atomic_add_fetch_8(int8_t volatile *ptr, int8_t val) {
|
int8_t atomic_add_fetch_8(int8_t volatile *ptr, int8_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_add_fetch_8((int8_t volatile*)(ptr), (int8_t)(val));
|
return interlocked_add_fetch_8((int8_t volatile*)(ptr), (int8_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_add_and_fetch((ptr), (val));
|
return __sync_add_and_fetch((ptr), (val));
|
||||||
|
@ -403,7 +489,7 @@ int8_t atomic_add_fetch_8(int8_t volatile *ptr, int8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_add_fetch_16(int16_t volatile *ptr, int16_t val) {
|
int16_t atomic_add_fetch_16(int16_t volatile *ptr, int16_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_add_fetch_16((int16_t volatile*)(ptr), (int16_t)(val));
|
return interlocked_add_fetch_16((int16_t volatile*)(ptr), (int16_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_add_and_fetch((ptr), (val));
|
return __sync_add_and_fetch((ptr), (val));
|
||||||
|
@ -413,7 +499,7 @@ int16_t atomic_add_fetch_16(int16_t volatile *ptr, int16_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_add_fetch_32(int32_t volatile *ptr, int32_t val) {
|
int32_t atomic_add_fetch_32(int32_t volatile *ptr, int32_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_add_fetch_32((int32_t volatile*)(ptr), (int32_t)(val));
|
return interlocked_add_fetch_32((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_add_and_fetch((ptr), (val));
|
return __sync_add_and_fetch((ptr), (val));
|
||||||
|
@ -423,7 +509,7 @@ int32_t atomic_add_fetch_32(int32_t volatile *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_add_fetch_64(int64_t volatile *ptr, int64_t val) {
|
int64_t atomic_add_fetch_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_add_fetch_64((int64_t volatile*)(ptr), (int64_t)(val));
|
return interlocked_add_fetch_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_add_and_fetch((ptr), (val));
|
return __sync_add_and_fetch((ptr), (val));
|
||||||
|
@ -432,18 +518,18 @@ int64_t atomic_add_fetch_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_add_fetch_ptr(void *ptr, int32_t val) {
|
void* atomic_add_fetch_ptr(void *ptr, void *val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_add_fetch_ptr((void* volatile*)(ptr), (void*)(val));
|
return interlocked_add_fetch_ptr((void* volatile*)(ptr), (void*)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_add_and_fetch((ptr), (val));
|
return __sync_add_and_fetch((ptr), (val));
|
||||||
#else
|
#else
|
||||||
return __atomic_add_fetch((void **)(ptr), (val), __ATOMIC_SEQ_CST);
|
return __atomic_add_fetch((void **)(ptr), (size_t)(val), __ATOMIC_SEQ_CST);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t atomic_fetch_add_8(int8_t volatile *ptr, int8_t val) {
|
int8_t atomic_fetch_add_8(int8_t volatile *ptr, int8_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchangeAdd8((int8_t volatile*)(ptr), (int8_t)(val));
|
return _InterlockedExchangeAdd8((int8_t volatile*)(ptr), (int8_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_add((ptr), (val));
|
return __sync_fetch_and_add((ptr), (val));
|
||||||
|
@ -453,7 +539,7 @@ int8_t atomic_fetch_add_8(int8_t volatile *ptr, int8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_fetch_add_16(int16_t volatile *ptr, int16_t val) {
|
int16_t atomic_fetch_add_16(int16_t volatile *ptr, int16_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchangeAdd16((int16_t volatile*)(ptr), (int16_t)(val));
|
return _InterlockedExchangeAdd16((int16_t volatile*)(ptr), (int16_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_add((ptr), (val));
|
return __sync_fetch_and_add((ptr), (val));
|
||||||
|
@ -463,7 +549,7 @@ int16_t atomic_fetch_add_16(int16_t volatile *ptr, int16_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_fetch_add_32(int32_t volatile *ptr, int32_t val) {
|
int32_t atomic_fetch_add_32(int32_t volatile *ptr, int32_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchangeAdd((int32_t volatile*)(ptr), (int32_t)(val));
|
return _InterlockedExchangeAdd((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_add((ptr), (val));
|
return __sync_fetch_and_add((ptr), (val));
|
||||||
|
@ -473,7 +559,7 @@ int32_t atomic_fetch_add_32(int32_t volatile *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_fetch_add_64(int64_t volatile *ptr, int64_t val) {
|
int64_t atomic_fetch_add_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchangeAdd64((int64_t volatile*)(ptr), (int64_t)(val));
|
return _InterlockedExchangeAdd64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_add((ptr), (val));
|
return __sync_fetch_and_add((ptr), (val));
|
||||||
|
@ -482,18 +568,18 @@ int64_t atomic_fetch_add_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_fetch_add_ptr(void *ptr, int32_t val) {
|
void* atomic_fetch_add_ptr(void *ptr, void *val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchangeAddptr((void* volatile*)(ptr), (void*)(val));
|
return _InterlockedExchangePointer((void* volatile*)(ptr), (void*)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_add((ptr), (val));
|
return __sync_fetch_and_add((ptr), (val));
|
||||||
#else
|
#else
|
||||||
return __atomic_fetch_add((void **)(ptr), (val), __ATOMIC_SEQ_CST);
|
return __atomic_fetch_add((void **)(ptr), (size_t)(val), __ATOMIC_SEQ_CST);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t atomic_sub_fetch_8(int8_t volatile *ptr, int8_t val) {
|
int8_t atomic_sub_fetch_8(int8_t volatile *ptr, int8_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_add_fetch_8((int8_t volatile*)(ptr), -(int8_t)(val));
|
return interlocked_add_fetch_8((int8_t volatile*)(ptr), -(int8_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_sub_and_fetch((ptr), (val));
|
return __sync_sub_and_fetch((ptr), (val));
|
||||||
|
@ -503,7 +589,7 @@ int8_t atomic_sub_fetch_8(int8_t volatile *ptr, int8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_sub_fetch_16(int16_t volatile *ptr, int16_t val) {
|
int16_t atomic_sub_fetch_16(int16_t volatile *ptr, int16_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_add_fetch_16((int16_t volatile*)(ptr), -(int16_t)(val));
|
return interlocked_add_fetch_16((int16_t volatile*)(ptr), -(int16_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_sub_and_fetch((ptr), (val));
|
return __sync_sub_and_fetch((ptr), (val));
|
||||||
|
@ -513,8 +599,8 @@ int16_t atomic_sub_fetch_16(int16_t volatile *ptr, int16_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_sub_fetch_32(int32_t volatile *ptr, int32_t val) {
|
int32_t atomic_sub_fetch_32(int32_t volatile *ptr, int32_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_add_fetch_32((int32_t volatile*)(ptr), -(int32_t)(val));
|
return interlocked_sub_fetch_32(ptr, val);
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_sub_and_fetch((ptr), (val));
|
return __sync_sub_and_fetch((ptr), (val));
|
||||||
#else
|
#else
|
||||||
|
@ -523,8 +609,8 @@ int32_t atomic_sub_fetch_32(int32_t volatile *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_sub_fetch_64(int64_t volatile *ptr, int64_t val) {
|
int64_t atomic_sub_fetch_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_add_fetch_64((int64_t volatile*)(ptr), -(int64_t)(val));
|
return interlocked_sub_fetch_64(ptr, val);
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_sub_and_fetch((ptr), (val));
|
return __sync_sub_and_fetch((ptr), (val));
|
||||||
#else
|
#else
|
||||||
|
@ -532,9 +618,9 @@ int64_t atomic_sub_fetch_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_sub_fetch_ptr(void *ptr, int32_t val) {
|
void* atomic_sub_fetch_ptr(void *ptr, void* val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_add_fetch_ptr((void* volatile*)(ptr), -(void*)(val));
|
return interlocked_sub_fetch_ptr(ptr, val);
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_sub_and_fetch((ptr), (val));
|
return __sync_sub_and_fetch((ptr), (val));
|
||||||
#else
|
#else
|
||||||
|
@ -543,7 +629,7 @@ void* atomic_sub_fetch_ptr(void *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t atomic_fetch_sub_8(int8_t volatile *ptr, int8_t val) {
|
int8_t atomic_fetch_sub_8(int8_t volatile *ptr, int8_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchangeAdd8((int8_t volatile*)(ptr), -(int8_t)(val));
|
return _InterlockedExchangeAdd8((int8_t volatile*)(ptr), -(int8_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_sub((ptr), (val));
|
return __sync_fetch_and_sub((ptr), (val));
|
||||||
|
@ -553,7 +639,7 @@ int8_t atomic_fetch_sub_8(int8_t volatile *ptr, int8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_fetch_sub_16(int16_t volatile *ptr, int16_t val) {
|
int16_t atomic_fetch_sub_16(int16_t volatile *ptr, int16_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchangeAdd16((int16_t volatile*)(ptr), -(int16_t)(val));
|
return _InterlockedExchangeAdd16((int16_t volatile*)(ptr), -(int16_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_sub((ptr), (val));
|
return __sync_fetch_and_sub((ptr), (val));
|
||||||
|
@ -563,17 +649,17 @@ int16_t atomic_fetch_sub_16(int16_t volatile *ptr, int16_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_fetch_sub_32(int32_t volatile *ptr, int32_t val) {
|
int32_t atomic_fetch_sub_32(int32_t volatile *ptr, int32_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchangeAdd((int32_t volatile*)(ptr), -(int32_t)(val));
|
return interlocked_fetch_sub_32(ptr, val);
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_sub((ptr), (val));
|
return __sync_fetch_and_sub(ptr, val);
|
||||||
#else
|
#else
|
||||||
return __atomic_fetch_sub((ptr), (val), __ATOMIC_SEQ_CST);
|
return __atomic_fetch_sub((ptr), (val), __ATOMIC_SEQ_CST);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_fetch_sub_64(int64_t volatile *ptr, int64_t val) {
|
int64_t atomic_fetch_sub_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchangeAdd64((int64_t volatile*)(ptr), -(int64_t)(val));
|
return _InterlockedExchangeAdd64((int64_t volatile*)(ptr), -(int64_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_sub((ptr), (val));
|
return __sync_fetch_and_sub((ptr), (val));
|
||||||
|
@ -582,9 +668,9 @@ int64_t atomic_fetch_sub_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_fetch_sub_ptr(void *ptr, int32_t val) {
|
void* atomic_fetch_sub_ptr(void *ptr, void* val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedExchangeAddptr((void* volatile*)(ptr), -(void*)(val));
|
return interlocked_fetch_sub_ptr(ptr, val);
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_sub((ptr), (val));
|
return __sync_fetch_and_sub((ptr), (val));
|
||||||
#else
|
#else
|
||||||
|
@ -593,7 +679,7 @@ void* atomic_fetch_sub_ptr(void *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t atomic_and_fetch_8(int8_t volatile *ptr, int8_t val) {
|
int8_t atomic_and_fetch_8(int8_t volatile *ptr, int8_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_and_fetch_8((int8_t volatile*)(ptr), (int8_t)(val));
|
return interlocked_and_fetch_8((int8_t volatile*)(ptr), (int8_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_and_and_fetch((ptr), (val));
|
return __sync_and_and_fetch((ptr), (val));
|
||||||
|
@ -603,7 +689,7 @@ int8_t atomic_and_fetch_8(int8_t volatile *ptr, int8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_and_fetch_16(int16_t volatile *ptr, int16_t val) {
|
int16_t atomic_and_fetch_16(int16_t volatile *ptr, int16_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_and_fetch_16((int16_t volatile*)(ptr), (int16_t)(val));
|
return interlocked_and_fetch_16((int16_t volatile*)(ptr), (int16_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_and_and_fetch((ptr), (val));
|
return __sync_and_and_fetch((ptr), (val));
|
||||||
|
@ -613,7 +699,7 @@ int16_t atomic_and_fetch_16(int16_t volatile *ptr, int16_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_and_fetch_32(int32_t volatile *ptr, int32_t val) {
|
int32_t atomic_and_fetch_32(int32_t volatile *ptr, int32_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_and_fetch_32((int32_t volatile*)(ptr), (int32_t)(val));
|
return interlocked_and_fetch_32((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_and_and_fetch((ptr), (val));
|
return __sync_and_and_fetch((ptr), (val));
|
||||||
|
@ -623,7 +709,7 @@ int32_t atomic_and_fetch_32(int32_t volatile *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_and_fetch_64(int64_t volatile *ptr, int64_t val) {
|
int64_t atomic_and_fetch_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_and_fetch_64((int64_t volatile*)(ptr), (int64_t)(val));
|
return interlocked_and_fetch_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_and_and_fetch((ptr), (val));
|
return __sync_and_and_fetch((ptr), (val));
|
||||||
|
@ -633,7 +719,7 @@ int64_t atomic_and_fetch_64(int64_t volatile *ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_and_fetch_ptr(void *ptr, void *val) {
|
void* atomic_and_fetch_ptr(void *ptr, void *val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_and_fetch_ptr((void* volatile*)(ptr), (void*)(val));
|
return interlocked_and_fetch_ptr((void* volatile*)(ptr), (void*)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_and_and_fetch((ptr), (val));
|
return __sync_and_and_fetch((ptr), (val));
|
||||||
|
@ -643,7 +729,7 @@ void* atomic_and_fetch_ptr(void *ptr, void *val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t atomic_fetch_and_8(int8_t volatile *ptr, int8_t val) {
|
int8_t atomic_fetch_and_8(int8_t volatile *ptr, int8_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedAnd8((int8_t volatile*)(ptr), (int8_t)(val));
|
return _InterlockedAnd8((int8_t volatile*)(ptr), (int8_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_and((ptr), (val));
|
return __sync_fetch_and_and((ptr), (val));
|
||||||
|
@ -653,7 +739,7 @@ int8_t atomic_fetch_and_8(int8_t volatile *ptr, int8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_fetch_and_16(int16_t volatile *ptr, int16_t val) {
|
int16_t atomic_fetch_and_16(int16_t volatile *ptr, int16_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedAnd16((int16_t volatile*)(ptr), (int16_t)(val));
|
return _InterlockedAnd16((int16_t volatile*)(ptr), (int16_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_and((ptr), (val));
|
return __sync_fetch_and_and((ptr), (val));
|
||||||
|
@ -663,7 +749,7 @@ int16_t atomic_fetch_and_16(int16_t volatile *ptr, int16_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_fetch_and_32(int32_t volatile *ptr, int32_t val) {
|
int32_t atomic_fetch_and_32(int32_t volatile *ptr, int32_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedAnd((int32_t volatile*)(ptr), (int32_t)(val));
|
return _InterlockedAnd((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_and((ptr), (val));
|
return __sync_fetch_and_and((ptr), (val));
|
||||||
|
@ -673,7 +759,7 @@ int32_t atomic_fetch_and_32(int32_t volatile *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_fetch_and_64(int64_t volatile *ptr, int64_t val) {
|
int64_t atomic_fetch_and_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_fetch_and_64((int64_t volatile*)(ptr), (int64_t)(val));
|
return interlocked_fetch_and_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_and((ptr), (val));
|
return __sync_fetch_and_and((ptr), (val));
|
||||||
|
@ -683,7 +769,7 @@ int64_t atomic_fetch_and_64(int64_t volatile *ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_fetch_and_ptr(void *ptr, void *val) {
|
void* atomic_fetch_and_ptr(void *ptr, void *val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_fetch_and_ptr((void* volatile*)(ptr), (void*)(val));
|
return interlocked_fetch_and_ptr((void* volatile*)(ptr), (void*)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_and((ptr), (val));
|
return __sync_fetch_and_and((ptr), (val));
|
||||||
|
@ -693,7 +779,7 @@ void* atomic_fetch_and_ptr(void *ptr, void *val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t atomic_or_fetch_8(int8_t volatile *ptr, int8_t val) {
|
int8_t atomic_or_fetch_8(int8_t volatile *ptr, int8_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_or_fetch_8((int8_t volatile*)(ptr), (int8_t)(val));
|
return interlocked_or_fetch_8((int8_t volatile*)(ptr), (int8_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_or_and_fetch((ptr), (val));
|
return __sync_or_and_fetch((ptr), (val));
|
||||||
|
@ -703,7 +789,7 @@ int8_t atomic_or_fetch_8(int8_t volatile *ptr, int8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_or_fetch_16(int16_t volatile *ptr, int16_t val) {
|
int16_t atomic_or_fetch_16(int16_t volatile *ptr, int16_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_or_fetch_16((int16_t volatile*)(ptr), (int16_t)(val));
|
return interlocked_or_fetch_16((int16_t volatile*)(ptr), (int16_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_or_and_fetch((ptr), (val));
|
return __sync_or_and_fetch((ptr), (val));
|
||||||
|
@ -713,7 +799,7 @@ int16_t atomic_or_fetch_16(int16_t volatile *ptr, int16_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_or_fetch_32(int32_t volatile *ptr, int32_t val) {
|
int32_t atomic_or_fetch_32(int32_t volatile *ptr, int32_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_or_fetch_32((int32_t volatile*)(ptr), (int32_t)(val));
|
return interlocked_or_fetch_32((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_or_and_fetch((ptr), (val));
|
return __sync_or_and_fetch((ptr), (val));
|
||||||
|
@ -723,7 +809,7 @@ int32_t atomic_or_fetch_32(int32_t volatile *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_or_fetch_64(int64_t volatile *ptr, int64_t val) {
|
int64_t atomic_or_fetch_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_or_fetch_64((int64_t volatile*)(ptr), (int64_t)(val));
|
return interlocked_or_fetch_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_or_and_fetch((ptr), (val));
|
return __sync_or_and_fetch((ptr), (val));
|
||||||
|
@ -733,7 +819,7 @@ int64_t atomic_or_fetch_64(int64_t volatile *ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_or_fetch_ptr(void *ptr, void *val) {
|
void* atomic_or_fetch_ptr(void *ptr, void *val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_or_fetch_ptr((void* volatile*)(ptr), (void*)(val));
|
return interlocked_or_fetch_ptr((void* volatile*)(ptr), (void*)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_or_and_fetch((ptr), (val));
|
return __sync_or_and_fetch((ptr), (val));
|
||||||
|
@ -743,7 +829,7 @@ void* atomic_or_fetch_ptr(void *ptr, void *val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t atomic_fetch_or_8(int8_t volatile *ptr, int8_t val) {
|
int8_t atomic_fetch_or_8(int8_t volatile *ptr, int8_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedOr8((int8_t volatile*)(ptr), (int8_t)(val));
|
return _InterlockedOr8((int8_t volatile*)(ptr), (int8_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_or((ptr), (val));
|
return __sync_fetch_and_or((ptr), (val));
|
||||||
|
@ -753,7 +839,7 @@ int8_t atomic_fetch_or_8(int8_t volatile *ptr, int8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_fetch_or_16(int16_t volatile *ptr, int16_t val) {
|
int16_t atomic_fetch_or_16(int16_t volatile *ptr, int16_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedOr16((int16_t volatile*)(ptr), (int16_t)(val));
|
return _InterlockedOr16((int16_t volatile*)(ptr), (int16_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_or((ptr), (val));
|
return __sync_fetch_and_or((ptr), (val));
|
||||||
|
@ -763,7 +849,7 @@ int16_t atomic_fetch_or_16(int16_t volatile *ptr, int16_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_fetch_or_32(int32_t volatile *ptr, int32_t val) {
|
int32_t atomic_fetch_or_32(int32_t volatile *ptr, int32_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedOr((int32_t volatile*)(ptr), (int32_t)(val));
|
return _InterlockedOr((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_or((ptr), (val));
|
return __sync_fetch_and_or((ptr), (val));
|
||||||
|
@ -773,7 +859,7 @@ int32_t atomic_fetch_or_32(int32_t volatile *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_fetch_or_64(int64_t volatile *ptr, int64_t val) {
|
int64_t atomic_fetch_or_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_fetch_or_64((int64_t volatile*)(ptr), (int64_t)(val));
|
return interlocked_fetch_or_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_or((ptr), (val));
|
return __sync_fetch_and_or((ptr), (val));
|
||||||
|
@ -783,7 +869,7 @@ int64_t atomic_fetch_or_64(int64_t volatile *ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_fetch_or_ptr(void *ptr, void *val) {
|
void* atomic_fetch_or_ptr(void *ptr, void *val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_fetch_or_ptr((void* volatile*)(ptr), (void*)(val));
|
return interlocked_fetch_or_ptr((void* volatile*)(ptr), (void*)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_or((ptr), (val));
|
return __sync_fetch_and_or((ptr), (val));
|
||||||
|
@ -793,7 +879,7 @@ void* atomic_fetch_or_ptr(void *ptr, void *val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t atomic_xor_fetch_8(int8_t volatile *ptr, int8_t val) {
|
int8_t atomic_xor_fetch_8(int8_t volatile *ptr, int8_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_xor_fetch_8((int8_t volatile*)(ptr), (int8_t)(val));
|
return interlocked_xor_fetch_8((int8_t volatile*)(ptr), (int8_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_xor_and_fetch((ptr), (val));
|
return __sync_xor_and_fetch((ptr), (val));
|
||||||
|
@ -803,7 +889,7 @@ int8_t atomic_xor_fetch_8(int8_t volatile *ptr, int8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_xor_fetch_16(int16_t volatile *ptr, int16_t val) {
|
int16_t atomic_xor_fetch_16(int16_t volatile *ptr, int16_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_xor_fetch_16((int16_t volatile*)(ptr), (int16_t)(val));
|
return interlocked_xor_fetch_16((int16_t volatile*)(ptr), (int16_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_xor_and_fetch((ptr), (val));
|
return __sync_xor_and_fetch((ptr), (val));
|
||||||
|
@ -813,7 +899,7 @@ int16_t atomic_xor_fetch_16(int16_t volatile *ptr, int16_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_xor_fetch_32(int32_t volatile *ptr, int32_t val) {
|
int32_t atomic_xor_fetch_32(int32_t volatile *ptr, int32_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_xor_fetch_32((int32_t volatile*)(ptr), (int32_t)(val));
|
return interlocked_xor_fetch_32((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_xor_and_fetch((ptr), (val));
|
return __sync_xor_and_fetch((ptr), (val));
|
||||||
|
@ -823,7 +909,7 @@ int32_t atomic_xor_fetch_32(int32_t volatile *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_xor_fetch_64(int64_t volatile *ptr, int64_t val) {
|
int64_t atomic_xor_fetch_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_xor_fetch_64((int64_t volatile*)(ptr), (int64_t)(val));
|
return interlocked_xor_fetch_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_xor_and_fetch((ptr), (val));
|
return __sync_xor_and_fetch((ptr), (val));
|
||||||
|
@ -833,7 +919,7 @@ int64_t atomic_xor_fetch_64(int64_t volatile *ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_xor_fetch_ptr(void *ptr, void *val) {
|
void* atomic_xor_fetch_ptr(void *ptr, void *val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_xor_fetch_ptr((void* volatile*)(ptr), (void*)(val));
|
return interlocked_xor_fetch_ptr((void* volatile*)(ptr), (void*)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_xor_and_fetch((ptr), (val));
|
return __sync_xor_and_fetch((ptr), (val));
|
||||||
|
@ -843,7 +929,7 @@ void* atomic_xor_fetch_ptr(void *ptr, void *val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t atomic_fetch_xor_8(int8_t volatile *ptr, int8_t val) {
|
int8_t atomic_fetch_xor_8(int8_t volatile *ptr, int8_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedXor8((int8_t volatile*)(ptr), (int8_t)(val));
|
return _InterlockedXor8((int8_t volatile*)(ptr), (int8_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_xor((ptr), (val));
|
return __sync_fetch_and_xor((ptr), (val));
|
||||||
|
@ -853,7 +939,7 @@ int8_t atomic_fetch_xor_8(int8_t volatile *ptr, int8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t atomic_fetch_xor_16(int16_t volatile *ptr, int16_t val) {
|
int16_t atomic_fetch_xor_16(int16_t volatile *ptr, int16_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedXor16((int16_t volatile*)(ptr), (int16_t)(val));
|
return _InterlockedXor16((int16_t volatile*)(ptr), (int16_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_xor((ptr), (val));
|
return __sync_fetch_and_xor((ptr), (val));
|
||||||
|
@ -863,7 +949,7 @@ int16_t atomic_fetch_xor_16(int16_t volatile *ptr, int16_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t atomic_fetch_xor_32(int32_t volatile *ptr, int32_t val) {
|
int32_t atomic_fetch_xor_32(int32_t volatile *ptr, int32_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return _InterlockedXor((int32_t volatile*)(ptr), (int32_t)(val));
|
return _InterlockedXor((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_xor((ptr), (val));
|
return __sync_fetch_and_xor((ptr), (val));
|
||||||
|
@ -873,7 +959,7 @@ int32_t atomic_fetch_xor_32(int32_t volatile *ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t atomic_fetch_xor_64(int64_t volatile *ptr, int64_t val) {
|
int64_t atomic_fetch_xor_64(int64_t volatile *ptr, int64_t val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_fetch_xor_64((int64_t volatile*)(ptr), (int64_t)(val));
|
return interlocked_fetch_xor_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_xor((ptr), (val));
|
return __sync_fetch_and_xor((ptr), (val));
|
||||||
|
@ -883,7 +969,7 @@ int64_t atomic_fetch_xor_64(int64_t volatile *ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* atomic_fetch_xor_ptr(void *ptr, void *val) {
|
void* atomic_fetch_xor_ptr(void *ptr, void *val) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return interlocked_fetch_xor_ptr((void* volatile*)(ptr), (void*)(val));
|
return interlocked_fetch_xor_ptr((void* volatile*)(ptr), (void*)(val));
|
||||||
#elif defined(_TD_NINGSI_60)
|
#elif defined(_TD_NINGSI_60)
|
||||||
return __sync_fetch_and_xor((ptr), (val));
|
return __sync_fetch_and_xor((ptr), (val));
|
||||||
|
|
|
@ -17,19 +17,40 @@
|
||||||
#define ALLOW_FORBID_FUNC
|
#define ALLOW_FORBID_FUNC
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "osString.h"
|
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
/*
|
|
||||||
* windows implementation
|
|
||||||
*/
|
|
||||||
|
|
||||||
// todo
|
#include <windows.h>
|
||||||
|
|
||||||
|
typedef struct TdDirEntry {
|
||||||
|
WIN32_FIND_DATA findFileData;
|
||||||
|
} TdDirEntry;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct TdDir {
|
||||||
|
TdDirEntry dirEntry;
|
||||||
|
HANDLE hFind;
|
||||||
|
} TdDir;
|
||||||
|
|
||||||
|
int wordexp(char *words, wordexp_t *pwordexp, int flags) {
|
||||||
|
pwordexp->we_offs = 0;
|
||||||
|
pwordexp->we_wordc = 1;
|
||||||
|
pwordexp->we_wordv[0] = pwordexp->wordPos;
|
||||||
|
|
||||||
|
memset(pwordexp->wordPos, 0, 1025);
|
||||||
|
if (_fullpath(pwordexp->wordPos, words, 1024) == NULL) {
|
||||||
|
pwordexp->we_wordv[0] = words;
|
||||||
|
printf("failed to parse relative path:%s to abs path", words);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("parse relative path:%s to abs path:%s", words, pwordexp->wordPos);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wordfree(wordexp_t *pwordexp) {}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/*
|
|
||||||
* linux implementation
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -39,19 +60,21 @@
|
||||||
|
|
||||||
typedef struct dirent dirent;
|
typedef struct dirent dirent;
|
||||||
typedef struct DIR TdDir;
|
typedef struct DIR TdDir;
|
||||||
typedef struct dirent TdDirent;
|
typedef struct dirent TdDirEntry;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void taosRemoveDir(const char *dirname) {
|
void taosRemoveDir(const char *dirname) {
|
||||||
DIR *dir = opendir(dirname);
|
TdDirPtr pDir = taosOpenDir(dirname);
|
||||||
if (dir == NULL) return;
|
if (pDir == NULL) return;
|
||||||
|
|
||||||
struct dirent *de = NULL;
|
TdDirEntryPtr de = NULL;
|
||||||
while ((de = readdir(dir)) != NULL) {
|
while ((de = taosReadDir(pDir)) != NULL) {
|
||||||
if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue;
|
if (strcmp(taosGetDirEntryName(de), ".") == 0 || strcmp(taosGetDirEntryName(de), "..") == 0) continue;
|
||||||
|
|
||||||
char filename[1024];
|
char filename[1024];
|
||||||
snprintf(filename, sizeof(filename), "%s/%s", dirname, de->d_name);
|
snprintf(filename, sizeof(filename), "%s/%s", dirname, taosGetDirEntryName(de));
|
||||||
if (de->d_type & DT_DIR) {
|
if (taosDirEntryIsDir(de)) {
|
||||||
taosRemoveDir(filename);
|
taosRemoveDir(filename);
|
||||||
} else {
|
} else {
|
||||||
(void)taosRemoveFile(filename);
|
(void)taosRemoveFile(filename);
|
||||||
|
@ -59,13 +82,14 @@ void taosRemoveDir(const char *dirname) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
taosCloseDir(&pDir);
|
||||||
rmdir(dirname);
|
rmdir(dirname);
|
||||||
|
|
||||||
//printf("dir:%s is removed\n", dirname);
|
//printf("dir:%s is removed\n", dirname);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosDirExist(char *dirname) { return taosCheckExistFile(dirname); }
|
bool taosDirExist(const char *dirname) { return taosCheckExistFile(dirname); }
|
||||||
|
|
||||||
int32_t taosMkDir(const char *dirname) {
|
int32_t taosMkDir(const char *dirname) {
|
||||||
int32_t code = mkdir(dirname, 0755);
|
int32_t code = mkdir(dirname, 0755);
|
||||||
|
@ -118,18 +142,18 @@ int32_t taosMulMkDir(const char *dirname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
|
void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
|
||||||
DIR *dir = opendir(dirname);
|
TdDirPtr pDir = taosOpenDir(dirname);
|
||||||
if (dir == NULL) return;
|
if (pDir == NULL) return;
|
||||||
|
|
||||||
int64_t sec = taosGetTimestampSec();
|
int64_t sec = taosGetTimestampSec();
|
||||||
struct dirent *de = NULL;
|
TdDirEntryPtr de = NULL;
|
||||||
|
|
||||||
while ((de = readdir(dir)) != NULL) {
|
while ((de = taosReadDir(pDir)) != NULL) {
|
||||||
if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue;
|
if (strcmp(taosGetDirEntryName(de), ".") == 0 || strcmp(taosGetDirEntryName(de), "..") == 0) continue;
|
||||||
|
|
||||||
char filename[1024];
|
char filename[1024];
|
||||||
snprintf(filename, sizeof(filename), "%s/%s", dirname, de->d_name);
|
snprintf(filename, sizeof(filename), "%s/%s", dirname, taosGetDirEntryName(de));
|
||||||
if (de->d_type & DT_DIR) {
|
if (taosDirEntryIsDir(de)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
int32_t len = (int32_t)strlen(filename);
|
int32_t len = (int32_t)strlen(filename);
|
||||||
|
@ -156,7 +180,7 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
taosCloseDir(&pDir);
|
||||||
rmdir(dirname);
|
rmdir(dirname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,65 +201,131 @@ int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosRealPath(char *dirname, int32_t maxlen) {
|
int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen) {
|
||||||
char tmp[PATH_MAX] = {0};
|
char tmp[PATH_MAX] = {0};
|
||||||
|
#ifdef WINDOWS
|
||||||
|
if (_fullpath(dirname, tmp, maxlen) != NULL) {
|
||||||
|
#else
|
||||||
if (realpath(dirname, tmp) != NULL) {
|
if (realpath(dirname, tmp) != NULL) {
|
||||||
|
#endif
|
||||||
|
if (realPath == NULL) {
|
||||||
strncpy(dirname, tmp, maxlen);
|
strncpy(dirname, tmp, maxlen);
|
||||||
|
} else {
|
||||||
|
strncpy(realPath, tmp, maxlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
bool taosIsDir(const char *dirname) {
|
bool taosIsDir(const char *dirname) {
|
||||||
DIR *dir = opendir(dirname);
|
TdDirPtr pDir = taosOpenDir(dirname);
|
||||||
if (dir != NULL) {
|
if (pDir != NULL) {
|
||||||
closedir(dir);
|
taosCloseDir(&pDir);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* taosDirName(char *name) {
|
char* taosDirName(char *name) {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
char Drive1[MAX_PATH], Dir1[MAX_PATH];
|
||||||
|
_splitpath(name, Drive1, Dir1, NULL, NULL);
|
||||||
|
size_t dirNameLen = strlen(Drive1) + strlen(Dir1);
|
||||||
|
if (dirNameLen > 0) {
|
||||||
|
name[dirNameLen] = 0;
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
#else
|
||||||
return dirname(name);
|
return dirname(name);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char* taosDirEntryBaseName(char *name) {
|
char* taosDirEntryBaseName(char *name) {
|
||||||
return basename(name);
|
#ifdef WINDOWS
|
||||||
|
char Filename1[MAX_PATH], Ext1[MAX_PATH];
|
||||||
|
_splitpath(name, NULL, NULL, Filename1, Ext1);
|
||||||
|
return name + (strlen(name) - strlen(Filename1) - strlen(Ext1));
|
||||||
|
#else
|
||||||
|
return (char*)basename(name);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TdDirPtr taosOpenDir(const char *dirname) {
|
TdDirPtr taosOpenDir(const char *dirname) {
|
||||||
if (dirname == NULL) {
|
if (dirname == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
char szFind[MAX_PATH]; //这是要找的
|
||||||
|
HANDLE hFind;
|
||||||
|
|
||||||
|
TdDirPtr pDir = taosMemoryMalloc(sizeof(TdDir));
|
||||||
|
|
||||||
|
strcpy(szFind, dirname);
|
||||||
|
strcat(szFind, "\\*.*"); //利用通配符找这个目录下的所以文件,包括目录
|
||||||
|
|
||||||
|
pDir->hFind = FindFirstFile(szFind, &(pDir->dirEntry.findFileData));
|
||||||
|
if (INVALID_HANDLE_VALUE == pDir->hFind) {
|
||||||
|
taosMemoryFree(pDir);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return pDir;
|
||||||
|
#else
|
||||||
return (TdDirPtr)opendir(dirname);
|
return (TdDirPtr)opendir(dirname);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TdDirEntryPtr taosReadDir(TdDirPtr pDir) {
|
TdDirEntryPtr taosReadDir(TdDirPtr pDir) {
|
||||||
if (pDir == NULL) {
|
if (pDir == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#ifdef WINDOWS
|
||||||
|
if (!FindNextFile(pDir->hFind, &(pDir->dirEntry.findFileData))) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return (TdDirEntryPtr)&(pDir->dirEntry.findFileData);
|
||||||
|
#else
|
||||||
return (TdDirEntryPtr)readdir((DIR*)pDir);
|
return (TdDirEntryPtr)readdir((DIR*)pDir);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosDirEntryIsDir(TdDirEntryPtr pDirEntry) {
|
bool taosDirEntryIsDir(TdDirEntryPtr pDirEntry) {
|
||||||
if (pDirEntry == NULL) {
|
if (pDirEntry == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#ifdef WINDOWS
|
||||||
|
return (pDirEntry->findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
|
#else
|
||||||
return (((dirent*)pDirEntry)->d_type & DT_DIR) != 0;
|
return (((dirent*)pDirEntry)->d_type & DT_DIR) != 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char* taosGetDirEntryName(TdDirEntryPtr pDirEntry) {
|
char* taosGetDirEntryName(TdDirEntryPtr pDirEntry) {
|
||||||
if (pDirEntry == NULL) {
|
if (pDirEntry == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#ifdef WINDOWS
|
||||||
|
return pDirEntry->findFileData.cFileName;
|
||||||
|
#else
|
||||||
return ((dirent*)pDirEntry)->d_name;
|
return ((dirent*)pDirEntry)->d_name;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosCloseDir(TdDirPtr pDir) {
|
int32_t taosCloseDir(TdDirPtr *ppDir) {
|
||||||
if (pDir == NULL) {
|
if (ppDir == NULL || *ppDir == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return closedir((DIR*)pDir);
|
#ifdef WINDOWS
|
||||||
}
|
FindClose((*ppDir)->hFind);
|
||||||
|
taosMemoryFree(*ppDir);
|
||||||
|
*ppDir = NULL;
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
closedir((DIR*)*ppDir);
|
||||||
|
*ppDir = NULL;
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "osEnv.h"
|
#include "osEnv.h"
|
||||||
|
|
||||||
extern void taosWinSocketInit();
|
|
||||||
|
|
||||||
char configDir[PATH_MAX] = {0};
|
char configDir[PATH_MAX] = {0};
|
||||||
char tsDataDir[PATH_MAX] = {0};
|
char tsDataDir[PATH_MAX] = {0};
|
||||||
char tsLogDir[PATH_MAX] = {0};
|
char tsLogDir[PATH_MAX] = {0};
|
||||||
|
@ -51,7 +49,7 @@ void osDefaultInit() {
|
||||||
tsNumOfCores = 2;
|
tsNumOfCores = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
taosWinSocketInit();
|
taosWinSocketInit();
|
||||||
|
|
||||||
const char *tmpDir = getenv("tmp");
|
const char *tmpDir = getenv("tmp");
|
||||||
|
|
|
@ -16,8 +16,11 @@
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "osSemaphore.h"
|
#include "osSemaphore.h"
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
#define F_OK 0
|
||||||
|
#define W_OK 2
|
||||||
|
#define R_OK 4
|
||||||
|
|
||||||
#if defined(_MSDOS)
|
#if defined(_MSDOS)
|
||||||
#define open _open
|
#define open _open
|
||||||
|
@ -33,6 +36,8 @@ extern int openU(const char *, int, ...); /* MsvcLibX UTF-8 version of open */
|
||||||
#endif /* defined(_UTF8_SOURCE) */
|
#endif /* defined(_UTF8_SOURCE) */
|
||||||
#endif /* defined(_WIN32) */
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
|
#define _SEND_FILE_STEP_ 1000
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
@ -66,7 +71,7 @@ typedef struct TdFile {
|
||||||
#define FILE_WITH_LOCK 1
|
#define FILE_WITH_LOCK 1
|
||||||
|
|
||||||
void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath) {
|
void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
const char *tdengineTmpFileNamePrefix = "tdengine-";
|
const char *tdengineTmpFileNamePrefix = "tdengine-";
|
||||||
char tmpPath[PATH_MAX];
|
char tmpPath[PATH_MAX];
|
||||||
|
|
||||||
|
@ -117,7 +122,7 @@ void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, cha
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t taosCopyFile(const char *from, const char *to) {
|
int64_t taosCopyFile(const char *from, const char *to) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
|
@ -160,7 +165,7 @@ _err:
|
||||||
int32_t taosRemoveFile(const char *path) { return remove(path); }
|
int32_t taosRemoveFile(const char *path) { return remove(path); }
|
||||||
|
|
||||||
int32_t taosRenameFile(const char *oldName, const char *newName) {
|
int32_t taosRenameFile(const char *oldName, const char *newName) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
int32_t code = MoveFileEx(oldName, newName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED);
|
int32_t code = MoveFileEx(oldName, newName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
// printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
|
// printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
|
||||||
|
@ -178,7 +183,7 @@ int32_t taosRenameFile(const char *oldName, const char *newName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
|
int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
struct stat fileStat;
|
struct stat fileStat;
|
||||||
|
@ -199,7 +204,7 @@ int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
int32_t taosDevInoFile(const char *path, int64_t *stDev, int64_t *stIno) {
|
int32_t taosDevInoFile(const char *path, int64_t *stDev, int64_t *stIno) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
struct stat fileStat;
|
struct stat fileStat;
|
||||||
|
@ -223,7 +228,7 @@ int32_t taosDevInoFile(const char *path, int64_t *stDev, int64_t *stIno) {
|
||||||
void autoDelFileListAdd(const char *path) { return; }
|
void autoDelFileListAdd(const char *path) { return; }
|
||||||
|
|
||||||
TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
@ -285,7 +290,7 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t taosCloseFile(TdFilePtr *ppFile) {
|
int64_t taosCloseFile(TdFilePtr *ppFile) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
if (ppFile == NULL || *ppFile == NULL) {
|
if (ppFile == NULL || *ppFile == NULL) {
|
||||||
|
@ -366,7 +371,14 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset)
|
||||||
taosThreadRwlockRdlock(&(pFile->rwlock));
|
taosThreadRwlockRdlock(&(pFile->rwlock));
|
||||||
#endif
|
#endif
|
||||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||||
|
#ifdef WINDOWS
|
||||||
|
size_t pos = lseek(pFile->fd, 0, SEEK_CUR);
|
||||||
|
lseek(pFile->fd, (long)offset, SEEK_SET);
|
||||||
|
int64_t ret = read(pFile->fd, buf, count);
|
||||||
|
lseek(pFile->fd, pos, SEEK_SET);
|
||||||
|
#else
|
||||||
int64_t ret = pread(pFile->fd, buf, count, offset);
|
int64_t ret = pread(pFile->fd, buf, count, offset);
|
||||||
|
#endif
|
||||||
#if FILE_WITH_LOCK
|
#if FILE_WITH_LOCK
|
||||||
taosThreadRwlockUnlock(&(pFile->rwlock));
|
taosThreadRwlockUnlock(&(pFile->rwlock));
|
||||||
#endif
|
#endif
|
||||||
|
@ -423,7 +435,7 @@ int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
|
@ -450,7 +462,7 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosLockFile(TdFilePtr pFile) {
|
int32_t taosLockFile(TdFilePtr pFile) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
|
@ -463,7 +475,7 @@ int32_t taosLockFile(TdFilePtr pFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosUnLockFile(TdFilePtr pFile) {
|
int32_t taosUnLockFile(TdFilePtr pFile) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
|
@ -476,10 +488,10 @@ int32_t taosUnLockFile(TdFilePtr pFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosFtruncateFile(TdFilePtr pFile, int64_t l_size) {
|
int32_t taosFtruncateFile(TdFilePtr pFile, int64_t l_size) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
if (pFile->fd < 0) {
|
if (pFile->fd < 0) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
uError("%s\n", "fd arg was negative");
|
printf("%s\n", "fd arg was negative");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +501,7 @@ int32_t taosFtruncateFile(TdFilePtr pFile, int64_t l_size) {
|
||||||
li_0.QuadPart = (int64_t)0;
|
li_0.QuadPart = (int64_t)0;
|
||||||
BOOL cur = SetFilePointerEx(h, li_0, NULL, FILE_CURRENT);
|
BOOL cur = SetFilePointerEx(h, li_0, NULL, FILE_CURRENT);
|
||||||
if (!cur) {
|
if (!cur) {
|
||||||
uError("SetFilePointerEx Error getting current position in file.\n");
|
printf("SetFilePointerEx Error getting current position in file.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,7 +510,7 @@ int32_t taosFtruncateFile(TdFilePtr pFile, int64_t l_size) {
|
||||||
BOOL cur2 = SetFilePointerEx(h, li_size, NULL, FILE_BEGIN);
|
BOOL cur2 = SetFilePointerEx(h, li_size, NULL, FILE_BEGIN);
|
||||||
if (cur2 == 0) {
|
if (cur2 == 0) {
|
||||||
int error = GetLastError();
|
int error = GetLastError();
|
||||||
uError("SetFilePointerEx GetLastError is: %d\n", error);
|
printf("SetFilePointerEx GetLastError is: %d\n", error);
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case ERROR_INVALID_HANDLE:
|
case ERROR_INVALID_HANDLE:
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
|
@ -512,7 +524,7 @@ int32_t taosFtruncateFile(TdFilePtr pFile, int64_t l_size) {
|
||||||
|
|
||||||
if (!SetEndOfFile(h)) {
|
if (!SetEndOfFile(h)) {
|
||||||
int error = GetLastError();
|
int error = GetLastError();
|
||||||
uError("SetEndOfFile GetLastError is:%d", error);
|
printf("SetEndOfFile GetLastError is:%d", error);
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case ERROR_INVALID_HANDLE:
|
case ERROR_INVALID_HANDLE:
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
|
@ -536,10 +548,10 @@ int32_t taosFtruncateFile(TdFilePtr pFile, int64_t l_size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosFsyncFile(TdFilePtr pFile) {
|
int32_t taosFsyncFile(TdFilePtr pFile) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
if (pFile->fd < 0) {
|
if (pFile->fd < 0) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
uError("%s\n", "fd arg was negative");
|
printf("%s\n", "fd arg was negative");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,84 +570,51 @@ int32_t taosFsyncFile(TdFilePtr pFile) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size) {
|
||||||
|
if (pFileOut == NULL || pFileIn == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
assert(pFileIn->fd >= 0 && pFileOut->fd >= 0);
|
||||||
|
|
||||||
#define _SEND_FILE_STEP_ 1000
|
#ifdef WINDOWS
|
||||||
|
|
||||||
int64_t taosFSendFile(FILE *out_file, FILE *in_file, int64_t *offset, int64_t count) {
|
lseek(pFileIn->fd, (int32_t)(*offset), 0);
|
||||||
fseek(in_file, (int32_t)(*offset), 0);
|
|
||||||
int64_t writeLen = 0;
|
int64_t writeLen = 0;
|
||||||
uint8_t buffer[_SEND_FILE_STEP_] = {0};
|
uint8_t buffer[_SEND_FILE_STEP_] = {0};
|
||||||
|
|
||||||
for (int64_t len = 0; len < (count - _SEND_FILE_STEP_); len += _SEND_FILE_STEP_) {
|
for (int64_t len = 0; len < (size - _SEND_FILE_STEP_); len += _SEND_FILE_STEP_) {
|
||||||
size_t rlen = fread(buffer, 1, _SEND_FILE_STEP_, in_file);
|
size_t rlen = read(pFileIn->fd, (void *)buffer, _SEND_FILE_STEP_);
|
||||||
if (rlen <= 0) {
|
if (rlen <= 0) {
|
||||||
return writeLen;
|
return writeLen;
|
||||||
} else if (rlen < _SEND_FILE_STEP_) {
|
} else if (rlen < _SEND_FILE_STEP_) {
|
||||||
fwrite(buffer, 1, rlen, out_file);
|
write(pFileOut->fd, (void *)buffer, (uint32_t)rlen);
|
||||||
return (int64_t)(writeLen + rlen);
|
return (int64_t)(writeLen + rlen);
|
||||||
} else {
|
} else {
|
||||||
fwrite(buffer, 1, _SEND_FILE_STEP_, in_file);
|
write(pFileOut->fd, (void *)buffer, _SEND_FILE_STEP_);
|
||||||
writeLen += _SEND_FILE_STEP_;
|
writeLen += _SEND_FILE_STEP_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t remain = count - writeLen;
|
int64_t remain = size - writeLen;
|
||||||
if (remain > 0) {
|
if (remain > 0) {
|
||||||
size_t rlen = fread(buffer, 1, (size_t)remain, in_file);
|
size_t rlen = read(pFileIn->fd, (void *)buffer, (size_t)remain);
|
||||||
if (rlen <= 0) {
|
if (rlen <= 0) {
|
||||||
return writeLen;
|
return writeLen;
|
||||||
} else {
|
} else {
|
||||||
fwrite(buffer, 1, (size_t)remain, out_file);
|
write(pFileOut->fd, (void *)buffer, (uint32_t)remain);
|
||||||
writeLen += remain;
|
writeLen += remain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return writeLen;
|
return writeLen;
|
||||||
}
|
|
||||||
|
|
||||||
int64_t taosSendFile(SocketFd dfd, FileFd sfd, int64_t *offset, int64_t count) {
|
|
||||||
if (offset != NULL) lseek(sfd, (int32_t)(*offset), 0);
|
|
||||||
|
|
||||||
int64_t writeLen = 0;
|
|
||||||
uint8_t buffer[_SEND_FILE_STEP_] = {0};
|
|
||||||
|
|
||||||
for (int64_t len = 0; len < (count - _SEND_FILE_STEP_); len += _SEND_FILE_STEP_) {
|
|
||||||
int32_t rlen = (int32_t)read(sfd, buffer, _SEND_FILE_STEP_);
|
|
||||||
if (rlen <= 0) {
|
|
||||||
return writeLen;
|
|
||||||
} else if (rlen < _SEND_FILE_STEP_) {
|
|
||||||
taosWriteSocket(dfd, buffer, rlen);
|
|
||||||
return (int64_t)(writeLen + rlen);
|
|
||||||
} else {
|
|
||||||
taosWriteSocket(dfd, buffer, _SEND_FILE_STEP_);
|
|
||||||
writeLen += _SEND_FILE_STEP_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t remain = count - writeLen;
|
|
||||||
if (remain > 0) {
|
|
||||||
int32_t rlen = read(sfd, buffer, (int32_t)remain);
|
|
||||||
if (rlen <= 0) {
|
|
||||||
return writeLen;
|
|
||||||
} else {
|
|
||||||
taosWriteSocket(sfd, buffer, (int32_t)remain);
|
|
||||||
writeLen += remain;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return writeLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
|
|
||||||
int64_t taosFSendFile(FILE *out_file, FILE *in_file, int64_t *offset, int64_t count) {
|
|
||||||
int r = 0;
|
int r = 0;
|
||||||
if (offset) {
|
if (offset) {
|
||||||
r = fseek(in_file, *offset, SEEK_SET);
|
r = fseek(in_file, *offset, SEEK_SET);
|
||||||
if (r == -1) return -1;
|
if (r == -1) return -1;
|
||||||
}
|
}
|
||||||
off_t len = count;
|
off_t len = size;
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
char buf[1024 * 16];
|
char buf[1024 * 16];
|
||||||
off_t n = sizeof(buf);
|
off_t n = sizeof(buf);
|
||||||
|
@ -651,64 +630,10 @@ int64_t taosFSendFile(FILE *out_file, FILE *in_file, int64_t *offset, int64_t co
|
||||||
}
|
}
|
||||||
len -= m;
|
len -= m;
|
||||||
}
|
}
|
||||||
return count - len;
|
return size - len;
|
||||||
}
|
|
||||||
|
|
||||||
int64_t taosSendFile(SocketFd dfd, FileFd sfd, int64_t *offset, int64_t count) {
|
|
||||||
int r = 0;
|
|
||||||
if (offset) {
|
|
||||||
r = lseek(sfd, *offset, SEEK_SET);
|
|
||||||
if (r == -1) return -1;
|
|
||||||
}
|
|
||||||
off_t len = count;
|
|
||||||
while (len > 0) {
|
|
||||||
char buf[1024 * 16];
|
|
||||||
off_t n = sizeof(buf);
|
|
||||||
if (len < n) n = len;
|
|
||||||
size_t m = read(sfd, buf, n);
|
|
||||||
if (m == -1) return -1;
|
|
||||||
if (m == 0) break;
|
|
||||||
size_t l = write(dfd, buf, m);
|
|
||||||
if (l == -1) return -1;
|
|
||||||
len -= l;
|
|
||||||
}
|
|
||||||
return count - len;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// int64_t taosSendFile(int fdDst, TdFilePtr pFileSrc, int64_t *offset, int64_t size) {
|
|
||||||
// if (pFileSrc == NULL) {
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
// assert(pFileSrc->fd >= 0);
|
|
||||||
|
|
||||||
// int64_t leftbytes = size;
|
|
||||||
// int64_t sentbytes;
|
|
||||||
|
|
||||||
// while (leftbytes > 0) {
|
|
||||||
// sentbytes = sendfile(fdDst, pFileSrc->fd, offset, leftbytes);
|
|
||||||
// if (sentbytes == -1) {
|
|
||||||
// if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
|
|
||||||
// continue;
|
|
||||||
// } else {
|
|
||||||
// return -1;
|
|
||||||
// }
|
|
||||||
// } else if (sentbytes == 0) {
|
|
||||||
// return (int64_t)(size - leftbytes);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// leftbytes -= sentbytes;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return size;
|
|
||||||
// }
|
|
||||||
|
|
||||||
int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size) {
|
|
||||||
if (pFileOut == NULL || pFileIn == NULL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
assert(pFileIn->fd >= 0 && pFileOut->fd >= 0);
|
|
||||||
int64_t leftbytes = size;
|
int64_t leftbytes = size;
|
||||||
int64_t sentbytes;
|
int64_t sentbytes;
|
||||||
|
|
||||||
|
@ -728,9 +653,8 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void taosFprintfFile(TdFilePtr pFile, const char *format, ...) {
|
void taosFprintfFile(TdFilePtr pFile, const char *format, ...) {
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
|
@ -745,22 +669,10 @@ void taosFprintfFile(TdFilePtr pFile, const char *format, ...) {
|
||||||
fflush(pFile->fp);
|
fflush(pFile->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(WINDOWS)
|
|
||||||
void *taosMmapReadOnlyFile(TdFilePtr pFile, int64_t length) {
|
|
||||||
if (pFile == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
|
||||||
|
|
||||||
void *ptr = mmap(NULL, length, PROT_READ, MAP_SHARED, pFile->fd, 0);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool taosValidFile(TdFilePtr pFile) { return pFile != NULL; }
|
bool taosValidFile(TdFilePtr pFile) { return pFile != NULL; }
|
||||||
|
|
||||||
int32_t taosUmaskFile(int32_t maskVal) {
|
int32_t taosUmaskFile(int32_t maskVal) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
return umask(maskVal);
|
return umask(maskVal);
|
||||||
|
@ -769,16 +681,26 @@ int32_t taosUmaskFile(int32_t maskVal) {
|
||||||
|
|
||||||
int32_t taosGetErrorFile(TdFilePtr pFile) { return errno; }
|
int32_t taosGetErrorFile(TdFilePtr pFile) { return errno; }
|
||||||
int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf) {
|
int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf) {
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL || ptrBuf == NULL ) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (*ptrBuf != NULL) {
|
if (*ptrBuf != NULL) {
|
||||||
taosMemoryFreeClear(*ptrBuf);
|
taosMemoryFreeClear(*ptrBuf);
|
||||||
}
|
}
|
||||||
assert(pFile->fp != NULL);
|
assert(pFile->fp != NULL);
|
||||||
|
#ifdef WINDOWS
|
||||||
|
*ptrBuf = taosMemoryMalloc(1024);
|
||||||
|
if (*ptrBuf == NULL) return -1;
|
||||||
|
if (fgets(*ptrBuf, 1023, pFile->fp) == NULL) {
|
||||||
|
taosMemoryFreeClear(*ptrBuf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
(*ptrBuf)[1023] = 0;
|
||||||
|
return strlen(*ptrBuf);
|
||||||
|
#else
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
return getline(ptrBuf, &len, pFile->fp);
|
return getline(ptrBuf, &len, pFile->fp);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
int32_t taosEOFFile(TdFilePtr pFile) {
|
int32_t taosEOFFile(TdFilePtr pFile) {
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
|
@ -789,8 +711,6 @@ int32_t taosEOFFile(TdFilePtr pFile) {
|
||||||
return feof(pFile->fp);
|
return feof(pFile->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(WINDOWS)
|
|
||||||
|
|
||||||
bool taosCheckAccessFile(const char *pathname, int32_t tdFileAccessOptions) {
|
bool taosCheckAccessFile(const char *pathname, int32_t tdFileAccessOptions) {
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
|
@ -805,10 +725,11 @@ bool taosCheckAccessFile(const char *pathname, int32_t tdFileAccessOptions) {
|
||||||
if (tdFileAccessOptions & TD_FILE_ACCESS_WRITE_OK) {
|
if (tdFileAccessOptions & TD_FILE_ACCESS_WRITE_OK) {
|
||||||
flags |= W_OK;
|
flags |= W_OK;
|
||||||
}
|
}
|
||||||
|
#ifdef WINDOWS
|
||||||
|
return _access(pathname, flags) == 0;
|
||||||
|
#else
|
||||||
return access(pathname, flags) == 0;
|
return access(pathname, flags) == 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosCheckExistFile(const char *pathname) { return taosCheckAccessFile(pathname, TD_FILE_ACCESS_EXIST_OK); };
|
bool taosCheckExistFile(const char *pathname) { return taosCheckAccessFile(pathname, TD_FILE_ACCESS_EXIST_OK); };
|
||||||
|
|
||||||
#endif // WINDOWS
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "osLocale.h"
|
#include "osLocale.h"
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
#if (_WIN64)
|
#if (_WIN64)
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
#include <mswsock.h>
|
#include <mswsock.h>
|
||||||
|
@ -87,7 +87,7 @@ void taosSetSystemLocale(const char *inLocale, const char *inCharSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosGetSystemLocale(char *outLocale, char *outCharset) {
|
void taosGetSystemLocale(char *outLocale, char *outCharset) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#ifdef WINDOWS
|
||||||
char *locale = setlocale(LC_CTYPE, "chs");
|
char *locale = setlocale(LC_CTYPE, "chs");
|
||||||
if (locale != NULL) {
|
if (locale != NULL) {
|
||||||
tstrncpy(outLocale, locale, TD_LOCALE_LEN);
|
tstrncpy(outLocale, locale, TD_LOCALE_LEN);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue