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-tools main_3.0_merge #712

Merged
merged 17 commits into from
Oct 13, 2023
Merged
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
86 changes: 86 additions & 0 deletions example/insertNow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"connection_pool_size": 8,
"thread_count": 5,
"create_table_thread_count": 7,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
"num_of_records_per_req": 2000,
"prepared_rand": 10000,
"chinese": "no",
"escape_character": "yes",
"databases": [
{
"dbinfo": {
"name": "smart",
"drop": "yes",
"vgroups": 4,
"duration": "10d",
"keep": "100d",
"pages": 512,
"minrows":5000,
"maxrows":10000,
"stt_trigger":1,
"wal_retention_period": 10,
"wal_retention_size": 100,
"cachemodel": "'both'",
"precision": "ms"
},
"super_tables": [
{
"name": "meters",
"child_table_exists": "no",
"childtable_count": 10000,
"childtable_prefix": "d",
"auto_create_table": "no",
"batch_create_tbl_num": 5,
"data_source": "rand",
"insert_mode": "taosc",
"non_stop_mode": "no",
"line_protocol": "line",
"insert_rows": 900000000000000,
"interlace_rows": 1,
"insert_interval": 1000,
"start_timestamp": "now",
"sample_format": "csv",
"sample_file": "./sample.csv",
"use_sample_ts": "no",
"tags_file": "",
"columns": [
{
"type": "FLOAT",
"name": "current",
"count": 1,
"max": 12,
"min": 8
},
{ "type": "INT", "name": "voltage", "max": 225, "min": 215 },
{ "type": "FLOAT", "name": "phase", "max": 1, "min": 0 }
],
"tags": [
{
"type": "TINYINT",
"name": "groupid",
"max": 10,
"min": 1
},
{
"name": "location",
"type": "BINARY",
"len": 16,
"values": ["San Francisco", "Los Angles", "San Diego",
"San Jose", "Palo Alto", "Campbell", "Mountain View",
"Sunnyvale", "Santa Clara", "Cupertino"]
}
]
}
]
}
]
}
11 changes: 7 additions & 4 deletions src/benchInsert.c
Original file line number Diff line number Diff line change
Expand Up @@ -1532,8 +1532,12 @@ static void *syncWriteInterlace(void *sarg) {
int64_t disorderTs = getDisorderTs(stbInfo,
&disorderRange);
char time_string[BIGINT_BUFF_LEN];
snprintf(time_string, BIGINT_BUFF_LEN, "%"PRId64"",
disorderTs?disorderTs:timestamp);
if(stbInfo->useNow && stbInfo->interlaceRows == 1) {
snprintf(time_string, BIGINT_BUFF_LEN, "now");
} else {
snprintf(time_string, BIGINT_BUFF_LEN, "%"PRId64"",
disorderTs?disorderTs:timestamp);
}
ds_add_strs(&pThreadInfo->buffer, 5,
"(",
time_string,
Expand Down Expand Up @@ -3530,8 +3534,7 @@ int insertTestProcess() {
}
// check fill child table count valid
if(fillChildTblName(database, stbInfo) <= 0) {
errorPrint(" fill child table is zero, please check parameters in json is correct. database:%s stb: %s \n", database->dbName, stbInfo->stbName);
return -1;
infoPrint(" warning fill childs table count is zero, please check parameters in json is correct. database:%s stb: %s \n", database->dbName, stbInfo->stbName);
}
if (0 != prepareSampleData(database, stbInfo)) {
return -1;
Expand Down
42 changes: 32 additions & 10 deletions src/taosdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -5203,8 +5203,8 @@ static int64_t writeResultToAvroNative(
if (0 != avro_value_get_by_name(
&record, "tbname", &avro_value, NULL)) {
errorPrint("%s() LN%d, avro_value_get_by_name(tbname) "
"failed\n",
__func__, __LINE__);
"failed dbName=%s tbName=%s\n",
__func__, __LINE__, dbName, tbName);
break;
}
avro_value_set_branch(&avro_value, 1, &branch);
Expand All @@ -5224,9 +5224,9 @@ static int64_t writeResultToAvroNative(

if (0 != avro_file_writer_append_value(db, &record)) {
errorPrint("%s() LN%d, "
"Unable to write record to file. Message: %s\n",
"Unable to write record to file. Message: %s dbName=%s tbName=%s\n",
__func__, __LINE__,
avro_strerror());
avro_strerror(), dbName, tbName);
failed--;
} else {
success++;
Expand All @@ -5237,9 +5237,9 @@ static int64_t writeResultToAvroNative(
}

if (countInBatch != limit) {
errorPrint("%s() LN%d, actual dump out: %d, batch %" PRId64 "\n",
errorPrint("%s() LN%d, table rows is zero. actual dump out: %d, batch %" PRId64 " dbName=%s tbName=%s\n",
__func__, __LINE__,
countInBatch, limit);
countInBatch, limit, dbName, tbName);
}
taos_free_result(res);
printDotOrX(offset, &printDot);
Expand Down Expand Up @@ -6969,8 +6969,10 @@ static int64_t dumpInAvroDataImpl(
avro_value_get_current_branch(&tbname_value, &tbname_branch);

size_t tbname_size;
char * avroName = NULL;
avro_value_get_string(&tbname_branch,
(const char **)&tbName, &tbname_size);
(const char **)&avroName, &tbname_size);
tbName = strdup(avroName);
} else {
tbName = malloc(TSDB_TABLE_NAME_LEN+1);
ASSERT(tbName);
Expand Down Expand Up @@ -7040,7 +7042,7 @@ static int64_t dumpInAvroDataImpl(
"reason: %s\n",
escapedTbName, taos_stmt_errstr(stmt));
free(escapedTbName);
freeTbNameIfLooseMode(tbName);
free(tbName);
tbName = NULL;
continue;
}
Expand All @@ -7061,8 +7063,28 @@ static int64_t dumpInAvroDataImpl(
#ifdef WEBSOCKET
}
#endif
}
}
} // tbName
#ifndef TD_VER_COMPATIBLE_3_0_0_0
else {
// 2.6 need call taos_stmt_set_tbname every loop
const int escapedTbNameLen = TSDB_DB_NAME_LEN + TSDB_TABLE_NAME_LEN + 3;
char *escapedTbName = calloc(1, escapedTbNameLen);
snprintf(escapedTbName, escapedTbNameLen, "%s%s%s",
g_escapeChar, tbName, g_escapeChar);

if (0 != taos_stmt_set_tbname(stmt, escapedTbName)) {
errorPrint("Failed to execute taos_stmt_set_tbname(%s)."
"reason: %s\n",
escapedTbName, taos_stmt_errstr(stmt));
free(escapedTbName);
freeTbNameIfLooseMode(tbName);
tbName = NULL;
continue;
}
free(escapedTbName);
}
#endif

debugPrint("%s() LN%d, count: %"PRId64"\n",
__func__, __LINE__, count);
Expand Down Expand Up @@ -7343,7 +7365,7 @@ static int64_t dumpInAvroDataImpl(
}
}

freeTbNameIfLooseMode(tbName);
free(tbName);
avro_value_decref(&value);
avro_value_iface_decref(value_class);
tfree(bindArray);
Expand Down
Loading