• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #4874

04 Dec 2025 01:55AM UTC coverage: 64.623% (+0.07%) from 64.558%
#4874

push

travis-ci

guanshengliang
Merge branch '3.0' into cover/3.0

865 of 2219 new or added lines in 36 files covered. (38.98%)

6317 existing lines in 143 files now uncovered.

159543 of 246882 relevant lines covered (64.62%)

106415537.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/source/libs/executor/inc/executorInt.h
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15
#ifndef TDENGINE_EXECUTORINT_H
16
#define TDENGINE_EXECUTORINT_H
17

18
#ifdef __cplusplus
19
extern "C" {
20
#endif
21

22
#include "os.h"
23
#include "tcommon.h"
24
#include "theap.h"
25
#include "tlosertree.h"
26
#include "tsort.h"
27
#include "tvariant.h"
28

29
#include "dataSinkMgt.h"
30
#include "executil.h"
31
#include "executor.h"
32
#include "planner.h"
33
#include "scalar.h"
34
#include "taosdef.h"
35
#include "tarray.h"
36
#include "tfill.h"
37
#include "thash.h"
38
#include "tlockfree.h"
39
#include "tmsg.h"
40
#include "tpagedbuf.h"
41
#include "tlrucache.h"
42
#include "tworker.h"
43

44
typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order);
45

46
typedef struct STsdbReader STsdbReader;
47
typedef struct STqReader   STqReader;
48

49
typedef enum SOperatorParamType { OP_GET_PARAM = 1, OP_NOTIFY_PARAM } SOperatorParamType;
50

51
typedef enum EExtWinMode {
52
  EEXT_MODE_SCALAR = 1,
53
  EEXT_MODE_AGG,
54
  EEXT_MODE_INDEFR_FUNC,
55
} EExtWinMode;
56

57
#define IS_VALID_SESSION_WIN(winInfo)        ((winInfo).sessionWin.win.skey > 0)
58
#define SET_SESSION_WIN_INVALID(winInfo)     ((winInfo).sessionWin.win.skey = INT64_MIN)
59
#define IS_INVALID_SESSION_WIN_KEY(winKey)   ((winKey).win.skey <= 0)
60
#define SET_SESSION_WIN_KEY_INVALID(pWinKey) ((pWinKey)->win.skey = INT64_MIN)
61

62
#define IS_STREAM_MODE(_task) ((_task)->execModel == OPTR_EXEC_MODEL_STREAM)
63

64
/**
65
 * If the number of generated results is greater than this value,
66
 * query query will be halt and return results to client immediate.
67
 */
68
typedef struct SResultInfo {  // TODO refactor
69
  int64_t totalRows;          // total generated result size in rows
70
  int64_t totalBytes;         // total results in bytes.
71
  int32_t capacity;           // capacity of current result output buffer
72
  int32_t threshold;          // result size threshold in rows.
73
} SResultInfo;
74

75
typedef struct STableQueryInfo {
76
  TSKEY              lastKey;  // last check ts, todo remove it later
77
  SResultRowPosition pos;      // current active time window
78
} STableQueryInfo;
79

80
typedef struct SLimit {
81
  int64_t limit;
82
  int64_t offset;
83
} SLimit;
84

85
typedef struct STableScanAnalyzeInfo SFileBlockLoadRecorder;
86

87
enum {
88
  STREAM_RECOVER_STEP__NONE = 0,
89
  STREAM_RECOVER_STEP__PREPARE1,
90
  STREAM_RECOVER_STEP__PREPARE2,
91
  STREAM_RECOVER_STEP__SCAN1,
92
};
93

94
extern int32_t exchangeObjRefPool;
95

96
typedef struct {
97
  char*   pData;
98
  bool    isNull;
99
  int16_t type;
100
  int32_t bytes;
101
} SGroupKeys, SStateKeys;
102

103
typedef struct {
104
  char*           tablename;
105
  char*           dbname;
106
  int32_t         tversion;
107
  int32_t         rversion;
108
  SSchemaWrapper* sw;
109
  SSchemaWrapper* qsw;
110
} SSchemaInfo;
111

112
typedef struct SExchangeOpStopInfo {
113
  int32_t operatorType;
114
  int64_t refId;
115
} SExchangeOpStopInfo;
116

117
typedef struct SGcOperatorParam {
118
  int64_t sessionId;
119
  int32_t downstreamIdx;
120
  int32_t vgId;
121
  int64_t tbUid;
122
  bool    needCache;
123
} SGcOperatorParam;
124

125
typedef struct SGcNotifyOperatorParam {
126
  int32_t downstreamIdx;
127
  int32_t vgId;
128
  int64_t tbUid;
129
} SGcNotifyOperatorParam;
130

131
struct SExprSupp {
132
  SExprInfo*      pExprInfo;
133
  int32_t         numOfExprs;  // the number of scalar expression in group operator
134
  SqlFunctionCtx* pCtx;
135
  int32_t*        rowEntryInfoOffset;  // offset value for each row result cell info
136
  SFilterInfo*    pFilterInfo;
137
  bool            hasWindowOrGroup;    // denote that the function is used with time window or group
138
  bool            hasWindow;           // denote that the function is used with time window
139
  bool            hasIndefRowsFunc;
140
};
141

142
typedef enum {
143
  EX_SOURCE_DATA_NOT_READY = 0x1,
144
  EX_SOURCE_DATA_STARTED,
145
  EX_SOURCE_DATA_READY,
146
  EX_SOURCE_DATA_EXHAUSTED,
147
} EX_SOURCE_STATUS;
148

149
#define COL_MATCH_FROM_COL_ID  0x1
150
#define COL_MATCH_FROM_SLOT_ID 0x2
151

152
typedef struct SLoadRemoteDataInfo {
153
  uint64_t totalSize;     // total load bytes from remote
154
  uint64_t totalRows;     // total number of rows
155
  uint64_t totalElapsed;  // total elapsed time
156
} SLoadRemoteDataInfo;
157

