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

taosdata / TDengine / #3519

05 Nov 2024 11:19AM UTC coverage: 57.706% (+8.4%) from 49.32%
#3519

push

travis-ci

web-flow
Merge pull request #28652 from taosdata/fix/3_liaohj

refactor: always successfully put the retrieve msg

109445 of 245179 branches covered (44.64%)

Branch coverage included in aggregate %.

187435 of 269288 relevant lines covered (69.6%)

12869818.21 hits per line

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

65.94
/source/libs/executor/src/executorInt.c
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

16
#include "filter.h"
17
#include "function.h"
18
#include "functionMgt.h"
19
#include "os.h"
20
#include "querynodes.h"
21
#include "tfill.h"
22
#include "tname.h"
23

24
#include "tdatablock.h"
25
#include "tmsg.h"
26
#include "ttime.h"
27

28
#include "executorInt.h"
29
#include "index.h"
30
#include "operator.h"
31
#include "query.h"
32
#include "querytask.h"
33
#include "storageapi.h"
34
#include "tcompare.h"
35
#include "thash.h"
36
#include "ttypes.h"
37

38
#define SET_REVERSE_SCAN_FLAG(runtime)    ((runtime)->scanFlag = REVERSE_SCAN)
39
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
40

41
#if 0
42
static UNUSED_FUNC void *u_malloc (size_t __size) {
43
  uint32_t v = taosRand();
44

45
  if (v % 1000 <= 0) {
46
    return NULL;
47
  } else {
48
    return taosMemoryMalloc(__size);
49
  }
50
}
51

52
static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
53
  uint32_t v = taosRand();
54
  if (v % 1000 <= 0) {
55
    return NULL;
56
  } else {
57
    return taosMemoryCalloc(num, __size);
58
  }
59
}
60

61
static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
62
  uint32_t v = taosRand();
63
  if (v % 5 <= 1) {
64
    return NULL;
65
  } else {
66
    return taosMemoryRealloc(p, __size);
67
  }
68
}
69

70
#define calloc  u_calloc
71
#define malloc  u_malloc
72
#define realloc u_realloc
73
#endif
74

75
static int32_t setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock);
76

77
static int32_t initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size);
78
static void    doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag);
79

80
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
81
                                   bool createDummyCol);
82
static void    doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
83
                                  SGroupResInfo* pGroupResInfo, int32_t threshold, bool ignoreGroup);
84

85
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize) {
177,921,543✔
86
  SFilePage* pData = NULL;
177,921,543✔
87

88
  // in the first scan, new space needed for results
89
  int32_t pageId = -1;
177,921,543✔
90
  if (*currentPageId == -1) {
177,921,543✔
91
    pData = getNewBufPage(pResultBuf, &pageId);
2,822,540✔
92
    if (pData == NULL) {
2,822,525✔
93
      qError("failed to get buffer, code:%s", tstrerror(terrno));
45!
94
      return NULL;
×
95
    }
96
    pData->num = sizeof(SFilePage);
2,822,480✔
97
  } else {
98
    pData = getBufPage(pResultBuf, *currentPageId);
175,099,003✔
99
    if (pData == NULL) {
175,063,292!
100
      qError("failed to get buffer, code:%s", tstrerror(terrno));
×
101
      return NULL;
×
102
    }
103

104
    pageId = *currentPageId;
175,063,292✔
105

106
    if (pData->num + interBufSize > getBufPageSize(pResultBuf)) {
175,063,292✔
107
      // release current page first, and prepare the next one
108
      releaseBufPage(pResultBuf, pData);
11,587,537✔
109

110
      pData = getNewBufPage(pResultBuf, &pageId);
11,699,473✔
111
      if (pData == NULL) {
11,713,566!
112
        qError("failed to get buffer, code:%s", tstrerror(terrno));
×
113
        return NULL;
×
114
      }
115
      pData->num = sizeof(SFilePage);
11,713,566✔
116
    }
117
  }
118

119
  if (pData == NULL) {
177,967,488!
120
    return NULL;
×
121
  }
122

123
  setBufPageDirty(pData, true);
177,967,488✔
124

125
  // set the number of rows in current disk page
126
  SResultRow* pResultRow = (SResultRow*)((char*)pData + pData->num);
177,831,491✔
127

128
  memset((char*)pResultRow, 0, interBufSize);
177,831,491✔
129
  pResultRow->pageId = pageId;
177,831,491✔
130
  pResultRow->offset = (int32_t)pData->num;
177,831,491✔
131

132
  *currentPageId = pageId;
177,831,491✔
133
  pData->num += interBufSize;
177,831,491✔
134
  return pResultRow;
177,831,491✔
135
}
136

137
/**
138
 * the struct of key in hash table
139
 * +----------+---------------+
140
 * | group id |   key data    |
141
 * | 8 bytes  | actual length |
142
 * +----------+---------------+
143
 */
144
SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, char* pData,
199,778,590✔
145
                                   int32_t bytes, bool masterscan, uint64_t groupId, SExecTaskInfo* pTaskInfo,
146
                                   bool isIntervalQuery, SAggSupporter* pSup, bool keepGroup) {
147
  SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, groupId);
199,778,590✔
148
  if (!keepGroup) {
199,778,590✔
149
    *(uint64_t*)pSup->keyBuf = calcGroupId(pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes));
5,173,419✔
150
  }
151

152
  SResultRowPosition* p1 =
153
      (SResultRowPosition*)tSimpleHashGet(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes));
199,778,903✔
154

155
  SResultRow* pResult = NULL;
200,306,996✔
156

157
  // in case of repeat scan/reverse scan, no new time window added.
158
  if (isIntervalQuery) {
200,306,996✔
159
    if (p1 != NULL) {  // the *p1 may be NULL in case of sliding+offset exists.
193,496,927✔
160
      pResult = getResultRowByPos(pResultBuf, p1, true);
20,530,542✔
161
      if (pResult == NULL) {
20,530,542!
162
        pTaskInfo->code = terrno;
×
163
        return NULL;
×
164
      }
165

166
      if (pResult->pageId != p1->pageId || pResult->offset != p1->offset) {
20,530,542!
167
        terrno = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
×
168
        pTaskInfo->code = terrno;
×
169
        return NULL;
×
170
      }
171
    }
172
  } else {
173
    // In case of group by column query, the required SResultRow object must be existInCurrentResusltRowInfo in the
174
    // pResultRowInfo object.
175
    if (p1 != NULL) {
6,810,069✔
176
      // todo
177
      pResult = getResultRowByPos(pResultBuf, p1, true);
1,218,056✔
178
      if (NULL == pResult) {
1,218,056!
179
        pTaskInfo->code = terrno;
×
180
        return NULL;
×
181
      }
182

183
      if (pResult->pageId != p1->pageId || pResult->offset != p1->offset) {
1,218,056!
184
        terrno = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
1✔
185
        pTaskInfo->code = terrno;
×
186
        return NULL;
521✔
187
      }
188
    }
189
  }
190

191
  // 1. close current opened time window
192
  if (pResultRowInfo->cur.pageId != -1 && ((pResult == NULL) || (pResult->pageId != pResultRowInfo->cur.pageId))) {
200,304,813✔
193
    SResultRowPosition pos = pResultRowInfo->cur;
178,650,463✔
194
    SFilePage*         pPage = getBufPage(pResultBuf, pos.pageId);
178,650,463✔
195
    if (pPage == NULL) {
178,088,647!
196
      qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
×
197
      pTaskInfo->code = terrno;
×
198
      return NULL;
×
199
    }
200
    releaseBufPage(pResultBuf, pPage);
178,088,647✔
201
  }
202

203
  // allocate a new buffer page
204
  if (pResult == NULL) {
199,316,706✔
205
    pResult = getNewResultRow(pResultBuf, &pSup->currentPageId, pSup->resultRowSize);
177,549,648✔
206
    if (pResult == NULL) {
177,833,922!
207
      pTaskInfo->code = terrno;
×
208
      return NULL;
×
209
    }
210

211
    // add a new result set for a new group
212
    SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset};
177,833,922✔
213
    int32_t code = tSimpleHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos,
177,833,922✔
214
                                  sizeof(SResultRowPosition));
215
    if (code != TSDB_CODE_SUCCESS) {
178,547,511✔
216
      qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
2,269!
217
      pTaskInfo->code = code;
×
218
      return NULL;
×
219
    }
