提交 53d2aeb5 编写于 作者: sangshuduo's avatar sangshuduo

Merge branch '2.6' into feat/sangshuduo/TD-14141-update-taostools-for2.6

...@@ -565,15 +565,23 @@ int64_t taosTimeSub(int64_t t, int64_t duration, char unit, int32_t precision) { ...@@ -565,15 +565,23 @@ int64_t taosTimeSub(int64_t t, int64_t duration, char unit, int32_t precision) {
return (int64_t)(mktime(&tm) * TSDB_TICK_PER_SECOND(precision)); return (int64_t)(mktime(&tm) * TSDB_TICK_PER_SECOND(precision));
} }
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision) { int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision) {
if (ekey < skey) { if (ekey < skey) {
int64_t tmp = ekey; int64_t tmp = ekey;
ekey = skey; ekey = skey;
skey = tmp; skey = tmp;
} }
#ifdef _MSC_VER
#if _MSC_VER >= 1900
int64_t timezone = _timezone;
#endif
#endif
int64_t tz_offset = -1 * timezone * TSDB_TICK_PER_SECOND(precision);
if (unit != 'n' && unit != 'y') { if (unit != 'n' && unit != 'y') {
return (int32_t)((ekey - skey) / interval); return (int32_t)((ekey+tz_offset)/interval - (skey+tz_offset)/interval) + 1;
} }
skey /= (int64_t)(TSDB_TICK_PER_SECOND(precision)); skey /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
...@@ -592,7 +600,7 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char ...@@ -592,7 +600,7 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char
interval *= 12; interval *= 12;
} }
return (emon - smon) / (int32_t)interval; return (int32_t)(emon/interval - smon/interval) + 1;
} }
int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precision) { int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precision) {
......
...@@ -5320,15 +5320,17 @@ int32_t doInitQInfo(SQInfo* pQInfo, STSBuf* pTsBuf, void* tsdb, void* sourceOptr ...@@ -5320,15 +5320,17 @@ int32_t doInitQInfo(SQInfo* pQInfo, STSBuf* pTsBuf, void* tsdb, void* sourceOptr
} }
static void doTableQueryInfoTimeWindowCheck(SQueryAttr* pQueryAttr, STableQueryInfo* pTableQueryInfo) { static void doTableQueryInfoTimeWindowCheck(SQueryAttr* pQueryAttr, STableQueryInfo* pTableQueryInfo) {
//
// current subscribe can not ensure pTableQueryInfo->lastKey >= pTableQueryInfo->win.skey, so remove this condition check
// reason is subscribe calc query windows skey is all child table smallest skey, so bigest child table block->skey maybe large than this table's pTableQueryInfo->win.skey
//
if (QUERY_IS_ASC_QUERY(pQueryAttr)) { if (QUERY_IS_ASC_QUERY(pQueryAttr)) {
assert( assert(
(pTableQueryInfo->win.skey <= pTableQueryInfo->win.ekey) && (pTableQueryInfo->win.skey <= pTableQueryInfo->win.ekey) &&
(pTableQueryInfo->lastKey >= pTableQueryInfo->win.skey) &&
(pTableQueryInfo->win.skey >= pQueryAttr->window.skey && pTableQueryInfo->win.ekey <= pQueryAttr->window.ekey)); (pTableQueryInfo->win.skey >= pQueryAttr->window.skey && pTableQueryInfo->win.ekey <= pQueryAttr->window.ekey));
} else { } else {
assert( assert(
(pTableQueryInfo->win.skey >= pTableQueryInfo->win.ekey) && (pTableQueryInfo->win.skey >= pTableQueryInfo->win.ekey) &&
(pTableQueryInfo->lastKey <= pTableQueryInfo->win.skey) &&
(pTableQueryInfo->win.skey <= pQueryAttr->window.skey && pTableQueryInfo->win.ekey >= pQueryAttr->window.ekey)); (pTableQueryInfo->win.skey <= pQueryAttr->window.skey && pTableQueryInfo->win.ekey >= pQueryAttr->window.ekey));
} }
} }
...@@ -5430,6 +5432,28 @@ static SSDataBlock* doTableScanImpl(void* param, bool* newgroup) { ...@@ -5430,6 +5432,28 @@ static SSDataBlock* doTableScanImpl(void* param, bool* newgroup) {
break; break;
} }
// check windows condition
if (pBlock->info.window.skey != INT64_MIN && pBlock->info.window.skey != INT64_MAX &&
pBlock->info.window.ekey != INT64_MIN && pBlock->info.window.ekey != INT64_MAX) {
// normal block not specail block like last_row
int64_t skey = (*pTableQueryInfo)->win.skey;
if (QUERY_IS_ASC_QUERY(pQueryAttr)) {
// ASC
if ( skey > pBlock->info.window.ekey ) {
qWarn(" pTableQueryInfo skey(%" PRId64 ") > pBlock ekey(%" PRId64 "), so remove this block. pBlock skey=%" PRId64 " tid=%d",
skey, pBlock->info.window.ekey, pBlock->info.window.skey, pBlock->info.tid);
continue;
}
} else {
// DESC
if ( skey < pBlock->info.window.skey ) {
qWarn(" pTableQueryInfo skey(%" PRId64 ") < pBlock skey(%" PRId64 "), so remove this block. pBlock ekey=%" PRId64 "tid=%d",
skey, pBlock->info.window.skey, pBlock->info.window.ekey, pBlock->info.tid);
continue;
}
}
}
pRuntimeEnv->current = *pTableQueryInfo; pRuntimeEnv->current = *pTableQueryInfo;
doTableQueryInfoTimeWindowCheck(pQueryAttr, *pTableQueryInfo); doTableQueryInfoTimeWindowCheck(pQueryAttr, *pTableQueryInfo);
......
...@@ -463,7 +463,6 @@ void taosFillSetInputDataBlock(SFillInfo* pFillInfo, const SSDataBlock* pInput) ...@@ -463,7 +463,6 @@ void taosFillSetInputDataBlock(SFillInfo* pFillInfo, const SSDataBlock* pInput)
pFillInfo->interval.sliding, pFillInfo->interval.sliding,
pFillInfo->interval.slidingUnit, pFillInfo->interval.slidingUnit,
pFillInfo->precision); pFillInfo->precision);
numOfRes += 1;
if(numOfRes < numOfRows || pFillInfo->currentKey < lastKey) { if(numOfRes < numOfRows || pFillInfo->currentKey < lastKey) {
// set currentKey max // set currentKey max
pFillInfo->currentKey = tsList[0]; pFillInfo->currentKey = tsList[0];
...@@ -504,7 +503,6 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma ...@@ -504,7 +503,6 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
pFillInfo->interval.sliding, pFillInfo->interval.sliding,
pFillInfo->interval.slidingUnit, pFillInfo->interval.slidingUnit,
pFillInfo->precision); pFillInfo->precision);
numOfRes += 1;
assert(numOfRes >= numOfRows); assert(numOfRes >= numOfRows);
} else { // reach the end of data } else { // reach the end of data
if ((ekey1 < pFillInfo->currentKey && FILL_IS_ASC_FILL(pFillInfo)) || if ((ekey1 < pFillInfo->currentKey && FILL_IS_ASC_FILL(pFillInfo)) ||
...@@ -517,7 +515,6 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma ...@@ -517,7 +515,6 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
pFillInfo->interval.sliding, pFillInfo->interval.sliding,
pFillInfo->interval.slidingUnit, pFillInfo->interval.slidingUnit,
pFillInfo->precision); pFillInfo->precision);
numOfRes += 1;
} }
return (numOfRes > maxNumOfRows) ? maxNumOfRows : numOfRes; return (numOfRes > maxNumOfRows) ? maxNumOfRows : numOfRes;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册