158
typedef struct SLimitInfo {
159
  SLimit   limit;
160
  SLimit   slimit;
161
  uint64_t currentGroupId;
162
  int64_t  remainGroupOffset;
163
  int64_t  numOfOutputGroups;
164
  int64_t  remainOffset;
165
  int64_t  numOfOutputRows;
166
} SLimitInfo;
167

168
typedef struct SSortMergeJoinOperatorParam {
169
  bool initDownstream;
170
} SSortMergeJoinOperatorParam;
171

172
typedef struct SExchangeOperatorBasicParam {
173
  int32_t               vgId;
174
  int32_t               srcOpType;
175
  bool                  tableSeq;
176
  SArray*               uidList;
177
  bool                  isVtbWinScan;
178
  bool                  isVtbRefScan;
179
  bool                  isVtbTagScan;
180
  bool                  isNewDeployed; // used with newDeployedSrc
181
  bool                  isNewParam;
182
  SOrgTbInfo*           colMap;
183
  STimeWindow           window;
184
  SDownstreamSourceNode newDeployedSrc; // used with isNewDeployed
185
} SExchangeOperatorBasicParam;
186

187
typedef struct SExchangeOperatorBatchParam {
188
  bool       multiParams;
189
  SSHashObj* pBatchs;  // SExchangeOperatorBasicParam
190
} SExchangeOperatorBatchParam;
191

192
typedef struct SExchangeOperatorParam {
193
  bool                        multiParams;
194
  SExchangeOperatorBasicParam basic;
195
} SExchangeOperatorParam;
196

197
typedef struct SExchangeSrcIndex {
198
  int32_t srcIdx;
199
  int32_t inUseIdx;
200
} SExchangeSrcIndex;
201

202
typedef struct SExchangeInfo {
203
  int64_t    seqId;
204
  SArray*    pSources;
205
  SSHashObj* pHashSources;
206
  SArray*    pSourceDataInfo;
207
  tsem_t     ready;
208
  void*      pTransporter;
209

210
  // SArray<SSDataBlock*>, result block list, used to keep the multi-block that
211
  // passed by downstream operator
212
  SArray*      pResultBlockList;
213
  SArray*      pRecycledBlocks;  // build a pool for small data block to avoid to repeatly create and then destroy.
214
  SSDataBlock* pDummyBlock;      // dummy block, not keep data
215
  bool         seqLoadData;      // sequential load data or not, false by default
216
  bool         dynamicOp;
217
  bool         dynTbname;         // %%tbname for stream    
218
  int32_t      current;
219
  SLoadRemoteDataInfo loadInfo;
220
  int64_t             self;
221
  SLimitInfo          limitInfo;
222
  int64_t             openedTs;  // start exec time stamp, todo: move to SLoadRemoteDataInfo
223
  char*               pTaskId;
224
  SArray*             pFetchRpcHandles;
225
} SExchangeInfo;
226

227
typedef struct SScanInfo {
228
  int32_t numOfAsc;
229
  int32_t numOfDesc;
230
} SScanInfo;
231

232
typedef struct SSampleExecInfo {
233
  double   sampleRatio;  // data block sample ratio, 1 by default
234
  uint32_t seed;         // random seed value
235
} SSampleExecInfo;
236

237
enum {
238
  TABLE_SCAN__TABLE_ORDER = 1,
239
  TABLE_SCAN__BLOCK_ORDER = 2,
240
};
241

242
typedef enum ETableCountState {
243
  TABLE_COUNT_STATE_NONE = 0,       // before start scan
244
  TABLE_COUNT_STATE_SCAN = 1,       // cur group scanning
245
  TABLE_COUNT_STATE_PROCESSED = 2,  // cur group processed
246
  TABLE_COUNT_STATE_END = 3,        // finish or noneed to process
247
} ETableCountState;
248

249
struct SAggSupporter {
250
  SSHashObj*     pResultRowHashTable;  // quick locate the window object for each result
251
  char*          keyBuf;               // window key buffer
252
  SDiskbasedBuf* pResultBuf;           // query result buffer based on blocked-wised disk file
253
  int32_t        resultRowSize;  // the result buffer size for each result row, with the meta data size for each row
254
  int32_t        currentPageId;  // current write page id
255
};
256

257
typedef struct {
258
  // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if
259
  // current data block needs to be loaded.
260
  SInterval      interval;
261
  SAggSupporter* pAggSup;
262
  SExprSupp*     pExprSup;  // expr supporter of aggregate operator
263
} SAggOptrPushDownInfo;
264

265
typedef struct STableMetaCacheInfo {
266
  SLRUCache* pTableMetaEntryCache;  // 100 by default
267
  uint64_t   metaFetch;
268
  uint64_t   cacheHit;
269
} STableMetaCacheInfo;
270

271
typedef struct STableScanBase {
272
  STsdbReader*           dataReader;
273
  SFileBlockLoadRecorder readRecorder;
274
  SQueryTableDataCond    cond;
275
  SQueryTableDataCond    orgCond; // use for virtual super table scan
276
  SAggOptrPushDownInfo   pdInfo;
277
  SColMatchInfo          matchInfo;
278
  SReadHandle            readHandle;
279
  SExprSupp              pseudoSup;
280
  STableMetaCacheInfo    metaCache;
281
  int32_t                scanFlag;  // table scan flag to denote if it is a repeat/reverse/main scan
282
  int32_t                dataBlockLoadFlag;
283
  SLimitInfo             limitInfo;
284
  // there are more than one table list exists in one task, if only one vnode exists.
285
  STableListInfo* pTableListInfo;
286
  TsdReader       readerAPI;
287
} STableScanBase;
288