220
  }
221

222
  // 2. set the new time window to be the new active time window
223
  pResultRowInfo->cur = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset};
200,312,300✔
224

225
  // too many time window in query
226
  if (pTaskInfo->execModel == OPTR_EXEC_MODEL_BATCH &&
400,373,265!
227
      tSimpleHashGetSize(pSup->pResultRowHashTable) > MAX_INTERVAL_TIME_WINDOW) {
200,304,599✔
228
    pTaskInfo->code = TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW;
×
229
    return NULL;
×
230
  }
231

232
  return pResult;
200,068,666✔
233
}
234

235
//  query_range_start, query_range_end, window_duration, window_start, window_end
236
int32_t initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow) {
2,437,939✔
237
  pColData->info.type = TSDB_DATA_TYPE_TIMESTAMP;
2,437,939✔
238
  pColData->info.bytes = sizeof(int64_t);
2,437,939✔
239

240
  int32_t code = colInfoDataEnsureCapacity(pColData, 5, false);
2,437,939✔
241
  if (code != TSDB_CODE_SUCCESS) {
2,442,313!
242
    return code;
×
243
  }
244
  colDataSetInt64(pColData, 0, &pQueryWindow->skey);
2,442,313✔
245
  colDataSetInt64(pColData, 1, &pQueryWindow->ekey);
2,442,313✔
246

247
  int64_t interval = 0;
2,442,313✔
248
  colDataSetInt64(pColData, 2, &interval);  // this value may be variable in case of 'n' and 'y'.
249
  colDataSetInt64(pColData, 3, &pQueryWindow->skey);
2,442,313✔
250
  colDataSetInt64(pColData, 4, &pQueryWindow->ekey);
2,442,313✔
251
  return TSDB_CODE_SUCCESS;
2,442,313✔
252
}
253

254
static int32_t doSetInputDataBlockInfo(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag) {
510✔
255
  int32_t         code = TSDB_CODE_SUCCESS;
510✔
256
  int32_t         lino = 0;
510✔
257
  SqlFunctionCtx* pCtx = pExprSup->pCtx;
510✔
258
  for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) {
1,020✔
259
    pCtx[i].order = order;
510✔
260
    pCtx[i].input.numOfRows = pBlock->info.rows;
510✔
261
    code = setBlockSMAInfo(&pCtx[i], &pExprSup->pExprInfo[i], pBlock);
510✔
262
    QUERY_CHECK_CODE(code, lino, _end);
510!
263
    pCtx[i].pSrcBlock = pBlock;
510✔
264
    pCtx[i].scanFlag = scanFlag;
510✔
265
  }
266

267
_end:
510✔
268
  if (code != TSDB_CODE_SUCCESS) {
510!
269
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
270
  }
271
  return code;
510✔
272
}
273

274
int32_t setInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
8,222,243✔
275
                          bool createDummyCol) {
276
  if (pBlock->pBlockAgg != NULL) {
8,222,243✔
277
    return doSetInputDataBlockInfo(pExprSup, pBlock, order, scanFlag);
510✔
278
  } else {
279
    return doSetInputDataBlock(pExprSup, pBlock, order, scanFlag, createDummyCol);
8,221,733✔
280
  }
281
}
282

283
static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, int32_t paramIndex,
×
284
                                             int32_t numOfRows) {
285
  int32_t          code = TSDB_CODE_SUCCESS;
×
286
  int32_t          lino = 0;
×
287
  SColumnInfoData* pColInfo = NULL;
×
288
  if (pInput->pData[paramIndex] == NULL) {
×
289
    pColInfo = taosMemoryCalloc(1, sizeof(SColumnInfoData));
×
290
    QUERY_CHECK_NULL(pColInfo, code, lino, _end, terrno);
×
291

292
    // Set the correct column info (data type and bytes)
293
    pColInfo->info.type = pFuncParam->param.nType;
×
294
    pColInfo->info.bytes = pFuncParam->param.nLen;
×
295

296
    pInput->pData[paramIndex] = pColInfo;
×
297
  } else {
298
    pColInfo = pInput->pData[paramIndex];
×
299
  }
300

301
  code = colInfoDataEnsureCapacity(pColInfo, numOfRows, false);
×
302
  QUERY_CHECK_CODE(code, lino, _end);
×
303

304
  int8_t type = pFuncParam->param.nType;
×
305
  if (type == TSDB_DATA_TYPE_BIGINT || type == TSDB_DATA_TYPE_UBIGINT) {
×
306
    int64_t v = pFuncParam->param.i;
×
307
    for (int32_t i = 0; i < numOfRows; ++i) {
×
308
      colDataSetInt64(pColInfo, i, &v);
×
309
    }
310
  } else if (type == TSDB_DATA_TYPE_DOUBLE) {
×
311
    double v = pFuncParam->param.d;
×
312
    for (int32_t i = 0; i < numOfRows; ++i) {
×
313
      colDataSetDouble(pColInfo, i, &v);
×
314
    }
315
  } else if (type == TSDB_DATA_TYPE_VARCHAR || type == TSDB_DATA_TYPE_GEOMETRY) {
×
316
    char* tmp = taosMemoryMalloc(pFuncParam->param.nLen + VARSTR_HEADER_SIZE);
×
317
    QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
×
318

319
    STR_WITH_SIZE_TO_VARSTR(tmp, pFuncParam->param.pz, pFuncParam->param.nLen);
×
320
    for (int32_t i = 0; i < numOfRows; ++i) {
×
321
      code = colDataSetVal(pColInfo, i, tmp, false);
×
322
      QUERY_CHECK_CODE(code, lino, _end);
×
323
    }
324
    taosMemoryFree(tmp);
×
325
  }
326

327
_end:
×
328
  if (code != TSDB_CODE_SUCCESS) {
×
329
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
330
  }
331
  return code;
×
332
}
333

334
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
8,221,742✔
335
                                   bool createDummyCol) {
336
  int32_t         code = TSDB_CODE_SUCCESS;
8,221,742✔
337
  int32_t         lino = 0;
8,221,742✔
338
  SqlFunctionCtx* pCtx = pExprSup->pCtx;
8,221,742✔
339

340
  for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) {
37,001,641✔
341
    pCtx[i].order = order;
28,781,351✔
342
    pCtx[i].input.numOfRows = pBlock->info.rows;
28,781,351✔
343

344
    pCtx[i].pSrcBlock = pBlock;
28,781,351✔
345
    pCtx[i].scanFlag = scanFlag;
28,781,351✔
346

347
    SInputColumnInfoData* pInput = &pCtx[i].input;
28,781,351✔
348
    pInput->uid = pBlock->info.id.uid;
28,781,351✔
349
    pInput->colDataSMAIsSet = false;
28,781,351✔
350

351
    SExprInfo* pOneExpr = &pExprSup->pExprInfo[i];
28,781,351✔
352
    bool       hasPk = pOneExpr->pExpr->nodeType == QUERY_NODE_FUNCTION && pOneExpr->pExpr->_function.pFunctNode->hasPk;
28,781,351✔
353
    pCtx[i].hasPrimaryKey = hasPk;
28,781,351✔
354

355
    int16_t tsParamIdx = (!hasPk) ? pOneExpr->base.numOfParams - 1 : pOneExpr->base.numOfParams - 2;
28,781,351✔
356
    int16_t pkParamIdx = pOneExpr->base.numOfParams - 1;
28,781,351✔
357

358
    for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) {
59,843,376✔
359
      SFunctParam* pFuncParam = &pOneExpr->base.pParam[j];
31,063,477✔
360
      if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) {
31,063,477✔
361
        int32_t slotId = pFuncParam->pCol->slotId;
29,004,215✔
362
        pInput->pData[j] = taosArrayGet(pBlock->pDataBlock, slotId);
29,004,215✔
363
        pInput->totalRows = pBlock->info.rows;
29,002,643✔
364
        pInput->numOfRows = pBlock->info.rows;
29,002,643✔
365
        pInput->startRowIndex = 0;
29,002,643✔
366
        pInput->blankFill = pBlock->info.blankFill;
29,002,643✔
367

368
        // NOTE: the last parameter is the primary timestamp column
369
        // todo: refactor this
370

371
        if (fmIsImplicitTsFunc(pCtx[i].functionId) && (j == tsParamIdx)) {
29,002,643✔
372
          pInput->pPTS = pInput->pData[j];  // in case of merge function, this is not always the ts column data.
3,610,251✔
373
        }
374
        if (hasPk && (j == pkParamIdx)) {
29,002,763✔
375
          pInput->pPrimaryKey = pInput->pData[j];
31,977✔
376
        }
377
        QUERY_CHECK_CONDITION((pInput->pData[j] != NULL), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
29,002,763!
378
      } else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) {
2,059,262✔
379
        // todo avoid case: top(k, 12), 12 is the value parameter.
380
        // sum(11), 11 is also the value parameter.
381
        if (createDummyCol && pOneExpr->base.numOfParams == 1) {
1,982,736!
382
          pInput->totalRows = pBlock->info.rows;
×
383
          pInput->numOfRows = pBlock->info.rows;
×
384
          pInput->startRowIndex = 0;
×
385
          pInput->blankFill = pBlock->info.blankFill;
×
386

387
          code = doCreateConstantValColumnInfo(pInput, pFuncParam, j, pBlock->info.rows);
×
388
          QUERY_CHECK_CODE(code, lino, _end);
×
389
        }
390
      }
