Merge pull request #20925 from taosdata/fix/TS-3106-MAIN
add option enableScience on taos.cfg to show float and double scientific notation
This commit is contained in:
commit
9597453631
|
@ -112,6 +112,7 @@ extern int32_t tsQueryNodeChunkSize;
|
||||||
extern bool tsQueryUseNodeAllocator;
|
extern bool tsQueryUseNodeAllocator;
|
||||||
extern bool tsKeepColumnName;
|
extern bool tsKeepColumnName;
|
||||||
extern bool tsEnableQueryHb;
|
extern bool tsEnableQueryHb;
|
||||||
|
extern bool tsEnableScience;
|
||||||
extern int32_t tsRedirectPeriod;
|
extern int32_t tsRedirectPeriod;
|
||||||
extern int32_t tsRedirectFactor;
|
extern int32_t tsRedirectFactor;
|
||||||
extern int32_t tsRedirectMaxPeriod;
|
extern int32_t tsRedirectMaxPeriod;
|
||||||
|
|
|
@ -105,6 +105,7 @@ int32_t tsQueryPolicy = 1;
|
||||||
int32_t tsQueryRspPolicy = 0;
|
int32_t tsQueryRspPolicy = 0;
|
||||||
int64_t tsQueryMaxConcurrentTables = 200; // unit is TSDB_TABLE_NUM_UNIT
|
int64_t tsQueryMaxConcurrentTables = 200; // unit is TSDB_TABLE_NUM_UNIT
|
||||||
bool tsEnableQueryHb = false;
|
bool tsEnableQueryHb = false;
|
||||||
|
bool tsEnableScience = false; // on taos-cli show float and doulbe with scientific notation if true
|
||||||
int32_t tsQuerySmaOptimize = 0;
|
int32_t tsQuerySmaOptimize = 0;
|
||||||
int32_t tsQueryRsmaTolerance = 1000; // the tolerance time (ms) to judge from which level to query rsma data.
|
int32_t tsQueryRsmaTolerance = 1000; // the tolerance time (ms) to judge from which level to query rsma data.
|
||||||
bool tsQueryPlannerTrace = false;
|
bool tsQueryPlannerTrace = false;
|
||||||
|
@ -117,6 +118,7 @@ int32_t tsRedirectMaxPeriod = 1000;
|
||||||
int32_t tsMaxRetryWaitTime = 10000;
|
int32_t tsMaxRetryWaitTime = 10000;
|
||||||
bool tsUseAdapter = false;
|
bool tsUseAdapter = false;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* denote if the server needs to compress response message at the application layer to client, including query rsp,
|
* denote if the server needs to compress response message at the application layer to client, including query rsp,
|
||||||
* metricmeta rsp, and multi-meter query rsp message body. The client compress the submit message to server.
|
* metricmeta rsp, and multi-meter query rsp message body. The client compress the submit message to server.
|
||||||
|
@ -328,6 +330,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
||||||
if (cfgAddInt32(pCfg, "compressColData", tsCompressColData, -1, 100000000, 1) != 0) return -1;
|
if (cfgAddInt32(pCfg, "compressColData", tsCompressColData, -1, 100000000, 1) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "queryPolicy", tsQueryPolicy, 1, 4, 1) != 0) return -1;
|
if (cfgAddInt32(pCfg, "queryPolicy", tsQueryPolicy, 1, 4, 1) != 0) return -1;
|
||||||
if (cfgAddBool(pCfg, "enableQueryHb", tsEnableQueryHb, false) != 0) return -1;
|
if (cfgAddBool(pCfg, "enableQueryHb", tsEnableQueryHb, false) != 0) return -1;
|
||||||
|
if (cfgAddBool(pCfg, "enableScience", tsEnableScience, false) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "querySmaOptimize", tsQuerySmaOptimize, 0, 1, 1) != 0) return -1;
|
if (cfgAddInt32(pCfg, "querySmaOptimize", tsQuerySmaOptimize, 0, 1, 1) != 0) return -1;
|
||||||
if (cfgAddBool(pCfg, "queryPlannerTrace", tsQueryPlannerTrace, true) != 0) return -1;
|
if (cfgAddBool(pCfg, "queryPlannerTrace", tsQueryPlannerTrace, true) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "queryNodeChunkSize", tsQueryNodeChunkSize, 1024, 128 * 1024, true) != 0) return -1;
|
if (cfgAddInt32(pCfg, "queryNodeChunkSize", tsQueryNodeChunkSize, 1024, 128 * 1024, true) != 0) return -1;
|
||||||
|
@ -730,6 +733,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
||||||
tsNumOfTaskQueueThreads = cfgGetItem(pCfg, "numOfTaskQueueThreads")->i32;
|
tsNumOfTaskQueueThreads = cfgGetItem(pCfg, "numOfTaskQueueThreads")->i32;
|
||||||
tsQueryPolicy = cfgGetItem(pCfg, "queryPolicy")->i32;
|
tsQueryPolicy = cfgGetItem(pCfg, "queryPolicy")->i32;
|
||||||
tsEnableQueryHb = cfgGetItem(pCfg, "enableQueryHb")->bval;
|
tsEnableQueryHb = cfgGetItem(pCfg, "enableQueryHb")->bval;
|
||||||
|
tsEnableScience = cfgGetItem(pCfg, "enableScience")->bval;
|
||||||
tsQuerySmaOptimize = cfgGetItem(pCfg, "querySmaOptimize")->i32;
|
tsQuerySmaOptimize = cfgGetItem(pCfg, "querySmaOptimize")->i32;
|
||||||
tsQueryPlannerTrace = cfgGetItem(pCfg, "queryPlannerTrace")->bval;
|
tsQueryPlannerTrace = cfgGetItem(pCfg, "queryPlannerTrace")->bval;
|
||||||
tsQueryNodeChunkSize = cfgGetItem(pCfg, "queryNodeChunkSize")->i32;
|
tsQueryNodeChunkSize = cfgGetItem(pCfg, "queryNodeChunkSize")->i32;
|
||||||
|
|
|
@ -317,6 +317,7 @@ void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, i
|
||||||
quotationStr[0] = '\"';
|
quotationStr[0] = '\"';
|
||||||
quotationStr[1] = 0;
|
quotationStr[1] = 0;
|
||||||
|
|
||||||
|
int n;
|
||||||
char buf[TSDB_MAX_BYTES_PER_ROW];
|
char buf[TSDB_MAX_BYTES_PER_ROW];
|
||||||
switch (field->type) {
|
switch (field->type) {
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
|
@ -347,11 +348,24 @@ void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, i
|
||||||
taosFprintfFile(pFile, "%" PRIu64, *((uint64_t *)val));
|
taosFprintfFile(pFile, "%" PRIu64, *((uint64_t *)val));
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_FLOAT:
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
|
if (tsEnableScience) {
|
||||||
taosFprintfFile(pFile, "%e", GET_FLOAT_VAL(val));
|
taosFprintfFile(pFile, "%e", GET_FLOAT_VAL(val));
|
||||||
|
} else {
|
||||||
|
taosFprintfFile(pFile, "%.5f", GET_FLOAT_VAL(val));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
snprintf(buf, TSDB_MAX_BYTES_PER_ROW, "%*.15e", 23, GET_DOUBLE_VAL(val));
|
if (tsEnableScience) {
|
||||||
|
snprintf(buf, TSDB_MAX_BYTES_PER_ROW, "%*.9e", 23, GET_DOUBLE_VAL(val));
|
||||||
taosFprintfFile(pFile, "%s", buf);
|
taosFprintfFile(pFile, "%s", buf);
|
||||||
|
} else {
|
||||||
|
n = snprintf(buf, TSDB_MAX_BYTES_PER_ROW, "%*.9f", length, GET_DOUBLE_VAL(val));
|
||||||
|
if (n > TMAX(25, length)) {
|
||||||
|
taosFprintfFile(pFile, "%*.15e", length, GET_DOUBLE_VAL(val));
|
||||||
|
} else {
|
||||||
|
taosFprintfFile(pFile, "%s", buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
|
@ -507,6 +521,7 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int n;
|
||||||
char buf[TSDB_MAX_BYTES_PER_ROW];
|
char buf[TSDB_MAX_BYTES_PER_ROW];
|
||||||
switch (field->type) {
|
switch (field->type) {
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
|
@ -537,11 +552,24 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t
|
||||||
printf("%*" PRIu64, width, *((uint64_t *)val));
|
printf("%*" PRIu64, width, *((uint64_t *)val));
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_FLOAT:
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
|
if (tsEnableScience) {
|
||||||
printf("%*e", width, GET_FLOAT_VAL(val));
|
printf("%*e", width, GET_FLOAT_VAL(val));
|
||||||
|
} else {
|
||||||
|
printf("%*.5f", width, GET_FLOAT_VAL(val));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
|
if (tsEnableScience) {
|
||||||
snprintf(buf, TSDB_MAX_BYTES_PER_ROW, "%.9e", GET_DOUBLE_VAL(val));
|
snprintf(buf, TSDB_MAX_BYTES_PER_ROW, "%.9e", GET_DOUBLE_VAL(val));
|
||||||
printf("%*s", width, buf);
|
printf("%*s", width, buf);
|
||||||
|
} else {
|
||||||
|
n = snprintf(buf, TSDB_MAX_BYTES_PER_ROW, "%*.9f", width, GET_DOUBLE_VAL(val));
|
||||||
|
if (n > TMAX(25, width)) {
|
||||||
|
printf("%*.15e", width, GET_DOUBLE_VAL(val));
|
||||||
|
} else {
|
||||||
|
printf("%s", buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
|
|
Loading…
Reference in New Issue