Skip to content

Commit

Permalink
fix: taosbenchmark code refactor (#599)
Browse files Browse the repository at this point in the history
* fix: refactor line protocol data generation

* test: change test branch

* test: add brew install pkg-config in macos workflows

* fix: check snprintf return

* fix: taosbenchmark insert refactor

* fix: reduce complexity of sml data generating

* test: don't build jdbc on windows

* fix: check unsigned int generated

* fix: refactor cleanup and print

* fix: refect prepare sml data

* fix: add sml_tags_json_array to accelerate sml json test

* fix: taosbenchmark json data generating refine

* fix: comma adding timing

* fix: coverity scan issues

* fix: use strncat instead of snprintf

* fix: adjust end time position

* fix: avoid random data generation

* fix: remove unused func

* fix: remove refactor macro

* test: add taosbenchmark/csv/insert-json-csv.py

* fix: csv read pos/len bug

* fix: support tdengine v2

* fix: don't repeat
  • Loading branch information
sangshuduo committed Mar 4, 2023
1 parent f806257 commit 7876113
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
27 changes: 11 additions & 16 deletions src/benchData.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,8 +1461,15 @@ int generateRandData(SSuperTable *stbInfo, char *sampleDataBuf,
return -1;
}

int prepareChildTblSampleData(SDataBase* database, SSuperTable* stbInfo) {
return -1;
static BArray *initChildCols(int colsSize) {
BArray *childCols = benchArrayInit(colsSize,
sizeof(ChildField));
for (int col = 0; col < colsSize; col++) {
ChildField *childCol = benchCalloc(
1, sizeof(ChildField), true);
benchArrayPush(childCols, childCol);
}
return childCols;
}

int prepareSampleData(SDataBase* database, SSuperTable* stbInfo) {
Expand Down Expand Up @@ -1523,13 +1530,7 @@ int prepareSampleData(SDataBase* database, SSuperTable* stbInfo) {
for (int64_t child = 0; child < stbInfo->childTblCount; child++) {
SChildTable *childTbl = stbInfo->childTblArray[child];
if (STMT_IFACE == stbInfo->iface) {
childTbl->childCols = benchArrayInit(stbInfo->cols->size,
sizeof(ChildField));
for (int col = 0; col < stbInfo->cols->size; col++) {
ChildField *childCol = benchCalloc(
1, sizeof(ChildField), true);
benchArrayPush(childTbl->childCols, childCol);
}
childTbl->childCols = initChildCols(stbInfo->cols->size);
}
childTbl->sampleDataBuf =
benchCalloc(
Expand Down Expand Up @@ -1609,13 +1610,7 @@ int prepareSampleData(SDataBase* database, SSuperTable* stbInfo) {
return -1;
}
if (STMT_IFACE == stbInfo->iface) {
childTbl->childCols = benchArrayInit(stbInfo->cols->size,
sizeof(ChildField));
for (int col = 0; col < stbInfo->cols->size; col++) {
ChildField *childCol = benchCalloc(
1, sizeof(ChildField), true);
benchArrayPush(childTbl->childCols, childCol);
}
childTbl->childCols = initChildCols(stbInfo->cols->size);
}
childTbl->useOwnSample = true;
debugPrint("sampleDataBuf: %s\n", childTbl->sampleDataBuf);
Expand Down
23 changes: 8 additions & 15 deletions src/benchInsert.c
Original file line number Diff line number Diff line change
Expand Up @@ -1813,9 +1813,7 @@ static int32_t prepareProgressDataSmlJson(
}

static int32_t prepareProgressDataSmlLine(
threadInfo *pThreadInfo,
uint64_t tableSeq,
char *sampleDataBuf,
threadInfo *pThreadInfo, uint64_t tableSeq, char *sampleDataBuf,
int64_t *timestamp, uint64_t i, char *ttl) {
// prepareProgressDataSmlLine
SSuperTable *stbInfo = pThreadInfo->stbInfo;
Expand All @@ -1828,11 +1826,9 @@ static int32_t prepareProgressDataSmlLine(
pThreadInfo->lines[j],
stbInfo->lenOfCols + stbInfo->lenOfTags,
"%s %s %" PRId64 "",
pThreadInfo
->sml_tags[(int)tableSeq -
pThreadInfo->start_table_from],
sampleDataBuf +
pos * stbInfo->lenOfCols,
pThreadInfo->sml_tags[tableSeq
- pThreadInfo->start_table_from],
sampleDataBuf + pos * stbInfo->lenOfCols,
*timestamp);
pos++;
if (pos >= g_arguments->prepared_rand) {
Expand All @@ -1851,9 +1847,7 @@ static int32_t prepareProgressDataSmlLine(
}

static int32_t prepareProgressDataSmlTelnet(
threadInfo *pThreadInfo,
uint64_t tableSeq,
char *sampleDataBuf,
threadInfo *pThreadInfo, uint64_t tableSeq, char *sampleDataBuf,
int64_t *timestamp, uint64_t i, char *ttl) {
// prepareProgressDataSmlTelnet
SSuperTable *stbInfo = pThreadInfo->stbInfo;
Expand All @@ -1868,10 +1862,9 @@ static int32_t prepareProgressDataSmlTelnet(
"%s %" PRId64 " %s %s", stbInfo->stbName,
*timestamp,
sampleDataBuf
+ pos * stbInfo->lenOfCols,
pThreadInfo
->sml_tags[(int)tableSeq
-pThreadInfo->start_table_from]);
+ pos * stbInfo->lenOfCols,
pThreadInfo->sml_tags[tableSeq
-pThreadInfo->start_table_from]);
pos++;
if (pos >= g_arguments->prepared_rand) {
pos = 0;
Expand Down

0 comments on commit 7876113

Please sign in to comment.