391
    }
392
  }
393

394
_end:
8,220,290✔
395
  if (code != TSDB_CODE_SUCCESS) {
8,220,290!
396
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
397
  }
398
  return code;
8,221,496✔
399
}
400

401
bool functionNeedToExecute(SqlFunctionCtx* pCtx) {
596,653,752✔
402
  struct SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
596,653,752✔
403

404
  // in case of timestamp column, always generated results.
405
  int32_t functionId = pCtx->functionId;
596,653,752✔
406
  if (functionId == -1) {
596,653,752✔
407
    return false;
13,583,205✔
408
  }
409

410
  if (pCtx->scanFlag == PRE_SCAN) {
583,070,547✔
411
    return fmIsRepeatScanFunc(pCtx->functionId);
58,838✔
412
  }
413

414
  if (isRowEntryCompleted(pResInfo)) {
583,011,709!
415
    return false;
×
416
  }
417

418
  return true;
583,011,709✔
419
}
420

421
static int32_t doCreateConstantValColumnSMAInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, int32_t type,
×
422
                                                int32_t paramIndex, int32_t numOfRows) {
423
  if (pInput->pData[paramIndex] == NULL) {
×
424
    pInput->pData[paramIndex] = taosMemoryCalloc(1, sizeof(SColumnInfoData));
×
425
    if (pInput->pData[paramIndex] == NULL) {
×
426
      return terrno;
×
427
    }
428

429
    // Set the correct column info (data type and bytes)
430
    pInput->pData[paramIndex]->info.type = type;
×
431
    pInput->pData[paramIndex]->info.bytes = tDataTypes[type].bytes;
×
432
  }
433

434
  SColumnDataAgg* da = NULL;
×
435
  if (pInput->pColumnDataAgg[paramIndex] == NULL) {
×
436
    da = taosMemoryCalloc(1, sizeof(SColumnDataAgg));
×
437
    if (!da) {
×
438
      return terrno;
×
439
    }
440
    pInput->pColumnDataAgg[paramIndex] = da;
×
441
    if (da == NULL) {
×
442
      return TSDB_CODE_OUT_OF_MEMORY;
×
443
    }
444
  } else {
445
    da = pInput->pColumnDataAgg[paramIndex];
×
446
  }
447

448
  if (type == TSDB_DATA_TYPE_BIGINT) {
×
449
    int64_t v = pFuncParam->param.i;
×
450
    *da = (SColumnDataAgg){.numOfNull = 0, .min = v, .max = v, .sum = v * numOfRows};
×
451
  } else if (type == TSDB_DATA_TYPE_DOUBLE) {
×
452
    double v = pFuncParam->param.d;
×
453
    *da = (SColumnDataAgg){.numOfNull = 0};
×
454

455
    *(double*)&da->min = v;
×
456
    *(double*)&da->max = v;
×
457
    *(double*)&da->sum = v * numOfRows;
×
458
  } else if (type == TSDB_DATA_TYPE_BOOL) {  // todo validate this data type
×
459
    bool v = pFuncParam->param.i;
×
460

461
    *da = (SColumnDataAgg){.numOfNull = 0};
×
462
    *(bool*)&da->min = 0;
×
463
    *(bool*)&da->max = v;
×
464
    *(bool*)&da->sum = v * numOfRows;
×
465
  } else if (type == TSDB_DATA_TYPE_TIMESTAMP) {
×
466
    // do nothing
467
  } else {
468
    qError("invalid constant type for sma info");
×
469
  }
470

471
  return TSDB_CODE_SUCCESS;
×
472
}
473

474
int32_t setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pBlock) {
510✔
475
  int32_t code = TSDB_CODE_SUCCESS;
510✔
476
  int32_t lino = 0;
510✔
477
  int32_t numOfRows = pBlock->info.rows;
510✔
478

479
  SInputColumnInfoData* pInput = &pCtx->input;
510✔
480
  pInput->numOfRows = numOfRows;
510✔
481
  pInput->totalRows = numOfRows;
510✔
482

483
  if (pBlock->pBlockAgg != NULL) {
510!
484
    pInput->colDataSMAIsSet = true;
510✔
485

486
    for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
1,020✔
487
      SFunctParam* pFuncParam = &pExprInfo->base.pParam[j];
510✔
488

489
      if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) {
510!
490
        int32_t slotId = pFuncParam->pCol->slotId;
510✔
491
        pInput->pColumnDataAgg[j] = &pBlock->pBlockAgg[slotId];
510✔
492
        if (pInput->pColumnDataAgg[j]->colId == -1) {
510!
493
          pInput->colDataSMAIsSet = false;
×
494
        }
495

496
        // Here we set the column info data since the data type for each column data is required, but
497
        // the data in the corresponding SColumnInfoData will not be used.
498
        pInput->pData[j] = taosArrayGet(pBlock->pDataBlock, slotId);
510✔
499
      } else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) {
×
500
        code = doCreateConstantValColumnSMAInfo(pInput, pFuncParam, pFuncParam->param.nType, j, pBlock->info.rows);
×
501
        QUERY_CHECK_CODE(code, lino, _end);
×
502
      }
503
    }
504
  } else {
505
    pInput->colDataSMAIsSet = false;
×
506
  }
507

508
_end:
510✔
509
  if (code != TSDB_CODE_SUCCESS) {
510!
510
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
511
  }
512
  return code;
510✔
513
}
514

515
/////////////////////////////////////////////////////////////////////////////////////////////
516
STimeWindow getAlignQueryTimeWindow(const SInterval* pInterval, int64_t key) {
31,158,682✔
517
  STimeWindow win = {0};
31,158,682✔
518
  win.skey = taosTimeTruncate(key, pInterval);
31,158,682✔
519

520
  /*
521
   * if the realSkey > INT64_MAX - pInterval->interval, the query duration between
522
   * realSkey and realEkey must be less than one interval.Therefore, no need to adjust the query ranges.
523
   */
524
  win.ekey = taosTimeGetIntervalEnd(win.skey, pInterval);
31,158,672✔
525
  if (win.ekey < win.skey) {
31,149,908✔
526
    win.ekey = INT64_MAX;
1,369✔
527
  }
528

529
  return win;
31,149,908✔
530
}
531

532
int32_t setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput,
367,173,957✔
533
                            int32_t* rowEntryInfoOffset) {
534
  bool init = false;
367,173,957✔
535
  for (int32_t i = 0; i < numOfOutput; ++i) {
1,113,078,311✔
536
    pCtx[i].resultInfo = getResultEntryInfo(pResult, i, rowEntryInfoOffset);
746,500,303✔
537
    if (init) {
746,436,974✔
538
      continue;
20,664,096✔
539
    }
540

541
    struct SResultRowEntryInfo* pResInfo = pCtx[i].resultInfo;
725,772,878✔
542
    if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) {
725,772,878!
543
      continue;
×
544
    }
545

546
    if (pCtx[i].isPseudoFunc) {
725,772,878✔
547
      continue;
144,975,947✔
548
    }
549

550
    if (!pResInfo->initialized) {
580,796,931✔
551
      if (pCtx[i].functionId != -1) {
560,164,396✔
552
        int32_t code = pCtx[i].fpSet.init(&pCtx[i], pResInfo);
549,305,001✔
553
        if (code != TSDB_CODE_SUCCESS && fmIsUserDefinedFunc(pCtx[i].functionId)) {
549,332,102!
554
          pResInfo->initialized = false;
×
555
          return TSDB_CODE_UDF_FUNC_EXEC_FAILURE;
×
556
        } else if (code != TSDB_CODE_SUCCESS) {
548,772,381!
557
          return code;
×
558
        }
559
      } else {
560
        pResInfo->initialized = true;
10,859,395✔
561
      }
562
    } else {
563
      init = true;
20,632,535✔
564
    }
565
  }