289
typedef struct STableScanInfo {
290
  STableScanBase  base;
291
  SScanInfo       scanInfo;
292
  int32_t         scanTimes;
293
  SSDataBlock*    pResBlock;
294
  SHashObj*       pIgnoreTables;
295
  SSampleExecInfo sample;           // sample execution info
296
  int32_t         tableStartIndex;  // current group scan start
297
  int32_t         tableEndIndex;    // current group scan end
298
  int32_t         currentGroupId;
299
  int32_t         currentTable;
300
  int8_t          scanMode;
301
  int8_t          assignBlockUid;
302
  uint8_t         countState;  // empty table count state
303
  bool            hasGroupByTag;
304
  bool            filesetDelimited;
305
  bool            needCountEmptyTable;
306
  SSDataBlock*    pOrgBlock;
307
  bool            ignoreTag;
308
  bool            virtualStableScan;
309
  SHashObj*       readerCache;
310
  bool            newReader;
311
} STableScanInfo;
312

313
typedef enum ESubTableInputType {
314
  SUB_TABLE_MEM_BLOCK,
315
  SUB_TABLE_EXT_PAGES,
316
} ESubTableInputType;
317

318
typedef struct STmsSubTableInput {
319
  STsdbReader*        pReader;
320
  SQueryTableDataCond tblCond;
321
  STableKeyInfo*      pKeyInfo;
322
  bool                bInMemReader;
323
  ESubTableInputType  type;
324
  SSDataBlock*        pReaderBlock;
325

326
  SArray*      aBlockPages;
327
  SSDataBlock* pPageBlock;
328
  int32_t      pageIdx;
329

330
  int32_t      rowIdx;
331
  int64_t*     aTs;
332
  SSDataBlock* pInputBlock;
333
} STmsSubTableInput;
334

335
typedef struct SBlockOrderInfo SBlockOrderInfo;
336
typedef struct STmsSubTablesMergeInfo {
337
  SBlockOrderInfo* pTsOrderInfo;
338
  SBlockOrderInfo* pPkOrderInfo;
339

340
  int32_t                 numSubTables;
341
  STmsSubTableInput*      aInputs;
342
  SMultiwayMergeTreeInfo* pTree;
343
  int32_t                 numSubTablesCompleted;
344

345
  int32_t        numTableBlocksInMem;
346
  SDiskbasedBuf* pBlocksBuf;
347

348
  int32_t numInMemReaders;
349
} STmsSubTablesMergeInfo;
350

351
typedef struct STableMergeScanInfo {
352
  int32_t         tableStartIndex;
353
  int32_t         tableEndIndex;
354
  bool            hasGroupId;
355
  uint64_t        groupId;
356
  STableScanBase  base;
357
  int32_t         bufPageSize;
358
  uint32_t        sortBufSize;  // max buffer size for in-memory sort
359
  SArray*         pSortInfo;
360
  SSortHandle*    pSortHandle;
361
  SSDataBlock*    pSortInputBlock;
362
  SSDataBlock*    pReaderBlock;
363
  int64_t         startTs;  // sort start time
364
  SLimitInfo      limitInfo;
365
  int64_t         numOfRows;
366
  SScanInfo       scanInfo;
367
  int32_t         scanTimes;
368
  int32_t         readIdx;
369
  SSDataBlock*    pResBlock;
370
  SSampleExecInfo sample;         // sample execution info
371
  SSHashObj*      mTableNumRows;  // uid->num of table rows
372
  SHashObj*       mSkipTables;
373
  int64_t         mergeLimit;
374
  SSortExecInfo   sortExecInfo;
375
  bool            needCountEmptyTable;
376
  bool            bGroupProcessed;  // the group return data means processed
377
  bool            filesetDelimited;
378
  bool            bNewFilesetEvent;
379
  bool            bNextDurationBlockEvent;
380
  int32_t         numNextDurationBlocks;
381
  SSDataBlock*    nextDurationBlocks[2];
382
  bool            rtnNextDurationBlocks;
383
  int32_t         nextDurationBlocksIdx;
384
  bool            bSortRowId;
385

386
  STmsSubTablesMergeInfo* pSubTablesMergeInfo;
387
} STableMergeScanInfo;
388

389
typedef struct STagScanFilterContext {
390
  SHashObj* colHash;
391
  int32_t   index;
392
  SArray*   cInfoList;
393
  int32_t   code;
394
} STagScanFilterContext;
395

396
typedef struct STagScanInfo {
397
  SColumnInfo*          pCols;
398
  SSDataBlock*          pRes;
399
  SColMatchInfo         matchInfo;
400
  int32_t               curPos;
401
  SReadHandle           readHandle;
402
  STableListInfo*       pTableListInfo;
403
  uint64_t              suid;
404
  void*                 pCtbCursor;
405
  SNode*                pTagCond;
406
  SNode*                pTagIndexCond;
407
  STagScanFilterContext filterCtx;
408
  SArray*               aUidTags;     // SArray<STUidTagInfo>
409
  SArray*               aFilterIdxs;  // SArray<int32_t>
410
  SStorageAPI*          pStorageAPI;
411
  SLimitInfo            limitInfo;
412
} STagScanInfo;
413

414
typedef enum EStreamScanMode {
415
  STREAM_SCAN_FROM_READERHANDLE = 1,
416
  STREAM_SCAN_FROM_RES,
417
  STREAM_SCAN_FROM_UPDATERES,
418
  STREAM_SCAN_FROM_DELETE_DATA,
419
  STREAM_SCAN_FROM_DATAREADER_RETRIEVE,
420
  STREAM_SCAN_FROM_DATAREADER_RANGE,
421
  STREAM_SCAN_FROM_CREATE_TABLERES,
422
} EStreamScanMode;
423

424
enum {
425
  PROJECT_RETRIEVE_CONTINUE = 0x1,
426
  PROJECT_RETRIEVE_DONE = 0x2,
427
};
428

