Merge branch 'develop' into feature/liaohj
This commit is contained in:
commit
25d888f13b
|
@ -38,21 +38,56 @@ IF (NOT DEFINED TD_CLUSTER)
|
|||
# Set macro definitions according to os platform
|
||||
SET(TD_LINUX_64 FALSE)
|
||||
SET(TD_LINUX_32 FALSE)
|
||||
SET(TD_ARM FALSE)
|
||||
SET(TD_ARM_64 FALSE)
|
||||
SET(TD_ARM_32 FALSE)
|
||||
SET(TD_MIPS_64 FALSE)
|
||||
SET(TD_DARWIN_64 FALSE)
|
||||
SET(TD_WINDOWS_64 FALSE)
|
||||
|
||||
# if generate ARM version:
|
||||
# cmake -DARMVER=arm32 .. or cmake -DARMVER=arm64
|
||||
IF (${ARMVER} MATCHES "arm32")
|
||||
SET(TD_ARM TRUE)
|
||||
SET(TD_ARM_32 TRUE)
|
||||
ADD_DEFINITIONS(-D_TD_ARM_)
|
||||
ADD_DEFINITIONS(-D_TD_ARM_32_)
|
||||
ELSEIF (${ARMVER} MATCHES "arm64")
|
||||
SET(TD_ARM TRUE)
|
||||
SET(TD_ARM_64 TRUE)
|
||||
ADD_DEFINITIONS(-D_TD_ARM_)
|
||||
ADD_DEFINITIONS(-D_TD_ARM_64_)
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_ARM)
|
||||
ADD_DEFINITIONS(-D_TD_ARM_)
|
||||
IF (TD_ARM_32)
|
||||
ADD_DEFINITIONS(-D_TD_ARM_32_)
|
||||
ELSEIF (TD_ARM_64)
|
||||
ADD_DEFINITIONS(-D_TD_ARM_64_)
|
||||
ELSE ()
|
||||
EXIT ()
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
||||
SET(TD_LINUX_64 TRUE)
|
||||
SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/linux)
|
||||
ADD_DEFINITIONS(-D_M_X64)
|
||||
MESSAGE(STATUS "The current platform is Linux 64-bit")
|
||||
ELSE ()
|
||||
ELSEIF (${CMAKE_SIZEOF_VOID_P} MATCHES 4)
|
||||
IF (TD_ARM)
|
||||
SET(TD_LINUX_32 TRUE)
|
||||
MESSAGE(FATAL_ERROR "The current platform is Linux 32-bit, not supported yet")
|
||||
SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/linux)
|
||||
#ADD_DEFINITIONS(-D_M_IX86)
|
||||
MESSAGE(STATUS "The current platform is Linux 32-bit")
|
||||
ELSE ()
|
||||
MESSAGE(FATAL_ERROR "The current platform is Linux 32-bit, but no ARM not supported yet")
|
||||
EXIT ()
|
||||
ENDIF ()
|
||||
ELSE ()
|
||||
MESSAGE(FATAL_ERROR "The current platform is Linux neither 32-bit nor 64-bit, not supported yet")
|
||||
EXIT ()
|
||||
ENDIF ()
|
||||
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
|
@ -102,13 +137,27 @@ IF (NOT DEFINED TD_CLUSTER)
|
|||
IF (TD_LINUX_64)
|
||||
SET(DEBUG_FLAGS "-O0 -DDEBUG")
|
||||
SET(RELEASE_FLAGS "-O0")
|
||||
IF (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||
IF (NOT TD_ARM)
|
||||
IF (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||
ELSE ()
|
||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||
ENDIF ()
|
||||
ELSE ()
|
||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -g -Wno-char-subscripts -fsigned-char -munaligned-access -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||
ENDIF ()
|
||||
ADD_DEFINITIONS(-DLINUX)
|
||||
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
|
||||
ELSEIF (TD_LINUX_32)
|
||||
IF (NOT TD_ARM)
|
||||
EXIT ()
|
||||
ENDIF ()
|
||||
SET(DEBUG_FLAGS "-O0 -DDEBUG")
|
||||
SET(RELEASE_FLAGS "-O0")
|
||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -g -Wno-char-subscripts -fsigned-char -munaligned-access -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||
ADD_DEFINITIONS(-DLINUX)
|
||||
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
|
||||
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
||||
ELSEIF (TD_WINDOWS_64)
|
||||
SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE)
|
||||
SET(COMMON_FLAGS "/nologo /WX- /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-")
|
||||
|
@ -169,6 +218,14 @@ IF (NOT DEFINED TD_CLUSTER)
|
|||
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
|
||||
INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})")
|
||||
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR})")
|
||||
ELSEIF (TD_LINUX_32)
|
||||
IF (NOT TD_ARM)
|
||||
EXIT ()
|
||||
ENDIF ()
|
||||
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
|
||||
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
|
||||
INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})")
|
||||
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR})")
|
||||
ELSEIF (TD_WINDOWS_64)
|
||||
SET(CMAKE_INSTALL_PREFIX C:/TDengine)
|
||||
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/go DESTINATION connector)
|
||||
|
|
|
@ -247,9 +247,9 @@ vercomp () {
|
|||
|
||||
function is_version_compatible() {
|
||||
|
||||
curr_version=$(${bin_dir}/taosd -V | cut -d ' ' -f 1)
|
||||
curr_version=$(${bin_dir}/taosd -V | cut -d ' ' -f 2)
|
||||
|
||||
min_compatible_version=$(${script_dir}/bin/taosd -V | cut -d ' ' -f 2)
|
||||
min_compatible_version=$(${script_dir}/bin/taosd -V | cut -d ' ' -f 4)
|
||||
|
||||
vercomp $curr_version $min_compatible_version
|
||||
case $? in
|
||||
|
|
|
@ -7,7 +7,7 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
|
|||
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
|
||||
AUX_SOURCE_DIRECTORY(./src SRC)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux)
|
||||
|
||||
# set the static lib name
|
||||
|
|
|
@ -206,10 +206,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn
|
|||
|
||||
ret = (jlong)taos_connect((char *)host, (char *)user, (char *)pass, (char *)dbname, jport);
|
||||
if (ret == 0) {
|
||||
jniError("jobj:%p, taos:%p, connect to tdengine failed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
|
||||
jniError("jobj:%p, conn:%p, connect to database failed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
|
||||
(char *)host, (char *)user, (char *)dbname, jport);
|
||||
} else {
|
||||
jniTrace("jobj:%p, taos:%p, connect to tdengine succeed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
|
||||
jniTrace("jobj:%p, conn:%p, connect to database succeed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
|
||||
(char *)host, (char *)user, (char *)dbname, jport);
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J
|
|||
}
|
||||
|
||||
if (jsql == NULL) {
|
||||
jniError("jobj:%p, taos:%p, sql is null", jobj, tscon);
|
||||
jniError("jobj:%p, conn:%p, sql is null", jobj, tscon);
|
||||
return JNI_SQL_NULL;
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J
|
|||
|
||||
int code = taos_query(tscon, dst);
|
||||
if (code != 0) {
|
||||
jniError("jobj:%p, taos:%p, code:%d, msg:%s, sql:%s", jobj, tscon, code, taos_errstr(tscon), dst);
|
||||
jniError("jobj:%p, conn:%p, code:%d, msg:%s, sql:%s", jobj, tscon, code, taos_errstr(tscon), dst);
|
||||
free(dst);
|
||||
return JNI_TDENGINE_ERROR;
|
||||
} else {
|
||||
|
@ -257,9 +257,9 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J
|
|||
|
||||
if (pSql->cmd.command == TSDB_SQL_INSERT) {
|
||||
affectRows = taos_affected_rows(tscon);
|
||||
jniTrace("jobj:%p, taos:%p, code:%d, affect rows:%d, sql:%s", jobj, tscon, code, affectRows, dst);
|
||||
jniTrace("jobj:%p, conn:%p, code:%d, affect rows:%d, sql:%s", jobj, tscon, code, affectRows, dst);
|
||||
} else {
|
||||
jniTrace("jobj:%p, taos:%p, code:%d, sql:%s", jobj, tscon, code, dst);
|
||||
jniTrace("jobj:%p, conn:%p, code:%d, sql:%s", jobj, tscon, code, dst);
|
||||
}
|
||||
|
||||
free(dst);
|
||||
|
@ -293,10 +293,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getResultSetImp(
|
|||
|
||||
if (tscIsUpdateQuery(tscon)) {
|
||||
ret = 0; // for update query, no result pointer
|
||||
jniTrace("jobj:%p, taos:%p, no result", jobj, tscon);
|
||||
jniTrace("jobj:%p, conn:%p, no result", jobj, tscon);
|
||||
} else {
|
||||
ret = (jlong) taos_use_result(tscon);
|
||||
jniTrace("jobj:%p, taos:%p, get resultset:%p", jobj, tscon, (void *) ret);
|
||||
jniTrace("jobj:%p, conn:%p, get resultset:%p", jobj, tscon, (void *) ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -311,12 +311,12 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_freeResultSetImp(
|
|||
}
|
||||
|
||||
if ((void *)res == NULL) {
|
||||
jniError("jobj:%p, taos:%p, resultset is null", jobj, tscon);
|
||||
jniError("jobj:%p, conn:%p, resultset is null", jobj, tscon);
|
||||
return JNI_RESULT_SET_NULL;
|
||||
}
|
||||
|
||||
taos_free_result((void *)res);
|
||||
jniTrace("jobj:%p, taos:%p, free resultset:%p", jobj, tscon, (void *)res);
|
||||
jniTrace("jobj:%p, conn:%p, free resultset:%p", jobj, tscon, (void *)res);
|
||||
return JNI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getAffectedRowsIm
|
|||
|
||||
jint ret = taos_affected_rows(tscon);
|
||||
|
||||
jniTrace("jobj:%p, taos:%p, affect rows:%d", jobj, tscon, (void *)con, ret);
|
||||
jniTrace("jobj:%p, conn:%p, affect rows:%d", jobj, tscon, (void *)con, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getSchemaMetaData
|
|||
|
||||
TAOS_RES *result = (TAOS_RES *)res;
|
||||
if (result == NULL) {
|
||||
jniError("jobj:%p, taos:%p, resultset is null", jobj, tscon);
|
||||
jniError("jobj:%p, conn:%p, resultset is null", jobj, tscon);
|
||||
return JNI_RESULT_SET_NULL;
|
||||
}
|
||||
|
||||
|
@ -356,10 +356,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getSchemaMetaData
|
|||
// jobject arrayListObj = (*env)->NewObject(env, g_arrayListClass, g_arrayListConstructFp, "");
|
||||
|
||||
if (num_fields == 0) {
|
||||
jniError("jobj:%p, taos:%p, resultset:%p, fields size is %d", jobj, tscon, res, num_fields);
|
||||
jniError("jobj:%p, conn:%p, resultset:%p, fields size is %d", jobj, tscon, res, num_fields);
|
||||
return JNI_NUM_OF_FIELDS_0;
|
||||
} else {
|
||||
jniTrace("jobj:%p, taos:%p, resultset:%p, fields size is %d", jobj, tscon, res, num_fields);
|
||||
jniTrace("jobj:%p, conn:%p, resultset:%p, fields size is %d", jobj, tscon, res, num_fields);
|
||||
for (int i = 0; i < num_fields; ++i) {
|
||||
jobject metadataObj = (*env)->NewObject(env, g_metadataClass, g_metadataConstructFp);
|
||||
(*env)->SetIntField(env, metadataObj, g_metadataColtypeField, fields[i].type);
|
||||
|
@ -402,7 +402,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn
|
|||
|
||||
TAOS_RES *result = (TAOS_RES *)res;
|
||||
if (result == NULL) {
|
||||
jniError("jobj:%p, taos:%p, resultset is null", jobj, tscon);
|
||||
jniError("jobj:%p, conn:%p, resultset is null", jobj, tscon);
|
||||
return JNI_RESULT_SET_NULL;
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn
|
|||
int num_fields = taos_num_fields(result);
|
||||
|
||||
if (num_fields == 0) {
|
||||
jniError("jobj:%p, taos:%p, resultset:%p, fields size is %d", jobj, tscon, res, num_fields);
|
||||
jniError("jobj:%p, conn:%p, resultset:%p, fields size is %d", jobj, tscon, res, num_fields);
|
||||
return JNI_NUM_OF_FIELDS_0;
|
||||
}
|
||||
|
||||
|
@ -418,10 +418,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn
|
|||
if (row == NULL) {
|
||||
int tserrno = taos_errno(tscon);
|
||||
if (tserrno == 0) {
|
||||
jniTrace("jobj:%p, taos:%p, resultset:%p, fields size is %d, fetch row to the end", jobj, tscon, res, num_fields);
|
||||
jniTrace("jobj:%p, conn:%p, resultset:%p, fields size is %d, fetch row to the end", jobj, tscon, res, num_fields);
|
||||
return JNI_FETCH_END;
|
||||
} else {
|
||||
jniTrace("jobj:%p, taos:%p, interruptted query", jobj, tscon);
|
||||
jniTrace("jobj:%p, conn:%p, interruptted query", jobj, tscon);
|
||||
return JNI_RESULT_SET_NULL;
|
||||
}
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_closeConnectionIm
|
|||
jniError("jobj:%p, connection is closed", jobj);
|
||||
return JNI_CONNECTION_NULL;
|
||||
} else {
|
||||
jniTrace("jobj:%p, taos:%p, close connection success", jobj, tscon);
|
||||
jniTrace("jobj:%p, conn:%p, close connection success", jobj, tscon);
|
||||
taos_close(tscon);
|
||||
return JNI_SUCCESS;
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab
|
|||
}
|
||||
|
||||
if (jsql == NULL) {
|
||||
jniError("jobj:%p, taos:%p, sql is null", jobj, tscon);
|
||||
jniError("jobj:%p, conn:%p, sql is null", jobj, tscon);
|
||||
return JNI_SQL_NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -3812,10 +3812,11 @@ static void getStatics_i64(int64_t *primaryKey, int64_t *data, int32_t numOfRow,
|
|||
|
||||
static void getStatics_f(int64_t *primaryKey, float *data, int32_t numOfRow, double *min, double *max, double *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int32_t *numOfNull) {
|
||||
*min = DBL_MAX;
|
||||
*max = -DBL_MAX;
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
float fmin = DBL_MAX;
|
||||
float fmax = -DBL_MAX;
|
||||
float fminIndex = 0;
|
||||
float fmaxIndex = 0;
|
||||
double dsum = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
|
@ -3825,15 +3826,19 @@ static void getStatics_f(int64_t *primaryKey, float *data, int32_t numOfRow, dou
|
|||
continue;
|
||||
}
|
||||
|
||||
*sum += data[i];
|
||||
if (*min > data[i]) {
|
||||
*min = data[i];
|
||||
*minIndex = i;
|
||||
float fv = 0;
|
||||
*(int32_t*)(&fv) = *(int32_t*)(&(data[i]));
|
||||
|
||||
//*sum += data[i];
|
||||
dsum += fv;
|
||||
if (fmin > fv) {
|
||||
fmin = fv;
|
||||
fminIndex = i;
|
||||
}
|
||||
|
||||
if (*max < data[i]) {
|
||||
*max = data[i];
|
||||
*maxIndex = i;
|
||||
if (fmax < fv) {
|
||||
fmax = fv;
|
||||
fmaxIndex = i;
|
||||
}
|
||||
|
||||
// if (isNull(&lastVal, TSDB_DATA_TYPE_FLOAT)) {
|
||||
|
@ -3845,14 +3850,26 @@ static void getStatics_f(int64_t *primaryKey, float *data, int32_t numOfRow, dou
|
|||
// lastVal = data[i];
|
||||
// }
|
||||
}
|
||||
|
||||
double csum = 0;
|
||||
*(int64_t*)(&csum) = *(int64_t*)sum;
|
||||
csum += dsum;
|
||||
*(int64_t*)(sum) = *(int64_t*)(&csum);
|
||||
|
||||
*(int32_t*)max = *(int32_t*)(&fmax);
|
||||
*(int32_t*)min = *(int32_t*)(&fmin);
|
||||
*(int32_t*)minIndex = *(int32_t*)(&fminIndex);
|
||||
*(int32_t*)maxIndex = *(int32_t*)(&fmaxIndex);
|
||||
|
||||
}
|
||||
|
||||
static void getStatics_d(int64_t *primaryKey, double *data, int32_t numOfRow, double *min, double *max, double *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int32_t *numOfNull) {
|
||||
*min = DBL_MAX;
|
||||
*max = -DBL_MAX;
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
double dmin = DBL_MAX;
|
||||
double dmax = -DBL_MAX;
|
||||
double dminIndex = 0;
|
||||
double dmaxIndex = 0;
|
||||
double dsum = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
|
@ -3865,15 +3882,19 @@ static void getStatics_d(int64_t *primaryKey, double *data, int32_t numOfRow, do
|
|||
continue;
|
||||
}
|
||||
|
||||
*sum += data[i];
|
||||
if (*min > data[i]) {
|
||||
*min = data[i];
|
||||
*minIndex = i;
|
||||
double dv = 0;
|
||||
*(int64_t*)(&dv) = *(int64_t*)(&(data[i]));
|
||||
|
||||
//*sum += data[i];
|
||||
dsum += dv;
|
||||
if (dmin > dv) {
|
||||
dmin = dv;
|
||||
dminIndex = i;
|
||||
}
|
||||
|
||||
if (*max < data[i]) {
|
||||
*max = data[i];
|
||||
*maxIndex = i;
|
||||
if (dmax < dv) {
|
||||
dmax = dv;
|
||||
dmaxIndex = i;
|
||||
}
|
||||
|
||||
// if (isNull(&lastVal, TSDB_DATA_TYPE_DOUBLE)) {
|
||||
|
@ -3885,6 +3906,16 @@ static void getStatics_d(int64_t *primaryKey, double *data, int32_t numOfRow, do
|
|||
// lastVal = data[i];
|
||||
// }
|
||||
}
|
||||
|
||||
double csum = 0;
|
||||
*(int64_t*)(&csum) = *(int64_t*)sum;
|
||||
csum += dsum;
|
||||
*(int64_t*)(sum) = *(int64_t*)(&csum);
|
||||
|
||||
*(int64_t*)max = *(int64_t*)(&dmax);
|
||||
*(int64_t*)min = *(int64_t*)(&dmin);
|
||||
*(int64_t*)minIndex = *(int64_t*)(&dminIndex);
|
||||
*(int64_t*)maxIndex = *(int64_t*)(&dmaxIndex);
|
||||
}
|
||||
|
||||
void getStatistics(char *priData, char *data, int32_t size, int32_t numOfRow, int32_t type, int64_t *min, int64_t *max,
|
||||
|
|
|
@ -20,6 +20,27 @@
|
|||
#include "ttimer.h"
|
||||
#include "tutil.h"
|
||||
|
||||
void tscSaveSlowQueryFp(void *handle, void *tmrId);
|
||||
void *tscSlowQueryConn = NULL;
|
||||
bool tscSlowQueryConnInitialized = false;
|
||||
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int),
|
||||
void *param, void **taos);
|
||||
|
||||
void tscInitConnCb(void *param, TAOS_RES *result, int code) {
|
||||
char *sql = param;
|
||||
if (code < 0) {
|
||||
tscError("taos:%p, slow query connect failed, code:%d", tscSlowQueryConn, code);
|
||||
taos_close(tscSlowQueryConn);
|
||||
tscSlowQueryConn = NULL;
|
||||
tscSlowQueryConnInitialized = false;
|
||||
free(sql);
|
||||
} else {
|
||||
tscTrace("taos:%p, slow query connect success, code:%d", tscSlowQueryConn, code);
|
||||
tscSlowQueryConnInitialized = true;
|
||||
tscSaveSlowQueryFp(sql, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void tscAddIntoSqlList(SSqlObj *pSql) {
|
||||
static uint32_t queryId = 1;
|
||||
|
||||
|
@ -44,33 +65,35 @@ void tscAddIntoSqlList(SSqlObj *pSql) {
|
|||
|
||||
void tscSaveSlowQueryFpCb(void *param, TAOS_RES *result, int code) {
|
||||
if (code < 0) {
|
||||
tscError("failed to save slowquery, code:%d", code);
|
||||
tscError("failed to save slow query, code:%d", code);
|
||||
} else {
|
||||
tscTrace("success to save slow query, code:%d", code);
|
||||
}
|
||||
}
|
||||
|
||||
void tscSaveSlowQueryFp(void *handle, void *tmrId) {
|
||||
char *sql = handle;
|
||||
|
||||
static void *taos = NULL;
|
||||
if (taos == NULL) {
|
||||
taos = taos_connect(NULL, "monitor", tsInternalPass, NULL, 0);
|
||||
if (taos == NULL) {
|
||||
tscError("failed to save slow query, can't connect to server");
|
||||
if (!tscSlowQueryConnInitialized) {
|
||||
if (tscSlowQueryConn == NULL) {
|
||||
tscTrace("start to init slow query connect");
|
||||
taos_connect_a(NULL, "monitor", tsInternalPass, "", 0, tscInitConnCb, sql, &tscSlowQueryConn);
|
||||
} else {
|
||||
tscError("taos:%p, slow query connect is already initialized", tscSlowQueryConn);
|
||||
free(sql);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
tscTrace("taos:%p, save slow query:%s", tscSlowQueryConn, sql);
|
||||
taos_query_a(tscSlowQueryConn, sql, tscSaveSlowQueryFpCb, NULL);
|
||||
free(sql);
|
||||
}
|
||||
|
||||
tscTrace("save slow query:sql", sql);
|
||||
taos_query_a(taos, sql, tscSaveSlowQueryFpCb, NULL);
|
||||
free(sql);
|
||||
}
|
||||
|
||||
void tscSaveSlowQuery(SSqlObj *pSql) {
|
||||
const static int64_t SLOW_QUERY_INTERVAL = 3000000L;
|
||||
if (pSql->res.useconds < SLOW_QUERY_INTERVAL) return;
|
||||
|
||||
tscTrace("%p query time:%ld sql:%s", pSql, pSql->res.useconds, pSql->sqlstr);
|
||||
tscTrace("%p query time:%lld sql:%s", pSql, pSql->res.useconds, pSql->sqlstr);
|
||||
|
||||
char *sql = malloc(200);
|
||||
int len = snprintf(sql, 200, "insert into %s.slowquery values(now, '%s', %lld, %lld, '", tsMonitorDbName,
|
||||
|
|
|
@ -562,7 +562,7 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
|
|||
void *taosres = tscKeepConn[command] ? pSql : NULL;
|
||||
code = pRes->code ? -pRes->code : pRes->numOfRows;
|
||||
|
||||
tscTrace("%p Async SQL result:%d taosres:%p", pSql, code, taosres);
|
||||
tscTrace("%p Async SQL result:%d res:%p", pSql, code, taosres);
|
||||
|
||||
/*
|
||||
* Whether to free sqlObj or not should be decided before call the user defined function, since this SqlObj
|
||||
|
|
|
@ -176,7 +176,7 @@ void taos_init_imp() {
|
|||
tscConnCache = taosOpenConnCache(tsMaxMeterConnections * 2, taosCloseRpcConn, tscTmr, tsShellActivityTimer * 1000);
|
||||
|
||||
initialized = 1;
|
||||
tscTrace("taos client is initialized successfully");
|
||||
tscTrace("client is initialized successfully");
|
||||
tsInsertHeadSize = tsRpcHeadSize + sizeof(SShellSubmitMsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,46 +29,47 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
func (mc *taosConn) taosConnect(ip, user, pass, db string, port int) (taos unsafe.Pointer, err error){
|
||||
func (mc *taosConn) taosConnect(ip, user, pass, db string, port int) (taos unsafe.Pointer, err error) {
|
||||
cuser := C.CString(user)
|
||||
cpass := C.CString(pass)
|
||||
cip := C.CString(ip)
|
||||
cdb := C.CString(db)
|
||||
cip := C.CString(ip)
|
||||
cdb := C.CString(db)
|
||||
defer C.free(unsafe.Pointer(cip))
|
||||
defer C.free(unsafe.Pointer(cuser))
|
||||
defer C.free(unsafe.Pointer(cpass))
|
||||
defer C.free(unsafe.Pointer(cdb))
|
||||
|
||||
taosObj := C.taos_connect(cip, cuser, cpass, cdb, (C.int)(port))
|
||||
if taosObj == nil {
|
||||
return nil, errors.New("taos_connect() fail!")
|
||||
}
|
||||
if taosObj == nil {
|
||||
return nil, errors.New("taos_connect() fail!")
|
||||
}
|
||||
|
||||
return (unsafe.Pointer)(taosObj), nil
|
||||
}
|
||||
return (unsafe.Pointer)(taosObj), nil
|
||||
}
|
||||
|
||||
func (mc *taosConn) taosQuery(sqlstr string) (int, error) {
|
||||
taosLog.Printf("taosQuery() input sql:%s\n", sqlstr)
|
||||
//taosLog.Printf("taosQuery() input sql:%s\n", sqlstr)
|
||||
|
||||
csqlstr := C.CString(sqlstr)
|
||||
csqlstr := C.CString(sqlstr)
|
||||
defer C.free(unsafe.Pointer(csqlstr))
|
||||
code := int(C.taos_query(mc.taos, csqlstr))
|
||||
code := int(C.taos_query(mc.taos, csqlstr))
|
||||
|
||||
if 0 != code {
|
||||
mc.taos_error()
|
||||
errStr := C.GoString(C.taos_errstr(mc.taos))
|
||||
taosLog.Println("taos_query() failed:", errStr)
|
||||
return 0, errors.New(errStr)
|
||||
}
|
||||
if 0 != code {
|
||||
mc.taos_error()
|
||||
errStr := C.GoString(C.taos_errstr(mc.taos))
|
||||
taosLog.Println("taos_query() failed:", errStr)
|
||||
taosLog.Printf("taosQuery() input sql:%s\n", sqlstr)
|
||||
return 0, errors.New(errStr)
|
||||
}
|
||||
|
||||
// read result and save into mc struct
|
||||
num_fields := int(C.taos_field_count(mc.taos))
|
||||
if 0 == num_fields { // there are no select and show kinds of commands
|
||||
mc.affectedRows = int(C.taos_affected_rows(mc.taos))
|
||||
mc.insertId = 0
|
||||
}
|
||||
// read result and save into mc struct
|
||||
num_fields := int(C.taos_field_count(mc.taos))
|
||||
if 0 == num_fields { // there are no select and show kinds of commands
|
||||
mc.affectedRows = int(C.taos_affected_rows(mc.taos))
|
||||
mc.insertId = 0
|
||||
}
|
||||
|
||||
return num_fields, nil
|
||||
return num_fields, nil
|
||||
}
|
||||
|
||||
func (mc *taosConn) taos_close() {
|
||||
|
@ -76,8 +77,8 @@ func (mc *taosConn) taos_close() {
|
|||
}
|
||||
|
||||
func (mc *taosConn) taos_error() {
|
||||
// free local resouce: allocated memory/metric-meta refcnt
|
||||
//var pRes unsafe.Pointer
|
||||
pRes := C.taos_use_result(mc.taos)
|
||||
C.taos_free_result(pRes)
|
||||
// free local resouce: allocated memory/metric-meta refcnt
|
||||
//var pRes unsafe.Pointer
|
||||
pRes := C.taos_use_result(mc.taos)
|
||||
C.taos_free_result(pRes)
|
||||
}
|
||||
|
|
|
@ -169,6 +169,8 @@ extern uint32_t debugFlag;
|
|||
extern uint32_t odbcdebugFlag;
|
||||
extern uint32_t qdebugFlag;
|
||||
|
||||
extern uint32_t taosMaxTmrCtrl;
|
||||
|
||||
extern int tsRpcTimer;
|
||||
extern int tsRpcMaxTime;
|
||||
extern int tsUdpDelay;
|
||||
|
|
|
@ -25,6 +25,7 @@ typedef void (*TAOS_TMR_CALLBACK)(void *, void *);
|
|||
|
||||
extern uint32_t tmrDebugFlag;
|
||||
extern int taosTmrThreads;
|
||||
extern uint32_t taosMaxTmrCtrl;
|
||||
|
||||
#define tmrError(...) \
|
||||
do { if (tmrDebugFlag & DEBUG_ERROR) { \
|
||||
|
@ -41,7 +42,6 @@ extern int taosTmrThreads;
|
|||
tprintf("TMR ", tmrDebugFlag, __VA_ARGS__); \
|
||||
} } while(0)
|
||||
|
||||
#define MAX_NUM_OF_TMRCTL 512
|
||||
#define MSECONDS_PER_TICK 5
|
||||
|
||||
void *taosTmrInit(int maxTmr, int resoultion, int longest, const char *label);
|
||||
|
|
|
@ -6,7 +6,7 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
|
|||
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
|
||||
INCLUDE_DIRECTORIES(inc)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||
AUX_SOURCE_DIRECTORY(./src SRC)
|
||||
LIST(REMOVE_ITEM SRC ./src/shellWindows.c)
|
||||
ADD_EXECUTABLE(shell ${SRC})
|
||||
|
|
|
@ -445,7 +445,7 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
|
|||
case TSDB_DATA_TYPE_BIGINT:
|
||||
printf("%*lld|", l[i], *((int64_t *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
#ifdef _TD_ARM_32_
|
||||
float fv = 0;
|
||||
//memcpy(&fv, row[i], sizeof(float));
|
||||
|
@ -454,8 +454,9 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
|
|||
#else
|
||||
printf("%*.5f|", l[i], *((float *)row[i]));
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
#ifdef _TD_ARM_32_
|
||||
double dv = 0;
|
||||
//memcpy(&dv, row[i], sizeof(double));
|
||||
|
@ -464,6 +465,7 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
|
|||
#else
|
||||
printf("%*.9f|", l[i], *((double *)row[i]));
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
|
@ -528,7 +530,7 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
|
|||
case TSDB_DATA_TYPE_BIGINT:
|
||||
printf("%lld\n", *((int64_t *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
#ifdef _TD_ARM_32_
|
||||
float fv = 0;
|
||||
//memcpy(&fv, row[i], sizeof(float));
|
||||
|
@ -537,8 +539,9 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
|
|||
#else
|
||||
printf("%.5f\n", *((float *)row[i]));
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
#ifdef _TD_ARM_32_
|
||||
double dv = 0;
|
||||
//memcpy(&dv, row[i], sizeof(double));
|
||||
|
@ -547,7 +550,8 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
|
|||
#else
|
||||
printf("%.9f\n", *((double *)row[i]));
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
memset(t_str, 0, TSDB_MAX_BYTES_PER_ROW);
|
||||
|
@ -614,7 +618,7 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
|
|||
case TSDB_DATA_TYPE_BIGINT:
|
||||
fprintf(fp, "%lld", *((int64_t *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
#ifdef _TD_ARM_32_
|
||||
float fv = 0;
|
||||
//memcpy(&fv, row[i], sizeof(float));
|
||||
|
@ -623,8 +627,9 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
|
|||
#else
|
||||
fprintf(fp, "%.5f", *((float *)row[i]));
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
#ifdef _TD_ARM_32_
|
||||
double dv = 0;
|
||||
//memcpy(&dv, row[i], sizeof(double));
|
||||
|
@ -633,6 +638,7 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
|
|||
#else
|
||||
fprintf(fp, "%.9f", *((double *)row[i]));
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
|
|
|
@ -6,7 +6,7 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
|
|||
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
|
||||
INCLUDE_DIRECTORIES(inc)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||
AUX_SOURCE_DIRECTORY(. SRC)
|
||||
ADD_EXECUTABLE(taosdemo ${SRC})
|
||||
TARGET_LINK_LIBRARIES(taosdemo taos_static)
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
#include <wordexp.h>
|
||||
|
||||
#include "taos.h"
|
||||
|
||||
extern char configDir[];
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wmissing-braces"
|
||||
|
||||
#define BUFFER_SIZE 65536
|
||||
|
|
|
@ -6,7 +6,7 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
|
|||
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
|
||||
INCLUDE_DIRECTORIES(inc)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||
AUX_SOURCE_DIRECTORY(. SRC)
|
||||
ADD_EXECUTABLE(taosdump ${SRC})
|
||||
TARGET_LINK_LIBRARIES(taosdump taos_static)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/zlib-1.2.11/inc)
|
||||
|
|
|
@ -50,7 +50,7 @@ int httpInitSystem() {
|
|||
httpServer = (HttpServer *)malloc(sizeof(HttpServer));
|
||||
memset(httpServer, 0, sizeof(HttpServer));
|
||||
|
||||
strcpy(httpServer->label, "taosh");
|
||||
strcpy(httpServer->label, "rest");
|
||||
strcpy(httpServer->serverIp, tsHttpIp);
|
||||
httpServer->serverPort = tsHttpPort;
|
||||
httpServer->cacheContext = tsHttpCacheSessions;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
|
||||
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
|
||||
|
|
|
@ -131,7 +131,7 @@ void monitorInitConn(void *para, void *unused) {
|
|||
|
||||
void monitorInitConnCb(void *param, TAOS_RES *result, int code) {
|
||||
if (code < 0) {
|
||||
monitorError("monitor:%p, connect to taosd failed, code:%d", monitor->conn, code);
|
||||
monitorError("monitor:%p, connect to database failed, code:%d", monitor->conn, code);
|
||||
taos_close(monitor->conn);
|
||||
monitor->conn = NULL;
|
||||
monitor->state = MONITOR_STATE_UN_INIT;
|
||||
|
@ -139,7 +139,7 @@ void monitorInitConnCb(void *param, TAOS_RES *result, int code) {
|
|||
return;
|
||||
}
|
||||
|
||||
monitorTrace("monitor:%p, connect to taosd success, code:%d", monitor->conn, code);
|
||||
monitorTrace("monitor:%p, connect to database success, code:%d", monitor->conn, code);
|
||||
monitorInitDatabase();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
|
||||
INCLUDE_DIRECTORIES(inc)
|
||||
AUX_SOURCE_DIRECTORY(src SRC)
|
||||
|
|
|
@ -5,7 +5,7 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
|
|||
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
|
||||
INCLUDE_DIRECTORIES(inc)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||
AUX_SOURCE_DIRECTORY(./src SRC)
|
||||
ELSEIF (TD_DARWIN_64)
|
||||
LIST(APPEND SRC ./src/thaship.c)
|
||||
|
|
|
@ -5,11 +5,11 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
|
|||
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
|
||||
INCLUDE_DIRECTORIES(inc)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||
AUX_SOURCE_DIRECTORY(src SRC)
|
||||
ADD_LIBRARY(sdb ${SRC})
|
||||
TARGET_LINK_LIBRARIES(sdb trpc)
|
||||
IF (TD_CLUSTER)
|
||||
TARGET_LINK_LIBRARIES(sdb sdb_cluster)
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/modules/http/inc)
|
||||
|
|
|
@ -866,7 +866,8 @@ int vnodeSaveQueryResult(void *handle, char *data, int32_t *size) {
|
|||
pQInfo->pointsRead);
|
||||
|
||||
if (pQInfo->over == 0) {
|
||||
dTrace("QInfo:%p set query flag, oldSig:%p, func:%s", pQInfo, pQInfo->signature, __FUNCTION__);
|
||||
//dTrace("QInfo:%p set query flag, oldSig:%p, func:%s", pQInfo, pQInfo->signature, __FUNCTION__);
|
||||
dTrace("QInfo:%p set query flag, oldSig:%p", pQInfo, pQInfo->signature);
|
||||
uint64_t oldSignature = TSDB_QINFO_SET_QUERY_FLAG(pQInfo);
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/modules/http/inc)
|
||||
|
|
|
@ -4,7 +4,7 @@ PROJECT(TDengine)
|
|||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
|
||||
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||
AUX_SOURCE_DIRECTORY(src SRC)
|
||||
ADD_LIBRARY(tutil ${SRC})
|
||||
TARGET_LINK_LIBRARIES(tutil pthread os m rt)
|
||||
|
|
|
@ -1353,7 +1353,7 @@ uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) {
|
|||
#endif // #ifndef _TD_ARM_
|
||||
|
||||
void taosResolveCRC() {
|
||||
#ifndef _TD_ARM_32
|
||||
#ifndef _TD_ARM_
|
||||
int sse42;
|
||||
SSE42(sse42);
|
||||
crc32c = sse42 ? crc32c_hw : crc32c_sf;
|
||||
|
|
|
@ -536,6 +536,11 @@ void tsInitGlobalConfig() {
|
|||
0, 2, 0, TSDB_CFG_UTYPE_NONE);
|
||||
// 0-any, 1-mgmt, 2-dnode
|
||||
|
||||
// timer
|
||||
tsInitConfigOption(cfg++, "maxTmrCtrl", &taosMaxTmrCtrl, TSDB_CFG_VTYPE_INT,
|
||||
TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLUSTER,
|
||||
8, 2048, 0, TSDB_CFG_UTYPE_NONE);
|
||||
|
||||
// time
|
||||
tsInitConfigOption(cfg++, "monitorInterval", &tsMonitorInterval, TSDB_CFG_VTYPE_INT,
|
||||
TSDB_CFG_CTYPE_B_CONFIG,
|
||||
|
|
|
@ -82,13 +82,16 @@ typedef struct time_wheel_t {
|
|||
} time_wheel_t;
|
||||
|
||||
uint32_t tmrDebugFlag = DEBUG_ERROR | DEBUG_WARN | DEBUG_FILE;
|
||||
uint32_t taosMaxTmrCtrl = 512;
|
||||
|
||||
static pthread_once_t tmrModuleInit = PTHREAD_ONCE_INIT;
|
||||
static pthread_mutex_t tmrCtrlMutex;
|
||||
static tmr_ctrl_t tmrCtrls[MAX_NUM_OF_TMRCTL];
|
||||
static tmr_ctrl_t* tmrCtrls;
|
||||
static tmr_ctrl_t* unusedTmrCtrl = NULL;
|
||||
void* tmrQhandle;
|
||||
int taosTmrThreads = 1;
|
||||
static void* tmrQhandle;
|
||||
static int numOfTmrCtrl = 0;
|
||||
|
||||
int taosTmrThreads = 1;
|
||||
|
||||
static uintptr_t nextTimerId = 0;
|
||||
|
||||
|
@ -129,7 +132,7 @@ static void unlockTimerList(timer_list_t* list) {
|
|||
int64_t tid = taosGetPthreadId();
|
||||
if (__sync_val_compare_and_swap_64(&(list->lockedBy), tid, 0) != tid) {
|
||||
assert(false);
|
||||
tmrError("trying to unlock a timer list not locked by current thread.");
|
||||
tmrError("%d trying to unlock a timer list not locked by current thread.", tid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,13 +259,13 @@ static void processExpiredTimer(void* handle, void* arg) {
|
|||
timer->executedBy = taosGetPthreadId();
|
||||
uint8_t state = __sync_val_compare_and_swap_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_EXPIRED);
|
||||
if (state == TIMER_STATE_WAITING) {
|
||||
const char* fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] execution start.";
|
||||
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] execution start.";
|
||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||
|
||||
(*timer->fp)(timer->param, (tmr_h)timer->id);
|
||||
atomic_store_8(&timer->state, TIMER_STATE_STOPPED);
|
||||
|
||||
fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] execution end.";
|
||||
fmt = "%s timer[id=%lld, fp=%p, param=%p] execution end.";
|
||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||
}
|
||||
removeTimer(timer->id);
|
||||
|
@ -270,18 +273,21 @@ static void processExpiredTimer(void* handle, void* arg) {
|
|||
}
|
||||
|
||||
static void addToExpired(tmr_obj_t* head) {
|
||||
const char* fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] expired";
|
||||
const char* fmt = "%s adding expired timer[id=%lld, fp=%p, param=%p] to queue.";
|
||||
|
||||
while (head != NULL) {
|
||||
tmrTrace(fmt, head->ctrl->label, head->id, head->fp, head->param);
|
||||
|
||||
uintptr_t id = head->id;
|
||||
tmr_obj_t* next = head->next;
|
||||
tmrTrace(fmt, head->ctrl->label, id, head->fp, head->param);
|
||||
|
||||
SSchedMsg schedMsg;
|
||||
schedMsg.fp = NULL;
|
||||
schedMsg.tfp = processExpiredTimer;
|
||||
schedMsg.ahandle = head;
|
||||
schedMsg.thandle = NULL;
|
||||
taosScheduleTask(tmrQhandle, &schedMsg);
|
||||
|
||||
tmrTrace("timer[id=%lld] has been added to queue.", id);
|
||||
head = next;
|
||||
}
|
||||
}
|
||||
|
@ -295,7 +301,7 @@ static uintptr_t doStartTimer(tmr_obj_t* timer, TAOS_TMR_CALLBACK fp, int msecon
|
|||
timer->ctrl = ctrl;
|
||||
addTimer(timer);
|
||||
|
||||
const char* fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] started";
|
||||
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] started";
|
||||
tmrTrace(fmt, ctrl->label, timer->id, timer->fp, timer->param);
|
||||
|
||||
if (mseconds == 0) {
|
||||
|
@ -318,7 +324,7 @@ tmr_h taosTmrStart(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle
|
|||
|
||||
tmr_obj_t* timer = (tmr_obj_t*)calloc(1, sizeof(tmr_obj_t));
|
||||
if (timer == NULL) {
|
||||
tmrError("failed to allocated memory for new timer object.");
|
||||
tmrError("%s failed to allocated memory for new timer object.", ctrl->label);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -389,7 +395,7 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
|
|||
// we cannot guarantee the thread safety of the timr in all other cases.
|
||||
reusable = true;
|
||||
}
|
||||
const char* fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] is cancelled.";
|
||||
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] is cancelled.";
|
||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||
} else if (state != TIMER_STATE_EXPIRED) {
|
||||
// timer already stopped or cancelled, has nothing to do in this case
|
||||
|
@ -400,7 +406,7 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
|
|||
} else {
|
||||
assert(timer->executedBy != taosGetPthreadId());
|
||||
|
||||
const char* fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] fired, waiting...";
|
||||
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] fired, waiting...";
|
||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||
|
||||
for (int i = 1; atomic_load_8(&timer->state) != TIMER_STATE_STOPPED; i++) {
|
||||
|
@ -409,7 +415,7 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
|
|||
}
|
||||
}
|
||||
|
||||
fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] stopped.";
|
||||
fmt = "%s timer[id=%lld, fp=%p, param=%p] stopped.";
|
||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||
}
|
||||
|
||||
|
@ -448,7 +454,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
|
|||
bool stopped = false;
|
||||
tmr_obj_t* timer = findTimer(id);
|
||||
if (timer == NULL) {
|
||||
tmrTrace("timer[id=%lld] does not exist", id);
|
||||
tmrTrace("%s timer[id=%lld] does not exist", ctrl->label, id);
|
||||
} else {
|
||||
uint8_t state = __sync_val_compare_and_swap_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_CANCELED);
|
||||
if (!doStopTimer(timer, state)) {
|
||||
|
@ -463,7 +469,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
|
|||
return stopped;
|
||||
}
|
||||
|
||||
tmrTrace("timer[id=%lld] is reused", timer->id);
|
||||
tmrTrace("%s timer[id=%lld] is reused", ctrl->label, timer->id);
|
||||
|
||||
// wait until there's no other reference to this timer,
|
||||
// so that we can reuse this timer safely.
|
||||
|
@ -481,7 +487,13 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
|
|||
}
|
||||
|
||||
static void taosTmrModuleInit(void) {
|
||||
for (int i = 0; i < tListLen(tmrCtrls) - 1; ++i) {
|
||||
tmrCtrls = malloc(sizeof(tmr_ctrl_t) * taosMaxTmrCtrl);
|
||||
if (tmrCtrls == NULL) {
|
||||
tmrError("failed to allocate memory for timer controllers.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < taosMaxTmrCtrl - 1; ++i) {
|
||||
tmr_ctrl_t* ctrl = tmrCtrls + i;
|
||||
ctrl->next = ctrl + 1;
|
||||
}
|
||||
|
@ -526,17 +538,18 @@ void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* lab
|
|||
tmr_ctrl_t* ctrl = unusedTmrCtrl;
|
||||
if (ctrl != NULL) {
|
||||
unusedTmrCtrl = ctrl->next;
|
||||
numOfTmrCtrl++;
|
||||
}
|
||||
pthread_mutex_unlock(&tmrCtrlMutex);
|
||||
|
||||
if (ctrl == NULL) {
|
||||
tmrError("too many timer controllers, failed to create timer controller[label=%s].", label);
|
||||
tmrError("%s too many timer controllers, failed to create timer controller.", label);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strncpy(ctrl->label, label, sizeof(ctrl->label));
|
||||
ctrl->label[sizeof(ctrl->label) - 1] = 0;
|
||||
tmrTrace("timer controller[label=%s] is initialized.", label);
|
||||
tmrTrace("%s timer controller is initialized, number of timer controllers: %d.", label, numOfTmrCtrl);
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
|
@ -544,11 +557,12 @@ void taosTmrCleanUp(void* handle) {
|
|||
tmr_ctrl_t* ctrl = (tmr_ctrl_t*)handle;
|
||||
assert(ctrl != NULL && ctrl->label[0] != 0);
|
||||
|
||||
tmrTrace("timer controller[label=%s] is cleaned up.", ctrl->label);
|
||||
tmrTrace("%s timer controller is cleaned up.", ctrl->label);
|
||||
ctrl->label[0] = 0;
|
||||
|
||||
pthread_mutex_lock(&tmrCtrlMutex);
|
||||
ctrl->next = unusedTmrCtrl;
|
||||
numOfTmrCtrl--;
|
||||
unusedTmrCtrl = ctrl;
|
||||
pthread_mutex_unlock(&tmrCtrlMutex);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
char version[64] = "1.6.4.0";
|
||||
char compatible_version[64] = "1.6.1.0";
|
||||
char gitinfo[128] = "869171d2331eb25ba0901e88d33ae627bf5a9d91";
|
||||
char buildinfo[512] = "Built by ubuntu at 2019-11-07 22:31";
|
||||
char gitinfo[128] = "d04354a8ac2f7dd9ba521d755e5d484a203783d9";
|
||||
char buildinfo[512] = "Built by root at 2019-11-11 10:23";
|
||||
|
|
|
@ -9,5 +9,5 @@ TDengine's JDBC driver jar is not yet published to maven center repo, so we need
|
|||
## Compile the Demo Code and Run It
|
||||
To compile the demo project, go to the source directory ``TDengine/tests/examples/JDBC/JDBCDemo`` and execute
|
||||
<pre>mvn clean assembly:single package</pre>
|
||||
The ``pom.xml`` is configured to package all the dependencies into one executable jar file. To run it, go to ``TDengine/tests/examples/JDBC/JDBCDemo/target`` and execute
|
||||
The ``pom.xml`` is configured to package all the dependencies into one executable jar file. To run it, go to ``examples/JDBC/JDBCDemo/target`` and execute
|
||||
<pre>java -jar jdbcdemo-1.0-SNAPSHOT-jar-with-dependencies.jar</pre>
|
||||
|
|
Loading…
Reference in New Issue