566
  return TSDB_CODE_SUCCESS;
366,578,008✔
567
}
568

569
void clearResultRowInitFlag(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
99,885,599✔
570
  for (int32_t i = 0; i < numOfOutput; ++i) {
250,708,381✔
571
    SResultRowEntryInfo* pResInfo = pCtx[i].resultInfo;
150,822,782✔
572
    if (pResInfo == NULL) {
150,822,782!
573
      continue;
×
574
    }
575

576
    pResInfo->initialized = false;
150,822,782✔
577
    pResInfo->numOfRes = 0;
150,822,782✔
578
    pResInfo->isNullRes = 0;
150,822,782✔
579
    pResInfo->complete = false;
150,822,782✔
580
  }
581
}
99,885,599✔
582

583
int32_t doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo) {
18,242,483✔
584
  int32_t code = TSDB_CODE_SUCCESS;
18,242,483✔
585
  int32_t lino = 0;
18,242,483✔
586
  if (pFilterInfo == NULL || pBlock->info.rows == 0) {
18,242,483✔
587
    return TSDB_CODE_SUCCESS;
13,755,230✔
588
  }
589

590
  SFilterColumnParam param1 = {.numOfCols = taosArrayGetSize(pBlock->pDataBlock), .pDataBlock = pBlock->pDataBlock};
4,487,253✔
591
  SColumnInfoData*   p = NULL;
4,487,223✔
592

593
  code = filterSetDataFromSlotId(pFilterInfo, &param1);
4,487,223✔
594
  QUERY_CHECK_CODE(code, lino, _err);
4,487,140!
595

596
  int32_t status = 0;
4,487,140✔
597
  code = filterExecute(pFilterInfo, pBlock, &p, NULL, param1.numOfCols, &status);
4,487,140✔
598
  QUERY_CHECK_CODE(code, lino, _err);
4,487,314!
599

600
  code = extractQualifiedTupleByFilterResult(pBlock, p, status);
4,487,314✔
601
  QUERY_CHECK_CODE(code, lino, _err);
4,487,264!
602

603
  if (pColMatchInfo != NULL) {
4,487,264✔
604
    size_t size = taosArrayGetSize(pColMatchInfo->pList);
4,094,548✔
605
    for (int32_t i = 0; i < size; ++i) {
4,095,713✔
606
      SColMatchItem* pInfo = taosArrayGet(pColMatchInfo->pList, i);
4,094,511✔
607
      QUERY_CHECK_NULL(pInfo, code, lino, _err, terrno);
4,094,449!
608
      if (pInfo->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
4,094,449✔
609
        SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, pInfo->dstSlotId);
4,093,273✔
610
        QUERY_CHECK_NULL(pColData, code, lino, _err, terrno);
4,093,204!
611
        if (pColData->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
4,093,226✔
612
          code = blockDataUpdateTsWindow(pBlock, pInfo->dstSlotId);
4,093,214✔
613
          QUERY_CHECK_CODE(code, lino, _err);
4,093,255!
614
          break;
4,093,255✔
615
        }
616
      }
617
    }
618
  }
619
  code = TSDB_CODE_SUCCESS;
4,487,173✔
620

621
_err:
4,487,173✔
622
  blockDataCheck(pBlock, true);
4,487,173✔
623

624
  colDataDestroy(p);
4,487,161✔
625
  taosMemoryFree(p);
4,487,346✔
626
  return code;
4,487,394✔
627
}
628

629
int32_t extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status) {
4,487,277✔
630
  int32_t code = TSDB_CODE_SUCCESS;
4,487,277✔
631
  int8_t* pIndicator = (int8_t*)p->pData;
4,487,277✔
632
  if (status == FILTER_RESULT_ALL_QUALIFIED) {
4,487,277✔
633
    // here nothing needs to be done
634
  } else if (status == FILTER_RESULT_NONE_QUALIFIED) {
466,712✔
635
    code = trimDataBlock(pBlock, pBlock->info.rows, NULL);
26,990✔
636
    pBlock->info.rows = 0;
26,988✔
637
  } else if (status == FILTER_RESULT_PARTIAL_QUALIFIED) {
439,722!
638
    code = trimDataBlock(pBlock, pBlock->info.rows, (bool*)pIndicator);
439,735✔
639
  } else {
640
    qError("unknown filter result type: %d", status);
×
641
  }
642
  return code;
4,487,282✔
643
}
644

645
void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs, const int32_t* rowEntryOffset) {
344,607,069✔
646
  bool returnNotNull = false;
344,607,069✔
647
  for (int32_t j = 0; j < numOfExprs; ++j) {
1,044,300,201✔
648
    SResultRowEntryInfo* pResInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
699,351,004✔
649
    if (!isRowEntryInitialized(pResInfo)) {
699,693,132✔
650
      continue;
139,105,660✔
651
    } else {
652
    }
653

654
    if (pRow->numOfRows < pResInfo->numOfRes) {
560,587,472✔
655
      pRow->numOfRows = pResInfo->numOfRes;
342,690,479✔
656
    }
657

658
    if (pCtx[j].isNotNullFunc) {
560,587,472✔
659
      returnNotNull = true;
156,391,121✔
660
    }
661
  }
662
  // if all expr skips all blocks, e.g. all null inputs for max function, output one row in final result.
663
  //  except for first/last, which require not null output, output no rows
664
  if (pRow->numOfRows == 0 && !returnNotNull) {
344,949,197✔
665
    pRow->numOfRows = 1;
3,708✔
666
  }
667
}
344,949,197✔
668

669
int32_t copyResultrowToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SResultRow* pRow, SqlFunctionCtx* pCtx,
339,903,935✔
670
                                 SSDataBlock* pBlock, const int32_t* rowEntryOffset, SExecTaskInfo* pTaskInfo) {
671
  int32_t code = TSDB_CODE_SUCCESS;
339,903,935✔
672
  int32_t lino = 0;
339,903,935✔
673
  for (int32_t j = 0; j < numOfExprs; ++j) {
1,026,887,788✔
674
    int32_t slotId = pExprInfo[j].base.resSchema.slotId;
687,622,169✔
675

676
    pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
687,622,169✔
677
    if (pCtx[j].fpSet.finalize) {
687,574,873✔
678
      if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_key") == 0 ||
392,440,021✔
679
          strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_const_value") == 0) {
359,504,364✔
680
        // for groupkey along with functions that output multiple lines(e.g. Histogram)
681
        // need to match groupkey result for each output row of that function.
682
        if (pCtx[j].resultInfo->numOfRes != 0) {
32,935,859!
683
          pCtx[j].resultInfo->numOfRes = pRow->numOfRows;
33,347,659✔
684
        }
685
      }
686

687
      code = blockDataEnsureCapacity(pBlock, pBlock->info.rows + pCtx[j].resultInfo->numOfRes);
392,440,021✔
688
      QUERY_CHECK_CODE(code, lino, _end);
392,664,016!
689

690
      code = pCtx[j].fpSet.finalize(&pCtx[j], pBlock);
392,664,016✔
691
      if (TSDB_CODE_SUCCESS != code) {
393,647,124!
692
        qError("%s build result data block error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
×
693
        QUERY_CHECK_CODE(code, lino, _end);
×
694
      }
695
    } else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) {
295,134,852✔
696
      // do nothing
697
    } else {
698
      // expand the result into multiple rows. E.g., _wstart, top(k, 20)
699
      // the _wstart needs to copy to 20 following rows, since the results of top-k expands to 20 different rows.
700
      SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
147,218,706✔
701
      QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
146,895,454!
702
      char*            in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo);
146,907,855✔
703
      for (int32_t k = 0; k < pRow->numOfRows; ++k) {
299,604,966✔
704
        code = colDataSetVal(pColInfoData, pBlock->info.rows + k, in, pCtx[j].resultInfo->isNullRes);
152,872,262✔
705
        QUERY_CHECK_CODE(code, lino, _end);
152,697,111!
706
      }
707
    }