429
typedef struct SStreamAggSupporter {
430
  int32_t         resultRowSize;  // the result buffer size for each result row, with the meta data size for each row
431
  SSDataBlock*    pScanBlock;
432
  SStreamState*   pState;
433
  int64_t         gap;        // stream session window gap
434
  SqlFunctionCtx* pDummyCtx;  // for combine
435
  SSHashObj*      pResultRows;
436
  int32_t         stateKeySize;
437
  int16_t         stateKeyType;
438
  SDiskbasedBuf*  pResultBuf;
439
  SStateStore     stateStore;
440
  STimeWindow     winRange;
441
  SStorageAPI*    pSessionAPI;
442
  struct SUpdateInfo* pUpdateInfo;
443
  int32_t             windowCount;
444
  int32_t             windowSliding;
445
  SStreamStateCur*    pCur;
446
} SStreamAggSupporter;
447

448
typedef struct SWindowSupporter {
449
  SStreamAggSupporter* pStreamAggSup;
450
  int64_t              gap;
451
  uint16_t             parentType;
452
  SAggSupporter*       pIntervalAggSup;
453
} SWindowSupporter;
454

455
typedef struct SPartitionBySupporter {
456
  SArray* pGroupCols;     // group by columns, SArray<SColumn>
457
  SArray* pGroupColVals;  // current group column values, SArray<SGroupKeys>
458
  char*   keyBuf;         // group by keys for hash
459
  bool    needCalc;       // partition by column
460
} SPartitionBySupporter;
461

462
typedef struct SPartitionDataInfo {
463
  uint64_t groupId;
464
  char*    tbname;
465
  SArray*  rowIds;
466
} SPartitionDataInfo;
467

468
typedef struct STimeWindowAggSupp {
469
  TSKEY           maxTs;
470
  TSKEY           minTs;
471
  SColumnInfoData timeWindowData;  // query time window info for scalar function execution.
472
} STimeWindowAggSupp;
473

474
typedef struct SStreamNotifyEventSupp {
475
  SHashObj*    pWindowEventHashMap;  // Hash map from gorupid+skey+eventType to the list node of window event.
476
  SHashObj*    pTableNameHashMap;    // Hash map from groupid to the dest child table name.
477
  SSDataBlock* pEventBlock;          // The datablock contains all window events and results.
478
  SArray*      pSessionKeys;
479
  const char*  windowType;
480
} SStreamNotifyEventSupp;
481

482
typedef struct SSteamOpBasicInfo {
483
  int32_t                primaryPkIndex;
484
  int16_t                operatorFlag;
485
  SStreamNotifyEventSupp notifyEventSup;
486
  bool                   recvCkBlock;
487
  SSDataBlock*           pCheckpointRes;
488
  SSHashObj*             pSeDeleted;
489
  void*                  pDelIterator;
490
  SSDataBlock*           pDelRes;
491
  SArray*                pUpdated;
492
  STableTsDataState*     pTsDataState;
493
  int32_t                numOfRecv;
494
} SSteamOpBasicInfo;
495

496
typedef struct SStreamFillSupporter {
497
  int32_t        type;  // fill type
498
  SInterval      interval;
499
  SResultRowData prev;
500
  TSKEY          prevOriginKey;
501
  SResultRowData cur;
502
  SResultRowData next;
503
  TSKEY          nextOriginKey;
504
  SResultRowData nextNext;
505
  SFillColInfo*  pAllColInfo;  // fill exprs and not fill exprs
506
  SExprSupp      notFillExprSup;
507
  int32_t        numOfAllCols;  // number of all exprs, including the tags columns
508
  int32_t        numOfFillCols;
509
  int32_t        numOfNotFillCols;
510
  int32_t        rowSize;
511
  SSHashObj*     pResMap;
512
  bool           hasDelete;
513
  SStorageAPI*   pAPI;
514
  STimeWindow    winRange;
515
  int32_t        pkColBytes;
516
  __compar_fn_t  comparePkColFn;
517
  int32_t*       pOffsetInfo;
518
  bool           normalFill;
519
  void*          pEmptyRow;
520
  SArray*        pResultRange;
521
} SStreamFillSupporter;
522

523
typedef struct SStreamScanInfo {
524
  SSteamOpBasicInfo basic;
525
  SExprInfo*        pPseudoExpr;
526
  int32_t           numOfPseudoExpr;
527
  SExprSupp         tbnameCalSup;
528
  SExprSupp*        pPartTbnameSup;
529
  SExprSupp         tagCalSup;
530
  int32_t           primaryTsIndex;  // primary time stamp slot id
531
  int32_t           primaryKeyIndex;
532
  SReadHandle       readHandle;
533
  SInterval         interval;  // if the upstream is an interval operator, the interval info is also kept here.
534
  SColMatchInfo     matchInfo;
535

536
  SArray*      pBlockLists;  // multiple SSDatablock.
537
  SSDataBlock* pRes;         // result SSDataBlock
538
  SSDataBlock* pUpdateRes;   // update SSDataBlock
539
  int32_t      updateResIndex;
540
  int32_t      blockType;        // current block type
541
  int32_t      validBlockIndex;  // Is current data has returned?
542
  uint64_t     numOfExec;        // execution times
543
  STqReader*   tqReader;
544

545
  SHashObj*       pVtableMergeHandles;  // key: vtable uid, value: SStreamVtableMergeHandle
546
  SDiskbasedBuf*  pVtableMergeBuf;      // page buffer used by vtable merge
547
  SArray*         pVtableReadyHandles;
548
  STableListInfo* pTableListInfo;
549

550
  uint64_t            groupId;
551
  bool                igCheckGroupId;
552
  struct SUpdateInfo* pUpdateInfo;
553

554
  EStreamScanMode       scanMode;
555
  struct SOperatorInfo* pStreamScanOp;
556
  struct SOperatorInfo* pTableScanOp;
557
  SArray*               childIds;
558
  SWindowSupporter      windowSup;
559
  SPartitionBySupporter partitionSup;
560
  SExprSupp*            pPartScalarSup;
561
  bool                  assignBlockUid;  // assign block uid to groupId, temporarily used for generating rollup SMA.
562
  int32_t               scanWinIndex;    // for state operator
563
  SSDataBlock*          pDeleteDataRes;  // delete data SSDataBlock
564
  int32_t               deleteDataIndex;
565
  STimeWindow           updateWin;
566
  STimeWindowAggSupp    twAggSup;
567
  SSDataBlock*          pUpdateDataRes;
568
  SStreamFillSupporter* pFillSup;
569
  // status for tmq
570
  SNodeList* pGroupTags;
571
  SNode*     pTagCond;
572
  SNode*     pTagIndexCond;
573

574
  // recover
575
  int32_t      blockRecoverTotCnt;
576
  SSDataBlock* pRecoverRes;
577

578
  SSDataBlock*      pCreateTbRes;
579
  int8_t            igCheckUpdate;
580
  int8_t            igExpired;
581
  void*             pState;  // void
582
  SStoreTqReader    readerFn;
583
  SStateStore       stateStore;
584
  SSDataBlock*      pCheckpointRes;
585
  int8_t            pkColType;
586
  int32_t           pkColLen;
587
  bool              useGetResultRange;
588
  STimeWindow       lastScanRange;
589
  SSDataBlock*      pRangeScanRes;  // update SSDataBlock
590
  bool              hasPart;
591

592
  //nonblock data scan
593
  TSKEY                  recalculateInterval;
594
  __compar_fn_t          comparePkColFn;
595
  SScanRange             curRange;
596
  struct SOperatorInfo*  pRecTableScanOp;
597
  bool                   scanAllTables;
598
  SSHashObj*             pRecRangeMap;
599
  SArray*                pRecRangeRes;
600
} SStreamScanInfo;
601

