Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

taos_stmt_add_batch call with taos_stmt_execute together #744

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ void printErrCmdCodeStr(char *cmd, int32_t code, TAOS_RES *res);
int32_t benchParseArgsNoArgp(int argc, char* argv[]);
#endif

int32_t execInsert(threadInfo *pThreadInfo, uint32_t k);
int32_t execInsert(threadInfo *pThreadInfo, uint32_t k, int64_t* delay3);
// if return true, timestmap must add timestap_step, else timestamp no need changed
bool needChangeTs(SSuperTable * stbInfo, int32_t *pkCur, int32_t *pkCnt);

Expand Down
2 changes: 1 addition & 1 deletion inc/benchData.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int generateRandData(SSuperTable *stbInfo, char *sampleDataBuf,
int prepareStmt(SSuperTable *stbInfo, TAOS_STMT *stmt, char* tagData, uint64_t tableSeq);
uint32_t bindParamBatch(threadInfo *pThreadInfo,
uint32_t batch, int64_t startTime,
SChildTable *childTbl, int32_t *pkCur, int32_t *pkCnt, int32_t *n, int64_t *delay2, int64_t *delay3);
SChildTable *childTbl, int32_t *pkCur, int32_t *pkCnt, int32_t *n, int64_t *delay2);
int prepareSampleData(SDataBase* database, SSuperTable* stbInfo);
void generateSmlJsonTags(tools_cJSON *tagsList,
char **sml_tags_json_array,
Expand Down
10 changes: 1 addition & 9 deletions src/benchData.c
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ int64_t getTSRandTail(int64_t timeStampStep, int32_t seq, int disorderRatio,

uint32_t bindParamBatch(threadInfo *pThreadInfo,
uint32_t batch, int64_t startTime,
SChildTable *childTbl, int32_t *pkCur, int32_t *pkCnt, int32_t *n, int64_t *delay2, int64_t *delay3) {
SChildTable *childTbl, int32_t *pkCur, int32_t *pkCnt, int32_t *n, int64_t *delay2) {
TAOS_STMT *stmt = pThreadInfo->conn->stmt;
SSuperTable *stbInfo = pThreadInfo->stbInfo;
uint32_t columnCount = stbInfo->cols->size;
Expand Down Expand Up @@ -1874,14 +1874,6 @@ uint32_t bindParamBatch(threadInfo *pThreadInfo,
tmfree(param->length);
}

// if msg > 3MB, break
start = toolsGetTimestampUs();
if (taos_stmt_add_batch(stmt)) {
errorPrint("taos_stmt_add_batch() failed! reason: %s\n",
taos_stmt_errstr(stmt));
return 0;
}
*delay3 += toolsGetTimestampUs() - start;
return batch;
}

Expand Down
25 changes: 19 additions & 6 deletions src/benchInsert.c
Original file line number Diff line number Diff line change
Expand Up @@ -1250,12 +1250,13 @@ void postFreeResource() {
tools_cJSON_Delete(root);
}

int32_t execInsert(threadInfo *pThreadInfo, uint32_t k) {
int32_t execInsert(threadInfo *pThreadInfo, uint32_t k, int64_t *delay3) {
SDataBase * database = pThreadInfo->dbInfo;
SSuperTable *stbInfo = pThreadInfo->stbInfo;
TAOS_RES * res = NULL;
int32_t code = 0;
uint16_t iface = stbInfo->iface;
int64_t start = 0;

int32_t trying = (stbInfo->keep_trying)?
stbInfo->keep_trying:g_arguments->keep_trying;
Expand Down Expand Up @@ -1309,6 +1310,18 @@ int32_t execInsert(threadInfo *pThreadInfo, uint32_t k) {
break;

case STMT_IFACE:
// add batch
start = toolsGetTimestampUs();
if (taos_stmt_add_batch(pThreadInfo->conn->stmt) != 0) {
errorPrint("taos_stmt_add_batch() failed! reason: %s\n",
taos_stmt_errstr(pThreadInfo->conn->stmt));
return -1;
}
if(delay3) {
*delay3 += toolsGetTimestampUs() - start;
}

// execute
code = taos_stmt_execute(pThreadInfo->conn->stmt);
if (code) {
errorPrint(
Expand Down Expand Up @@ -1743,7 +1756,7 @@ static void *syncWriteInterlace(void *sarg) {

int32_t n = 0;
generated = bindParamBatch(pThreadInfo, interlaceRows,
childTbl->ts, childTbl, &childTbl->pkCur, &childTbl->pkCnt, &n, &delay2, &delay3);
childTbl->ts, childTbl, &childTbl->pkCur, &childTbl->pkCnt, &n, &delay2);

childTbl->ts += stbInfo->timestamp_step * n;
break;
Expand Down Expand Up @@ -1838,7 +1851,7 @@ static void *syncWriteInterlace(void *sarg) {
}

startTs = toolsGetTimestampUs();
if (execInsert(pThreadInfo, generated)) {
if (execInsert(pThreadInfo, generated, &delay3)) {
g_fail = true;
goto free_of_interlace;
}
Expand Down Expand Up @@ -1962,7 +1975,7 @@ static int32_t prepareProgressDataStmt(
(g_arguments->reqPerReq > (stbInfo->insertRows - i))
? (stbInfo->insertRows - i)
: g_arguments->reqPerReq,
*timestamp, childTbl, pkCur, pkCnt, &n, delay2, delay3);
*timestamp, childTbl, pkCur, pkCnt, &n, delay2);
*timestamp += n * stbInfo->timestamp_step;
return generated;
}
Expand Down Expand Up @@ -2531,7 +2544,7 @@ void *syncWriteProgressive(void *sarg) {
}
// only measure insert
startTs = toolsGetTimestampUs();
int code = execInsert(pThreadInfo, generated);
int code = execInsert(pThreadInfo, generated, &delay3);
if (code) {
if (NO_IF_FAILED == stbInfo->continueIfFail) {
warnPrint("The super table parameter "
Expand Down Expand Up @@ -2572,7 +2585,7 @@ void *syncWriteProgressive(void *sarg) {
w = 0;
}

code = execInsert(pThreadInfo, generated);
code = execInsert(pThreadInfo, generated, &delay3);
if (code) {
g_fail = true;
goto free_of_progressive;
Expand Down
4 changes: 2 additions & 2 deletions src/benchInsertMix.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ bool insertDataMix(threadInfo* info, SDataBase* db, SSuperTable* stb) {
int64_t startTs = toolsGetTimestampUs();
//g_arguments->debug_print = false;

if(execInsert(info, batchRows) != 0) {
if(execInsert(info, batchRows, NULL) != 0) {
FAILED_BREAK()
}
//g_arguments->debug_print = true;
Expand Down Expand Up @@ -893,7 +893,7 @@ bool insertDataMix(threadInfo* info, SDataBase* db, SSuperTable* stb) {
batTotal.delRows = genBatchDelSql(stb, &mixRatio, batStartTime, info->conn->taos, tbName, info->buffer, len, querySql);
if (batTotal.delRows > 0) {
// g_arguments->debug_print = false;
if (execInsert(info, batTotal.delRows) != 0) {
if (execInsert(info, batTotal.delRows, NULL) != 0) {
FAILED_BREAK()
}

Expand Down
Loading