708
  }
709

710
_end:
339,265,619✔
711
  if (code != TSDB_CODE_SUCCESS) {
339,265,619!
712
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
713
  }
714
  return code;
340,294,945✔
715
}
716

717
// todo refactor. SResultRow has direct pointer in miainfo
718
void finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup,
64,633,480✔
719
                        SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
720
  SFilePage* page = getBufPage(pBuf, resultRowPosition->pageId);
64,633,480✔
721
  if (page == NULL) {
64,637,367!
722
    qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
×
723
    T_LONG_JMP(pTaskInfo->env, terrno);
×
724
  }
725

726
  SResultRow* pRow = (SResultRow*)((char*)page + resultRowPosition->offset);
64,637,367✔
727

728
  SqlFunctionCtx* pCtx = pSup->pCtx;
64,637,367✔
729
  SExprInfo*      pExprInfo = pSup->pExprInfo;
64,637,367✔
730
  const int32_t*  rowEntryOffset = pSup->rowEntryInfoOffset;
64,637,367✔
731

732
  doUpdateNumOfRows(pCtx, pRow, pSup->numOfExprs, rowEntryOffset);
64,637,367✔
733
  if (pRow->numOfRows == 0) {
64,632,306✔
734
    releaseBufPage(pBuf, page);
240✔
735
    return;
×
736
  }
737

738
  int32_t size = pBlock->info.capacity;
64,632,066✔
739
  while (pBlock->info.rows + pRow->numOfRows > size) {
64,709,729✔
740
    size = size * 1.25;
77,663✔
741
  }
742

743
  int32_t code = blockDataEnsureCapacity(pBlock, size);
64,632,066✔
744
  if (TAOS_FAILED(code)) {
64,631,525!
745
    releaseBufPage(pBuf, page);
×
746
    qError("%s ensure result data capacity failed, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
×
747
    T_LONG_JMP(pTaskInfo->env, code);
×
748
  }
749

750
  code = copyResultrowToDataBlock(pExprInfo, pSup->numOfExprs, pRow, pCtx, pBlock, rowEntryOffset, pTaskInfo);
64,631,525✔
751
  if (TAOS_FAILED(code)) {
64,622,687!
752
    releaseBufPage(pBuf, page);
×
753
    qError("%s copy result row to datablock failed, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
×
754
    T_LONG_JMP(pTaskInfo->env, code);
×
755
  }
756

757
  releaseBufPage(pBuf, page);
64,622,687✔
758
  pBlock->info.rows += pRow->numOfRows;
64,621,318✔
759
}
760

761
void doCopyToSDataBlockByHash(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
1,087,571✔
762
                              SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, int32_t threshold, bool ignoreGroup) {
763
  int32_t         code = TSDB_CODE_SUCCESS;
1,087,571✔
764
  int32_t         lino = 0;
1,087,571✔
765
  SExprInfo*      pExprInfo = pSup->pExprInfo;
1,087,571✔
766
  int32_t         numOfExprs = pSup->numOfExprs;
1,087,571✔
767
  int32_t*        rowEntryOffset = pSup->rowEntryInfoOffset;
1,087,571✔
768
  SqlFunctionCtx* pCtx = pSup->pCtx;
1,087,571✔
769

770
  size_t  keyLen = 0;
1,087,571✔
771
  int32_t numOfRows = tSimpleHashGetSize(pHashmap);
1,087,571✔
772

773
  // begin from last iter
774
  void*   pData = pGroupResInfo->dataPos;
1,087,556✔
775
  int32_t iter = pGroupResInfo->iter;
1,087,556✔
776
  while ((pData = tSimpleHashIterate(pHashmap, pData, &iter)) != NULL) {
5,057,547✔
777
    void*               key = tSimpleHashGetKey(pData, &keyLen);
5,011,731✔
778
    SResultRowPosition* pos = pData;
5,011,731✔
779
    uint64_t            groupId = *(uint64_t*)key;
5,011,731✔
780

781
    SFilePage* page = getBufPage(pBuf, pos->pageId);
5,011,731✔
782
    if (page == NULL) {
5,011,677!
783
      qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
×
784
      T_LONG_JMP(pTaskInfo->env, terrno);
×
785
    }
786

787
    SResultRow* pRow = (SResultRow*)((char*)page + pos->offset);
5,011,677✔
788

789
    doUpdateNumOfRows(pCtx, pRow, numOfExprs, rowEntryOffset);
5,011,677✔
790

791
    // no results, continue to check the next one
792
    if (pRow->numOfRows == 0) {
5,011,483!
793
      pGroupResInfo->index += 1;
×
794
      pGroupResInfo->iter = iter;
×
795
      pGroupResInfo->dataPos = pData;
×
796

797
      releaseBufPage(pBuf, page);
×
798
      continue;
×
799
    }
800

801
    if (!ignoreGroup) {
5,011,483✔
802
      if (pBlock->info.id.groupId == 0) {
2,089,484✔
803
        pBlock->info.id.groupId = groupId;
1,047,995✔
804
      } else {
805
        // current value belongs to different group, it can't be packed into one datablock
806
        if (pBlock->info.id.groupId != groupId) {
1,041,489!
807
          releaseBufPage(pBuf, page);
1,041,652✔
808
          break;
1,041,643✔
809
        }
810
      }
811
    }
812

813
    if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) {
3,969,831!
814
      uint32_t newSize = pBlock->info.rows + pRow->numOfRows + ((numOfRows - iter) > 1 ? 1 : 0);
×
815
      code = blockDataEnsureCapacity(pBlock, newSize);
×
816
      QUERY_CHECK_CODE(code, lino, _end);
×
817
      qDebug("datablock capacity not sufficient, expand to required:%d, current capacity:%d, %s", newSize,
×
818
             pBlock->info.capacity, GET_TASKID(pTaskInfo));
819
      // todo set the pOperator->resultInfo size
820
    }
821

822
    pGroupResInfo->index += 1;
3,969,831✔
823
    pGroupResInfo->iter = iter;
3,969,831✔
824
    pGroupResInfo->dataPos = pData;
3,969,831✔
825

826
    code = copyResultrowToDataBlock(pExprInfo, numOfExprs, pRow, pCtx, pBlock, rowEntryOffset, pTaskInfo);
3,969,831✔
827
    releaseBufPage(pBuf, page);
3,970,010✔
828
    QUERY_CHECK_CODE(code, lino, _end);
3,970,001!
829
    pBlock->info.rows += pRow->numOfRows;
3,970,001✔
830
    if (pBlock->info.rows >= threshold) {
3,970,001✔
831
      break;
10✔
832
    }
833
  }
834

835
  qDebug("%s result generated, rows:%" PRId64 ", groupId:%" PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows,
1,087,457✔
836
         pBlock->info.id.groupId);
837
  pBlock->info.dataLoad = 1;
1,087,460✔
838
  code = blockDataUpdateTsWindow(pBlock, 0);
1,087,460✔
839
  QUERY_CHECK_CODE(code, lino, _end);
1,087,421!
840

841
_end:
1,087,421✔
842
  if (code != TSDB_CODE_SUCCESS) {
1,087,421!
843
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
844
    T_LONG_JMP(pTaskInfo->env, code);
×
845
  }
846
}
1,087,421✔
847