602
typedef struct {
603
  struct SVnode*       vnode;  // todo remove this
604
  SSDataBlock          pRes;   // result SSDataBlock
605
  STsdbReader*         dataReader;
606
  struct SSnapContext* sContext;
607
  SStorageAPI*         pAPI;
608
  STableListInfo*      pTableListInfo;
609
} SStreamRawScanInfo;
610

611
typedef struct STableCountScanSupp {
612
  int16_t dbNameSlotId;
613
  int16_t stbNameSlotId;
614
  int16_t tbCountSlotId;
615
  bool    groupByDbName;
616
  bool    groupByStbName;
617
  char    dbNameFilter[TSDB_DB_NAME_LEN];
618
  char    stbNameFilter[TSDB_TABLE_NAME_LEN];
619
} STableCountScanSupp;
620

621
typedef struct SOptrBasicInfo {
622
  SResultRowInfo resultRowInfo;
623
  SSDataBlock*   pRes;
624
  bool           mergeResultBlock;
625
  int32_t        inputTsOrder;
626
  int32_t        outputTsOrder;
627
} SOptrBasicInfo;
628

629
typedef struct SIntervalAggOperatorInfo {
630
  SOptrBasicInfo     binfo;              // basic info
631
  SAggSupporter      aggSup;             // aggregate supporter
632
  SExprSupp          scalarSupp;         // supporter for perform scalar function
633
  SGroupResInfo      groupResInfo;       // multiple results build supporter
634
  SInterval          interval;           // interval info
635
  int32_t            primaryTsIndex;     // primary time stamp slot id from result of downstream operator.
636
  STimeWindow        win;                // query time range
637
  bool               timeWindowInterpo;  // interpolation needed or not
638
  SArray*            pInterpCols;        // interpolation columns
639
  EOPTR_EXEC_MODEL   execModel;          // operator execution model [batch model|stream model]
640
  STimeWindowAggSupp twAggSup;
641
  SArray*            pPrevValues;  //  SArray<SGroupKeys> used to keep the previous not null value for interpolation.
642
  bool               cleanGroupResInfo;
643
  struct SOperatorInfo* pOperator;
644
  // for limit optimization
645
  bool          limited;
646
  int64_t       limit;
647
  bool          slimited;
648
  int64_t       slimit;
649
  uint64_t      curGroupId;  // initialize to UINT64_MAX
650
  uint64_t      handledGroupNum;
651
  BoundedQueue* pBQ;
652
} SIntervalAggOperatorInfo;
653

654
typedef struct SMergeAlignedIntervalAggOperatorInfo {
655
  SIntervalAggOperatorInfo* intervalAggOperatorInfo;
656

657
  uint64_t     groupId;  // current groupId
658
  int64_t      curTs;    // current ts
659
  SSDataBlock* prefetchedBlock;
660
  SResultRow*  pResultRow;
661
} SMergeAlignedIntervalAggOperatorInfo;
662

663
typedef struct SOpCheckPointInfo {
664
  uint16_t  checkPointId;
665
  SHashObj* children;  // key:child id
666
} SOpCheckPointInfo;
667

668
typedef struct SDataGroupInfo {
669
  uint64_t groupId;
670
  int64_t  numOfRows;
671
  SArray*  pPageList;
672
  SArray*  blockForNotLoaded;   // SSDataBlock that data is not loaded
673
  int32_t  offsetForNotLoaded;  // read offset for SSDataBlock that data is not loaded
674
} SDataGroupInfo;
675

676
typedef struct SWindowRowsSup {
677
  STimeWindow win;
678
  TSKEY       prevTs;
679
  int32_t     startRowIndex;
680
  int32_t     numOfRows;
681
  uint64_t    groupId;
682
  uint32_t    numNullRows;  // number of continuous rows with null state col
683
  TSKEY       lastTs; // this ts is used to record the last timestamp, so that we can know whether the new row's ts is duplicated
684
} SWindowRowsSup;
685

686
// return true if there are continuous rows with null state col
687
// state window operator needs to handle these rows specially
688
static inline bool hasContinuousNullRows(SWindowRowsSup* pRowSup) {
87,909,914✔
689
  return pRowSup->numNullRows > 0;
87,909,914✔
690
}
691

692
// reset on initialization or found of a row with non-null state col
693
static inline void resetNumNullRows(SWindowRowsSup* pRowSup) {
11,819,721✔
694
  pRowSup->numNullRows = 0;
11,819,721✔
695
}
11,819,721✔
696

