From 398c3e79884861debef9f5c10a8a7f7fc7414c48 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 11 Jul 2020 14:28:12 +0800 Subject: [PATCH] [td-225] refactor codes. --- src/common/src/tglobal.c | 2 +- src/common/src/tname.c | 2 +- src/query/inc/qtsbuf.h | 2 +- src/util/src/ttime.c | 20 ++++++++++++-------- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 684fb71af9..fd5c6d8c25 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -560,7 +560,7 @@ static void doInitGlobalConfig() { cfg.ptr = &tsMinIntervalTime; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = 10; + cfg.minValue = 1; cfg.maxValue = 1000000; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_MS; diff --git a/src/common/src/tname.c b/src/common/src/tname.c index 8b85ecfbc7..15ec68fc66 100644 --- a/src/common/src/tname.c +++ b/src/common/src/tname.c @@ -82,7 +82,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in } int64_t start = ((startTime - intervalTime) / slidingTime + 1) * slidingTime; - if (!(timeUnit == 'a' || timeUnit == 'm' || timeUnit == 's' || timeUnit == 'h')) { + if (!(timeUnit == 'u' || timeUnit == 'a' || timeUnit == 'm' || timeUnit == 's' || timeUnit == 'h')) { /* * here we revised the start time of day according to the local time zone, * but in case of DST, the start time of one day need to be dynamically decided. diff --git a/src/query/inc/qtsbuf.h b/src/query/inc/qtsbuf.h index e437e1c4e5..59b224e096 100644 --- a/src/query/inc/qtsbuf.h +++ b/src/query/inc/qtsbuf.h @@ -107,7 +107,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order); STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete); STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_t len, int32_t tsOrder); -void* tsBufDestory(STSBuf* pTSBuf); +void* tsBufDestroy(STSBuf* pTSBuf); void tsBufAppend(STSBuf* pTSBuf, int32_t vnodeId, int64_t tag, const char* pData, int32_t len); int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeIdx); diff --git a/src/util/src/ttime.c b/src/util/src/ttime.c index 6f67c4a136..018c0d640b 100644 --- a/src/util/src/ttime.c +++ b/src/util/src/ttime.c @@ -317,29 +317,34 @@ int32_t parseLocaltimeWithDst(char* timestr, int64_t* time, int32_t timePrec) { static int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t* result) { *result = val; + int64_t factor = 1000L; + switch (unit) { case 's': - (*result) *= MILLISECOND_PER_SECOND; + (*result) *= MILLISECOND_PER_SECOND*factor; break; case 'm': - (*result) *= MILLISECOND_PER_MINUTE; + (*result) *= MILLISECOND_PER_MINUTE*factor; break; case 'h': - (*result) *= MILLISECOND_PER_HOUR; + (*result) *= MILLISECOND_PER_HOUR*factor; break; case 'd': - (*result) *= MILLISECOND_PER_DAY; + (*result) *= MILLISECOND_PER_DAY*factor; break; case 'w': - (*result) *= MILLISECOND_PER_WEEK; + (*result) *= MILLISECOND_PER_WEEK*factor; break; case 'n': - (*result) *= MILLISECOND_PER_MONTH; + (*result) *= MILLISECOND_PER_MONTH*factor; break; case 'y': - (*result) *= MILLISECOND_PER_YEAR; + (*result) *= MILLISECOND_PER_YEAR*factor; break; case 'a': + (*result) *= factor; + break; + case 'u': break; default: { ; @@ -348,7 +353,6 @@ static int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t* resu } /* get the value in microsecond */ - (*result) *= 1000L; return 0; } -- GitLab