diff --git a/Jenkinsfile b/Jenkinsfile
index edbe11d428d0381a81f64bbc823b5b51a5edf199..6dc55be4bd0e8a0c4c5cddfb0a265898d9211c3a 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,3 +1,47 @@
+
+properties([pipelineTriggers([githubPush()])])
+node {
+ git url: 'https://github.com/taosdata/TDengine'
+}
+
+
+// execute this before anything else, including requesting any time on an agent
+if (currentBuild.rawBuild.getCauses().toString().contains('BranchIndexingCause')) {
+ print "INFO: Build skipped due to trigger being Branch Indexing"
+ currentBuild.result = 'ABORTED' // optional, gives a better hint to the user that it's been skipped, rather than the default which shows it's successful
+ return
+}
+
+
+def pre_test(){
+ catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
+ sh '''
+ sudo rmtaos
+ '''
+ }
+ sh '''
+ cd ${WKC}
+ rm -rf *
+ cd ${WK}
+ git reset --hard
+ git checkout develop
+ git pull
+ cd ${WKC}
+ rm -rf *
+ mv ${WORKSPACE}/* .
+ cd ${WK}
+ export TZ=Asia/Harbin
+ date
+ rm -rf ${WK}/debug
+ mkdir debug
+ cd debug
+ cmake .. > /dev/null
+ make > /dev/null
+ make install > /dev/null
+ cd ${WKC}/tests
+ '''
+ return 1
+}
pipeline {
agent none
environment{
@@ -8,85 +52,31 @@ pipeline {
stages {
stage('Parallel test stage') {
parallel {
- stage('pytest') {
- agent{label '184'}
+ stage('python p1') {
+ agent{label 'p1'}
steps {
+ pre_test()
sh '''
- date
- cd ${WKC}
- git reset --hard
- git checkout develop
- git pull
- git submodule update
- cd ${WK}
- git reset --hard
- git checkout develop
- git pull
- export TZ=Asia/Harbin
- date
- rm -rf ${WK}/debug
- mkdir debug
- cd debug
- cmake .. > /dev/null
- make > /dev/null
- make install > /dev/null
cd ${WKC}/tests
- #./test-all.sh smoke
- ./test-all.sh pytest
+ ./test-all.sh p1
date'''
}
}
stage('test_b1') {
- agent{label 'master'}
+ agent{label 'b1'}
steps {
+ pre_test()
sh '''
- cd ${WKC}
- git reset --hard
- git checkout develop
- git pull
-
- git submodule update
- cd ${WK}
- git reset --hard
- git checkout develop
- git pull
- export TZ=Asia/Harbin
- date
- rm -rf ${WK}/debug
- mkdir debug
- cd debug
- cmake .. > /dev/null
- make > /dev/null
cd ${WKC}/tests
- #./test-all.sh smoke
./test-all.sh b1
date'''
}
}
stage('test_crash_gen') {
- agent{label "185"}
+ agent{label "b2"}
steps {
- sh '''
- cd ${WKC}
- git reset --hard
- git checkout develop
- git pull
-
- git submodule update
- cd ${WK}
- git reset --hard
- git checkout develop
- git pull
- export TZ=Asia/Harbin
-
- rm -rf ${WK}/debug
- mkdir debug
- cd debug
- cmake .. > /dev/null
- make > /dev/null
- cd ${WKC}/tests/pytest
- '''
+ pre_test()
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''
cd ${WKC}/tests/pytest
@@ -109,193 +99,42 @@ pipeline {
}
stage('test_valgrind') {
- agent{label "186"}
+ agent{label "b3"}
steps {
+ pre_test()
+ catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
+ sh '''
+ cd ${WKC}/tests/pytest
+ ./valgrind-test.sh 2>&1 > mem-error-out.log
+ ./handle_val_log.sh
+ '''
+ }
sh '''
- cd ${WKC}
- git reset --hard
- git checkout develop
- git pull
-
- git submodule update
- cd ${WK}
- git reset --hard
- git checkout develop
- git pull
- export TZ=Asia/Harbin
- date
- rm -rf ${WK}/debug
- mkdir debug
- cd debug
- cmake .. > /dev/null
- make > /dev/null
- cd ${WKC}/tests/pytest
- ./valgrind-test.sh 2>&1 > mem-error-out.log
- ./handle_val_log.sh
-
date
cd ${WKC}/tests
./test-all.sh b3
date'''
}
}
- stage('connector'){
- agent{label "release"}
+ stage('python p2'){
+ agent{label "p2"}
steps{
- sh'''
- cd ${WORKSPACE}
- git checkout develop
+ pre_test()
+ sh '''
+ date
+ cd ${WKC}/tests
+ ./test-all.sh p2
+ date
'''
- catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
- sh '''
- cd ${WORKSPACE}/tests/gotest
- bash batchtest.sh
- '''
- }
- catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
- sh '''
- cd ${WORKSPACE}/tests/examples/python/PYTHONConnectorChecker
- python3 PythonChecker.py
- '''
- }
- catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
- sh '''
- cd ${WORKSPACE}/tests/examples/JDBC/JDBCDemo/
- mvn clean package assembly:single >/dev/null
- java -jar target/jdbcChecker-SNAPSHOT-jar-with-dependencies.jar -host 127.0.0.1
- '''
- }
- catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
- sh '''
- cd ${JENKINS_HOME}/workspace/C#NET/src/CheckC#
- dotnet run
- '''
- }
}
}
- stage('arm64_build'){
- agent{label 'arm64'}
- steps{
- sh '''
- cd ${WK}
- git fetch
- git checkout develop
- git pull
- cd ${WKC}
- git fetch
- git checkout develop
- git pull
- git submodule update
- cd ${WKC}/packaging
- ./release.sh -v cluster -c aarch64 -n 2.0.0.0 -m 2.0.0.0
-
- '''
- }
- }
- stage('arm32_build'){
- agent{label 'arm32'}
- steps{
- catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
- sh '''
- cd ${WK}
- git fetch
- git checkout develop
- git pull
- cd ${WKC}
- git fetch
- git checkout develop
- git pull
- git submodule update
- cd ${WKC}/packaging
- ./release.sh -v cluster -c aarch32 -n 2.0.0.0 -m 2.0.0.0
-
- '''
- }
-
- }
- }
+
+
}
}
}
- post {
- success {
- emailext (
- subject: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
- body: '''
-
-
-
-
-
-
-
-
- 构建信息
-
|
-
-
-
-
-
- - 构建名称>>分支:${PROJECT_NAME}
- - 构建结果: Successful
- - 构建编号:${BUILD_NUMBER}
- - 触发用户:${CAUSE}
- - 变更概要:${CHANGES}
- - 构建地址:${BUILD_URL}
- - 构建日志:${BUILD_URL}console
- - 变更集:${JELLY_SCRIPT}
-
-
- |
-
-
-
- ''',
- to: "yqliu@taosdata.com,pxiao@taosdata.com",
- from: "support@taosdata.com"
- )
- }
- failure {
- emailext (
- subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
- body: '''
-
-
-
-
-
-
-
-
- 构建信息
-
|
-
-
-
-
-
- - 构建名称>>分支:${PROJECT_NAME}
- - 构建结果: Successful
- - 构建编号:${BUILD_NUMBER}
- - 触发用户:${CAUSE}
- - 变更概要:${CHANGES}
- - 构建地址:${BUILD_URL}
- - 构建日志:${BUILD_URL}console
- - 变更集:${JELLY_SCRIPT}
-
-
- |
-
-
-
- ''',
- to: "yqliu@taosdata.com,pxiao@taosdata.com",
- from: "support@taosdata.com"
- )
- }
- }
-}
\ No newline at end of file
+
+}
diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg
index 8a68d02dfd232e557d0877e738aa8aa33a02467f..8c2ef193826ca6b433b0923b76461527cd436400 100644
--- a/packaging/cfg/taos.cfg
+++ b/packaging/cfg/taos.cfg
@@ -29,8 +29,12 @@
# number of threads per CPU core
# numOfThreadsPerCore 1.0
-# the proportion of total threads responsible for query
-# ratioOfQueryThreads 0.5
+# the proportion of total CPU cores available for query processing
+# 2.0: the query threads will be set to double of the CPU cores.
+# 1.0: all CPU cores are available for query processing [default].
+# 0.5: only half of the CPU cores are available for query.
+# 0.0: only one core available.
+# tsRatioOfQueryCores 1.0
# number of management nodes in the system
# numOfMnodes 3
@@ -265,5 +269,5 @@
# enable/disable stream (continuous query)
# stream 1
-# only 50% CPU resources will be used in query processing
-# halfCoresForQuery 0
+# in retrieve blocking model, only in 50% query threads will be used in query processing in dnode
+# retrieveBlockingModel 0
diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c
index 960f2561e294c1aad2be6218143166dbd5d9cc46..994dace1e3f5c129970efefbceee806d0e803c82 100644
--- a/src/client/src/tscServer.c
+++ b/src/client/src/tscServer.c
@@ -152,7 +152,13 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
SRpcEpSet * epSet = &pRsp->epSet;
if (epSet->numOfEps > 0) {
tscEpSetHtons(epSet);
- tscUpdateMgmtEpSet(pSql, epSet);
+ if (!tscEpSetIsEqual(&pSql->pTscObj->tscCorMgmtEpSet->epSet, epSet)) {
+ tscTrace("%p updating epset: numOfEps: %d, inUse: %d", pSql, epSet->numOfEps, epSet->inUse);
+ for (int8_t i = 0; i < epSet->numOfEps; i++) {
+ tscTrace("endpoint %d: fqdn = %s, port=%d", i, epSet->fqdn[i], epSet->port[i]);
+ }
+ tscUpdateMgmtEpSet(pSql, epSet);
+ }
}
pSql->pTscObj->connId = htonl(pRsp->connId);
diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h
index 5b88c9b0d02804781c221d0bc36f0e944f34b049..b5bb8998b4f9b6f81cc681d07b74a5e32e0410f7 100644
--- a/src/common/inc/tglobal.h
+++ b/src/common/inc/tglobal.h
@@ -46,7 +46,7 @@ extern int32_t tsShellActivityTimer;
extern uint32_t tsMaxTmrCtrl;
extern float tsNumOfThreadsPerCore;
extern int32_t tsNumOfCommitThreads;
-extern float tsRatioOfQueryThreads; // todo remove it
+extern float tsRatioOfQueryCores;
extern int8_t tsDaylight;
extern char tsTimezone[];
extern char tsLocale[];
@@ -57,7 +57,7 @@ extern char tsTempDir[];
//query buffer management
extern int32_t tsQueryBufferSize; // maximum allowed usage buffer for each data node during query processing
-extern int32_t tsHalfCoresForQuery; // only 50% will be used in query processing
+extern int32_t tsRetrieveBlockingModel; // only 50% will be used in query processing
// client
extern int32_t tsTableMetaKeepTimer;
diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c
index 17eb5714e0272bcebe21de84d938f94708b7c4d9..662df490273e9ec01bec5951c05b7516827cf44f 100644
--- a/src/common/src/tglobal.c
+++ b/src/common/src/tglobal.c
@@ -52,7 +52,7 @@ int32_t tsMaxConnections = 5000;
int32_t tsShellActivityTimer = 3; // second
float tsNumOfThreadsPerCore = 1.0f;
int32_t tsNumOfCommitThreads = 1;
-float tsRatioOfQueryThreads = 0.5f;
+float tsRatioOfQueryCores = 1.0f;
int8_t tsDaylight = 0;
char tsTimezone[TSDB_TIMEZONE_LEN] = {0};
char tsLocale[TSDB_LOCALE_LEN] = {0};
@@ -107,8 +107,8 @@ int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance
// positive value (in MB)
int32_t tsQueryBufferSize = -1;
-// only 50% cpu will be used in query processing in dnode
-int32_t tsHalfCoresForQuery = 0;
+// in retrieve blocking model, the retrieve threads will wait for the completion of the query processing.
+int32_t tsRetrieveBlockingModel = 0;
// db parameters
int32_t tsCacheBlockSize = TSDB_DEFAULT_CACHE_BLOCK_SIZE;
@@ -444,12 +444,12 @@ static void doInitGlobalConfig(void) {
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
- cfg.option = "ratioOfQueryThreads";
- cfg.ptr = &tsRatioOfQueryThreads;
+ cfg.option = "ratioOfQueryCores";
+ cfg.ptr = &tsRatioOfQueryCores;
cfg.valType = TAOS_CFG_VTYPE_FLOAT;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
- cfg.minValue = 0.1f;
- cfg.maxValue = 0.9f;
+ cfg.minValue = 0.0f;
+ cfg.maxValue = 2.0f;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
@@ -887,8 +887,8 @@ static void doInitGlobalConfig(void) {
cfg.unitType = TAOS_CFG_UTYPE_BYTE;
taosInitConfigOption(cfg);
- cfg.option = "halfCoresForQuery";
- cfg.ptr = &tsHalfCoresForQuery;
+ cfg.option = "retrieveBlockingModel";
+ cfg.ptr = &tsRetrieveBlockingModel;
cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 0;
diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c
index d76af4e3dcf4027191e7cb92e0a9701e2c30c942..79cc70005b6e83bc1c455abb7cd3709ae29a8643 100644
--- a/src/dnode/src/dnodeShell.c
+++ b/src/dnode/src/dnodeShell.c
@@ -70,8 +70,7 @@ int32_t dnodeInitShell() {
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_NETWORK_TEST] = dnodeSendStartupStep;
- int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore;
- numOfThreads = (int32_t) ((1.0 - tsRatioOfQueryThreads) * numOfThreads / 2.0);
+ int32_t numOfThreads = (tsNumOfCores * tsNumOfThreadsPerCore) / 2.0;
if (numOfThreads < 1) {
numOfThreads = 1;
}
diff --git a/src/dnode/src/dnodeVRead.c b/src/dnode/src/dnodeVRead.c
index 0d4add2a5c4c793667bb36300fbe3baf1894ce6a..3f31e4937052d7a505031b4c8083ae1acd00bf6c 100644
--- a/src/dnode/src/dnodeVRead.c
+++ b/src/dnode/src/dnodeVRead.c
@@ -26,16 +26,20 @@ static SWorkerPool tsVQueryWP;
static SWorkerPool tsVFetchWP;
int32_t dnodeInitVRead() {
+ const int32_t maxFetchThreads = 4;
+
+ // calculate the available query thread
+ float threadsForQuery = MAX(tsNumOfCores * tsRatioOfQueryCores, 1);
+
tsVQueryWP.name = "vquery";
tsVQueryWP.workerFp = dnodeProcessReadQueue;
- tsVQueryWP.min = tsNumOfCores;
- tsVQueryWP.max = tsNumOfCores/* * tsNumOfThreadsPerCore*/;
-// if (tsVQueryWP.max <= tsVQueryWP.min * 2) tsVQueryWP.max = 2 * tsVQueryWP.min;
+ tsVQueryWP.min = (int32_t) threadsForQuery;
+ tsVQueryWP.max = tsVQueryWP.min;
if (tWorkerInit(&tsVQueryWP) != 0) return -1;
tsVFetchWP.name = "vfetch";
tsVFetchWP.workerFp = dnodeProcessReadQueue;
- tsVFetchWP.min = MIN(4, tsNumOfCores);
+ tsVFetchWP.min = MIN(maxFetchThreads, tsNumOfCores);
tsVFetchWP.max = tsVFetchWP.min;
if (tWorkerInit(&tsVFetchWP) != 0) return -1;
diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c
index bdfea26294201e4ee8a96acc3ec0a8c17c524f13..588d21574b6d4c07b746ee487b0449c705186298 100644
--- a/src/kit/taosdump/taosdump.c
+++ b/src/kit/taosdump/taosdump.c
@@ -14,6 +14,9 @@
*/
#include
+#include
+#include
+
#include "os.h"
#include "taos.h"
#include "taosdef.h"
@@ -366,6 +369,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
static struct argp argp = {options, parse_opt, args_doc, doc};
static resultStatistics g_resultStatistics = {0};
static FILE *g_fpOfResult = NULL;
+static int g_numOfCores = 1;
int taosDumpOut(struct arguments *arguments);
int taosDumpIn(struct arguments *arguments);
@@ -378,7 +382,7 @@ int32_t taosDumpTable(char *table, char *metric, struct arguments *arguments, FI
int taosDumpTableData(FILE *fp, char *tbname, struct arguments *arguments, TAOS* taosCon, char* dbName);
int taosCheckParam(struct arguments *arguments);
void taosFreeDbInfos();
-static void taosStartDumpOutWorkThreads(struct arguments* args, int32_t numOfThread, char *dbName);
+static void taosStartDumpOutWorkThreads(void* taosCon, struct arguments* args, int32_t numOfThread, char *dbName);
struct arguments tsArguments = {
// connection option
@@ -540,6 +544,8 @@ int main(int argc, char *argv[]) {
}
}
+ g_numOfCores = (int32_t)sysconf(_SC_NPROCESSORS_ONLN);
+
time_t tTime = time(NULL);
struct tm tm = *localtime(&tTime);
@@ -692,64 +698,97 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu
sprintf(tmpCommand, "select tbname from %s", metric);
- TAOS_RES *result = taos_query(taosCon, tmpCommand);
- int32_t code = taos_errno(result);
+ TAOS_RES *res = taos_query(taosCon, tmpCommand);
+ int32_t code = taos_errno(res);
if (code != 0) {
fprintf(stderr, "failed to run command %s\n", tmpCommand);
free(tmpCommand);
- taos_free_result(result);
+ taos_free_result(res);
return -1;
}
+ free(tmpCommand);
- TAOS_FIELD *fields = taos_fetch_fields(result);
+ char tmpBuf[TSDB_FILENAME_LEN + 1];
+ memset(tmpBuf, 0, TSDB_FILENAME_LEN);
+ sprintf(tmpBuf, ".select-tbname.tmp");
+ fd = open(tmpBuf, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH);
+ if (fd == -1) {
+ fprintf(stderr, "failed to open temp file: %s\n", tmpBuf);
+ taos_free_result(res);
+ return -1;
+ }
- int32_t numOfTable = 0;
- int32_t numOfThread = *totalNumOfThread;
- char tmpFileName[TSDB_FILENAME_LEN + 1];
- while ((row = taos_fetch_row(result)) != NULL) {
- if (0 == numOfTable) {
- memset(tmpFileName, 0, TSDB_FILENAME_LEN);
- sprintf(tmpFileName, ".tables.tmp.%d", numOfThread);
- fd = open(tmpFileName, O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH);
- if (fd == -1) {
- fprintf(stderr, "failed to open temp file: %s\n", tmpFileName);
- taos_free_result(result);
- for (int32_t loopCnt = 0; loopCnt < numOfThread; loopCnt++) {
- sprintf(tmpFileName, ".tables.tmp.%d", loopCnt);
- (void)remove(tmpFileName);
- }
- free(tmpCommand);
- return -1;
- }
-
- numOfThread++;
- }
+ TAOS_FIELD *fields = taos_fetch_fields(res);
+ int32_t numOfTable = 0;
+ while ((row = taos_fetch_row(res)) != NULL) {
+
memset(&tableRecord, 0, sizeof(STableRecord));
tstrncpy(tableRecord.name, (char *)row[0], fields[0].bytes);
tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN);
-
- taosWrite(fd, &tableRecord, sizeof(STableRecord));
-
+
+ taosWrite(fd, &tableRecord, sizeof(STableRecord));
numOfTable++;
+ }
+ taos_free_result(res);
+ lseek(fd, 0, SEEK_SET);
+
+ int maxThreads = arguments->thread_num;
+ int tableOfPerFile ;
+ if (numOfTable <= arguments->thread_num) {
+ tableOfPerFile = 1;
+ maxThreads = numOfTable;
+ } else {
+ tableOfPerFile = numOfTable / arguments->thread_num;
+ if (0 != numOfTable % arguments->thread_num) {
+ tableOfPerFile += 1;
+ }
+ }
- if (numOfTable >= arguments->table_batch) {
- numOfTable = 0;
+ char* tblBuf = (char*)calloc(1, tableOfPerFile * sizeof(STableRecord));
+ if (NULL == tblBuf){
+ fprintf(stderr, "failed to calloc %" PRIzu "\n", tableOfPerFile * sizeof(STableRecord));
+ close(fd);
+ return -1;
+ }
+
+ int32_t numOfThread = *totalNumOfThread;
+ int subFd = -1;
+ for (; numOfThread < maxThreads; numOfThread++) {
+ memset(tmpBuf, 0, TSDB_FILENAME_LEN);
+ sprintf(tmpBuf, ".tables.tmp.%d", numOfThread);
+ subFd = open(tmpBuf, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH);
+ if (subFd == -1) {
+ fprintf(stderr, "failed to open temp file: %s\n", tmpBuf);
+ for (int32_t loopCnt = 0; loopCnt < numOfThread; loopCnt++) {
+ sprintf(tmpBuf, ".tables.tmp.%d", loopCnt);
+ (void)remove(tmpBuf);
+ }
+ sprintf(tmpBuf, ".select-tbname.tmp");
+ (void)remove(tmpBuf);
close(fd);
- fd = -1;
+ return -1;
}
+
+ // read tableOfPerFile for fd, write to subFd
+ ssize_t readLen = read(fd, tblBuf, tableOfPerFile * sizeof(STableRecord));
+ if (readLen <= 0) {
+ close(subFd);
+ break;
+ }
+ taosWrite(subFd, tblBuf, readLen);
+ close(subFd);
}
+
+ sprintf(tmpBuf, ".select-tbname.tmp");
+ (void)remove(tmpBuf);
if (fd >= 0) {
close(fd);
fd = -1;
- }
-
- taos_free_result(result);
+ }
*totalNumOfThread = numOfThread;
-
- free(tmpCommand);
return 0;
}
@@ -946,7 +985,7 @@ int taosDumpOut(struct arguments *arguments) {
}
// start multi threads to dumpout
- taosStartDumpOutWorkThreads(arguments, totalNumOfThread, dbInfos[0]->name);
+ taosStartDumpOutWorkThreads(taos, arguments, totalNumOfThread, dbInfos[0]->name);
char tmpFileName[TSDB_FILENAME_LEN + 1];
_clean_tmp_file:
@@ -1181,34 +1220,34 @@ void* taosDumpOutWorkThreadFp(void *arg)
STableRecord tableRecord;
int fd;
- char tmpFileName[TSDB_FILENAME_LEN*4] = {0};
- sprintf(tmpFileName, ".tables.tmp.%d", pThread->threadIndex);
- fd = open(tmpFileName, O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH);
+ char tmpBuf[TSDB_FILENAME_LEN*4] = {0};
+ sprintf(tmpBuf, ".tables.tmp.%d", pThread->threadIndex);
+ fd = open(tmpBuf, O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH);
if (fd == -1) {
- fprintf(stderr, "taosDumpTableFp() failed to open temp file: %s\n", tmpFileName);
+ fprintf(stderr, "taosDumpTableFp() failed to open temp file: %s\n", tmpBuf);
return NULL;
}
FILE *fp = NULL;
- memset(tmpFileName, 0, TSDB_FILENAME_LEN + 128);
+ memset(tmpBuf, 0, TSDB_FILENAME_LEN + 128);
if (tsArguments.outpath[0] != 0) {
- sprintf(tmpFileName, "%s/%s.tables.%d.sql", tsArguments.outpath, pThread->dbName, pThread->threadIndex);
+ sprintf(tmpBuf, "%s/%s.tables.%d.sql", tsArguments.outpath, pThread->dbName, pThread->threadIndex);
} else {
- sprintf(tmpFileName, "%s.tables.%d.sql", pThread->dbName, pThread->threadIndex);
+ sprintf(tmpBuf, "%s.tables.%d.sql", pThread->dbName, pThread->threadIndex);
}
- fp = fopen(tmpFileName, "w");
+ fp = fopen(tmpBuf, "w");
if (fp == NULL) {
- fprintf(stderr, "failed to open file %s\n", tmpFileName);
+ fprintf(stderr, "failed to open file %s\n", tmpBuf);
close(fd);
return NULL;
}
- memset(tmpFileName, 0, TSDB_FILENAME_LEN);
- sprintf(tmpFileName, "use %s", pThread->dbName);
+ memset(tmpBuf, 0, TSDB_FILENAME_LEN);
+ sprintf(tmpBuf, "use %s", pThread->dbName);
- TAOS_RES* tmpResult = taos_query(pThread->taosCon, tmpFileName);
+ TAOS_RES* tmpResult = taos_query(pThread->taosCon, tmpBuf);
int32_t code = taos_errno(tmpResult);
if (code != 0) {
fprintf(stderr, "invalid database %s\n", pThread->dbName);
@@ -1218,6 +1257,9 @@ void* taosDumpOutWorkThreadFp(void *arg)
return NULL;
}
+ int fileNameIndex = 1;
+ int tablesInOneFile = 0;
+ int64_t lastRowsPrint = 5000000;
fprintf(fp, "USE %s;\n\n", pThread->dbName);
while (1) {
ssize_t readLen = read(fd, &tableRecord, sizeof(STableRecord));
@@ -1228,6 +1270,33 @@ void* taosDumpOutWorkThreadFp(void *arg)
// TODO: sum table count and table rows by self
pThread->tablesOfDumpOut++;
pThread->rowsOfDumpOut += ret;
+
+ if (pThread->rowsOfDumpOut >= lastRowsPrint) {
+ printf(" %"PRId64 " rows already be dumpout from database %s\n", pThread->rowsOfDumpOut, pThread->dbName);
+ lastRowsPrint += 5000000;
+ }
+
+ tablesInOneFile++;
+ if (tablesInOneFile >= tsArguments.table_batch) {
+ fclose(fp);
+ tablesInOneFile = 0;
+
+ memset(tmpBuf, 0, TSDB_FILENAME_LEN + 128);
+ if (tsArguments.outpath[0] != 0) {
+ sprintf(tmpBuf, "%s/%s.tables.%d-%d.sql", tsArguments.outpath, pThread->dbName, pThread->threadIndex, fileNameIndex);
+ } else {
+ sprintf(tmpBuf, "%s.tables.%d-%d.sql", pThread->dbName, pThread->threadIndex, fileNameIndex);
+ }
+ fileNameIndex++;
+
+ fp = fopen(tmpBuf, "w");
+ if (fp == NULL) {
+ fprintf(stderr, "failed to open file %s\n", tmpBuf);
+ close(fd);
+ taos_free_result(tmpResult);
+ return NULL;
+ }
+ }
}
}
@@ -1238,7 +1307,7 @@ void* taosDumpOutWorkThreadFp(void *arg)
return NULL;
}
-static void taosStartDumpOutWorkThreads(struct arguments* args, int32_t numOfThread, char *dbName)
+static void taosStartDumpOutWorkThreads(void* taosCon, struct arguments* args, int32_t numOfThread, char *dbName)
{
pthread_attr_t thattr;
SThreadParaObj *threadObj = (SThreadParaObj *)calloc(numOfThread, sizeof(SThreadParaObj));
@@ -1249,12 +1318,7 @@ static void taosStartDumpOutWorkThreads(struct arguments* args, int32_t numOfTh
pThread->threadIndex = t;
pThread->totalThreads = numOfThread;
tstrncpy(pThread->dbName, dbName, TSDB_TABLE_NAME_LEN);
- pThread->taosCon = taos_connect(args->host, args->user, args->password, NULL, args->port);
-
- if (pThread->taosCon == NULL) {
- fprintf(stderr, "ERROR: thread:%d failed connect to TDengine, reason:%s\n", pThread->threadIndex, taos_errstr(NULL));
- exit(0);
- }
+ pThread->taosCon = taosCon;
pthread_attr_init(&thattr);
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
@@ -1273,7 +1337,6 @@ static void taosStartDumpOutWorkThreads(struct arguments* args, int32_t numOfTh
int64_t totalRowsOfDumpOut = 0;
int64_t totalChildTblsOfDumpOut = 0;
for (int32_t t = 0; t < numOfThread; ++t) {
- taos_close(threadObj[t].taosCon);
totalChildTblsOfDumpOut += threadObj[t].tablesOfDumpOut;
totalRowsOfDumpOut += threadObj[t].rowsOfDumpOut;
}
@@ -1398,44 +1461,81 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao
return -1;
}
- TAOS_FIELD *fields = taos_fetch_fields(res);
-
- int32_t numOfTable = 0;
- int32_t numOfThread = 0;
- char tmpFileName[TSDB_FILENAME_LEN + 1];
- while ((row = taos_fetch_row(res)) != NULL) {
- if (0 == numOfTable) {
- memset(tmpFileName, 0, TSDB_FILENAME_LEN);
- sprintf(tmpFileName, ".tables.tmp.%d", numOfThread);
- fd = open(tmpFileName, O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH);
- if (fd == -1) {
- fprintf(stderr, "failed to open temp file: %s\n", tmpFileName);
- taos_free_result(res);
- for (int32_t loopCnt = 0; loopCnt < numOfThread; loopCnt++) {
- sprintf(tmpFileName, ".tables.tmp.%d", loopCnt);
- (void)remove(tmpFileName);
- }
- return -1;
- }
+ char tmpBuf[TSDB_FILENAME_LEN + 1];
+ memset(tmpBuf, 0, TSDB_FILENAME_LEN);
+ sprintf(tmpBuf, ".show-tables.tmp");
+ fd = open(tmpBuf, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH);
+ if (fd == -1) {
+ fprintf(stderr, "failed to open temp file: %s\n", tmpBuf);
+ taos_free_result(res);
+ return -1;
+ }
- numOfThread++;
- }
+ TAOS_FIELD *fields = taos_fetch_fields(res);
+ int32_t numOfTable = 0;
+ while ((row = taos_fetch_row(res)) != NULL) {
memset(&tableRecord, 0, sizeof(STableRecord));
tstrncpy(tableRecord.name, (char *)row[TSDB_SHOW_TABLES_NAME_INDEX], fields[TSDB_SHOW_TABLES_NAME_INDEX].bytes);
tstrncpy(tableRecord.metric, (char *)row[TSDB_SHOW_TABLES_METRIC_INDEX], fields[TSDB_SHOW_TABLES_METRIC_INDEX].bytes);
-
+
taosWrite(fd, &tableRecord, sizeof(STableRecord));
-
+
numOfTable++;
+ }
+ taos_free_result(res);
+ lseek(fd, 0, SEEK_SET);
- if (numOfTable >= arguments->table_batch) {
- numOfTable = 0;
+ int maxThreads = tsArguments.thread_num;
+ int tableOfPerFile ;
+ if (numOfTable <= tsArguments.thread_num) {
+ tableOfPerFile = 1;
+ maxThreads = numOfTable;
+ } else {
+ tableOfPerFile = numOfTable / tsArguments.thread_num;
+ if (0 != numOfTable % tsArguments.thread_num) {
+ tableOfPerFile += 1;
+ }
+ }
+
+ char* tblBuf = (char*)calloc(1, tableOfPerFile * sizeof(STableRecord));
+ if (NULL == tblBuf){
+ fprintf(stderr, "failed to calloc %" PRIzu "\n", tableOfPerFile * sizeof(STableRecord));
+ close(fd);
+ return -1;
+ }
+
+ int32_t numOfThread = 0;
+ int subFd = -1;
+ for (numOfThread = 0; numOfThread < maxThreads; numOfThread++) {
+ memset(tmpBuf, 0, TSDB_FILENAME_LEN);
+ sprintf(tmpBuf, ".tables.tmp.%d", numOfThread);
+ subFd = open(tmpBuf, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH);
+ if (subFd == -1) {
+ fprintf(stderr, "failed to open temp file: %s\n", tmpBuf);
+ for (int32_t loopCnt = 0; loopCnt < numOfThread; loopCnt++) {
+ sprintf(tmpBuf, ".tables.tmp.%d", loopCnt);
+ (void)remove(tmpBuf);
+ }
+ sprintf(tmpBuf, ".show-tables.tmp");
+ (void)remove(tmpBuf);
close(fd);
- fd = -1;
+ return -1;
}
+
+ // read tableOfPerFile for fd, write to subFd
+ ssize_t readLen = read(fd, tblBuf, tableOfPerFile * sizeof(STableRecord));
+ if (readLen <= 0) {
+ close(subFd);
+ break;
+ }
+ taosWrite(subFd, tblBuf, readLen);
+ close(subFd);
}
+ sprintf(tmpBuf, ".show-tables.tmp");
+ (void)remove(tmpBuf);
+
if (fd >= 0) {
close(fd);
fd = -1;
@@ -1444,10 +1544,10 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao
taos_free_result(res);
// start multi threads to dumpout
- taosStartDumpOutWorkThreads(arguments, numOfThread, dbInfo->name);
+ taosStartDumpOutWorkThreads(taosCon, arguments, numOfThread, dbInfo->name);
for (int loopCnt = 0; loopCnt < numOfThread; loopCnt++) {
- sprintf(tmpFileName, ".tables.tmp.%d", loopCnt);
- (void)remove(tmpFileName);
+ sprintf(tmpBuf, ".tables.tmp.%d", loopCnt);
+ (void)remove(tmpBuf);
}
return 0;
@@ -1552,8 +1652,8 @@ void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, int numOfCols
}
int taosDumpTableData(FILE *fp, char *tbname, struct arguments *arguments, TAOS* taosCon, char* dbName) {
- /* char temp[MAX_COMMAND_SIZE] = "\0"; */
- int64_t totalRows = 0;
+ int64_t lastRowsPrint = 5000000;
+ int64_t totalRows = 0;
int count = 0;
char *pstr = NULL;
TAOS_ROW row = NULL;
@@ -1680,9 +1780,14 @@ int taosDumpTableData(FILE *fp, char *tbname, struct arguments *arguments, TAOS*
curr_sqlstr_len += sprintf(pstr + curr_sqlstr_len, ") ");
- totalRows++;
+ totalRows++;
count++;
fprintf(fp, "%s", tmpBuffer);
+
+ if (totalRows >= lastRowsPrint) {
+ printf(" %"PRId64 " rows already be dumpout from %s.%s\n", totalRows, dbName, tbname);
+ lastRowsPrint += 5000000;
+ }
total_sqlstr_len += curr_sqlstr_len;
@@ -2048,6 +2153,7 @@ int taosDumpInOneFile(TAOS * taos, FILE* fp, char* fcharset, char* encode, c
return -1;
}
+ int lastRowsPrint = 5000000;
int lineNo = 0;
while ((read_len = getline(&line, &line_len, fp)) != -1) {
++lineNo;
@@ -2074,7 +2180,12 @@ int taosDumpInOneFile(TAOS * taos, FILE* fp, char* fcharset, char* encode, c
}
memset(cmd, 0, TSDB_MAX_ALLOWED_SQL_LEN);
- cmd_len = 0;
+ cmd_len = 0;
+
+ if (lineNo >= lastRowsPrint) {
+ printf(" %d lines already be executed from file %s\n", lineNo, fileName);
+ lastRowsPrint += 5000000;
+ }
}
tfree(cmd);
@@ -2101,7 +2212,7 @@ void* taosDumpInWorkThreadFp(void *arg)
return NULL;
}
-static void taosStartDumpInWorkThreads(struct arguments *args)
+static void taosStartDumpInWorkThreads(void* taosCon, struct arguments *args)
{
pthread_attr_t thattr;
SThreadParaObj *pThread;
@@ -2116,11 +2227,7 @@ static void taosStartDumpInWorkThreads(struct arguments *args)
pThread = threadObj + t;
pThread->threadIndex = t;
pThread->totalThreads = totalThreads;
- pThread->taosCon = taos_connect(args->host, args->user, args->password, NULL, args->port);
- if (pThread->taosCon == NULL) {
- fprintf(stderr, "ERROR: thread:%d failed connect to TDengine, reason:%s\n", pThread->threadIndex, taos_errstr(NULL));
- exit(0);
- }
+ pThread->taosCon = taosCon;
pthread_attr_init(&thattr);
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
@@ -2169,7 +2276,7 @@ int taosDumpIn(struct arguments *arguments) {
taosDumpInOneFile(taos, fp, tsfCharset, arguments->encode, tsDbSqlFile);
}
- taosStartDumpInWorkThreads(arguments);
+ taosStartDumpInWorkThreads(taos, arguments);
taos_close(taos);
taosFreeSQLFiles();
diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c
index e83cafa0ac526b88546f7a29a144e3cdc86cbe50..58f05c9d9d55381ce1ad3073685640f067c0932b 100644
--- a/src/query/src/qExecutor.c
+++ b/src/query/src/qExecutor.c
@@ -7635,7 +7635,7 @@ int32_t qRetrieveQueryResultInfo(qinfo_t qinfo, bool* buildRes, void* pRspContex
int32_t code = TSDB_CODE_SUCCESS;
- if (tsHalfCoresForQuery) {
+ if (tsRetrieveBlockingModel) {
pQInfo->rspContext = pRspContext;
tsem_wait(&pQInfo->ready);
*buildRes = true;
diff --git a/src/query/src/qFilterfunc.c b/src/query/src/qFilterfunc.c
index b6050dddd8fecc8f0a0b764313efcbe2a630113a..2a40533e90218170a465a4f439477e102123157f 100644
--- a/src/query/src/qFilterfunc.c
+++ b/src/query/src/qFilterfunc.c
@@ -21,6 +21,12 @@
#include "tcompare.h"
#include "tsqlfunction.h"
+#define FLT_EQUAL(_x, _y) (fabs((_x) - (_y)) <= (4 * FLT_EPSILON))
+#define FLT_GREATER(_x, _y) (!FLT_EQUAL((_x), (_y)) && ((_x) > (_y)))
+#define FLT_LESS(_x, _y) (!FLT_EQUAL((_x), (_y)) && ((_x) < (_y)))
+#define FLT_GREATEREQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) > (_y)))
+#define FLT_LESSEQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) < (_y)))
+
bool less_i8(SColumnFilterElem *pFilter, char *minval, char *maxval) {
return (*(int8_t *)minval < pFilter->filterInfo.upperBndi);
}
@@ -38,35 +44,35 @@ bool less_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) {
}
bool less_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) {
- return (*(float *)minval < pFilter->filterInfo.upperBndd);
+ return FLT_LESS(*(float*)minval, pFilter->filterInfo.upperBndd);
}
bool less_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
- return (*(double *)minval < pFilter->filterInfo.upperBndd);
+ return *(double *)minval < pFilter->filterInfo.upperBndd;
}
//////////////////////////////////////////////////////////////////
-bool large_i8(SColumnFilterElem *pFilter, char *minval, char *maxval) {
+bool larger_i8(SColumnFilterElem *pFilter, char *minval, char *maxval) {
return (*(int8_t *)maxval > pFilter->filterInfo.lowerBndi);
}
-bool large_i16(SColumnFilterElem *pFilter, char *minval, char *maxval) {
+bool larger_i16(SColumnFilterElem *pFilter, char *minval, char *maxval) {
return (*(int16_t *)maxval > pFilter->filterInfo.lowerBndi);
}
-bool large_i32(SColumnFilterElem *pFilter, char *minval, char *maxval) {
+bool larger_i32(SColumnFilterElem *pFilter, char *minval, char *maxval) {
return (*(int32_t *)maxval > pFilter->filterInfo.lowerBndi);
}
-bool large_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) {
+bool larger_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) {
return (*(int64_t *)maxval > pFilter->filterInfo.lowerBndi);
}
-bool large_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) {
- return (*(float *)maxval > pFilter->filterInfo.lowerBndd);
+bool larger_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) {
+ return FLT_GREATER(*(float*)maxval, pFilter->filterInfo.lowerBndd);
}
-bool large_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
+bool larger_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
return (*(double *)maxval > pFilter->filterInfo.lowerBndd);
}
/////////////////////////////////////////////////////////////////////
@@ -88,10 +94,14 @@ bool lessEqual_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) {
}
bool lessEqual_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) {
- return (*(float *)minval <= pFilter->filterInfo.upperBndd);
+ return FLT_LESSEQUAL(*(float*)minval, pFilter->filterInfo.upperBndd);
}
bool lessEqual_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
+ if ((fabs(*(double*)minval) - pFilter->filterInfo.upperBndd) <= 2 * DBL_EPSILON) {
+ return true;
+ }
+
return (*(double *)minval <= pFilter->filterInfo.upperBndd);
}
@@ -113,11 +123,15 @@ bool largeEqual_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) {
}
bool largeEqual_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) {
- return (*(float *)maxval >= pFilter->filterInfo.lowerBndd);
+ return FLT_GREATEREQUAL(*(float*)maxval, pFilter->filterInfo.lowerBndd);
}
bool largeEqual_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
- return (*(double *)maxval >= pFilter->filterInfo.lowerBndd);
+ if (fabs(*(double *)maxval - pFilter->filterInfo.lowerBndd) <= 2 * DBL_EPSILON) {
+ return true;
+ }
+
+ return (*(double *)maxval - pFilter->filterInfo.lowerBndd > (2 * DBL_EPSILON));
}
////////////////////////////////////////////////////////////////////////
@@ -162,10 +176,12 @@ bool equal_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) {
}
}
+// user specified input filter value and the original saved float value may needs to
+// increase the tolerance to obtain the correct result.
bool equal_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) {
if (*(float *)minval == *(float *)maxval) {
- return (fabs(*(float *)minval - pFilter->filterInfo.lowerBndd) <= FLT_EPSILON);
- } else { /* range filter */
+ return FLT_EQUAL(*(float*)minval, pFilter->filterInfo.lowerBndd);
+ } else { // range filter
assert(*(float *)minval < *(float *)maxval);
return *(float *)minval <= pFilter->filterInfo.lowerBndd && *(float *)maxval >= pFilter->filterInfo.lowerBndd;
}
@@ -173,10 +189,9 @@ bool equal_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) {
bool equal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
if (*(double *)minval == *(double *)maxval) {
- return (*(double *)minval == pFilter->filterInfo.lowerBndd);
- } else { /* range filter */
+ return (fabs(*(double *)minval - pFilter->filterInfo.lowerBndd) <= 2 * DBL_EPSILON);
+ } else { // range filter
assert(*(double *)minval < *(double *)maxval);
-
return *(double *)minval <= pFilter->filterInfo.lowerBndi && *(double *)maxval >= pFilter->filterInfo.lowerBndi;
}
}
@@ -255,7 +270,7 @@ bool nequal_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) {
bool nequal_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) {
if (*(float *)minval == *(float *)maxval) {
- return (*(float *)minval != pFilter->filterInfo.lowerBndd);
+ return !FLT_EQUAL(*(float *)minval, pFilter->filterInfo.lowerBndd);
}
return true;
@@ -364,7 +379,8 @@ bool rangeFilter_i64_ei(SColumnFilterElem *pFilter, char *minval, char *maxval)
////////////////////////////////////////////////////////////////////////
bool rangeFilter_ds_ii(SColumnFilterElem *pFilter, char *minval, char *maxval) {
- return (*(float *)minval <= pFilter->filterInfo.upperBndd && *(float *)maxval >= pFilter->filterInfo.lowerBndd);
+ return FLT_LESSEQUAL(*(float *)minval, pFilter->filterInfo.upperBndd) &&
+ FLT_GREATEREQUAL(*(float *)maxval, pFilter->filterInfo.lowerBndd);
}
bool rangeFilter_ds_ee(SColumnFilterElem *pFilter, char *minval, char *maxval) {
@@ -376,7 +392,8 @@ bool rangeFilter_ds_ie(SColumnFilterElem *pFilter, char *minval, char *maxval) {
}
bool rangeFilter_ds_ei(SColumnFilterElem *pFilter, char *minval, char *maxval) {
- return (*(float *)minval <= pFilter->filterInfo.upperBndd && *(float *)maxval > pFilter->filterInfo.lowerBndd);
+ return FLT_GREATER(*(float *)maxval, pFilter->filterInfo.lowerBndd) &&
+ FLT_LESSEQUAL(*(float *)minval, pFilter->filterInfo.upperBndd);
}
//////////////////////////////////////////////////////////////////////////
@@ -400,7 +417,7 @@ bool rangeFilter_dd_ei(SColumnFilterElem *pFilter, char *minval, char *maxval) {
bool (*filterFunc_i8[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = {
NULL,
less_i8,
- large_i8,
+ larger_i8,
equal_i8,
lessEqual_i8,
largeEqual_i8,
@@ -413,7 +430,7 @@ bool (*filterFunc_i8[])(SColumnFilterElem *pFilter, char *minval, char *maxval)
bool (*filterFunc_i16[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = {
NULL,
less_i16,
- large_i16,
+ larger_i16,
equal_i16,
lessEqual_i16,
largeEqual_i16,
@@ -426,7 +443,7 @@ bool (*filterFunc_i16[])(SColumnFilterElem *pFilter, char *minval, char *maxval)
bool (*filterFunc_i32[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = {
NULL,
less_i32,
- large_i32,
+ larger_i32,
equal_i32,
lessEqual_i32,
largeEqual_i32,
@@ -439,7 +456,7 @@ bool (*filterFunc_i32[])(SColumnFilterElem *pFilter, char *minval, char *maxval)
bool (*filterFunc_i64[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = {
NULL,
less_i64,
- large_i64,
+ larger_i64,
equal_i64,
lessEqual_i64,
largeEqual_i64,
@@ -452,7 +469,7 @@ bool (*filterFunc_i64[])(SColumnFilterElem *pFilter, char *minval, char *maxval)
bool (*filterFunc_ds[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = {
NULL,
less_ds,
- large_ds,
+ larger_ds,
equal_ds,
lessEqual_ds,
largeEqual_ds,
@@ -465,7 +482,7 @@ bool (*filterFunc_ds[])(SColumnFilterElem *pFilter, char *minval, char *maxval)
bool (*filterFunc_dd[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = {
NULL,
less_dd,
- large_dd,
+ larger_dd,
equal_dd,
lessEqual_dd,
largeEqual_dd,
@@ -551,7 +568,7 @@ bool (*rangeFilterFunc_dd[])(SColumnFilterElem *pFilter, char *minval, char *max
__filter_func_t* getRangeFilterFuncArray(int32_t type) {
switch(type) {
- case TSDB_DATA_TYPE_BOOL: return rangeFilterFunc_i8;
+ case TSDB_DATA_TYPE_BOOL:
case TSDB_DATA_TYPE_TINYINT: return rangeFilterFunc_i8;
case TSDB_DATA_TYPE_SMALLINT: return rangeFilterFunc_i16;
case TSDB_DATA_TYPE_INT: return rangeFilterFunc_i32;
@@ -565,7 +582,7 @@ __filter_func_t* getRangeFilterFuncArray(int32_t type) {
__filter_func_t* getValueFilterFuncArray(int32_t type) {
switch(type) {
- case TSDB_DATA_TYPE_BOOL: return filterFunc_i8;
+ case TSDB_DATA_TYPE_BOOL:
case TSDB_DATA_TYPE_TINYINT: return filterFunc_i8;
case TSDB_DATA_TYPE_SMALLINT: return filterFunc_i16;
case TSDB_DATA_TYPE_INT: return filterFunc_i32;
diff --git a/src/sync/src/syncRestore.c b/src/sync/src/syncRestore.c
index 589ff470f170f2ff94efe1974b1c755ea8e16bb1..4247468bcae77dab49f61dd684a80ada9701418c 100644
--- a/src/sync/src/syncRestore.c
+++ b/src/sync/src/syncRestore.c
@@ -36,6 +36,8 @@ static void syncRemoveExtraFile(SSyncPeer *pPeer, int32_t sindex, int32_t eindex
if (sindex < 0 || eindex < sindex) return;
+ sDebug("%s, extra files will be removed between sindex:%d and eindex:%d", pPeer->id, sindex, eindex);
+
while (1) {
name[0] = 0;
magic = (*pNode->getFileInfo)(pNode->vgId, name, &index, eindex, &size, &fversion);
@@ -61,11 +63,12 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
bool fileChanged = false;
*fversion = 0;
- sinfo.index = 0;
+ sinfo.index = -1;
while (1) {
// read file info
- int32_t ret = taosReadMsg(pPeer->syncFd, &(minfo), sizeof(SFileInfo));
- if (ret != sizeof(SFileInfo)) {
+ minfo.index = -1;
+ int32_t ret = taosReadMsg(pPeer->syncFd, &minfo, sizeof(SFileInfo));
+ if (ret != sizeof(SFileInfo) || minfo.index == -1) {
sError("%s, failed to read file info while restore file since %s", pPeer->id, strerror(errno));
break;
}
@@ -75,7 +78,7 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
sDebug("%s, no more files to restore", pPeer->id);
// remove extra files after the current index
- syncRemoveExtraFile(pPeer, sinfo.index + 1, TAOS_SYNC_MAX_INDEX);
+ if (sinfo.index != -1) syncRemoveExtraFile(pPeer, sinfo.index + 1, TAOS_SYNC_MAX_INDEX);
code = 0;
break;
}
diff --git a/src/util/src/ttimer.c b/src/util/src/ttimer.c
index 0222a6d80a3f36bacde9847b1cc326fe22aa389a..4eafbd1ae9bd87f6541d8c35c70bcf8a57d96454 100644
--- a/src/util/src/ttimer.c
+++ b/src/util/src/ttimer.c
@@ -225,10 +225,11 @@ static void addToWheel(tmr_obj_t* timer, uint32_t delay) {
}
static bool removeFromWheel(tmr_obj_t* timer) {
- if (timer->wheel >= tListLen(wheels)) {
+ uint8_t wheelIdx = timer->wheel;
+ if (wheelIdx >= tListLen(wheels)) {
return false;
}
- time_wheel_t* wheel = wheels + timer->wheel;
+ time_wheel_t* wheel = wheels + wheelIdx;
bool removed = false;
pthread_mutex_lock(&wheel->mutex);
diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c
index 7ad97396c2df2b105056861e5c2916de92c7d8d9..637d470f8a775706b1d04799af83e741a81b0ee4 100644
--- a/src/vnode/src/vnodeRead.c
+++ b/src/vnode/src/vnodeRead.c
@@ -281,7 +281,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
vTrace("vgId:%d, QInfo:%p, dnode continues to exec query", pVnode->vgId, *qhandle);
// In the retrieve blocking model, only 50% CPU will be used in query processing
- if (tsHalfCoresForQuery) {
+ if (tsRetrieveBlockingModel) {
qTableQuery(*qhandle); // do execute query
qReleaseQInfo(pVnode->qMgmt, (void **)&qhandle, false);
} else {
@@ -380,7 +380,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
freeHandle = true;
} else { // result is not ready, return immediately
// Only effects in the non-blocking model
- if (!tsHalfCoresForQuery) {
+ if (!tsRetrieveBlockingModel) {
if (!buildRes) {
assert(pRead->rpcHandle != NULL);
diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c
index 7cf1a9059839e2111808b9458b35fb1ad0573f57..80e2dc422e07395f19fa2cad79b37037e3d06f86 100644
--- a/src/vnode/src/vnodeWrite.c
+++ b/src/vnode/src/vnodeWrite.c
@@ -243,8 +243,10 @@ int32_t vnodeWriteToWQueue(void *vparam, void *wparam, int32_t qtype, void *rpar
int32_t queued = atomic_add_fetch_32(&pVnode->queuedWMsg, 1);
if (queued > MAX_QUEUED_MSG_NUM) {
- vDebug("vgId:%d, too many msg:%d in vwqueue, flow control", pVnode->vgId, queued);
- taosMsleep(3);
+ int32_t ms = (queued / MAX_QUEUED_MSG_NUM) * 10 + 3;
+ if (ms > 100) ms = 100;
+ vDebug("vgId:%d, too many msg:%d in vwqueue, flow control %dms", pVnode->vgId, queued, ms);
+ taosMsleep(ms);
}
code = vnodePerformFlowCtrl(pWrite);
diff --git a/tests/Jenkinsfile b/tests/Jenkinsfile
index 5e9fcd15cd3c300429ff65d980fbaf5f8ccf2365..e343de789e466143ca05a1e2c42275709aaa9c2a 100644
--- a/tests/Jenkinsfile
+++ b/tests/Jenkinsfile
@@ -1,18 +1,3 @@
-
-properties([pipelineTriggers([githubPush()])])
-node {
- git url: 'https://github.com/taosdata/TDengine'
-}
-
-
-// execute this before anything else, including requesting any time on an agent
-if (currentBuild.rawBuild.getCauses().toString().contains('BranchIndexingCause')) {
- print "INFO: Build skipped due to trigger being Branch Indexing"
- currentBuild.result = 'ABORTED' // optional, gives a better hint to the user that it's been skipped, rather than the default which shows it's successful
- return
-}
-
-
def pre_test(){
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''
@@ -21,15 +6,14 @@ def pre_test(){
}
sh '''
cd ${WKC}
- rm -rf *
- cd ${WK}
git reset --hard
- git checkout develop
+ git checkout ${BRANCH}
git pull
- cd ${WKC}
- rm -rf *
- mv ${WORKSPACE}/* .
+ git submodule update
cd ${WK}
+ git reset --hard
+ git checkout ${BRANCH}
+ git pull
export TZ=Asia/Harbin
date
rm -rf ${WK}/debug
@@ -38,13 +22,13 @@ def pre_test(){
cmake .. > /dev/null
make > /dev/null
make install > /dev/null
- cd ${WKC}/tests
'''
return 1
}
pipeline {
agent none
environment{
+ BRANCH = 'develop'
WK = '/var/lib/jenkins/workspace/TDinternal'
WKC= '/var/lib/jenkins/workspace/TDinternal/community'
}
@@ -52,13 +36,13 @@ pipeline {
stages {
stage('Parallel test stage') {
parallel {
- stage('python p1') {
- agent{label 'p1'}
+ stage('pytest') {
+ agent{label '184'}
steps {
pre_test()
sh '''
cd ${WKC}/tests
- ./test-all.sh p1
+ ./test-all.sh pytest
date'''
}
}
@@ -66,6 +50,12 @@ pipeline {
agent{label 'master'}
steps {
pre_test()
+ catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
+ sh '''
+ cd ${WKC}/tests/pytest
+ python3 concurrent_inquiry.py -c 1
+ '''
+ }
sh '''
cd ${WKC}/tests
./test-all.sh b1
@@ -74,9 +64,12 @@ pipeline {
}
stage('test_crash_gen') {
- agent{label "b2"}
+ agent{label "185"}
steps {
pre_test()
+ sh '''
+ cd ${WKC}/tests/pytest
+ '''
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''
cd ${WKC}/tests/pytest
@@ -90,7 +83,6 @@ pipeline {
'''
}
sh '''
- date
cd ${WKC}/tests
./test-all.sh b2
date
@@ -99,42 +91,177 @@ pipeline {
}
stage('test_valgrind') {
- agent{label "b3"}
+ agent{label "186"}
steps {
pre_test()
- catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
- sh '''
- cd ${WKC}/tests/pytest
- ./valgrind-test.sh 2>&1 > mem-error-out.log
- ./handle_val_log.sh
- '''
- }
sh '''
+ cd ${WKC}/tests/pytest
+ ./valgrind-test.sh 2>&1 > mem-error-out.log
+ ./handle_val_log.sh
+
date
cd ${WKC}/tests
./test-all.sh b3
date'''
}
}
- stage('python p2'){
- agent{label "p2"}
+ stage('connector'){
+ agent{label "release"}
steps{
- pre_test()
- sh '''
- date
- cd ${WKC}/tests
- ./test-all.sh p2
- date
+ sh'''
+ cd ${WORKSPACE}
+ git checkout develop
'''
+ catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
+ sh '''
+ cd ${WORKSPACE}/tests/gotest
+ bash batchtest.sh
+ '''
+ }
+ catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
+ sh '''
+ cd ${WORKSPACE}/tests/examples/python/PYTHONConnectorChecker
+ python3 PythonChecker.py
+ '''
+ }
+ catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
+ sh '''
+ cd ${WORKSPACE}/tests/examples/JDBC/JDBCDemo/
+ mvn clean package assembly:single >/dev/null
+ java -jar target/jdbcChecker-SNAPSHOT-jar-with-dependencies.jar -host 127.0.0.1
+ '''
+ }
+ catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
+ sh '''
+ cd ${JENKINS_HOME}/workspace/C#NET/src/CheckC#
+ dotnet run
+ '''
+ }
}
}
-
-
+ stage('arm64_build'){
+ agent{label 'arm64'}
+ steps{
+ sh '''
+ cd ${WK}
+ git fetch
+ git checkout develop
+ git pull
+ cd ${WKC}
+ git fetch
+ git checkout develop
+ git pull
+ git submodule update
+ cd ${WKC}/packaging
+ ./release.sh -v cluster -c aarch64 -n 2.0.0.0 -m 2.0.0.0
+
+ '''
+ }
+ }
+ stage('arm32_build'){
+ agent{label 'arm32'}
+ steps{
+ catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
+ sh '''
+ cd ${WK}
+ git fetch
+ git checkout develop
+ git pull
+ cd ${WKC}
+ git fetch
+ git checkout develop
+ git pull
+ git submodule update
+ cd ${WKC}/packaging
+ ./release.sh -v cluster -c aarch32 -n 2.0.0.0 -m 2.0.0.0
+
+ '''
+ }
+
+ }
+ }
}
}
}
-
-}
+ post {
+ success {
+ emailext (
+ subject: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
+ body: '''
+
+
+
+
+
+
+
+
+ 构建信息
+
|
+
+
+
+
+
+ - 构建名称>>分支:${PROJECT_NAME}
+ - 构建结果: Successful
+ - 构建编号:${BUILD_NUMBER}
+ - 触发用户:${CAUSE}
+ - 变更概要:${CHANGES}
+ - 构建地址:${BUILD_URL}
+ - 构建日志:${BUILD_URL}console
+ - 变更集:${JELLY_SCRIPT}
+
+
+ |
+
+
+
+ ''',
+ to: "yqliu@taosdata.com,pxiao@taosdata.com",
+ from: "support@taosdata.com"
+ )
+ }
+ failure {
+ emailext (
+ subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
+ body: '''
+
+
+
+
+
+
+
+
+ 构建信息
+
|
+
+
+
+
+
+ - 构建名称>>分支:${PROJECT_NAME}
+ - 构建结果: Successful
+ - 构建编号:${BUILD_NUMBER}
+ - 触发用户:${CAUSE}
+ - 变更概要:${CHANGES}
+ - 构建地址:${BUILD_URL}
+ - 构建日志:${BUILD_URL}console
+ - 变更集:${JELLY_SCRIPT}
+
+
+ |
+
+
+
+ ''',
+ to: "yqliu@taosdata.com,pxiao@taosdata.com",
+ from: "support@taosdata.com"
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/examples/JDBC/taosdemo/.gitignore b/tests/examples/JDBC/taosdemo/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..549e00a2a96fa9d7c5dbc9859664a78d980158c2
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/.gitignore
@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
diff --git a/tests/examples/JDBC/taosdemo/.mvn/wrapper/MavenWrapperDownloader.java b/tests/examples/JDBC/taosdemo/.mvn/wrapper/MavenWrapperDownloader.java
new file mode 100644
index 0000000000000000000000000000000000000000..a45eb6ba269cd38f8965cef786729790945d9537
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/.mvn/wrapper/MavenWrapperDownloader.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2007-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.net.*;
+import java.io.*;
+import java.nio.channels.*;
+import java.util.Properties;
+
+public class MavenWrapperDownloader {
+
+ private static final String WRAPPER_VERSION = "0.5.6";
+ /**
+ * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
+ */
+ private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
+
+ /**
+ * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
+ * use instead of the default one.
+ */
+ private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
+ ".mvn/wrapper/maven-wrapper.properties";
+
+ /**
+ * Path where the maven-wrapper.jar will be saved to.
+ */
+ private static final String MAVEN_WRAPPER_JAR_PATH =
+ ".mvn/wrapper/maven-wrapper.jar";
+
+ /**
+ * Name of the property which should be used to override the default download url for the wrapper.
+ */
+ private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
+
+ public static void main(String args[]) {
+ System.out.println("- Downloader started");
+ File baseDirectory = new File(args[0]);
+ System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
+
+ // If the maven-wrapper.properties exists, read it and check if it contains a custom
+ // wrapperUrl parameter.
+ File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
+ String url = DEFAULT_DOWNLOAD_URL;
+ if (mavenWrapperPropertyFile.exists()) {
+ FileInputStream mavenWrapperPropertyFileInputStream = null;
+ try {
+ mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
+ Properties mavenWrapperProperties = new Properties();
+ mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
+ url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
+ } catch (IOException e) {
+ System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
+ } finally {
+ try {
+ if (mavenWrapperPropertyFileInputStream != null) {
+ mavenWrapperPropertyFileInputStream.close();
+ }
+ } catch (IOException e) {
+ // Ignore ...
+ }
+ }
+ }
+ System.out.println("- Downloading from: " + url);
+
+ File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
+ if (!outputFile.getParentFile().exists()) {
+ if (!outputFile.getParentFile().mkdirs()) {
+ System.out.println(
+ "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
+ }
+ }
+ System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
+ try {
+ downloadFileFromURL(url, outputFile);
+ System.out.println("Done");
+ System.exit(0);
+ } catch (Throwable e) {
+ System.out.println("- Error downloading");
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ private static void downloadFileFromURL(String urlString, File destination) throws Exception {
+ if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
+ String username = System.getenv("MVNW_USERNAME");
+ char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
+ Authenticator.setDefault(new Authenticator() {
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(username, password);
+ }
+ });
+ }
+ URL website = new URL(urlString);
+ ReadableByteChannel rbc;
+ rbc = Channels.newChannel(website.openStream());
+ FileOutputStream fos = new FileOutputStream(destination);
+ fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+ fos.close();
+ rbc.close();
+ }
+
+}
diff --git a/tests/examples/JDBC/taosdemo/.mvn/wrapper/maven-wrapper.jar b/tests/examples/JDBC/taosdemo/.mvn/wrapper/maven-wrapper.jar
new file mode 100644
index 0000000000000000000000000000000000000000..2cc7d4a55c0cd0092912bf49ae38b3a9e3fd0054
Binary files /dev/null and b/tests/examples/JDBC/taosdemo/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/tests/examples/JDBC/taosdemo/.mvn/wrapper/maven-wrapper.properties b/tests/examples/JDBC/taosdemo/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000000000000000000000000000000000000..642d572ce90e5085986bdd9c9204b9404f028084
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1,2 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
diff --git a/tests/examples/JDBC/taosdemo/mvnw b/tests/examples/JDBC/taosdemo/mvnw
new file mode 100755
index 0000000000000000000000000000000000000000..3c8a5537314954d53ec2fb774b34fe5d5a5f253a
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/mvnw
@@ -0,0 +1,322 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# M2_HOME - location of maven2's installed home dir
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ]; then
+
+ if [ -f /etc/mavenrc ]; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ]; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false
+darwin=false
+mingw=false
+case "$(uname)" in
+CYGWIN*) cygwin=true ;;
+MINGW*) mingw=true ;;
+Darwin*)
+ darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ export JAVA_HOME="$(/usr/libexec/java_home)"
+ else
+ export JAVA_HOME="/Library/Java/Home"
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ]; then
+ if [ -r /etc/gentoo-release ]; then
+ JAVA_HOME=$(java-config --jre-home)
+ fi
+fi
+
+if [ -z "$M2_HOME" ]; then
+ ## resolve links - $0 may be a link to maven's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ]; do
+ ls=$(ls -ld "$PRG")
+ link=$(expr "$ls" : '.*-> \(.*\)$')
+ if expr "$link" : '/.*' >/dev/null; then
+ PRG="$link"
+ else
+ PRG="$(dirname "$PRG")/$link"
+ fi
+ done
+
+ saveddir=$(pwd)
+
+ M2_HOME=$(dirname "$PRG")/..
+
+ # make it fully qualified
+ M2_HOME=$(cd "$M2_HOME" && pwd)
+
+ cd "$saveddir"
+ # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=$(cygpath --unix "$M2_HOME")
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME="$( (
+ cd "$M2_HOME"
+ pwd
+ ))"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="$( (
+ cd "$JAVA_HOME"
+ pwd
+ ))"
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="$(which javac)"
+ if [ -n "$javaExecutable" ] && ! [ "$(expr \"$javaExecutable\" : '\([^ ]*\)')" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=$(which readlink)
+ if [ ! $(expr "$readLink" : '\([^ ]*\)') = "no" ]; then
+ if $darwin; then
+ javaHome="$(dirname \"$javaExecutable\")"
+ javaExecutable="$(cd \"$javaHome\" && pwd -P)/javac"
+ else
+ javaExecutable="$(readlink -f \"$javaExecutable\")"
+ fi
+ javaHome="$(dirname \"$javaExecutable\")"
+ javaHome=$(expr "$javaHome" : '\(.*\)/bin')
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ]; then
+ if [ -n "$JAVA_HOME" ]; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ]; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="$(which java)"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ]; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+ if [ -z "$1" ]; then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ]; do
+ if [ -d "$wdir"/.mvn ]; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=$(
+ cd "$wdir/.."
+ pwd
+ )
+ fi
+ # end of workaround
+ done
+ echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ echo "$(tr -s '\n' ' ' <"$1")"
+ fi
+}
+
+BASE_DIR=$(find_maven_basedir "$(pwd)")
+if [ -z "$BASE_DIR" ]; then
+ exit 1
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found .mvn/wrapper/maven-wrapper.jar"
+ fi
+else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+ fi
+ if [ -n "$MVNW_REPOURL" ]; then
+ jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ else
+ jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ fi
+ while IFS="=" read key value; do
+ case "$key" in wrapperUrl)
+ jarUrl="$value"
+ break
+ ;;
+ esac
+ done <"$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Downloading from: $jarUrl"
+ fi
+ wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+ if $cygwin; then
+ wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
+ fi
+
+ if command -v wget >/dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found wget ... using wget"
+ fi
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ wget "$jarUrl" -O "$wrapperJarPath"
+ else
+ wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
+ fi
+ elif command -v curl >/dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found curl ... using curl"
+ fi
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ curl -o "$wrapperJarPath" "$jarUrl" -f
+ else
+ curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
+ fi
+
+ else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Falling back to using Java to download"
+ fi
+ javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ # For Cygwin, switch paths to Windows format before running javac
+ if $cygwin; then
+ javaClass=$(cygpath --path --windows "$javaClass")
+ fi
+ if [ -e "$javaClass" ]; then
+ if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Compiling MavenWrapperDownloader.java ..."
+ fi
+ # Compiling the Java class
+ ("$JAVA_HOME/bin/javac" "$javaClass")
+ fi
+ if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ # Running the downloader
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Running MavenWrapperDownloader.java ..."
+ fi
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+ fi
+ fi
+ fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+ echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=$(cygpath --path --windows "$M2_HOME")
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
+fi
+
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+export MAVEN_CMD_LINE_ARGS
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/tests/examples/JDBC/taosdemo/mvnw.cmd b/tests/examples/JDBC/taosdemo/mvnw.cmd
new file mode 100644
index 0000000000000000000000000000000000000000..c8d43372c986d97911cdc21bd87e0cbe3d83bdda
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/mvnw.cmd
@@ -0,0 +1,182 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM https://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+
+FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Found %WRAPPER_JAR%
+ )
+) else (
+ if not "%MVNW_REPOURL%" == "" (
+ SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ )
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ )
+
+ powershell -Command "&{"^
+ "$webclient = new-object System.Net.WebClient;"^
+ "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+ "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+ "}"^
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
+ "}"
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Finished downloading %WRAPPER_JAR%
+ )
+)
+@REM End of extension
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%
diff --git a/tests/examples/JDBC/taosdemo/pom.xml b/tests/examples/JDBC/taosdemo/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5cbf6cb7004566e8d6ea6e16e8b70f289ac2941d
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/pom.xml
@@ -0,0 +1,117 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.4.0
+
+
+ com.taosdata
+ taosdemo
+ 2.0
+ taosdemo
+ Demo project for TDengine
+
+
+ 1.8
+
+
+
+
+
+
+ com.taosdata.jdbc
+ taos-jdbcdriver
+ 2.0.14
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.47
+
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ 3.1.2
+
+
+
+ log4j
+ log4j
+ 1.2.17
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 2.1.4
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ src/main/resources
+
+ **/*.properties
+ **/*.xml
+
+ true
+
+
+ src/main/java
+
+ **/*.properties
+ **/*.xml
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosdemoApplication.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosdemoApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..db1b20527d88f5bca24ed5c6a3b477fa3a71bdf1
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosdemoApplication.java
@@ -0,0 +1,15 @@
+package com.taosdata.taosdemo;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@MapperScan(basePackages = {"com.taosdata.taosdemo.mapper"})
+@SpringBootApplication
+public class TaosdemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(TaosdemoApplication.class, args);
+ }
+
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/components/TaosDemoCommandLineRunner.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/components/TaosDemoCommandLineRunner.java
new file mode 100644
index 0000000000000000000000000000000000000000..e58c68f7a5f60b57f064075c4004267918526b15
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/components/TaosDemoCommandLineRunner.java
@@ -0,0 +1,174 @@
+package com.taosdata.taosdemo.components;
+
+import com.taosdata.taosdemo.domain.*;
+import com.taosdata.taosdemo.service.DatabaseService;
+import com.taosdata.taosdemo.service.SubTableService;
+import com.taosdata.taosdemo.service.SuperTableService;
+import com.taosdata.taosdemo.service.data.SubTableMetaGenerator;
+import com.taosdata.taosdemo.service.data.SubTableValueGenerator;
+import com.taosdata.taosdemo.service.data.SuperTableMetaGenerator;
+import com.taosdata.taosdemo.utils.JdbcTaosdemoConfig;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+
+@Component
+public class TaosDemoCommandLineRunner implements CommandLineRunner {
+
+ private static Logger logger = Logger.getLogger(TaosDemoCommandLineRunner.class);
+ @Autowired
+ private DatabaseService databaseService;
+ @Autowired
+ private SuperTableService superTableService;
+ @Autowired
+ private SubTableService subTableService;
+
+ private SuperTableMeta superTableMeta;
+ private List subTableMetaList;
+ private List subTableValueList;
+ private List> dataList;
+
+
+ @Override
+ public void run(String... args) throws Exception {
+ // 读配置参数
+ JdbcTaosdemoConfig config = new JdbcTaosdemoConfig(args);
+ boolean isHelp = Arrays.asList(args).contains("--help");
+ if (isHelp) {
+ JdbcTaosdemoConfig.printHelp();
+ System.exit(0);
+ }
+ // 准备数据
+ prepareData(config);
+ // 创建数据库
+ createDatabaseTask(config);
+ // 建表
+ createTableTask(config);
+ // 插入
+ insertTask(config);
+ // 查询: 1. 生成查询语句, 2. 执行查询
+ // 删除表
+ if (config.dropTable) {
+ superTableService.drop(config.database, config.superTable);
+ }
+
+ System.exit(0);
+ }
+
+ private void createDatabaseTask(JdbcTaosdemoConfig config) {
+ long start = System.currentTimeMillis();
+
+ Map databaseParam = new HashMap<>();
+ databaseParam.put("database", config.database);
+ databaseParam.put("keep", Integer.toString(config.keep));
+ databaseParam.put("days", Integer.toString(config.days));
+ databaseParam.put("replica", Integer.toString(config.replica));
+ //TODO: other database parameters
+ databaseService.dropDatabase(config.database);
+ databaseService.createDatabase(databaseParam);
+ databaseService.useDatabase(config.database);
+
+ long end = System.currentTimeMillis();
+ logger.info(">>> insert time cost : " + (end - start) + " ms.");
+ }
+
+ // 建超级表,三种方式:1. 指定SQL,2. 指定field和tags的个数,3. 默认
+ private void createTableTask(JdbcTaosdemoConfig config) {
+ long start = System.currentTimeMillis();
+ if (config.doCreateTable) {
+ superTableService.create(superTableMeta);
+ // 批量建子表
+ subTableService.createSubTable(subTableMetaList, config.numOfThreadsForCreate);
+ }
+ long end = System.currentTimeMillis();
+ logger.info(">>> create table time cost : " + (end - start) + " ms.");
+ }
+
+ private void insertTask(JdbcTaosdemoConfig config) {
+ long start = System.currentTimeMillis();
+
+ int numOfThreadsForInsert = config.numOfThreadsForInsert;
+ int sleep = config.sleep;
+ if (config.autoCreateTable) {
+ // 批量插入,自动建表
+ dataList.stream().forEach(subTableValues -> {
+ subTableService.insertAutoCreateTable(subTableValues, numOfThreadsForInsert);
+ sleep(sleep);
+ });
+ } else {
+ dataList.stream().forEach(subTableValues -> {
+ subTableService.insert(subTableValues, numOfThreadsForInsert);
+ sleep(sleep);
+ });
+ }
+ long end = System.currentTimeMillis();
+ logger.info(">>> insert time cost : " + (end - start) + " ms.");
+ }
+
+ private void prepareData(JdbcTaosdemoConfig config) {
+ long start = System.currentTimeMillis();
+ // 超级表的meta
+ superTableMeta = createSupertable(config);
+ // 子表的meta
+ subTableMetaList = SubTableMetaGenerator.generate(superTableMeta, config.numOfTables, config.tablePrefix);
+ // 子表的data
+ subTableValueList = SubTableValueGenerator.generate(subTableMetaList, config.numOfRowsPerTable, config.startTime, config.timeGap);
+ // 如果有乱序,给数据搞乱
+ if (config.order != 0) {
+ SubTableValueGenerator.disrupt(subTableValueList, config.rate, config.range);
+ }
+ // 分割数据
+ int numOfTables = config.numOfTables;
+ int numOfTablesPerSQL = config.numOfTablesPerSQL;
+ int numOfRowsPerTable = config.numOfRowsPerTable;
+ int numOfValuesPerSQL = config.numOfValuesPerSQL;
+ dataList = SubTableValueGenerator.split(subTableValueList, numOfTables, numOfTablesPerSQL, numOfRowsPerTable, numOfValuesPerSQL);
+ long end = System.currentTimeMillis();
+ logger.info(">>> prepare data time cost : " + (end - start) + " ms.");
+ }
+
+ private SuperTableMeta createSupertable(JdbcTaosdemoConfig config) {
+ SuperTableMeta tableMeta;
+ // create super table
+ logger.info(">>> create super table <<<");
+ if (config.superTableSQL != null) {
+ // use a sql to create super table
+ tableMeta = SuperTableMetaGenerator.generate(config.superTableSQL);
+ } else if (config.numOfFields == 0) {
+ // default sql = "create table test.weather (ts timestamp, temperature float, humidity int) tags(location nchar(64), groupId int)";
+ SuperTableMeta superTableMeta = new SuperTableMeta();
+ superTableMeta.setDatabase(config.database);
+ superTableMeta.setName(config.superTable);
+ List fields = new ArrayList<>();
+ fields.add(new FieldMeta("ts", "timestamp"));
+ fields.add(new FieldMeta("temperature", "float"));
+ fields.add(new FieldMeta("humidity", "int"));
+ superTableMeta.setFields(fields);
+ List tags = new ArrayList<>();
+ tags.add(new TagMeta("location", "nchar(64)"));
+ tags.add(new TagMeta("groupId", "int"));
+ superTableMeta.setTags(tags);
+ return superTableMeta;
+ } else {
+ // create super table with specified field size and tag size
+ tableMeta = SuperTableMetaGenerator.generate(config.database, config.superTable, config.numOfFields, config.prefixOfFields, config.numOfTags, config.prefixOfTags);
+ }
+ return tableMeta;
+ }
+
+ private static void sleep(int sleep) {
+ if (sleep <= 0)
+ return;
+ try {
+ TimeUnit.MILLISECONDS.sleep(sleep);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/DatabaseController.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/DatabaseController.java
new file mode 100644
index 0000000000000000000000000000000000000000..1cf1463f0ab4f2a8c67258f512e407d54c1d869e
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/DatabaseController.java
@@ -0,0 +1,40 @@
+package com.taosdata.taosdemo.controller;
+
+import com.taosdata.taosdemo.service.DatabaseService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+@RestController
+@RequestMapping
+public class DatabaseController {
+
+ @Autowired
+ private DatabaseService databaseService;
+
+ /**
+ * create database
+ ***/
+ @PostMapping
+ public int create(@RequestBody Map map) {
+ return databaseService.createDatabase(map);
+ }
+
+
+ /**
+ * drop database
+ **/
+ @DeleteMapping("/{dbname}")
+ public int delete(@PathVariable("dbname") String dbname) {
+ return databaseService.dropDatabase(dbname);
+ }
+
+ /**
+ * use database
+ **/
+ @GetMapping("/{dbname}")
+ public int use(@PathVariable("dbname") String dbname) {
+ return databaseService.useDatabase(dbname);
+ }
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/InsertController.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/InsertController.java
new file mode 100644
index 0000000000000000000000000000000000000000..788f68a30af5ac7dd4c8c27f4cfe5f1a6f2b440b
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/InsertController.java
@@ -0,0 +1,17 @@
+package com.taosdata.taosdemo.controller;
+
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class InsertController {
+
+ //TODO:多线程写一张表, thread = 10, table = 1
+ //TODO:一个批次写多张表, insert into t1 using weather values() t2 using weather values()
+ //TODO:插入的频率,
+ //TODO:指定一张表内的records数量
+ //TODO:是否乱序,
+ //TODO:乱序的比例,乱序的范围
+ //TODO:先建表,自动建表
+ //TODO:一个批次写多张表
+
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/SubTableController.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/SubTableController.java
new file mode 100644
index 0000000000000000000000000000000000000000..797c3708d3357c19bf5f64046bb794b66786e080
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/SubTableController.java
@@ -0,0 +1,45 @@
+package com.taosdata.taosdemo.controller;
+
+import com.taosdata.taosdemo.domain.TableValue;
+import com.taosdata.taosdemo.service.SuperTableService;
+import com.taosdata.taosdemo.service.TableService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class SubTableController {
+
+ @Autowired
+ private TableService tableService;
+ @Autowired
+ private SuperTableService superTableService;
+
+ //TODO: 使用supertable创建一个子表
+
+ //TODO:使用supertable创建多个子表
+
+ //TODO:使用supertable多线程创建子表
+
+ //TODO:使用supertable多线程创建子表,指定子表的name_prefix,子表的数量,使用线程的个数
+
+ /**
+ * 创建表,超级表或者普通表
+ **/
+
+
+ /**
+ * 创建超级表的子表
+ **/
+ @PostMapping("/{database}/{superTable}")
+ public int createTable(@PathVariable("database") String database,
+ @PathVariable("superTable") String superTable,
+ @RequestBody TableValue tableMetadta) {
+ tableMetadta.setDatabase(database);
+ return 0;
+ }
+
+
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/SuperTableController.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/SuperTableController.java
new file mode 100644
index 0000000000000000000000000000000000000000..cf53c1440fa710c3bea510973ca2efecb0705828
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/SuperTableController.java
@@ -0,0 +1,26 @@
+package com.taosdata.taosdemo.controller;
+
+import com.taosdata.taosdemo.domain.SuperTableMeta;
+import com.taosdata.taosdemo.service.SuperTableService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+public class SuperTableController {
+ @Autowired
+ private SuperTableService superTableService;
+
+
+ @PostMapping("/{database}")
+ public int createTable(@PathVariable("database") String database, @RequestBody SuperTableMeta tableMetadta) {
+ tableMetadta.setDatabase(database);
+ return superTableService.create(tableMetadta);
+ }
+
+ //TODO: 删除超级表
+
+ //TODO:查询超级表
+
+ //TODO:统计查询表
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/TableController.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/TableController.java
new file mode 100644
index 0000000000000000000000000000000000000000..dbdd978e746eb89d8927617ae4026cdcf544559b
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/controller/TableController.java
@@ -0,0 +1,11 @@
+package com.taosdata.taosdemo.controller;
+
+public class TableController {
+
+ //TODO:创建普通表,create table(ts timestamp, temperature float)
+
+ //TODO:创建普通表,指定表的列数,包括第一列timestamp
+
+ //TODO:创建普通表,指定表每列的name和type
+
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/FieldMeta.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/FieldMeta.java
new file mode 100644
index 0000000000000000000000000000000000000000..8a45e99989821562fdf9333b90a2972388cf6003
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/FieldMeta.java
@@ -0,0 +1,17 @@
+package com.taosdata.taosdemo.domain;
+
+import lombok.Data;
+
+@Data
+public class FieldMeta {
+ private String name;
+ private String type;
+
+ public FieldMeta() {
+ }
+
+ public FieldMeta(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+}
\ No newline at end of file
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/FieldValue.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/FieldValue.java
new file mode 100644
index 0000000000000000000000000000000000000000..44805c0d7c2f4e0df60d723afd598f2aa788ee65
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/FieldValue.java
@@ -0,0 +1,17 @@
+package com.taosdata.taosdemo.domain;
+
+import lombok.Data;
+
+@Data
+public class FieldValue {
+ private String name;
+ private T value;
+
+ public FieldValue() {
+ }
+
+ public FieldValue(String name, T value) {
+ this.name = name;
+ this.value = value;
+ }
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/RowValue.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/RowValue.java
new file mode 100644
index 0000000000000000000000000000000000000000..a9f216f6792820931af4570450318ddc53e3c8b7
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/RowValue.java
@@ -0,0 +1,15 @@
+package com.taosdata.taosdemo.domain;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class RowValue {
+ private List fields;
+
+
+ public RowValue(List fields) {
+ this.fields = fields;
+ }
+}
\ No newline at end of file
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SubTableMeta.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SubTableMeta.java
new file mode 100644
index 0000000000000000000000000000000000000000..81de882448121532a3c840296702d1fb24c37326
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SubTableMeta.java
@@ -0,0 +1,15 @@
+package com.taosdata.taosdemo.domain;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class SubTableMeta {
+
+ private String database;
+ private String supertable;
+ private String name;
+ private List tags;
+ private List fields;
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SubTableValue.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SubTableValue.java
new file mode 100644
index 0000000000000000000000000000000000000000..74fb9598bc8e920123180f948b88fb98baf9218e
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SubTableValue.java
@@ -0,0 +1,15 @@
+package com.taosdata.taosdemo.domain;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class SubTableValue {
+
+ private String database;
+ private String supertable;
+ private String name;
+ private List tags;
+ private List values;
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SuperTableMeta.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SuperTableMeta.java
new file mode 100644
index 0000000000000000000000000000000000000000..c5c65a4599b776faeead19ffbf065361b293b44b
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SuperTableMeta.java
@@ -0,0 +1,14 @@
+package com.taosdata.taosdemo.domain;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class SuperTableMeta {
+
+ private String database;
+ private String name;
+ private List fields;
+ private List tags;
+}
\ No newline at end of file
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TableMeta.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TableMeta.java
new file mode 100644
index 0000000000000000000000000000000000000000..3ab0a75c0b8ddda46f016c93e0a4893ff1ef21fa
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TableMeta.java
@@ -0,0 +1,13 @@
+package com.taosdata.taosdemo.domain;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class TableMeta {
+
+ private String database;
+ private String name;
+ private List fields;
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TableValue.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TableValue.java
new file mode 100644
index 0000000000000000000000000000000000000000..d5502aa46f3508d2f6dcc3668e741adde5b0a4f0
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TableValue.java
@@ -0,0 +1,15 @@
+package com.taosdata.taosdemo.domain;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class TableValue {
+
+ private String database;
+ private String name;
+ private List columns;
+ private List values;
+
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TagMeta.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TagMeta.java
new file mode 100644
index 0000000000000000000000000000000000000000..a385bb4e125e46fe37c1f9542817a4d81301d72f
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TagMeta.java
@@ -0,0 +1,18 @@
+package com.taosdata.taosdemo.domain;
+
+import lombok.Data;
+
+@Data
+public class TagMeta {
+ private String name;
+ private String type;
+
+ public TagMeta() {
+
+ }
+
+ public TagMeta(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TagValue.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TagValue.java
new file mode 100644
index 0000000000000000000000000000000000000000..98ea8c0dc97ebfd330c57f8852eaf2fa379aef50
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TagValue.java
@@ -0,0 +1,17 @@
+package com.taosdata.taosdemo.domain;
+
+import lombok.Data;
+
+@Data
+public class TagValue {
+ private String name;
+ private T value;
+
+ public TagValue() {
+ }
+
+ public TagValue(String name, T value) {
+ this.name = name;
+ this.value = value;
+ }
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/DatabaseMapper.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/DatabaseMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..e535ed1f985d37688c8461e1f0bef3a803f541d4
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/DatabaseMapper.java
@@ -0,0 +1,27 @@
+package com.taosdata.taosdemo.mapper;
+
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.Map;
+
+@Repository
+public interface DatabaseMapper {
+
+ // create database if not exists XXX
+ int createDatabase(@Param("database") String dbname);
+
+ // drop database if exists XXX
+ int dropDatabase(@Param("database") String dbname);
+
+ // create database if not exists XXX keep XX days XX replica XX
+ int createDatabaseWithParameters(Map map);
+
+ // use XXX
+ int useDatabase(@Param("database") String dbname);
+
+ //TODO: alter database
+
+ //TODO: show database
+
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/DatabaseMapper.xml b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/DatabaseMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..1a1de348428ae63ad16f9988f535f339f61d8c25
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/DatabaseMapper.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+ create database if not exists ${database}
+
+
+
+ DROP database if exists ${database}
+
+
+
+ CREATE database if not exists ${database}
+
+ KEEP ${keep}
+
+
+ DAYS ${days}
+
+
+ REPLICA ${replica}
+
+
+ cache ${cache}
+
+
+ blocks ${blocks}
+
+
+ minrows ${minrows}
+
+
+ maxrows ${maxrows}
+
+
+
+
+ use ${database}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/SubTableMapper.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/SubTableMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..d23473ba313899eee04f07f5c06177a2d55f6295
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/SubTableMapper.java
@@ -0,0 +1,30 @@
+package com.taosdata.taosdemo.mapper;
+
+import com.taosdata.taosdemo.domain.SubTableMeta;
+import com.taosdata.taosdemo.domain.SubTableValue;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface SubTableMapper {
+
+ // 创建:子表
+ int createUsingSuperTable(SubTableMeta subTableMeta);
+
+ // 插入:一张子表多个values
+ int insertOneTableMultiValues(SubTableValue subTableValue);
+
+ // 插入:一张子表多个values, 自动建表
+ int insertOneTableMultiValuesUsingSuperTable(SubTableValue subTableValue);
+
+ // 插入:多张表多个values
+ int insertMultiTableMultiValues(@Param("tables") List tables);
+
+ // 插入:多张表多个values,自动建表
+ int insertMultiTableMultiValuesUsingSuperTable(@Param("tables") List tables);
+
+ //
+
+}
\ No newline at end of file
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/SubTableMapper.xml b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/SubTableMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2fb94e99b77623ab8731c03f398058dbdc459d07
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/SubTableMapper.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+ CREATE table IF NOT EXISTS ${database}.${name} USING ${supertable} TAGS
+
+ #{tag.value}
+
+
+
+
+
+ INSERT INTO ${database}.${name}
+ VALUES
+
+
+ #{field.value}
+
+
+
+
+
+
+ INSERT INTO ${database}.${name} USING ${supertable} TAGS
+
+ #{tag.value}
+
+ VALUES
+
+
+ #{field.value}
+
+
+
+
+
+
+
+
+
+
+ INSERT INTO
+
+ ${table.database}.${table.name}
+ VALUES
+
+
+ #{field.value}
+
+
+
+
+
+
+
+ INSERT INTO
+
+ ${table.database}.${table.name} USING ${table.supertable} TAGS
+
+ #{tag.value}
+
+ VALUES
+
+
+ #{field.value}
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/SuperTableMapper.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/SuperTableMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..c8610fac901efa907971d700bd9956cac264236f
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/SuperTableMapper.java
@@ -0,0 +1,33 @@
+package com.taosdata.taosdemo.mapper;
+
+import com.taosdata.taosdemo.domain.SuperTableMeta;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface SuperTableMapper {
+
+ // 创建超级表,使用自己定义的SQL语句
+ int createSuperTableUsingSQL(@Param("createSuperTableSQL") String sql);
+
+ // 创建超级表 create table if not exists xxx.xxx (f1 type1, f2 type2, ... ) tags( t1 type1, t2 type2 ...)
+ int createSuperTable(SuperTableMeta tableMetadata);
+
+ // 删除超级表 drop table if exists xxx;
+ int dropSuperTable(@Param("database") String database, @Param("name") String name);
+
+ //
+
+ //
+
+ //
+
+ //
+
+ //
+
+ //
+
+ //
+
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/SuperTableMapper.xml b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/SuperTableMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..8b83d57a4bcbf7a2a6b3f69911b3accc61064480
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/SuperTableMapper.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+ ${createSuperTableSQL}
+
+
+
+
+ create table if not exists ${database}.${name}
+
+ ${field.name} ${field.type}
+
+ tags
+
+ ${tag.name} ${tag.type}
+
+
+
+
+
+ drop table if exists ${database}.${name}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/TableMapper.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/TableMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..f00f6c96941d47258d91a34ffeb1de99c4c8435e
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/TableMapper.java
@@ -0,0 +1,28 @@
+package com.taosdata.taosdemo.mapper;
+
+import com.taosdata.taosdemo.domain.TableMeta;
+import com.taosdata.taosdemo.domain.TableValue;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface TableMapper {
+
+ // 创建:普通表
+ int create(TableMeta tableMeta);
+
+ // 插入:一张表多个value
+ int insertOneTableMultiValues(TableValue values);
+
+ // 插入: 一张表多个value,指定的列
+ int insertOneTableMultiValuesWithColumns(TableValue values);
+
+ // 插入:多个表多个value
+ int insertMultiTableMultiValues(@Param("tables") List tables);
+
+ // 插入:多个表多个value, 指定的列
+ int insertMultiTableMultiValuesWithColumns(@Param("tables") List tables);
+
+}
\ No newline at end of file
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/TableMapper.xml b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/TableMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e2e7cbb30def21f88ec7615b7a6dd4a769cb643a
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/mapper/TableMapper.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+ create table if not exists ${database}.${name}
+
+ ${field.name} ${field.type}
+
+
+
+
+
+ insert into ${database}.${name} values
+
+
+ ${field.value}
+
+
+
+
+
+
+ insert into ${database}.${name}
+
+ ${column.name}
+
+ values
+
+
+ ${field.value}
+
+
+
+
+
+
+ insert into
+
+ ${table.database}.${table.name} values
+
+
+ ${field.value}
+
+
+
+
+
+
+
+ insert into
+
+ ${table.database}.${table.name}
+
+ ${column.name}
+
+ values
+
+
+ ${field.value}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/AbstractService.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/AbstractService.java
new file mode 100644
index 0000000000000000000000000000000000000000..4afbe9dae82516e050eb7d729d6ecb8eb1e59d6b
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/AbstractService.java
@@ -0,0 +1,35 @@
+package com.taosdata.taosdemo.service;
+
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+public class AbstractService {
+
+ protected int getAffectRows(List> futureList) {
+ int count = 0;
+ for (Future future : futureList) {
+ try {
+ count += future.get();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ }
+ return count;
+ }
+
+ protected int getAffectRows(Future future) {
+ int count = 0;
+ try {
+ count += future.get();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ return count;
+ }
+
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/DatabaseService.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/DatabaseService.java
new file mode 100644
index 0000000000000000000000000000000000000000..e9aa2727a06ade0ff3d7661f84977c64f64ea9af
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/DatabaseService.java
@@ -0,0 +1,38 @@
+package com.taosdata.taosdemo.service;
+
+import com.taosdata.taosdemo.mapper.DatabaseMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+@Service
+public class DatabaseService {
+
+ @Autowired
+ private DatabaseMapper databaseMapper;
+
+ // 建库,指定 name
+ public int createDatabase(String database) {
+ return databaseMapper.createDatabase(database);
+ }
+
+ // 建库,指定参数 keep,days,replica等
+ public int createDatabase(Map map) {
+ if (map.isEmpty())
+ return 0;
+ if (map.containsKey("database") && map.size() == 1)
+ return databaseMapper.createDatabase(map.get("database"));
+ return databaseMapper.createDatabaseWithParameters(map);
+ }
+
+ // drop database
+ public int dropDatabase(String dbname) {
+ return databaseMapper.dropDatabase(dbname);
+ }
+
+ // use database
+ public int useDatabase(String dbname) {
+ return databaseMapper.useDatabase(dbname);
+ }
+}
diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SubTableService.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SubTableService.java
new file mode 100644
index 0000000000000000000000000000000000000000..07c315b65a9e07222fe85066c3f1f3b1edb107fe
--- /dev/null
+++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SubTableService.java
@@ -0,0 +1,118 @@
+package com.taosdata.taosdemo.service;
+
+import com.taosdata.taosdemo.domain.SubTableMeta;
+import com.taosdata.taosdemo.domain.SubTableValue;
+import com.taosdata.taosdemo.mapper.SubTableMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+@Service
+public class SubTableService extends AbstractService {
+
+ @Autowired
+ private SubTableMapper mapper;
+
+ /**
+ * 1. 选择database,找到所有supertable
+ * 2. 选择supertable,可以拿到表结构,包括field和tag
+ * 3. 指定子表的前缀和个数
+ * 4. 指定创建子表的线程数
+ */
+ //TODO:指定database、supertable、子表前缀、子表个数、线程数
+
+ // 多线程创建表,指定线程个数
+ public int createSubTable(List subTables, int threadSize) {
+ ExecutorService executor = Executors.newFixedThreadPool(threadSize);
+ List> futureList = new ArrayList<>();
+ for (SubTableMeta subTableMeta : subTables) {
+ Future future = executor.submit(() -> createSubTable(subTableMeta));
+ futureList.add(future);
+ }
+ executor.shutdown();
+ return getAffectRows(futureList);
+ }
+
+
+ // 创建一张子表,可以指定database,supertable,tablename,tag值
+ public int createSubTable(SubTableMeta subTableMeta) {
+ return mapper.createUsingSuperTable(subTableMeta);
+ }
+
+ // 单线程创建多张子表,每张子表分别可以指定自己的database,supertable,tablename,tag值
+ public int createSubTable(List subTables) {
+ return createSubTable(subTables, 1);
+ }
+
+ /*************************************************************************************************************************/
+ // 插入:多线程,多表
+ public int insert(List subTableValues, int threadSize) {
+ ExecutorService executor = Executors.newFixedThreadPool(threadSize);
+ Future future = executor.submit(() -> insert(subTableValues));
+ executor.shutdown();
+ return getAffectRows(future);
+ }
+
+ // 插入:多线程,多表, 自动建表
+ public int insertAutoCreateTable(List subTableValues, int threadSize) {
+ ExecutorService executor = Executors.newFixedThreadPool(threadSize);
+ Future future = executor.submit(() -> insertAutoCreateTable(subTableValues));
+ executor.shutdown();
+ return getAffectRows(future);
+ }
+
+ // 插入:单表,insert into xxx values(),()...
+ public int insert(SubTableValue subTableValue) {
+ return mapper.insertOneTableMultiValues(subTableValue);
+ }
+
+ // 插入: 多表,insert into xxx values(),()... xxx values(),()...
+ public int insert(List subTableValues) {
+ return mapper.insertMultiTableMultiValuesUsingSuperTable(subTableValues);
+ }
+
+ // 插入:单表,自动建表, insert into xxx using xxx tags(...) values(),()...
+ public int insertAutoCreateTable(SubTableValue subTableValue) {
+ return mapper.insertOneTableMultiValuesUsingSuperTable(subTableValue);
+ }
+
+ // 插入:多表,自动建表, insert into xxx using XXX tags(...) values(),()... xxx using XXX tags(...) values(),()...
+ public int insertAutoCreateTable(List subTableValues) {
+ return mapper.insertMultiTableMultiValuesUsingSuperTable(subTableValues);
+ }
+
+
+// ExecutorService executors = Executors.newFixedThreadPool(threadSize);
+// int count = 0;
+//
+// //
+// List subTableValues = new ArrayList<>();
+// for (int tableIndex = 1; tableIndex <= numOfTablesPerSQL; tableIndex++) {
+// // each table
+// SubTableValue subTableValue = new SubTableValue();
+// subTableValue.setDatabase();
+// subTableValue.setName();
+// subTableValue.setSupertable();
+//
+// List values = new ArrayList<>();
+// for (int valueCnt = 0; valueCnt < numOfValuesPerSQL; valueCnt++) {
+// List fields = new ArrayList<>();
+// for (int fieldInd = 0; fieldInd <; fieldInd++) {
+// FieldValue