697
static inline void resetWindowRowsSup(SWindowRowsSup* pRowSup) {
23,439✔
698
  if (NULL == pRowSup) {
23,439✔
UNCOV
699
    return;
×
700
  }
701

702
  pRowSup->win.skey = pRowSup->win.ekey = 0;
23,439✔
703
  pRowSup->prevTs = pRowSup->startRowIndex = 0;
23,439✔
704
  pRowSup->numOfRows = pRowSup->groupId = 0;
23,439✔
705
  resetNumNullRows(pRowSup);
23,439✔
706
}
707

708
typedef int32_t (*AggImplFn)(struct SOperatorInfo* pOperator, SSDataBlock* pBlock);
709

710
typedef struct SSessionAggOperatorInfo {
711
  SOptrBasicInfo        binfo;
712
  SAggSupporter         aggSup;
713
  SExprSupp             scalarSupp;  // supporter for perform scalar function
714
  SGroupResInfo         groupResInfo;
715
  SWindowRowsSup        winSup;
716
  bool                  reptScan;  // next round scan
717
  int64_t               gap;       // session window gap
718
  int32_t               tsSlotId;  // primary timestamp slot id
719
  STimeWindowAggSupp    twAggSup;
720
  struct SOperatorInfo* pOperator;
721
  bool                  cleanGroupResInfo;
722
} SSessionAggOperatorInfo;
723

724
typedef struct SStateWindowOperatorInfo {
725
  SOptrBasicInfo        binfo;
726
  SAggSupporter         aggSup;
727
  SExprSupp             scalarSup;
728
  SGroupResInfo         groupResInfo;
729
  SWindowRowsSup        winSup;
730
  SColumn               stateCol;
731
  bool                  hasKey;
732
  SStateKeys            stateKey;
733
  int32_t               tsSlotId;  // primary timestamp column slot id
734
  STimeWindowAggSupp    twAggSup;
735
  struct SOperatorInfo* pOperator;
736
  bool                  cleanGroupResInfo;
737
  int64_t               trueForLimit;
738
  EStateWinExtendOption extendOption;
739
} SStateWindowOperatorInfo;
740

741

742
typedef struct SEventWindowOperatorInfo {
743
  SOptrBasicInfo     binfo;
744
  SAggSupporter      aggSup;
745
  SExprSupp          scalarSup;
746
  SWindowRowsSup     winSup;
747
  int32_t            tsSlotId;  // primary timestamp column slot id
748
  STimeWindowAggSupp twAggSup;
749
  uint64_t           groupId;  // current group id, used to identify the data block from different groups
750
  SFilterInfo*       pStartCondInfo;
751
  SFilterInfo*       pEndCondInfo;
752
  bool               inWindow;
753
  SResultRow*        pRow;
754
  SSDataBlock*       pPreDataBlock;
755
  struct SOperatorInfo*     pOperator;
756
  int64_t            trueForLimit;
757
} SEventWindowOperatorInfo;
758

759
#define OPTR_IS_OPENED(_optr)  (((_optr)->status & OP_OPENED) == OP_OPENED)
760
#define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED)
761
#define OPTR_CLR_OPENED(_optr) ((_optr)->status &= ~OP_OPENED)
762

763
SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode);
764

765
int32_t initQueriedTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNode, const char* dbName,
766
                                   SExecTaskInfo* pTaskInfo);
767
void    cleanupQueriedTableScanInfo(void* p);
768

769
void initBasicInfo(SOptrBasicInfo* pInfo, SSDataBlock* pBlock);
770
void cleanupBasicInfo(SOptrBasicInfo* pInfo);
771

772
int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr, SFunctionStateStore* pStore);
773
void checkIndefRowsFuncs(SExprSupp* pSup);
774
void    cleanupExprSupp(SExprSupp* pSup);
775
void    cleanupExprSuppWithoutFilter(SExprSupp* pSupp);
776

777
void     cleanupResultInfoInStream(SExecTaskInfo* pTaskInfo, void* pState, SExprSupp* pSup,
778
                                   SGroupResInfo* pGroupResInfo);
779
void     cleanupResultInfoInHashMap(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf,
780
                                    SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap);
781
void     cleanupResultInfo(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SGroupResInfo* pGroupResInfo,
782
                           SAggSupporter *pAggSup, bool cleanHashmap);
783
void     cleanupResultInfoWithoutHash(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf,
784
                                      SGroupResInfo* pGroupResInfo);
785

786
int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize,
787
                   const char* pkey, void* pState, SFunctionStateStore* pStore);
788
void    cleanupAggSup(SAggSupporter* pAggSup);
789

790
void initResultSizeInfo(SResultInfo* pResultInfo, int32_t numOfRows);
791

792
void doBuildResultDatablock(struct SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo,
793
                            SDiskbasedBuf* pBuf);
794

795
/**
796
 * @brief copydata from hash table, instead of copying from SGroupResInfo's pRow
797
 */
798
void doCopyToSDataBlockByHash(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
799
                              SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, int32_t threshold, bool ignoreGroup);
800
void doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
801
                        SGroupResInfo* pGroupResInfo, int32_t threshold, bool ignoreGroup, int64_t minWindowSize);
802

803
bool hasLimitOffsetInfo(SLimitInfo* pLimitInfo);
804
bool hasSlimitOffsetInfo(SLimitInfo* pLimitInfo);
805
void initLimitInfo(const SNode* pLimit, const SNode* pSLimit, SLimitInfo* pLimitInfo);
806
void resetLimitInfoForNextGroup(SLimitInfo* pLimitInfo);
807
bool applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
808

809
int32_t applyAggFunctionOnPartialTuples(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, SColumnInfoData* pTimeWindowData,
810
                                        int32_t offset, int32_t forwardStep, int32_t numOfTotal, int32_t numOfOutput);
811

812
int32_t setFunctionResultOutput(struct SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t stage,
813
                             int32_t numOfExprs);
814
int32_t      setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols, SArray** pResList);                             
815
int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, SArray* pColList, char** pNextStart);
816
void    updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int64_t numOfRows, int32_t dataLen, int64_t startTs,
817
                             struct SOperatorInfo* pOperator);
