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

taosdata / TDengine / #4875

09 Dec 2025 01:22AM UTC coverage: 64.472% (-0.2%) from 64.623%
#4875

push

travis-ci

guanshengliang
fix: temporarily disable memory leak detection for UDF tests (#33856)

162014 of 251293 relevant lines covered (64.47%)

104318075.66 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
  SArray*         pBlockColMap;
312
} STableScanInfo;
313

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

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

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

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

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

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

346
  int32_t        numTableBlocksInMem;
347
  SDiskbasedBuf* pBlocksBuf;
348

349
  int32_t numInMemReaders;
350
} STmsSubTablesMergeInfo;
351

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

387
  STmsSubTablesMergeInfo* pSubTablesMergeInfo;
388
} STableMergeScanInfo;
389

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

655
typedef struct SMergeAlignedIntervalAggOperatorInfo {
656
  SIntervalAggOperatorInfo* intervalAggOperatorInfo;
657

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

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

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

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

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

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

698
static inline void resetWindowRowsSup(SWindowRowsSup* pRowSup) {
163,909✔
699
  if (NULL == pRowSup) {
163,909✔
700
    return;
×
701
  }
702

703
  pRowSup->win.skey = pRowSup->win.ekey = 0;
163,909✔
704
  pRowSup->prevTs = INT64_MIN;
163,909✔
705
  pRowSup->startRowIndex = pRowSup->groupId = 0;
163,909✔
706
  pRowSup->numOfRows = pRowSup->numNullRows = 0;
163,909✔
707
}
708

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

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

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

742

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

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

764
SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode);
765

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

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

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

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

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

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

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

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

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

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

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

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

823
extern void doDestroyExchangeOperatorInfo(void* param);
824

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

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

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

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

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

847
int32_t checkForQueryBuf(size_t numOfTables);
848

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

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

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

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

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

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

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

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

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

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

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

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

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

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

976
#ifdef __cplusplus
977
}
978
#endif
979

980
#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