Skip to content

Commit

Permalink
feat: creating table interval (#622)
Browse files Browse the repository at this point in the history
* feat: taosbenchmark support creating table intervals

* feat: taosbenchmark support creating table intervals

* fix: mem leak if insert row is 0

* chore: refactor code

* feat: completed

* fix: taosbenchmark/taosc_insert-table-creating-interval.py

* chore: refactor
  • Loading branch information
sangshuduo committed Mar 15, 2023
1 parent f0cd7e7 commit 09ab2bd
Show file tree
Hide file tree
Showing 12 changed files with 366 additions and 191 deletions.
10 changes: 8 additions & 2 deletions inc/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,13 @@ typedef struct SSuperTable_S {
char *childTblSample;
bool childTblExists;
uint64_t childTblCount;
uint64_t batchCreateTableNum; // 0: no batch, > 0: batch table number in
uint64_t batchTblCreatingNum; // 0: no batch, > 0: batch table number in
char *batchTblCreatingNumbers; // NULL: no numbers
BArray *batchTblCreatingNumbersArray;
char *batchTblCreatingIntervals; // NULL: no interval
BArray *batchTblCreatingIntervalsArray;
// one sql
bool autoCreateTable;
bool autoTblCreating;
uint16_t iface; // 0: taosc, 1: rest, 2: stmt
uint16_t lineProtocol;
uint64_t childTblLimit;
Expand Down Expand Up @@ -940,6 +944,8 @@ typedef struct SThreadInfo_S {
SVGroup *vg;
#endif

int posOfTblCreatingBatch;
int posOfTblCreatingInterval;
// new
uint16_t batCols[MAX_BATCOLS];
uint16_t nBatCols; // valid count for array batCols
Expand Down
7 changes: 3 additions & 4 deletions src/benchCommandOpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ void printVersion() {
}

void parseFieldDatatype(char *dataType, BArray *fields, bool isTag) {
char *dup_str;
benchArrayClear(fields);
if (strstr(dataType, ",") == NULL) {
Field * field = benchCalloc(1, sizeof(Field), true);
Expand All @@ -75,11 +74,11 @@ void parseFieldDatatype(char *dataType, BArray *fields, bool isTag) {
field->max = convertDatatypeToDefaultMax(field->type);
tstrncpy(field->name, isTag?"t0":"c0", TSDB_COL_NAME_LEN);
} else {
dup_str = strdup(dataType);
char *dup_str = strdup(dataType);
char *running = dup_str;
char *token = strsep(&running, ",");
int index = 0;
while (token != NULL) {
while (token) {
Field * field = benchCalloc(1, sizeof(Field), true);
benchArrayPush(fields, field);
field = benchArrayGet(fields, index);
Expand Down Expand Up @@ -172,7 +171,7 @@ static void initStable() {
stbInfo->childTblCount = DEFAULT_CHILDTABLES;
stbInfo->childTblLimit = 0;
stbInfo->childTblOffset = 0;
stbInfo->autoCreateTable = false;
stbInfo->autoTblCreating = false;
stbInfo->childTblExists = false;
stbInfo->random_data_source = true;
stbInfo->lineProtocol = TSDB_SML_LINE_PROTOCOL;
Expand Down
2 changes: 1 addition & 1 deletion src/benchData.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ int prepareStmt(SSuperTable *stbInfo, TAOS_STMT *stmt, uint64_t tableSeq) {
int len = 0;
char *prepare = benchCalloc(1, TSDB_MAX_ALLOWED_SQL_LEN, true);
int n;
if (stbInfo->autoCreateTable) {
if (stbInfo->autoTblCreating) {
char ttl[SMALL_BUFF_LEN] = "";
if (stbInfo->ttl != 0) {
snprintf(ttl, SMALL_BUFF_LEN, "TTL %d", stbInfo->ttl);
Expand Down
Loading

0 comments on commit 09ab2bd

Please sign in to comment.