818

819
STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order);
820
int32_t     getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, int64_t* defaultBufsz);
821

822
extern void doDestroyExchangeOperatorInfo(void* param);
823

824
int32_t doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo, SColumnInfoData** pRet);
825
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr, SSDataBlock* pBlock,
826
                               int32_t rows, SExecTaskInfo* pTask, STableMetaCacheInfo* pCache);
827

828
int32_t appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle);
829
int32_t setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput,
830
                            int32_t* rowEntryInfoOffset);
831
void    clearResultRowInitFlag(SqlFunctionCtx* pCtx, int32_t numOfOutput);
832

833
SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, char* pData,
834
                                   int32_t bytes, bool masterscan, uint64_t groupId, SExecTaskInfo* pTaskInfo,
835
                                   bool isIntervalQuery, SAggSupporter* pSup, bool keepGroup);
836

837
int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx,
838
                              int32_t numOfOutput, SArray* pPseudoList, const void* pExtraParams);
839
int32_t projectApplyFunctionsWithSelect(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock,
840
                                        SqlFunctionCtx* pCtx, int32_t numOfOutput, SArray* pPseudoList,
841
                                        const void* pExtraParams, bool doSelectFunc, bool hasIndefRowsFunc);
842

843
int32_t setInputDataBlock(SExprSupp* pExprSupp, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
844
                          bool createDummyCol);
845

846
int32_t checkForQueryBuf(size_t numOfTables);
847

848
int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, SExecTaskInfo* pTask, SReadHandle* readHandle);
849

850
STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval,
851
                                int32_t order);
852
int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey,
853
                                 __block_search_fn_t searchFn, STableQueryInfo* item, int32_t order);
854
int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
855
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize);
856
void getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endTs, uint64_t groupId, SSessionKey* pKey);
857
bool isInTimeWindow(STimeWindow* pWin, TSKEY ts, int64_t gap);
858
bool functionNeedToExecute(SqlFunctionCtx* pCtx);
859
bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup);
860
bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup);
861
bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, void* pState, STimeWindowAggSupp* pTwSup,
862
                           SStateStore* pStore);
863

864
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId);
865

866
void finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup,
867
                        SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
868

869
bool    groupbyTbname(SNodeList* pGroupList);
870
void    getNextIntervalWindow(SInterval* pInterval, STimeWindow* tw, int32_t order);
871
int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn_t searchFn, TSKEY ekey, int32_t pos, int32_t order,
872
                               int64_t* pData);
873
SSDataBlock* buildCreateTableBlock(SExprSupp* tbName, SExprSupp* tag);
874
SExprInfo*   createExpr(SNodeList* pNodeList, int32_t* numOfExprs);
875

876
int32_t copyResultrowToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SResultRow* pRow, SqlFunctionCtx* pCtx,
877
                                 SSDataBlock* pBlock, const int32_t* rowEntryOffset, SExecTaskInfo* pTaskInfo);
878
void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs, const int32_t* rowEntryOffset);
879

880
void    streamOpReleaseState(struct SOperatorInfo* pOperator);
881
void    streamOpReloadState(struct SOperatorInfo* pOperator);
882
void    destroyStreamAggSupporter(SStreamAggSupporter* pSup);
883
void    clearGroupResInfo(SGroupResInfo* pGroupResInfo);
884
int32_t initBasicInfoEx(SOptrBasicInfo* pBasicInfo, SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfCols,
885
                        SSDataBlock* pResultBlock, SFunctionStateStore* pStore);
886
int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, SExprSupp* pExpSup, int32_t numOfOutput, int64_t gap,
887
                               SStreamState* pState, int32_t keySize, int16_t keyType, SStateStore* pStore,
888
                               SReadHandle* pHandle, STimeWindowAggSupp* pTwAggSup, const char* taskIdStr,
889
                               SStorageAPI* pApi, int32_t tsIndex, int8_t stateType, int32_t ratio);
890
int32_t initDownStream(struct SOperatorInfo* downstream, SStreamAggSupporter* pAggSup, uint16_t type,
891
                       int32_t tsColIndex, STimeWindowAggSupp* pTwSup, struct SSteamOpBasicInfo* pBasic, int64_t recalculateInterval);
892
int32_t getMaxTsWins(const SArray* pAllWins, SArray* pMaxWins);
893
void    initGroupResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList);
894
void    getSessionHashKey(const SSessionKey* pKey, SSessionKey* pHashKey);
895
int32_t deleteSessionWinState(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SSHashObj* pMapUpdate,
896
                              SSHashObj* pMapDelete, SSHashObj* pPkDelete, bool needAdd);
897
int32_t getAllSessionWindow(SSHashObj* pHashMap, SSHashObj* pStUpdated);
898
int32_t closeSessionWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SSHashObj* pClosed);
899
int32_t copyUpdateResult(SSHashObj** ppWinUpdated, SArray* pUpdated, __compar_fn_t compar);
900
int32_t sessionKeyCompareAsc(const void* pKey1, const void* pKey2);
901
void    removeSessionDeleteResults(SSHashObj* pHashMap, SArray* pWins);
902
int32_t doOneWindowAggImpl(SColumnInfoData* pTimeWindowData, SResultWindowInfo* pCurWin, SResultRow** pResult,
903
                           int32_t startIndex, int32_t winRows, int32_t rows, int32_t numOutput,
904
                           struct SOperatorInfo* pOperator, int64_t winDelta);
905
void    setSessionWinOutputInfo(SSHashObj* pStUpdated, SResultWindowInfo* pWinInfo);
906
int32_t saveSessionOutputBuf(SStreamAggSupporter* pAggSup, SResultWindowInfo* pWinInfo);
907
int32_t saveResult(SResultWindowInfo winInfo, SSHashObj* pStUpdated);
908
int32_t saveDeleteRes(SSHashObj* pStDelete, SSessionKey key);
909
void    removeSessionResult(SStreamAggSupporter* pAggSup, SSHashObj* pHashMap, SSHashObj* pResMap, SSessionKey* pKey);
910
void    doBuildDeleteDataBlock(struct SOperatorInfo* pOp, SSHashObj* pStDeleted, SSDataBlock* pBlock, void** Ite,
911
                               SGroupResInfo* pGroupResInfo);
