From f65e61148f96f75cc87e6204d632fff950e0282b Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 11 Jul 2022 11:52:37 +0000 Subject: [PATCH] more row refact --- include/common/tdataformat.h | 40 ------------------- source/libs/executor/src/timewindowoperator.c | 6 +-- 2 files changed, 3 insertions(+), 43 deletions(-) diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index 26566bba31..08da5e8f1f 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -304,49 +304,9 @@ int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int8_t flags, STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder); // ----------------- Semantic timestamp key definition -// typedef uint64_t TKEY; -#define TKEY TSKEY - -#define TKEY_INVALID UINT64_MAX -#define TKEY_NULL TKEY_INVALID -#define TKEY_NEGATIVE_FLAG (((TKEY)1) << 63) -#define TKEY_VALUE_FILTER (~(TKEY_NEGATIVE_FLAG)) - -#define TKEY_IS_NEGATIVE(tkey) (((tkey)&TKEY_NEGATIVE_FLAG) != 0) -#define TKEY_IS_DELETED(tkey) (false) - -#define tdGetTKEY(key) (key) -#define tdGetKey(tskey) (tskey) - #define MIN_TS_KEY ((TSKEY)0x8000000000000001) #define MAX_TS_KEY ((TSKEY)0x7fffffffffffffff) -#define TD_TO_TKEY(key) tdGetTKEY(((key) < MIN_TS_KEY) ? MIN_TS_KEY : (((key) > MAX_TS_KEY) ? MAX_TS_KEY : key)) - -static FORCE_INLINE TKEY keyToTkey(TSKEY key) { - TSKEY lkey = key; - if (key > MAX_TS_KEY) { - lkey = MAX_TS_KEY; - } else if (key < MIN_TS_KEY) { - lkey = MIN_TS_KEY; - } - - return tdGetTKEY(lkey); -} - -static FORCE_INLINE int32_t tkeyComparFn(const void *tkey1, const void *tkey2) { - TSKEY key1 = tdGetKey(*(TKEY *)tkey1); - TSKEY key2 = tdGetKey(*(TKEY *)tkey2); - - if (key1 < key2) { - return -1; - } else if (key1 > key2) { - return 1; - } else { - return 0; - } -} - #endif #ifdef __cplusplus diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 78775073a4..893ccd6782 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -1285,7 +1285,7 @@ static void doClearWindows(SAggSupporter* pAggSup, SExprSupp* pSup1, SInterval* STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCols[i], pInterval, TSDB_ORDER_ASC); step = getNumOfRowsInTimeWindow(&pBlock->info, tsCols, i, win.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC); uint64_t winGpId = pGpDatas ? pGpDatas[i] : pBlock->info.groupId; - bool res = doClearWindow(pAggSup, pSup1, (char*)&win.skey, sizeof(TKEY), winGpId, numOfOutput); + bool res = doClearWindow(pAggSup, pSup1, (char*)&win.skey, sizeof(TSKEY), winGpId, numOfOutput); if (pUpWins && res) { SWinRes winRes = {.ts = win.skey, .groupId = winGpId}; taosArrayPush(pUpWins, &winRes); @@ -2491,8 +2491,8 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc if (IS_FINAL_OP(pInfo)) { forwardRows = 1; } else { - forwardRows = getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, nextWin.ekey, binarySearchForKey, NULL, - TSDB_ORDER_ASC); + forwardRows = getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, nextWin.ekey, binarySearchForKey, + NULL, TSDB_ORDER_ASC); } if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pUpdated) { saveResultRow(pResult, tableGroupId, pUpdated);