848
void doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
1,524,030✔
849
                        SGroupResInfo* pGroupResInfo, int32_t threshold, bool ignoreGroup) {
850
  int32_t         code = TSDB_CODE_SUCCESS;
1,524,030✔
851
  int32_t         lino = 0;
1,524,030✔
852
  SExprInfo*      pExprInfo = pSup->pExprInfo;
1,524,030✔
853
  int32_t         numOfExprs = pSup->numOfExprs;
1,524,030✔
854
  int32_t*        rowEntryOffset = pSup->rowEntryInfoOffset;
1,524,030✔
855
  SqlFunctionCtx* pCtx = pSup->pCtx;
1,524,030✔
856

857
  int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
1,524,030✔
858

859
  for (int32_t i = pGroupResInfo->index; i < numOfRows; i += 1) {
173,104,483✔
860
    SResKeyPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i);
171,944,839✔
861
    SFilePage*  page = getBufPage(pBuf, pPos->pos.pageId);
171,581,956✔
862
    if (page == NULL) {
171,992,527!
863
      qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
×
864
      T_LONG_JMP(pTaskInfo->env, terrno);
×
865
    }
866

867
    SResultRow* pRow = (SResultRow*)((char*)page + pPos->pos.offset);
171,992,527✔
868

869
    doUpdateNumOfRows(pCtx, pRow, numOfExprs, rowEntryOffset);
171,992,527✔
870

871
    // no results, continue to check the next one
872
    if (pRow->numOfRows == 0) {
171,198,746✔
873
      pGroupResInfo->index += 1;
16✔
874
      releaseBufPage(pBuf, page);
16✔
875
      continue;
16✔
876
    }
877

878
    if (!ignoreGroup) {
171,198,730✔
879
      if (pBlock->info.id.groupId == 0) {
122,538,902✔
880
        pBlock->info.id.groupId = pPos->groupId;
121,527,494✔
881
      } else {
882
        // current value belongs to different group, it can't be packed into one datablock
883
        if (pBlock->info.id.groupId != pPos->groupId) {
1,011,408✔
884
          releaseBufPage(pBuf, page);
20,232✔
885
          break;
20,232✔
886
        }
887
      }
888
    }
889

890
    if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) {
171,178,498✔
891
      uint32_t newSize = pBlock->info.rows + pRow->numOfRows + ((numOfRows - i) > 1 ? 1 : 0);
1,796✔
892
      code = blockDataEnsureCapacity(pBlock, newSize);
1,796✔
893
      QUERY_CHECK_CODE(code, lino, _end);
1,796!
894
      qDebug("datablock capacity not sufficient, expand to required:%d, current capacity:%d, %s", newSize,
1,796!
895
             pBlock->info.capacity, GET_TASKID(pTaskInfo));
896
      // todo set the pOperator->resultInfo size
897
    }
898

899
    pGroupResInfo->index += 1;
171,178,498✔
900
    code = copyResultrowToDataBlock(pExprInfo, numOfExprs, pRow, pCtx, pBlock, rowEntryOffset, pTaskInfo);
171,178,498✔
901
    releaseBufPage(pBuf, page);
172,168,626✔
902
    QUERY_CHECK_CODE(code, lino, _end);
171,913,136!
903

904
    pBlock->info.rows += pRow->numOfRows;
171,913,136✔
905
    if (pBlock->info.rows >= threshold) {
171,913,136✔
906
      break;
332,698✔
907
    }
908
  }
909

910
  qDebug("%s result generated, rows:%" PRId64 ", groupId:%" PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows,
1,512,574✔
911
         pBlock->info.id.groupId);
912
  pBlock->info.dataLoad = 1;
1,512,575✔
913
  code = blockDataUpdateTsWindow(pBlock, 0);
1,512,575✔
914
  QUERY_CHECK_CODE(code, lino, _end);
1,524,041!
915

916
_end:
1,524,041✔
917
  if (code != TSDB_CODE_SUCCESS) {
1,524,041!
918
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
919
    T_LONG_JMP(pTaskInfo->env, code);
×
920
  }
921
}
1,524,041✔
922

923
void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo,
2,302,398✔
924
                            SDiskbasedBuf* pBuf) {
925
  SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
2,302,398✔
926
  SSDataBlock*   pBlock = pbInfo->pRes;
2,302,398✔
927

928
  // set output datablock version
929
  pBlock->info.version = pTaskInfo->version;
2,302,398✔
930

931
  blockDataCleanup(pBlock);
2,302,398✔
932
  if (!hasRemainResults(pGroupResInfo)) {
2,302,935✔
933
    return;
778,761✔
934
  }
935

936
  // clear the existed group id
937
  pBlock->info.id.groupId = 0;
1,524,067✔
938
  if (!pbInfo->mergeResultBlock) {
1,524,067✔
939
    doCopyToSDataBlock(pTaskInfo, pBlock, &pOperator->exprSupp, pBuf, pGroupResInfo, pOperator->resultInfo.threshold,
959,561✔
940
                       false);
941
  } else {
942
    while (hasRemainResults(pGroupResInfo)) {
955,667✔
943
      doCopyToSDataBlock(pTaskInfo, pBlock, &pOperator->exprSupp, pBuf, pGroupResInfo, pOperator->resultInfo.threshold,
564,503✔
944
                         true);
945
      if (pBlock->info.rows >= pOperator->resultInfo.threshold) {
564,509✔
946
        break;
173,348✔
947
      }
948

949
      // clearing group id to continue to merge data that belong to different groups
950
      pBlock->info.id.groupId = 0;
391,161✔
951
    }
952

953
    // clear the group id info in SSDataBlock, since the client does not need it
954
    pBlock->info.id.groupId = 0;
564,509✔
955
  }
956
}
957

958
void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) {
6,873,136✔
959
  for (int32_t i = 0; i < numOfExprs; ++i) {
30,075,023✔
960
    SExprInfo* pExprInfo = &pExpr[i];
23,201,571✔
961
    for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
47,253,252✔
962
      if (pExprInfo->base.pParam[j].type == FUNC_PARAM_TYPE_COLUMN) {
24,056,270✔
963
        taosMemoryFreeClear(pExprInfo->base.pParam[j].pCol);
22,529,323!
964
      } else if (pExprInfo->base.pParam[j].type == FUNC_PARAM_TYPE_VALUE) {
1,526,947✔
965
        taosVariantDestroy(&pExprInfo->base.pParam[j].param);
1,493,160✔
966
      }
967
    }
968

969
    taosMemoryFree(pExprInfo->base.pParam);
23,196,982✔
970
    taosMemoryFree(pExprInfo->pExpr);
23,204,207✔
971
  }
972
}
6,873,452✔
973

974
int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz) {
4,111,084✔
975
  *defaultPgsz = 4096;
4,111,084✔
976
  uint32_t last = *defaultPgsz;
4,111,084✔
977
  while (*defaultPgsz < rowSize * 4) {
5,121,732✔
978
    *defaultPgsz <<= 1u;
1,010,648✔
979
    if (*defaultPgsz < last) {
1,010,648!
980
      return TSDB_CODE_INVALID_PARA;
×
981
    }
982
    last = *defaultPgsz;
1,010,648✔
983
  }
984

985
  // The default buffer for each operator in query is 10MB.
986
  // at least four pages need to be in buffer
987
  // TODO: make this variable to be configurable.
988
  *defaultBufsz = 4096 * 2560;
4,111,084✔
989
  if ((*defaultBufsz) <= (*defaultPgsz)) {
4,111,084!
990
    (*defaultBufsz) = (*defaultPgsz) * 4;
×
991
    if (*defaultBufsz < ((int64_t)(*defaultPgsz)) * 4) {
×
992
      return TSDB_CODE_INVALID_PARA;
×
993
    }
994
  }
995

996
  return 0;
4,111,084✔
997
}
998

999
void initResultSizeInfo(SResultInfo* pResultInfo, int32_t numOfRows) {
10,580,688✔
1000
  if (numOfRows == 0) {
10,580,688!
1001
    numOfRows = 4096;
×
1002
  }
1003

1004
  pResultInfo->capacity = numOfRows;
10,580,688✔
1005
  pResultInfo->threshold = numOfRows * 0.75;
10,580,688✔
1006

1007
  if (pResultInfo->threshold == 0) {
10,580,688✔
1008
    pResultInfo->threshold = numOfRows;
2,758✔
1009
  }
1010
}
10,580,688✔
1011

1012
void initBasicInfo(SOptrBasicInfo* pInfo, SSDataBlock* pBlock) {
4,103,378✔
1013
  pInfo->pRes = pBlock;
4,103,378✔
1014
  initResultRowInfo(&pInfo->resultRowInfo);
4,103,378✔
1015
}
4,103,293✔
1016