912
void    doBuildSessionResult(struct SOperatorInfo* pOperator, void* pState, SGroupResInfo* pGroupResInfo,
913
                             SSDataBlock* pBlock, SArray* pSessionKeys);
914
int32_t getSessionWindowInfoByKey(SStreamAggSupporter* pAggSup, SSessionKey* pKey, SResultWindowInfo* pWinInfo);
915
void    getNextSessionWinInfo(SStreamAggSupporter* pAggSup, SSHashObj* pStUpdated, SResultWindowInfo* pCurWin,
916
                              SResultWindowInfo* pNextWin);
917
int32_t compactTimeWindow(SExprSupp* pSup, SStreamAggSupporter* pAggSup, STimeWindowAggSupp* pTwAggSup,
918
                          SExecTaskInfo* pTaskInfo, SResultWindowInfo* pCurWin, SResultWindowInfo* pNextWin,
919
                          SSHashObj* pStUpdated, SSHashObj* pStDeleted, bool addGap);
920
void    releaseOutputBuf(void* pState, SRowBuffPos* pPos, SStateStore* pAPI);
921
void    resetWinRange(STimeWindow* winRange);
922
int64_t getDeleteMark(SWindowPhysiNode* pWinPhyNode, int64_t interval);
923
void    resetUnCloseSessionWinInfo(SSHashObj* winMap);
924
void    setStreamOperatorCompleted(struct SOperatorInfo* pOperator);
925
void    reloadAggSupFromDownStream(struct SOperatorInfo* downstream, SStreamAggSupporter* pAggSup);
926
void    destroyFlusedPos(void* pRes);
927
bool    isIrowtsPseudoColumn(SExprInfo* pExprInfo);
928
bool    isIsfilledPseudoColumn(SExprInfo* pExprInfo);
929
bool    isInterpFunc(SExprInfo* pExprInfo);
930
bool    isIrowtsOriginPseudoColumn(SExprInfo* pExprInfo);
931

932
int32_t encodeSSessionKey(void** buf, SSessionKey* key);
933
void*   decodeSSessionKey(void* buf, SSessionKey* key);
934
int32_t encodeSResultWindowInfo(void** buf, SResultWindowInfo* key, int32_t outLen);
935
void*   decodeSResultWindowInfo(void* buf, SResultWindowInfo* key, int32_t outLen);
936
int32_t encodeSTimeWindowAggSupp(void** buf, STimeWindowAggSupp* pTwAggSup);
937
void*   decodeSTimeWindowAggSupp(void* buf, STimeWindowAggSupp* pTwAggSup);
938

939
void    destroyOperatorParamValue(void* pValues);
940
int32_t mergeOperatorParams(SOperatorParam* pDst, SOperatorParam* pSrc);
941
int32_t buildTableScanOperatorParam(SOperatorParam** ppRes, SArray* pUidList, int32_t srcOpType, bool tableSeq);
942
int32_t buildTableScanOperatorParamEx(SOperatorParam** ppRes, SArray* pUidList, int32_t srcOpType, SOrgTbInfo *pMap, bool tableSeq, STimeWindow *window, bool isNewParam);
943
void    freeExchangeGetBasicOperatorParam(void* pParam);
944
void    freeOperatorParam(SOperatorParam* pParam, SOperatorParamType type);
945
void    freeResetOperatorParams(struct SOperatorInfo* pOperator, SOperatorParamType type, bool allFree);
946
int32_t getNextBlockFromDownstreamImpl(struct SOperatorInfo* pOperator, int32_t idx, bool clearParam,
947
                                       SSDataBlock** pResBlock);
948
void getCountWinRange(SStreamAggSupporter* pAggSup, const SSessionKey* pKey, EStreamType mode, SSessionKey* pDelRange);
949
void    doDeleteSessionWindow(SStreamAggSupporter* pAggSup, SSessionKey* pKey);
950

951
int32_t saveDeleteInfo(SArray* pWins, SSessionKey key);
952
void    removeSessionResults(SStreamAggSupporter* pAggSup, SSHashObj* pHashMap, SArray* pWins);
953
int32_t copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted);
954
int32_t copyDeleteSessionKey(SSHashObj* source, SSHashObj* dest);
955

956
bool inSlidingWindow(SInterval* pInterval, STimeWindow* pWin, SDataBlockInfo* pBlockInfo);
957
bool inCalSlidingWindow(SInterval* pInterval, STimeWindow* pWin, TSKEY calStart, TSKEY calEnd, EStreamType blockType);
958
bool compareVal(const char* v, const SStateKeys* pKey);
959
bool inWinRange(STimeWindow* range, STimeWindow* cur);
960
int32_t doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SArray* result);
961

962
int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext, SDataBlockInfo* pDataBlockInfo,
963
                               TSKEY* primaryKeys, int32_t prevPosition, int32_t order);
964
int32_t extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status);
965
bool    getIgoreNullRes(SExprSupp* pExprSup);
966
bool    checkNullRow(SExprSupp* pExprSup, SSDataBlock* pSrcBlock, int32_t index, bool ignoreNull);
967
int64_t getMinWindowSize(struct SOperatorInfo* pOperator);
968

969
void    destroyTmqScanOperatorInfo(void* param);
970
int32_t checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock* pBlock, bool out);
971
void resetBasicOperatorState(SOptrBasicInfo* pBasicInfo);
972

973
int32_t addNewResultRowBuf(SResultRow* pWindowRes, SDiskbasedBuf* pResultBuf, uint32_t size);
974

975
#ifdef __cplusplus
976
}
977
#endif
978

979
#endif  // TDENGINE_EXECUTORINT_H
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc