Feature/sangshuduo/td 4068 taosdemo stmt (#6166)
* merge with develop branch. change query/tests/CMakeLists.txt to allow unused function and variable. * refactor data generating. * refactor. * refactor. * refactor. Co-authored-by: Shuduo Sang <sdsang@taosdata.com>
This commit is contained in:
parent
b05e9dc640
commit
0a07ea10ad
|
@ -70,6 +70,8 @@ enum TEST_MODE {
|
||||||
|
|
||||||
#define MAX_RECORDS_PER_REQ 32766
|
#define MAX_RECORDS_PER_REQ 32766
|
||||||
|
|
||||||
|
#define HEAD_BUFF_LEN 1024*24 // 16*1024 + (192+32)*2 + insert into ..
|
||||||
|
|
||||||
#define MAX_SQL_SIZE 65536
|
#define MAX_SQL_SIZE 65536
|
||||||
#define BUFFER_SIZE (65536*2)
|
#define BUFFER_SIZE (65536*2)
|
||||||
#define COND_BUF_LEN BUFFER_SIZE - 30
|
#define COND_BUF_LEN BUFFER_SIZE - 30
|
||||||
|
@ -1079,8 +1081,6 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool getInfoFromJsonFile(char* file);
|
static bool getInfoFromJsonFile(char* file);
|
||||||
//static int generateOneRowDataForStb(SSuperTable* stbInfo);
|
|
||||||
//static int getDataIntoMemForStb(SSuperTable* stbInfo);
|
|
||||||
static void init_rand_data();
|
static void init_rand_data();
|
||||||
static void tmfclose(FILE *fp) {
|
static void tmfclose(FILE *fp) {
|
||||||
if (NULL != fp) {
|
if (NULL != fp) {
|
||||||
|
@ -1180,7 +1180,8 @@ static void appendResultToFile(TAOS_RES *res, char* resultFile) {
|
||||||
totalLen += len;
|
totalLen += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
verbosePrint("%s() LN%d, databuf=%s resultFile=%s\n", __func__, __LINE__, databuf, resultFile);
|
verbosePrint("%s() LN%d, databuf=%s resultFile=%s\n",
|
||||||
|
__func__, __LINE__, databuf, resultFile);
|
||||||
appendResultBufToFile(databuf, resultFile);
|
appendResultBufToFile(databuf, resultFile);
|
||||||
free(databuf);
|
free(databuf);
|
||||||
}
|
}
|
||||||
|
@ -1640,8 +1641,10 @@ static void printfInsertMetaToFile(FILE* fp) {
|
||||||
*/
|
*/
|
||||||
fprintf(fp, " interlaceRows: %"PRIu64"\n",
|
fprintf(fp, " interlaceRows: %"PRIu64"\n",
|
||||||
g_Dbs.db[i].superTbls[j].interlaceRows);
|
g_Dbs.db[i].superTbls[j].interlaceRows);
|
||||||
fprintf(fp, " disorderRange: %d\n", g_Dbs.db[i].superTbls[j].disorderRange);
|
fprintf(fp, " disorderRange: %d\n",
|
||||||
fprintf(fp, " disorderRatio: %d\n", g_Dbs.db[i].superTbls[j].disorderRatio);
|
g_Dbs.db[i].superTbls[j].disorderRange);
|
||||||
|
fprintf(fp, " disorderRatio: %d\n",
|
||||||
|
g_Dbs.db[i].superTbls[j].disorderRatio);
|
||||||
fprintf(fp, " maxSqlLen: %"PRIu64"\n",
|
fprintf(fp, " maxSqlLen: %"PRIu64"\n",
|
||||||
g_Dbs.db[i].superTbls[j].maxSqlLen);
|
g_Dbs.db[i].superTbls[j].maxSqlLen);
|
||||||
|
|
||||||
|
@ -1649,11 +1652,15 @@ static void printfInsertMetaToFile(FILE* fp) {
|
||||||
g_Dbs.db[i].superTbls[j].timeStampStep);
|
g_Dbs.db[i].superTbls[j].timeStampStep);
|
||||||
fprintf(fp, " startTimestamp: %s\n",
|
fprintf(fp, " startTimestamp: %s\n",
|
||||||
g_Dbs.db[i].superTbls[j].startTimestamp);
|
g_Dbs.db[i].superTbls[j].startTimestamp);
|
||||||
fprintf(fp, " sampleFormat: %s\n", g_Dbs.db[i].superTbls[j].sampleFormat);
|
fprintf(fp, " sampleFormat: %s\n",
|
||||||
fprintf(fp, " sampleFile: %s\n", g_Dbs.db[i].superTbls[j].sampleFile);
|
g_Dbs.db[i].superTbls[j].sampleFormat);
|
||||||
fprintf(fp, " tagsFile: %s\n", g_Dbs.db[i].superTbls[j].tagsFile);
|
fprintf(fp, " sampleFile: %s\n",
|
||||||
|
g_Dbs.db[i].superTbls[j].sampleFile);
|
||||||
|
fprintf(fp, " tagsFile: %s\n",
|
||||||
|
g_Dbs.db[i].superTbls[j].tagsFile);
|
||||||
|
|
||||||
fprintf(fp, " columnCount: %d\n ", g_Dbs.db[i].superTbls[j].columnCount);
|
fprintf(fp, " columnCount: %d\n ",
|
||||||
|
g_Dbs.db[i].superTbls[j].columnCount);
|
||||||
for (int k = 0; k < g_Dbs.db[i].superTbls[j].columnCount; k++) {
|
for (int k = 0; k < g_Dbs.db[i].superTbls[j].columnCount; k++) {
|
||||||
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].columns[k].dataType, g_Dbs.db[i].superTbls[j].columns[k].dataLen);
|
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].columns[k].dataType, g_Dbs.db[i].superTbls[j].columns[k].dataLen);
|
||||||
if ((0 == strncasecmp(
|
if ((0 == strncasecmp(
|
||||||
|
@ -1665,7 +1672,8 @@ static void printfInsertMetaToFile(FILE* fp) {
|
||||||
g_Dbs.db[i].superTbls[j].columns[k].dataType,
|
g_Dbs.db[i].superTbls[j].columns[k].dataType,
|
||||||
g_Dbs.db[i].superTbls[j].columns[k].dataLen);
|
g_Dbs.db[i].superTbls[j].columns[k].dataLen);
|
||||||
} else {
|
} else {
|
||||||
fprintf(fp, "column[%d]:%s ", k, g_Dbs.db[i].superTbls[j].columns[k].dataType);
|
fprintf(fp, "column[%d]:%s ",
|
||||||
|
k, g_Dbs.db[i].superTbls[j].columns[k].dataType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
|
@ -4637,16 +4645,22 @@ static int getRowDataFromSample(
|
||||||
return dataLen;
|
return dataLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t generateRowData(char* recBuf, int64_t timestamp, SSuperTable* stbInfo) {
|
static int64_t generateStbRowData(
|
||||||
|
SSuperTable* stbInfo,
|
||||||
|
char* recBuf, int64_t timestamp
|
||||||
|
) {
|
||||||
int64_t dataLen = 0;
|
int64_t dataLen = 0;
|
||||||
char *pstr = recBuf;
|
char *pstr = recBuf;
|
||||||
int64_t maxLen = MAX_DATA_SIZE;
|
int64_t maxLen = MAX_DATA_SIZE;
|
||||||
|
|
||||||
dataLen += snprintf(pstr + dataLen, maxLen - dataLen, "(%" PRId64 ",", timestamp);
|
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
||||||
|
"(%" PRId64 ",", timestamp);
|
||||||
|
|
||||||
for (int i = 0; i < stbInfo->columnCount; i++) {
|
for (int i = 0; i < stbInfo->columnCount; i++) {
|
||||||
if ((0 == strncasecmp(stbInfo->columns[i].dataType, "BINARY", strlen("BINARY")))
|
if ((0 == strncasecmp(stbInfo->columns[i].dataType,
|
||||||
|| (0 == strncasecmp(stbInfo->columns[i].dataType, "NCHAR", strlen("NCHAR")))) {
|
"BINARY", strlen("BINARY")))
|
||||||
|
|| (0 == strncasecmp(stbInfo->columns[i].dataType,
|
||||||
|
"NCHAR", strlen("NCHAR")))) {
|
||||||
if (stbInfo->columns[i].dataLen > TSDB_MAX_BINARY_LEN) {
|
if (stbInfo->columns[i].dataLen > TSDB_MAX_BINARY_LEN) {
|
||||||
errorPrint( "binary or nchar length overflow, max size:%u\n",
|
errorPrint( "binary or nchar length overflow, max size:%u\n",
|
||||||
(uint32_t)TSDB_MAX_BINARY_LEN);
|
(uint32_t)TSDB_MAX_BINARY_LEN);
|
||||||
|
@ -4708,7 +4722,7 @@ static int64_t generateRowData(char* recBuf, int64_t timestamp, SSuperTable* stb
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t generateData(char *recBuf, char **data_type,
|
static int64_t generateData(char *recBuf, char **data_type,
|
||||||
int num_of_cols, int64_t timestamp, int lenOfBinary) {
|
int64_t timestamp, int lenOfBinary) {
|
||||||
memset(recBuf, 0, MAX_DATA_SIZE);
|
memset(recBuf, 0, MAX_DATA_SIZE);
|
||||||
char *pstr = recBuf;
|
char *pstr = recBuf;
|
||||||
pstr += sprintf(pstr, "(%" PRId64, timestamp);
|
pstr += sprintf(pstr, "(%" PRId64, timestamp);
|
||||||
|
@ -4859,99 +4873,52 @@ static void getTableName(char *pTblName, threadInfo* pThreadInfo, uint64_t table
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t generateDataTail(
|
static int64_t generateDataTailWithoutStb(
|
||||||
SSuperTable* superTblInfo,
|
uint64_t batch, char* buffer,
|
||||||
uint64_t batch, char* buffer, int64_t remainderBufLen, int64_t insertRows,
|
int64_t remainderBufLen, int64_t insertRows,
|
||||||
uint64_t startFrom, int64_t startTime, int64_t *pSamplePos, int64_t *dataLen) {
|
uint64_t startFrom, int64_t startTime,
|
||||||
|
/* int64_t *pSamplePos, */int64_t *dataLen) {
|
||||||
|
|
||||||
uint64_t len = 0;
|
uint64_t len = 0;
|
||||||
uint32_t ncols_per_record = 1; // count first col ts
|
|
||||||
|
|
||||||
char *pstr = buffer;
|
char *pstr = buffer;
|
||||||
|
|
||||||
if (superTblInfo == NULL) {
|
|
||||||
uint32_t datatypeSeq = 0;
|
|
||||||
while(g_args.datatype[datatypeSeq]) {
|
|
||||||
datatypeSeq ++;
|
|
||||||
ncols_per_record ++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
verbosePrint("%s() LN%d batch=%"PRIu64"\n", __func__, __LINE__, batch);
|
verbosePrint("%s() LN%d batch=%"PRIu64"\n", __func__, __LINE__, batch);
|
||||||
|
|
||||||
uint64_t k = 0;
|
int64_t k = 0;
|
||||||
for (k = 0; k < batch;) {
|
for (k = 0; k < batch;) {
|
||||||
char data[MAX_DATA_SIZE];
|
char data[MAX_DATA_SIZE];
|
||||||
memset(data, 0, MAX_DATA_SIZE);
|
memset(data, 0, MAX_DATA_SIZE);
|
||||||
|
|
||||||
int64_t retLen = 0;
|
int64_t retLen = 0;
|
||||||
|
|
||||||
if (superTblInfo) {
|
char **data_type = g_args.datatype;
|
||||||
if (0 == strncasecmp(superTblInfo->dataSource,
|
int lenOfBinary = g_args.len_of_binary;
|
||||||
"sample", strlen("sample"))) {
|
|
||||||
retLen = getRowDataFromSample(
|
|
||||||
data,
|
|
||||||
remainderBufLen,
|
|
||||||
startTime + superTblInfo->timeStampStep * k,
|
|
||||||
superTblInfo,
|
|
||||||
pSamplePos);
|
|
||||||
} else if (0 == strncasecmp(superTblInfo->dataSource,
|
|
||||||
"rand", strlen("rand"))) {
|
|
||||||
|
|
||||||
int64_t randTail = superTblInfo->timeStampStep * k;
|
int64_t randTail = DEFAULT_TIMESTAMP_STEP * k;
|
||||||
if (superTblInfo->disorderRatio > 0) {
|
|
||||||
int rand_num = taosRandom() % 100;
|
|
||||||
if(rand_num < superTblInfo->disorderRatio) {
|
|
||||||
randTail = (randTail + (taosRandom() % superTblInfo->disorderRange + 1)) * (-1);
|
|
||||||
debugPrint("rand data generated, back %"PRId64"\n", randTail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t d = startTime
|
if (g_args.disorderRatio != 0) {
|
||||||
+ randTail;
|
|
||||||
retLen = generateRowData(
|
|
||||||
data,
|
|
||||||
d,
|
|
||||||
superTblInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (retLen > remainderBufLen) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
pstr += snprintf(pstr , retLen + 1, "%s", data);
|
|
||||||
k++;
|
|
||||||
len += retLen;
|
|
||||||
remainderBufLen -= retLen;
|
|
||||||
} else {
|
|
||||||
char **data_type = g_args.datatype;
|
|
||||||
int lenOfBinary = g_args.len_of_binary;
|
|
||||||
|
|
||||||
int64_t randTail = DEFAULT_TIMESTAMP_STEP * k;
|
|
||||||
|
|
||||||
if (g_args.disorderRatio != 0) {
|
|
||||||
int rand_num = taosRandom() % 100;
|
int rand_num = taosRandom() % 100;
|
||||||
if (rand_num < g_args.disorderRatio) {
|
if (rand_num < g_args.disorderRatio) {
|
||||||
randTail = (randTail + (taosRandom() % g_args.disorderRange + 1)) * (-1);
|
randTail = (randTail +
|
||||||
|
(taosRandom() % g_args.disorderRange + 1)) * (-1);
|
||||||
|
|
||||||
debugPrint("rand data generated, back %"PRId64"\n", randTail);
|
debugPrint("rand data generated, back %"PRId64"\n", randTail);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
randTail = DEFAULT_TIMESTAMP_STEP * k;
|
randTail = DEFAULT_TIMESTAMP_STEP * k;
|
||||||
}
|
}
|
||||||
|
|
||||||
retLen = generateData(data, data_type,
|
retLen = generateData(data, data_type,
|
||||||
ncols_per_record,
|
startTime + randTail,
|
||||||
startTime + randTail,
|
lenOfBinary);
|
||||||
lenOfBinary);
|
|
||||||
|
|
||||||
if (len > remainderBufLen)
|
if (len > remainderBufLen)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pstr += sprintf(pstr, "%s", data);
|
pstr += sprintf(pstr, "%s", data);
|
||||||
k++;
|
k++;
|
||||||
len += retLen;
|
len += retLen;
|
||||||
remainderBufLen -= retLen;
|
remainderBufLen -= retLen;
|
||||||
}
|
|
||||||
|
|
||||||
verbosePrint("%s() LN%d len=%"PRIu64" k=%"PRIu64" \nbuffer=%s\n",
|
verbosePrint("%s() LN%d len=%"PRIu64" k=%"PRIu64" \nbuffer=%s\n",
|
||||||
__func__, __LINE__, len, k, buffer);
|
__func__, __LINE__, len, k, buffer);
|
||||||
|
@ -4967,17 +4934,107 @@ static int64_t generateDataTail(
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int generateSQLHead(char *tableName, int32_t tableSeq,
|
static int64_t generateStbDataTail(
|
||||||
threadInfo* pThreadInfo, SSuperTable* superTblInfo,
|
SSuperTable* superTblInfo,
|
||||||
|
uint64_t batch, char* buffer,
|
||||||
|
int64_t remainderBufLen, int64_t insertRows,
|
||||||
|
uint64_t startFrom, int64_t startTime,
|
||||||
|
int64_t *pSamplePos, int64_t *dataLen) {
|
||||||
|
uint64_t len = 0;
|
||||||
|
|
||||||
|
char *pstr = buffer;
|
||||||
|
|
||||||
|
verbosePrint("%s() LN%d batch=%"PRIu64"\n", __func__, __LINE__, batch);
|
||||||
|
|
||||||
|
int64_t k = 0;
|
||||||
|
for (k = 0; k < batch;) {
|
||||||
|
char data[MAX_DATA_SIZE];
|
||||||
|
memset(data, 0, MAX_DATA_SIZE);
|
||||||
|
|
||||||
|
int64_t retLen = 0;
|
||||||
|
|
||||||
|
if (0 == strncasecmp(superTblInfo->dataSource,
|
||||||
|
"sample", strlen("sample"))) {
|
||||||
|
retLen = getRowDataFromSample(
|
||||||
|
data,
|
||||||
|
remainderBufLen,
|
||||||
|
startTime + superTblInfo->timeStampStep * k,
|
||||||
|
superTblInfo,
|
||||||
|
pSamplePos);
|
||||||
|
} else if (0 == strncasecmp(superTblInfo->dataSource,
|
||||||
|
"rand", strlen("rand"))) {
|
||||||
|
int64_t randTail = superTblInfo->timeStampStep * k;
|
||||||
|
if (superTblInfo->disorderRatio > 0) {
|
||||||
|
int rand_num = taosRandom() % 100;
|
||||||
|
if(rand_num < superTblInfo->disorderRatio) {
|
||||||
|
randTail = (randTail +
|
||||||
|
(taosRandom() % superTblInfo->disorderRange + 1)) * (-1);
|
||||||
|
debugPrint("rand data generated, back %"PRId64"\n", randTail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t d = startTime + randTail;
|
||||||
|
retLen = generateStbRowData(superTblInfo, data, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (retLen > remainderBufLen) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
pstr += snprintf(pstr , retLen + 1, "%s", data);
|
||||||
|
k++;
|
||||||
|
len += retLen;
|
||||||
|
remainderBufLen -= retLen;
|
||||||
|
|
||||||
|
verbosePrint("%s() LN%d len=%"PRIu64" k=%"PRIu64" \nbuffer=%s\n",
|
||||||
|
__func__, __LINE__, len, k, buffer);
|
||||||
|
|
||||||
|
startFrom ++;
|
||||||
|
|
||||||
|
if (startFrom >= insertRows) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*dataLen = len;
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int generateSQLHeadWithoutStb(char *tableName,
|
||||||
|
char *dbName,
|
||||||
char *buffer, int remainderBufLen)
|
char *buffer, int remainderBufLen)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
#define HEAD_BUFF_LEN 1024*24 // 16*1024 + (192+32)*2 + insert into ..
|
|
||||||
char headBuf[HEAD_BUFF_LEN];
|
char headBuf[HEAD_BUFF_LEN];
|
||||||
|
|
||||||
if (superTblInfo) {
|
len = snprintf(
|
||||||
if (AUTO_CREATE_SUBTBL == superTblInfo->autoCreateTable) {
|
headBuf,
|
||||||
|
HEAD_BUFF_LEN,
|
||||||
|
"%s.%s values",
|
||||||
|
dbName,
|
||||||
|
tableName);
|
||||||
|
|
||||||
|
if (len > remainderBufLen)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
tstrncpy(buffer, headBuf, len + 1);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int generateStbSQLHead(
|
||||||
|
SSuperTable* superTblInfo,
|
||||||
|
char *tableName, int32_t tableSeq,
|
||||||
|
char *dbName,
|
||||||
|
char *buffer, int remainderBufLen)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
char headBuf[HEAD_BUFF_LEN];
|
||||||
|
|
||||||
|
if (AUTO_CREATE_SUBTBL == superTblInfo->autoCreateTable) {
|
||||||
char* tagsValBuf = NULL;
|
char* tagsValBuf = NULL;
|
||||||
if (0 == superTblInfo->tagSource) {
|
if (0 == superTblInfo->tagSource) {
|
||||||
tagsValBuf = generateTagVaulesForStb(superTblInfo, tableSeq);
|
tagsValBuf = generateTagVaulesForStb(superTblInfo, tableSeq);
|
||||||
|
@ -4996,9 +5053,9 @@ static int generateSQLHead(char *tableName, int32_t tableSeq,
|
||||||
headBuf,
|
headBuf,
|
||||||
HEAD_BUFF_LEN,
|
HEAD_BUFF_LEN,
|
||||||
"%s.%s using %s.%s tags %s values",
|
"%s.%s using %s.%s tags %s values",
|
||||||
pThreadInfo->db_name,
|
dbName,
|
||||||
tableName,
|
tableName,
|
||||||
pThreadInfo->db_name,
|
dbName,
|
||||||
superTblInfo->sTblName,
|
superTblInfo->sTblName,
|
||||||
tagsValBuf);
|
tagsValBuf);
|
||||||
tmfree(tagsValBuf);
|
tmfree(tagsValBuf);
|
||||||
|
@ -5007,22 +5064,14 @@ static int generateSQLHead(char *tableName, int32_t tableSeq,
|
||||||
headBuf,
|
headBuf,
|
||||||
HEAD_BUFF_LEN,
|
HEAD_BUFF_LEN,
|
||||||
"%s.%s values",
|
"%s.%s values",
|
||||||
pThreadInfo->db_name,
|
dbName,
|
||||||
tableName);
|
tableName);
|
||||||
} else {
|
} else {
|
||||||
len = snprintf(
|
len = snprintf(
|
||||||
headBuf,
|
headBuf,
|
||||||
HEAD_BUFF_LEN,
|
HEAD_BUFF_LEN,
|
||||||
"%s.%s values",
|
"%s.%s values",
|
||||||
pThreadInfo->db_name,
|
dbName,
|
||||||
tableName);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
len = snprintf(
|
|
||||||
headBuf,
|
|
||||||
HEAD_BUFF_LEN,
|
|
||||||
"%s.%s values",
|
|
||||||
pThreadInfo->db_name,
|
|
||||||
tableName);
|
tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5046,8 +5095,10 @@ static int64_t generateInterlaceDataBuffer(
|
||||||
char *pstr = buffer;
|
char *pstr = buffer;
|
||||||
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
|
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
|
||||||
|
|
||||||
int headLen = generateSQLHead(tableName, tableSeq, pThreadInfo,
|
int headLen = generateStbSQLHead(
|
||||||
superTblInfo, pstr, *pRemainderBufLen);
|
superTblInfo,
|
||||||
|
tableName, tableSeq, pThreadInfo->db_name,
|
||||||
|
pstr, *pRemainderBufLen);
|
||||||
|
|
||||||
if (headLen <= 0) {
|
if (headLen <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -5065,19 +5116,24 @@ static int64_t generateInterlaceDataBuffer(
|
||||||
pThreadInfo->threadID, __func__, __LINE__,
|
pThreadInfo->threadID, __func__, __LINE__,
|
||||||
i, batchPerTblTimes, batchPerTbl);
|
i, batchPerTblTimes, batchPerTbl);
|
||||||
|
|
||||||
|
int64_t k;
|
||||||
if (superTblInfo) {
|
if (superTblInfo) {
|
||||||
if (0 == strncasecmp(superTblInfo->startTimestamp, "now", 3)) {
|
if (0 == strncasecmp(superTblInfo->startTimestamp, "now", 3)) {
|
||||||
startTime = taosGetTimestamp(pThreadInfo->time_precision);
|
startTime = taosGetTimestamp(pThreadInfo->time_precision);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
startTime = 1500000000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t k = generateDataTail(
|
k = generateStbDataTail(
|
||||||
superTblInfo,
|
superTblInfo,
|
||||||
batchPerTbl, pstr, *pRemainderBufLen, insertRows, 0,
|
batchPerTbl, pstr, *pRemainderBufLen, insertRows, 0,
|
||||||
startTime,
|
startTime,
|
||||||
&(pThreadInfo->samplePos), &dataLen);
|
&(pThreadInfo->samplePos), &dataLen);
|
||||||
|
} else {
|
||||||
|
startTime = 1500000000000;
|
||||||
|
k = generateDataTailWithoutStb(
|
||||||
|
batchPerTbl, pstr, *pRemainderBufLen, insertRows, 0,
|
||||||
|
startTime,
|
||||||
|
/* &(pThreadInfo->samplePos), */&dataLen);
|
||||||
|
}
|
||||||
|
|
||||||
if (k == batchPerTbl) {
|
if (k == batchPerTbl) {
|
||||||
pstr += dataLen;
|
pstr += dataLen;
|
||||||
|
@ -5103,25 +5159,23 @@ static int64_t generateProgressiveDataBuffer(
|
||||||
{
|
{
|
||||||
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
|
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
|
||||||
|
|
||||||
int ncols_per_record = 1; // count first col ts
|
|
||||||
|
|
||||||
if (superTblInfo == NULL) {
|
|
||||||
int datatypeSeq = 0;
|
|
||||||
while(g_args.datatype[datatypeSeq]) {
|
|
||||||
datatypeSeq ++;
|
|
||||||
ncols_per_record ++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(buffer != NULL);
|
assert(buffer != NULL);
|
||||||
char *pstr = buffer;
|
char *pstr = buffer;
|
||||||
|
|
||||||
int64_t k = 0;
|
|
||||||
|
|
||||||
memset(buffer, 0, *pRemainderBufLen);
|
memset(buffer, 0, *pRemainderBufLen);
|
||||||
|
|
||||||
int64_t headLen = generateSQLHead(tableName, tableSeq, pThreadInfo, superTblInfo,
|
int64_t headLen;
|
||||||
|
|
||||||
|
if (superTblInfo) {
|
||||||
|
headLen = generateStbSQLHead(
|
||||||
|
superTblInfo,
|
||||||
|
tableName, tableSeq, pThreadInfo->db_name,
|
||||||
buffer, *pRemainderBufLen);
|
buffer, *pRemainderBufLen);
|
||||||
|
} else {
|
||||||
|
headLen = generateSQLHeadWithoutStb(
|
||||||
|
tableName, pThreadInfo->db_name,
|
||||||
|
buffer, *pRemainderBufLen);
|
||||||
|
}
|
||||||
|
|
||||||
if (headLen <= 0) {
|
if (headLen <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -5130,10 +5184,20 @@ static int64_t generateProgressiveDataBuffer(
|
||||||
*pRemainderBufLen -= headLen;
|
*pRemainderBufLen -= headLen;
|
||||||
|
|
||||||
int64_t dataLen;
|
int64_t dataLen;
|
||||||
k = generateDataTail(superTblInfo,
|
int64_t k;
|
||||||
g_args.num_of_RPR, pstr, *pRemainderBufLen, insertRows, startFrom,
|
|
||||||
|
if (superTblInfo) {
|
||||||
|
k = generateStbDataTail(superTblInfo,
|
||||||
|
g_args.num_of_RPR, pstr, *pRemainderBufLen,
|
||||||
|
insertRows, startFrom,
|
||||||
startTime,
|
startTime,
|
||||||
pSamplePos, &dataLen);
|
pSamplePos, &dataLen);
|
||||||
|
} else {
|
||||||
|
k = generateDataTailWithoutStb(
|
||||||
|
g_args.num_of_RPR, pstr, *pRemainderBufLen, insertRows, startFrom,
|
||||||
|
startTime,
|
||||||
|
/*pSamplePos, */&dataLen);
|
||||||
|
}
|
||||||
|
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
@ -5147,6 +5211,7 @@ static void printStatPerThread(threadInfo *pThreadInfo)
|
||||||
(double)(pThreadInfo->totalAffectedRows / (pThreadInfo->totalDelay/1000.0)));
|
(double)(pThreadInfo->totalAffectedRows / (pThreadInfo->totalDelay/1000.0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sync write interlace data
|
||||||
static void* syncWriteInterlace(threadInfo *pThreadInfo) {
|
static void* syncWriteInterlace(threadInfo *pThreadInfo) {
|
||||||
debugPrint("[%d] %s() LN%d: ### interlace write\n",
|
debugPrint("[%d] %s() LN%d: ### interlace write\n",
|
||||||
pThreadInfo->threadID, __func__, __LINE__);
|
pThreadInfo->threadID, __func__, __LINE__);
|
||||||
|
@ -5197,7 +5262,8 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
|
||||||
pThreadInfo->totalInsertRows = 0;
|
pThreadInfo->totalInsertRows = 0;
|
||||||
pThreadInfo->totalAffectedRows = 0;
|
pThreadInfo->totalAffectedRows = 0;
|
||||||
|
|
||||||
int64_t nTimeStampStep = superTblInfo?superTblInfo->timeStampStep:DEFAULT_TIMESTAMP_STEP;
|
int64_t nTimeStampStep =
|
||||||
|
superTblInfo?superTblInfo->timeStampStep:DEFAULT_TIMESTAMP_STEP;
|
||||||
|
|
||||||
uint64_t insert_interval =
|
uint64_t insert_interval =
|
||||||
superTblInfo?superTblInfo->insertInterval:g_args.insert_interval;
|
superTblInfo?superTblInfo->insertInterval:g_args.insert_interval;
|
||||||
|
@ -5211,7 +5277,8 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
|
||||||
uint64_t tableSeq = pThreadInfo->start_table_from;
|
uint64_t tableSeq = pThreadInfo->start_table_from;
|
||||||
|
|
||||||
debugPrint("[%d] %s() LN%d: start_table_from=%"PRIu64" ntables=%"PRId64" insertRows=%"PRIu64"\n",
|
debugPrint("[%d] %s() LN%d: start_table_from=%"PRIu64" ntables=%"PRId64" insertRows=%"PRIu64"\n",
|
||||||
pThreadInfo->threadID, __func__, __LINE__, pThreadInfo->start_table_from,
|
pThreadInfo->threadID, __func__, __LINE__,
|
||||||
|
pThreadInfo->start_table_from,
|
||||||
pThreadInfo->ntables, insertRows);
|
pThreadInfo->ntables, insertRows);
|
||||||
|
|
||||||
int64_t startTime = pThreadInfo->start_time;
|
int64_t startTime = pThreadInfo->start_time;
|
||||||
|
@ -5384,19 +5451,18 @@ free_of_interlace:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sync insertion
|
// sync insertion progressive data
|
||||||
/*
|
|
||||||
1 thread: 100 tables * 2000 rows/s
|
|
||||||
1 thread: 10 tables * 20000 rows/s
|
|
||||||
6 thread: 300 tables * 2000 rows/s
|
|
||||||
|
|
||||||
2 taosinsertdata , 1 thread: 10 tables * 20000 rows/s
|
|
||||||
*/
|
|
||||||
static void* syncWriteProgressive(threadInfo *pThreadInfo) {
|
static void* syncWriteProgressive(threadInfo *pThreadInfo) {
|
||||||
debugPrint("%s() LN%d: ### progressive write\n", __func__, __LINE__);
|
debugPrint("%s() LN%d: ### progressive write\n", __func__, __LINE__);
|
||||||
|
|
||||||
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
|
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
|
||||||
uint64_t maxSqlLen = superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len;
|
uint64_t maxSqlLen = superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len;
|
||||||
|
int64_t timeStampStep =
|
||||||
|
superTblInfo?superTblInfo->timeStampStep:DEFAULT_TIMESTAMP_STEP;
|
||||||
|
int64_t insertRows =
|
||||||
|
(superTblInfo)?superTblInfo->insertRows:g_args.num_of_DPT;
|
||||||
|
verbosePrint("%s() LN%d insertRows=%"PRId64"\n",
|
||||||
|
__func__, __LINE__, insertRows);
|
||||||
|
|
||||||
pThreadInfo->buffer = calloc(maxSqlLen, 1);
|
pThreadInfo->buffer = calloc(maxSqlLen, 1);
|
||||||
if (NULL == pThreadInfo->buffer) {
|
if (NULL == pThreadInfo->buffer) {
|
||||||
|
@ -5410,8 +5476,6 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
|
||||||
uint64_t startTs = taosGetTimestampMs();
|
uint64_t startTs = taosGetTimestampMs();
|
||||||
uint64_t endTs;
|
uint64_t endTs;
|
||||||
|
|
||||||
int64_t timeStampStep =
|
|
||||||
superTblInfo?superTblInfo->timeStampStep:DEFAULT_TIMESTAMP_STEP;
|
|
||||||
/* int insert_interval =
|
/* int insert_interval =
|
||||||
superTblInfo?superTblInfo->insertInterval:g_args.insert_interval;
|
superTblInfo?superTblInfo->insertInterval:g_args.insert_interval;
|
||||||
uint64_t st = 0;
|
uint64_t st = 0;
|
||||||
|
@ -5423,21 +5487,12 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
|
||||||
|
|
||||||
pThreadInfo->samplePos = 0;
|
pThreadInfo->samplePos = 0;
|
||||||
|
|
||||||
for (uint64_t tableSeq =
|
for (uint64_t tableSeq = pThreadInfo->start_table_from;
|
||||||
pThreadInfo->start_table_from; tableSeq <= pThreadInfo->end_table_to;
|
tableSeq <= pThreadInfo->end_table_to;
|
||||||
tableSeq ++) {
|
tableSeq ++) {
|
||||||
int64_t start_time = pThreadInfo->start_time;
|
int64_t start_time = pThreadInfo->start_time;
|
||||||
|
|
||||||
int64_t insertRows = (superTblInfo)?superTblInfo->insertRows:g_args.num_of_DPT;
|
|
||||||
verbosePrint("%s() LN%d insertRows=%"PRId64"\n", __func__, __LINE__, insertRows);
|
|
||||||
|
|
||||||
for (uint64_t i = 0; i < insertRows;) {
|
for (uint64_t i = 0; i < insertRows;) {
|
||||||
/*
|
|
||||||
if (insert_interval) {
|
|
||||||
st = taosGetTimestampMs();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
char tableName[TSDB_TABLE_NAME_LEN];
|
char tableName[TSDB_TABLE_NAME_LEN];
|
||||||
getTableName(tableName, pThreadInfo, tableSeq);
|
getTableName(tableName, pThreadInfo, tableSeq);
|
||||||
verbosePrint("%s() LN%d: tid=%d seq=%"PRId64" tableName=%s\n",
|
verbosePrint("%s() LN%d: tid=%d seq=%"PRId64" tableName=%s\n",
|
||||||
|
@ -5502,27 +5557,14 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
|
||||||
|
|
||||||
if (i >= insertRows)
|
if (i >= insertRows)
|
||||||
break;
|
break;
|
||||||
/*
|
|
||||||
if (insert_interval) {
|
|
||||||
et = taosGetTimestampMs();
|
|
||||||
|
|
||||||
if (insert_interval > ((et - st)) ) {
|
|
||||||
int sleep_time = insert_interval - (et -st);
|
|
||||||
performancePrint("%s() LN%d sleep: %d ms for insert interval\n",
|
|
||||||
__func__, __LINE__, sleep_time);
|
|
||||||
taosMsleep(sleep_time); // ms
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
} // num_of_DPT
|
} // num_of_DPT
|
||||||
|
|
||||||
if (g_args.verbose_print) {
|
if ((g_args.verbose_print) &&
|
||||||
if ((tableSeq == pThreadInfo->ntables - 1) && superTblInfo &&
|
(tableSeq == pThreadInfo->ntables - 1) && (superTblInfo) &&
|
||||||
(0 == strncasecmp(
|
(0 == strncasecmp(
|
||||||
superTblInfo->dataSource, "sample", strlen("sample")))) {
|
superTblInfo->dataSource, "sample", strlen("sample")))) {
|
||||||
verbosePrint("%s() LN%d samplePos=%"PRId64"\n",
|
verbosePrint("%s() LN%d samplePos=%"PRId64"\n",
|
||||||
__func__, __LINE__, pThreadInfo->samplePos);
|
__func__, __LINE__, pThreadInfo->samplePos);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // tableSeq
|
} // tableSeq
|
||||||
|
|
||||||
|
@ -5557,7 +5599,6 @@ static void* syncWrite(void *sarg) {
|
||||||
// progressive mode
|
// progressive mode
|
||||||
return syncWriteProgressive(pThreadInfo);
|
return syncWriteProgressive(pThreadInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void callBack(void *param, TAOS_RES *res, int code) {
|
static void callBack(void *param, TAOS_RES *res, int code) {
|
||||||
|
@ -5595,10 +5636,12 @@ static void callBack(void *param, TAOS_RES *res, int code) {
|
||||||
int rand_num = taosRandom() % 100;
|
int rand_num = taosRandom() % 100;
|
||||||
if (0 != pThreadInfo->superTblInfo->disorderRatio
|
if (0 != pThreadInfo->superTblInfo->disorderRatio
|
||||||
&& rand_num < pThreadInfo->superTblInfo->disorderRatio) {
|
&& rand_num < pThreadInfo->superTblInfo->disorderRatio) {
|
||||||
int64_t d = pThreadInfo->lastTs - (taosRandom() % pThreadInfo->superTblInfo->disorderRange + 1);
|
int64_t d = pThreadInfo->lastTs
|
||||||
generateRowData(data, d, pThreadInfo->superTblInfo);
|
- (taosRandom() % pThreadInfo->superTblInfo->disorderRange + 1);
|
||||||
|
generateStbRowData(pThreadInfo->superTblInfo, data, d);
|
||||||
} else {
|
} else {
|
||||||
generateRowData(data, pThreadInfo->lastTs += 1000, pThreadInfo->superTblInfo);
|
generateStbRowData(pThreadInfo->superTblInfo,
|
||||||
|
data, pThreadInfo->lastTs += 1000);
|
||||||
}
|
}
|
||||||
pstr += sprintf(pstr, "%s", data);
|
pstr += sprintf(pstr, "%s", data);
|
||||||
pThreadInfo->counter++;
|
pThreadInfo->counter++;
|
||||||
|
|
Loading…
Reference in New Issue