1017
static void destroySqlFunctionCtx(SqlFunctionCtx* pCtx, SExprInfo* pExpr, int32_t numOfOutput) {
21,444,733✔
1018
  if (pCtx == NULL) {
21,444,733✔
1019
    return;
13,816,322✔
1020
  }
1021

1022
  for (int32_t i = 0; i < numOfOutput; ++i) {
30,653,891✔
1023
    if (pExpr != NULL) {
23,022,482!
1024
      SExprInfo* pExprInfo = &pExpr[i];
23,023,869✔
1025
      for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
46,899,639✔
1026
        if (pExprInfo->base.pParam[j].type == FUNC_PARAM_TYPE_VALUE) {
23,876,322✔
1027
          taosMemoryFree(pCtx[i].input.pData[j]);
1,491,506✔
1028
          taosMemoryFree(pCtx[i].input.pColumnDataAgg[j]);
1,491,481✔
1029
        }
1030
      }
1031
    }
1032
    for (int32_t j = 0; j < pCtx[i].numOfParams; ++j) {
46,894,295✔
1033
      taosVariantDestroy(&pCtx[i].param[j].param);
23,875,725✔
1034
    }
1035

1036
    taosMemoryFreeClear(pCtx[i].subsidiaries.pCtx);
23,018,570✔
1037
    taosMemoryFreeClear(pCtx[i].subsidiaries.buf);
23,018,659✔
1038
    taosMemoryFree(pCtx[i].input.pData);
23,018,671✔
1039
    taosMemoryFree(pCtx[i].input.pColumnDataAgg);
23,028,067✔
1040

1041
    if (pCtx[i].udfName != NULL) {
23,025,076✔
1042
      taosMemoryFree(pCtx[i].udfName);
117✔
1043
    }
1044
  }
1045

1046
  taosMemoryFreeClear(pCtx);
7,631,409✔
1047
  return;
7,631,374✔
1048
}
1049

1050
int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr, SFunctionStateStore* pStore) {
6,011,507✔
1051
  pSup->pExprInfo = pExprInfo;
6,011,507✔
1052
  pSup->numOfExprs = numOfExpr;
6,011,507✔
1053
  if (pSup->pExprInfo != NULL) {
6,011,507✔
1054
    pSup->pCtx = createSqlFunctionCtx(pExprInfo, numOfExpr, &pSup->rowEntryInfoOffset, pStore);
5,316,828✔
1055
    if (pSup->pCtx == NULL) {
5,314,847!
1056
      return TSDB_CODE_OUT_OF_MEMORY;
×
1057
    }
1058
  }
1059

1060
  return TSDB_CODE_SUCCESS;
6,009,526✔
1061
}
1062

1063
void cleanupExprSupp(SExprSupp* pSupp) {
21,445,088✔
1064
  destroySqlFunctionCtx(pSupp->pCtx, pSupp->pExprInfo, pSupp->numOfExprs);
21,445,088✔
1065
  if (pSupp->pExprInfo != NULL) {
21,444,078✔
1066
    destroyExprInfo(pSupp->pExprInfo, pSupp->numOfExprs);
6,870,958✔
1067
    taosMemoryFreeClear(pSupp->pExprInfo);
6,871,080!
1068
  }
1069

1070
  if (pSupp->pFilterInfo != NULL) {
21,444,252✔
1071
    filterFreeInfo(pSupp->pFilterInfo);
2,624,068✔
1072
    pSupp->pFilterInfo = NULL;
2,624,117✔
1073
  }
1074

1075
  taosMemoryFree(pSupp->rowEntryInfoOffset);
21,444,301✔
1076
}
21,442,516✔
1077

1078
void cleanupBasicInfo(SOptrBasicInfo* pInfo) {
4,117,586✔
1079
  blockDataDestroy(pInfo->pRes);
4,117,586✔
1080
  pInfo->pRes = NULL;
4,117,772✔
1081
}
4,117,772✔
1082

1083
bool groupbyTbname(SNodeList* pGroupList) {
3,604,136✔
1084
  bool bytbname = false;
3,604,136✔
1085
  if (LIST_LENGTH(pGroupList) == 1) {
3,604,136✔
1086
    SNode* p = nodesListGetNode(pGroupList, 0);
81,045✔
1087
    if (!p) {
81,066✔
1088
      qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
128!
1089
      return false;
×
1090
    }
1091
    if (p->type == QUERY_NODE_FUNCTION) {
80,938✔
1092
      // partition by tbname/group by tbname
1093
      bytbname = (strcmp(((struct SFunctionNode*)p)->functionName, "tbname") == 0);
56,220✔
1094
    }
1095
  }
1096

1097
  return bytbname;
3,604,029✔
1098
}
1099

1100
int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, SExecTaskInfo* pTask, SReadHandle* readHandle) {
5,488,133✔
1101
  switch (pNode->type) {
5,488,133✔
1102
    case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT: {
296✔
1103
      SInserterParam* pInserterParam = taosMemoryCalloc(1, sizeof(SInserterParam));
296✔
1104
      if (NULL == pInserterParam) {
296!
1105
        return terrno;
×
1106
      }
1107
      pInserterParam->readHandle = readHandle;
296✔
1108

1109
      *pParam = pInserterParam;
296✔
1110
      break;
296✔
1111
    }
1112
    case QUERY_NODE_PHYSICAL_PLAN_DELETE: {
53,233✔
1113
      SDeleterParam* pDeleterParam = taosMemoryCalloc(1, sizeof(SDeleterParam));
53,233✔
1114
      if (NULL == pDeleterParam) {
53,232!
1115
        return terrno;
×
1116
      }
1117

1118
      SArray* pInfoList = NULL;
53,232✔
1119
      int32_t code = getTableListInfo(pTask, &pInfoList);
53,232✔
1120
      if (code != TSDB_CODE_SUCCESS || pInfoList == NULL) {
53,231!
1121
        taosMemoryFree(pDeleterParam);
×
1122
        return code;
×
1123
      }
1124

1125
      STableListInfo* pTableListInfo = taosArrayGetP(pInfoList, 0);
53,231✔
1126
      taosArrayDestroy(pInfoList);
53,231✔
1127

1128
      pDeleterParam->suid = tableListGetSuid(pTableListInfo);
53,233✔
1129

1130
      // TODO extract uid list
1131
      int32_t numOfTables = 0;
53,232✔
1132
      code = tableListGetSize(pTableListInfo, &numOfTables);
53,232✔
1133
      if (code != TSDB_CODE_SUCCESS) {
53,233!
1134
        qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
×
1135
        taosMemoryFree(pDeleterParam);
×
1136
        return code;
×
1137
      }
1138

1139
      pDeleterParam->pUidList = taosArrayInit(numOfTables, sizeof(uint64_t));
53,233✔
1140
      if (NULL == pDeleterParam->pUidList) {
53,234!
1141
        taosMemoryFree(pDeleterParam);
×
1142
        return terrno;
×
1143
      }
1144

1145
      for (int32_t i = 0; i < numOfTables; ++i) {
120,857✔
1146
        STableKeyInfo* pTable = tableListGetInfo(pTableListInfo, i);
67,620✔
1147
        if (!pTable) {
67,617!
1148
          taosArrayDestroy(pDeleterParam->pUidList);
×
1149
          taosMemoryFree(pDeleterParam);
×
1150
          return TSDB_CODE_OUT_OF_MEMORY;
×
1151
        }
1152
        void*          tmp = taosArrayPush(pDeleterParam->pUidList, &pTable->uid);
67,617✔
1153
        if (!tmp) {
67,622!
1154
          taosArrayDestroy(pDeleterParam->pUidList);
×
1155
          taosMemoryFree(pDeleterParam);
×
1156
          return terrno;
×
1157
        }
1158
      }
1159

1160
      *pParam = pDeleterParam;
53,237✔
1161
      break;
53,237✔
1162
    }
1163
    default:
5,434,604✔
1164
      break;
5,434,604✔
1165
  }
1166

1167
  return TSDB_CODE_SUCCESS;
5,488,137✔
1168
}
1169

1170
void streamOpReleaseState(SOperatorInfo* pOperator) {
287✔
1171
  SOperatorInfo* downstream = pOperator->pDownstream[0];
287✔
1172
  if (downstream->fpSet.releaseStreamStateFn) {
287!
1173
    downstream->fpSet.releaseStreamStateFn(downstream);
288✔
1174
  }
1175
}
287✔
1176

1177
void streamOpReloadState(SOperatorInfo* pOperator) {
288✔
1178
  SOperatorInfo* downstream = pOperator->pDownstream[0];
288✔
1179
  if (downstream->fpSet.reloadStreamStateFn) {
288!
1180
    downstream->fpSet.reloadStreamStateFn(downstream);
288✔
1181
  }
1182
}
288✔
1183

