Skip to content

Commit

Permalink
fix: test passed version
Browse files Browse the repository at this point in the history
  • Loading branch information
DuanKuanJun committed May 21, 2024
1 parent 589991f commit 28a3ddc
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 25 deletions.
42 changes: 37 additions & 5 deletions case/exportCsv.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,52 @@
"databases": [
{
"dbinfo": {
"name": "exportCsv"
"name": "csvdb"
},
"super_tables": [
{
"name": "meters",
"childtable_count": 100,
"insert_rows": 100000,
"name": "batchTable",
"childtable_count": 10,
"insert_rows": 50,
"childtable_prefix": "d",
"timestamp_step": 10,
"start_timestamp":1600000000000,
"columns": [
{ "type": "bool", "name": "bc"},
{ "type": "float", "name": "fc", "min": 1},
{ "type": "double", "name": "dc", "min":10},
{ "type": "double", "name": "dc", "min":10, "max":10},
{ "type": "tinyint", "name": "ti"},
{ "type": "smallint", "name": "si"},
{ "type": "int", "name": "ic", "fillNull":"false"},
{ "type": "bigint", "name": "bi"},
{ "type": "utinyint", "name": "uti"},
{ "type": "usmallint", "name": "usi", "min":100, "max":120},
{ "type": "uint", "name": "ui"},
{ "type": "ubigint", "name": "ubi"},
{ "type": "binary", "name": "bin", "len": 16},
{ "type": "nchar", "name": "nch", "len": 16}
],
"tags": [
{"type": "tinyint", "name": "groupid","max": 10,"min": 1},
{"type": "binary", "name": "location", "len": 16,
"values": ["San Francisco", "Los Angles", "San Diego",
"San Jose", "Palo Alto", "Campbell", "Mountain View",
"Sunnyvale", "Santa Clara", "Cupertino"]
}
]
},
{
"name": "interlaceTable",
"childtable_count": 5,
"insert_rows": 100,
"interlace_rows": 10,
"childtable_prefix": "e",
"timestamp_step": 1000,
"start_timestamp":1700000000000,
"columns": [
{ "type": "bool", "name": "bc"},
{ "type": "float", "name": "fc", "min":16},
{ "type": "double", "name": "dc", "min":16},
{ "type": "tinyint", "name": "ti"},
{ "type": "smallint", "name": "si"},
{ "type": "int", "name": "ic", "fillNull":"false"},
Expand Down
28 changes: 14 additions & 14 deletions src/benchData.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,19 +440,7 @@ uint32_t accumulateRowLen(BArray *fields, int iface) {


int tmpStr(char *tmp, int iface, Field *field, int64_t k) {
if (g_arguments->demo_mode) {
unsigned int tmpRand = taosRandom();
if (g_arguments->chinese) {
snprintf(tmp, field->length, "%s",
locations_chinese[tmpRand % 10]);
} else if (SML_IFACE == iface) {
snprintf(tmp, field->length, "%s",
locations_sml[tmpRand % 10]);
} else {
snprintf(tmp, field->length, "%s",
locations[tmpRand % 10]);
}
} else if (field->values) {
if (field->values) {
int arraySize = tools_cJSON_GetArraySize(field->values);
if (arraySize) {
tools_cJSON *buf = tools_cJSON_GetArrayItem(
Expand All @@ -466,11 +454,23 @@ int tmpStr(char *tmp, int iface, Field *field, int64_t k) {
__func__, arraySize);
return -1;
}
} else if (g_arguments->demo_mode) {
unsigned int tmpRand = taosRandom();
if (g_arguments->chinese) {
snprintf(tmp, field->length, "%s",
locations_chinese[tmpRand % 10]);
} else if (SML_IFACE == iface) {
snprintf(tmp, field->length, "%s",
locations_sml[tmpRand % 10]);
} else {
snprintf(tmp, field->length, "%s",
locations[tmpRand % 10]);
}
} else {
if(field->gen == GEN_ORDER) {
snprintf(tmp, field->length, "%"PRId64, k);
} else {
rand_string(tmp, field->length, g_arguments->chinese);
rand_string(tmp, taosRandom() % field->length, g_arguments->chinese);
}
}
return 0;
Expand Down
13 changes: 7 additions & 6 deletions src/benchDataMix.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,18 @@ uint32_t dataGenByField(Field* fd, char* pstr, uint32_t len, char* prefix, int64
return size;
}

const char * format = ",%s";

switch (fd->type) {
case TSDB_DATA_TYPE_BOOL:
sprintf(val, "%d", tmpBool(fd));
break;
// timestamp
case TSDB_DATA_TYPE_TIMESTAMP:
int64_t nowts = toolsGetTimestampMs();
strcpy(val, "\'");
toolsFormatTimestamp(val, nowts, TSDB_TIME_PRECISION_MILLI);
strcat(val, "\'");
break;
// signed
case TSDB_DATA_TYPE_TINYINT:
Expand Down Expand Up @@ -150,17 +154,14 @@ uint32_t dataGenByField(Field* fd, char* pstr, uint32_t len, char* prefix, int64
// binary nchar
case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_BINARY:
if(fd->gen == GEN_ORDER) {
tmpStr(val, 0, fd, *k);
} else {
genRadomString(val, fd->length > sizeof(val) ? sizeof(val) : fd->length, prefix);
}
format = ",\'%s\'";
tmpStr(val, 0, fd, *k);
break;
default:
break;
}

size += sprintf(pstr + len, ",%s", val);
size += sprintf(pstr + len, format, val);
return size;
}

Expand Down

0 comments on commit 28a3ddc

Please sign in to comment.