1184
void freeOperatorParamImpl(SOperatorParam* pParam, SOperatorParamType type) {
22,602✔
1185
  int32_t childrenNum = taosArrayGetSize(pParam->pChildren);
22,602✔
1186
  for (int32_t i = 0; i < childrenNum; ++i) {
22,602!
1187
    SOperatorParam* pChild = taosArrayGetP(pParam->pChildren, i);
×
1188
    freeOperatorParam(pChild, type);
×
1189
  }
1190

1191
  taosArrayDestroy(pParam->pChildren);
22,602✔
1192

1193
  taosMemoryFree(pParam->value);
22,602✔
1194

1195
  taosMemoryFree(pParam);
22,602✔
1196
}
22,602✔
1197

1198
void freeExchangeGetBasicOperatorParam(void* pParam) {
366✔
1199
  SExchangeOperatorBasicParam* pBasic = (SExchangeOperatorBasicParam*)pParam;
366✔
1200
  taosArrayDestroy(pBasic->uidList);
366✔
1201
}
366✔
1202

1203
void freeExchangeGetOperatorParam(SOperatorParam* pParam) {
208✔
1204
  SExchangeOperatorParam* pExcParam = (SExchangeOperatorParam*)pParam->value;
208✔
1205
  if (pExcParam->multiParams) {
208✔
1206
    SExchangeOperatorBatchParam* pExcBatch = (SExchangeOperatorBatchParam*)pParam->value;
196✔
1207
    tSimpleHashCleanup(pExcBatch->pBatchs);
196✔
1208
  } else {
1209
    freeExchangeGetBasicOperatorParam(&pExcParam->basic);
12✔
1210
  }
1211

1212
  freeOperatorParamImpl(pParam, OP_GET_PARAM);
208✔
1213
}
208✔
1214

1215
void freeExchangeNotifyOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_NOTIFY_PARAM); }
×
1216

1217
void freeGroupCacheGetOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_GET_PARAM); }
14,500✔
1218

1219
void freeGroupCacheNotifyOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_NOTIFY_PARAM); }
×
1220

1221
void freeMergeJoinGetOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_GET_PARAM); }
7,250✔
1222

1223
void freeMergeJoinNotifyOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_NOTIFY_PARAM); }
×
1224

1225
void freeTableScanGetOperatorParam(SOperatorParam* pParam) {
644✔
1226
  STableScanOperatorParam* pTableScanParam = (STableScanOperatorParam*)pParam->value;
644✔
1227
  taosArrayDestroy(pTableScanParam->pUidList);
644✔
1228
  freeOperatorParamImpl(pParam, OP_GET_PARAM);
644✔
1229
}
644✔
1230

1231
void freeTableScanNotifyOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_NOTIFY_PARAM); }
×
1232

1233
void freeOperatorParam(SOperatorParam* pParam, SOperatorParamType type) {
3,378,718✔
1234
  if (NULL == pParam) {
3,378,718✔
1235
    return;
3,356,125✔
1236
  }
1237

1238
  switch (pParam->opType) {
22,593!
1239
    case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:
208✔
1240
      type == OP_GET_PARAM ? freeExchangeGetOperatorParam(pParam) : freeExchangeNotifyOperatorParam(pParam);
208!
1241
      break;
208✔
1242
    case QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE:
14,500✔
1243
      type == OP_GET_PARAM ? freeGroupCacheGetOperatorParam(pParam) : freeGroupCacheNotifyOperatorParam(pParam);
14,500!
1244
      break;
14,500✔
1245
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN:
7,250✔
1246
      type == OP_GET_PARAM ? freeMergeJoinGetOperatorParam(pParam) : freeMergeJoinNotifyOperatorParam(pParam);
7,250!
1247
      break;
7,250✔
1248
    case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
644✔
1249
      type == OP_GET_PARAM ? freeTableScanGetOperatorParam(pParam) : freeTableScanNotifyOperatorParam(pParam);
644!
1250
      break;
644✔
1251
    default:
×
1252
      qError("unsupported op %d param, type %d", pParam->opType, type);
×
1253
      break;
×
1254
  }
1255
}
1256

1257
void freeResetOperatorParams(struct SOperatorInfo* pOperator, SOperatorParamType type, bool allFree) {
27,258,814✔
1258
  SOperatorParam**  ppParam = NULL;
27,258,814✔
1259
  SOperatorParam*** pppDownstramParam = NULL;
27,258,814✔
1260
  switch (type) {
27,258,814!
1261
    case OP_GET_PARAM:
13,639,034✔
1262
      ppParam = &pOperator->pOperatorGetParam;
13,639,034✔
1263
      pppDownstramParam = &pOperator->pDownstreamGetParams;
13,639,034✔
1264
      break;
13,639,034✔
1265
    case OP_NOTIFY_PARAM:
13,630,851✔
1266
      ppParam = &pOperator->pOperatorNotifyParam;
13,630,851✔
1267
      pppDownstramParam = &pOperator->pDownstreamNotifyParams;
13,630,851✔
1268
      break;
13,630,851✔
1269
    default:
×
1270
      return;
×
1271
  }
1272

1273
  if (*ppParam) {
27,269,885✔
1274
    freeOperatorParam(*ppParam, type);
7,250✔
1275
    *ppParam = NULL;
7,250✔
1276
  }
1277

1278
  if (*pppDownstramParam) {
27,269,885✔
1279
    for (int32_t i = 0; i < pOperator->numOfDownstream; ++i) {
22,236✔
1280
      if ((*pppDownstramParam)[i]) {
14,500!
1281
        freeOperatorParam((*pppDownstramParam)[i], type);
×
1282
        (*pppDownstramParam)[i] = NULL;
×
1283
      }
1284
    }
1285
    if (allFree) {
7,736✔
1286
      taosMemoryFreeClear(*pppDownstramParam);
581!
1287
    }
1288
  }
1289
}
1290

1291
FORCE_INLINE int32_t getNextBlockFromDownstreamImpl(struct SOperatorInfo* pOperator, int32_t idx, bool clearParam,
12,788,804✔
1292
                                                    SSDataBlock** pResBlock) {
1293
  QRY_PARAM_CHECK(pResBlock);
12,788,804!
1294

1295
  int32_t code = 0;
12,788,804✔
1296
  if (pOperator->pDownstreamGetParams && pOperator->pDownstreamGetParams[idx]) {
12,788,804!
1297
    qDebug("DynOp: op %s start to get block from downstream %s", pOperator->name, pOperator->pDownstream[idx]->name);
21,646✔
1298
    code = pOperator->pDownstream[idx]->fpSet.getNextExtFn(pOperator->pDownstream[idx],
21,646✔
1299
                                                           pOperator->pDownstreamGetParams[idx], pResBlock);
21,646✔
1300
    if (clearParam && (code == 0)) {
21,646!
1301
      freeOperatorParam(pOperator->pDownstreamGetParams[idx], OP_GET_PARAM);
×
1302
      pOperator->pDownstreamGetParams[idx] = NULL;
×
1303
    }
1304

1305
    if (code) {
21,646!
1306
      qError("failed to get next data block from upstream at %s, line:%d code:%s", __func__, __LINE__, tstrerror(code));
×
1307
    }
1308
    return code;
21,646✔
1309
  }
1310

1311
  code = pOperator->pDownstream[idx]->fpSet.getNextFn(pOperator->pDownstream[idx], pResBlock);
12,767,158✔
1312
  if (code) {
12,775,898!
1313
    qError("failed to get next data block from upstream at %s, %d code:%s", __func__, __LINE__, tstrerror(code));
×
1314
  }
1315
  return code;
12,775,878✔
1316
}
1317

1318
bool compareVal(const char* v, const SStateKeys* pKey) {
20,421,914✔
1319
  if (IS_VAR_DATA_TYPE(pKey->type)) {
20,421,914!
1320
    if (varDataLen(v) != varDataLen(pKey->pData)) {
×
1321
      return false;
×
1322
    } else {
1323
      return memcmp(varDataVal(v), varDataVal(pKey->pData), varDataLen(v)) == 0;
×
1324
    }
1325
  } else {
1326
    return memcmp(pKey->pData, v, pKey->bytes) == 0;
20,421,959✔
1327
  }
1328
}
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