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

taosdata / TDengine / #5029

21 Apr 2026 10:00AM UTC coverage: 73.003% (+0.02%) from 72.986%
#5029

push

travis-ci

web-flow
fix(tmq): balance vgroup error (#35183)

273843 of 375111 relevant lines covered (73.0%)

134074995.07 hits per line

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

81.71
/source/libs/executor/src/querytask.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 "streamMsg.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 "thash.h"
35
#include "ttypes.h"
36
#include "tref.h"
37

38
#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st)))
39

40
int32_t doCreateTask(uint64_t queryId, uint64_t taskId, int32_t vgId, EOPTR_EXEC_MODEL model, SStorageAPI* pAPI,
380,964,088✔
41
                     SExecTaskInfo** pTaskInfo) {
42
  if (pTaskInfo == NULL) {
380,964,088✔
43
    return TSDB_CODE_SUCCESS;
×
44
  }
45

46
  SExecTaskInfo* p = taosMemoryCalloc(1, sizeof(SExecTaskInfo));
380,964,088✔
47
  if (p == NULL) {
380,941,881✔
48
    return terrno;
×
49
  }
50

51
  setTaskStatus(p, TASK_NOT_COMPLETED);
380,941,881✔
52
  p->cost.created = taosGetTimestampUs();
380,975,262✔
53

54
  p->execModel = model;
380,969,325✔
55
  p->stopInfo.pStopInfo = taosArrayInit(4, sizeof(SExchangeOpStopInfo));
380,975,553✔
56
  p->pResultBlockList = taosArrayInit(128, POINTER_BYTES);
380,934,808✔
57
  if (p->stopInfo.pStopInfo == NULL || p->pResultBlockList == NULL) {
380,939,432✔
58
    doDestroyTask(p);
93✔
59
    return terrno;
×
60
  }
61

62
  p->storageAPI = *pAPI;
380,966,641✔
63
  taosInitRWLatch(&p->lock);
380,955,853✔
64

65
  p->id.vgId = vgId;
380,954,286✔
66
  p->id.queryId = queryId;
380,959,138✔
67
  p->id.taskId = taskId;
380,961,535✔
68
  p->id.str = taosMemoryMalloc(64);
380,962,914✔
69
  if (p->id.str == NULL) {
380,919,235✔
70
    doDestroyTask(p);
×
71
    return terrno;
×
72
  }
73

74
  buildTaskId(taskId, queryId, p->id.str, 64);
380,955,711✔
75
  p->schemaInfos = taosArrayInit(1, sizeof(SSchemaInfo));
380,929,669✔
76
  if (p->id.str == NULL || p->schemaInfos == NULL) {
380,912,203✔
77
    doDestroyTask(p);
×
78
    return terrno;
×
79
  }
80

81
  *pTaskInfo = p;
380,952,214✔
82
  return TSDB_CODE_SUCCESS;
380,957,341✔
83
}
84

85
int32_t getTaskCode(void* pTaskInfo) { return ((SExecTaskInfo*)pTaskInfo)->code; }
19,880✔
86

87
bool isTaskKilled(void* pTaskInfo) { return (0 != ((SExecTaskInfo*)pTaskInfo)->code); }
2,147,483,647✔
88

89
void setTaskKilled(SExecTaskInfo* pTaskInfo, int32_t rspCode) {
99,024✔
90
  pTaskInfo->code = rspCode;
99,024✔
91
  (void)stopTableScanOperator(pTaskInfo->pRoot, pTaskInfo->id.str, &pTaskInfo->storageAPI);
99,024✔
92
}
99,024✔
93

94
void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status) {
1,293,291,645✔
95
  if (status == TASK_NOT_COMPLETED) {
1,293,291,645✔
96
    pTaskInfo->status = status;
381,138,795✔
97
  } else {
98
    // QUERY_NOT_COMPLETED is not compatible with any other status, so clear its position first
99
    CLEAR_QUERY_STATUS(pTaskInfo, TASK_NOT_COMPLETED);
912,152,850✔
100
    pTaskInfo->status |= status;
912,162,984✔
101
  }
102
}
1,293,311,768✔
103

104

105
int32_t initTaskSubJobCtx(SExecTaskInfo* pTaskInfo, SArray** subEndPoints, SReadHandle* readHandle) {
42,889,975✔
106
  int32_t code = 0, lino = 0;
42,889,975✔
107
  int32_t subJobNum = taosArrayGetSize(*subEndPoints);
42,889,975✔
108
  
109
  pTaskInfo->pSubJobCtx = taosMemoryCalloc(1, sizeof(*pTaskInfo->pSubJobCtx));
42,889,975✔
110
  TSDB_CHECK_NULL(pTaskInfo->pSubJobCtx, code, lino, _exit, terrno);
42,887,445✔
111
  
112
  STaskSubJobCtx* ctx = pTaskInfo->pSubJobCtx;
42,889,149✔
113

114
  ctx->queryId = pTaskInfo->id.queryId;
42,888,013✔
115
  ctx->taskId = pTaskInfo->id.taskId;
42,889,707✔
116
  ctx->idStr = pTaskInfo->id.str;
42,890,110✔
117
  ctx->pTaskInfo = pTaskInfo;
42,889,149✔
118
  ctx->subEndPoints = *subEndPoints;
42,890,833✔
119
  ctx->rpcHandle = (readHandle && readHandle->pMsgCb) ? readHandle->pMsgCb->clientRpc : NULL;
42,888,571✔
120
  ctx->isStream = pTaskInfo && IS_STREAM_MODE(pTaskInfo);
42,888,984✔
121

122
  *subEndPoints = NULL;
42,890,120✔
123
  
124
  ctx->subResNodes = taosArrayInit_s(POINTER_BYTES, subJobNum);
42,887,290✔
125
  if (NULL == ctx->subResNodes) {
42,887,290✔
126
    qError("%s taosArrayInit_s %d subResNodes failed, error:%s", GET_TASKID(pTaskInfo), subJobNum, tstrerror(terrno));
×
127
    TSDB_CHECK_NULL(ctx->subResNodes, code, lino, _exit, terrno);
×
128
  }
129
  
130
  TAOS_CHECK_EXIT(tsem_init(&ctx->ready, 0, 0));
42,887,145✔
131

132
  int64_t refId = taosAddRef(fetchObjRefPool, ctx);
42,884,470✔
133
  if (refId < 0) {
42,889,975✔
134
    qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
×
135
    TAOS_CHECK_EXIT(terrno);
×
136
  }
137
  
138
  ctx->subJobRefId = refId;
42,889,975✔
139

140
  qDebug("%s subJobCtx %" PRIu64 " with %d endPoints inited", pTaskInfo->id.str, (uint64_t)refId, (int32_t)taosArrayGetSize(ctx->subEndPoints));
42,887,310✔
141

142
_exit:
41,853,336✔
143

144
  if (code) {
42,887,155✔
145
    destroySubJobCtx(pTaskInfo->pSubJobCtx);
×
146
    pTaskInfo->pSubJobCtx = NULL;
×
147
    
148
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
149
  }
150

151
  return code;
42,886,587✔
152
}
153

154

155

156
int32_t createExecTaskInfo(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId,
380,824,118✔
157
                           int32_t vgId, char* sql, EOPTR_EXEC_MODEL model, SArray** subEndPoints, bool enableExplain) {
158
  int32_t code = doCreateTask(pPlan->id.queryId, taskId, vgId, model, &pHandle->api, pTaskInfo);
380,824,118✔
159
  if (*pTaskInfo == NULL || code != 0) {
380,789,761✔
160
    nodesDestroyNode((SNode*)pPlan);
×
161
    return code;
×
162
  }
163

164
  (*pTaskInfo)->pSubplan = pPlan;
380,809,167✔
165

166
  if (NULL != sql) {
380,822,074✔
167
    (*pTaskInfo)->sql = taosStrdup(sql);
354,694,308✔
168
    if (NULL == (*pTaskInfo)->sql) {
354,685,158✔
169
      code = terrno;
×
170
      doDestroyTask(*pTaskInfo);
×
171
      (*pTaskInfo) = NULL;
×
172
      return code;
×
173
    }
174
  }
175

176
  (*pTaskInfo)->pWorkerCb = pHandle->pWorkerCb;
380,807,165✔
177
  (*pTaskInfo)->pStreamRuntimeInfo = pHandle->streamRtInfo;
380,809,829✔
178
  (*pTaskInfo)->enableExplain = enableExplain;
380,792,491✔
179

180
  if (subEndPoints && taosArrayGetSize(*subEndPoints) > 0) {
380,820,540✔
181
    code = initTaskSubJobCtx(*pTaskInfo, subEndPoints, pHandle);
42,891,659✔
182
    if (code != TSDB_CODE_SUCCESS) {
42,887,155✔
183
      doDestroyTask(*pTaskInfo);
×
184
      (*pTaskInfo) = NULL;
×
185
      return code;
×
186
    }
187
  }
188
  
189
  setTaskScalarExtraInfo(*pTaskInfo);
380,803,398✔
190
  
191
  code = createOperator(pPlan->pNode, *pTaskInfo, pHandle, pPlan->pTagCond, pPlan->pTagIndexCond, pPlan->user,
380,776,243✔
192
                        pPlan->dbFName, &((*pTaskInfo)->pRoot), model);
380,730,660✔
193

194
  if (NULL == (*pTaskInfo)->pRoot || code != 0) {
380,641,885✔
195
    doDestroyTask(*pTaskInfo);
607,946✔
196
    (*pTaskInfo) = NULL;
484,598✔
197
  }
198
  return code;
380,618,380✔
199
}
200

201
void cleanupQueriedTableScanInfo(void* p) {
277,397,306✔
202
  SSchemaInfo* pSchemaInfo = p;
277,397,306✔
203

204
  taosMemoryFreeClear(pSchemaInfo->dbname);
277,397,306✔
205
  taosMemoryFreeClear(pSchemaInfo->tablename);
277,379,510✔
206
  tDeleteSchemaWrapper(pSchemaInfo->sw);
277,336,783✔
207
  tDeleteSchemaWrapper(pSchemaInfo->qsw);
277,319,949✔
208
}
277,319,296✔
209

210
int32_t initQueriedTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNode, const char* dbName,
277,429,901✔
211
                                   SExecTaskInfo* pTaskInfo) {
212
  SMetaReader mr = {0};
277,429,901✔
213
  if (pHandle == NULL) {
277,434,501✔
214
    return TSDB_CODE_INVALID_PARA;
×
215
  }
216

217
  SStorageAPI* pAPI = &pTaskInfo->storageAPI;
277,434,501✔
218

219
  pAPI->metaReaderFn.initReader(&mr, pHandle->vnode, META_READER_LOCK, &pAPI->metaFn);
277,431,451✔
220
  int32_t code = pAPI->metaReaderFn.getEntryGetUidCache(&mr, pScanNode->uid);
277,431,160✔
221
  if (code != TSDB_CODE_SUCCESS) {
277,320,943✔
222
    qError("failed to get the table meta, uid:0x%" PRIx64 ", suid:0x%" PRIx64 ", %s", pScanNode->uid, pScanNode->suid,
×
223
           GET_TASKID(pTaskInfo));
224

225
    pAPI->metaReaderFn.clearReader(&mr);
×
226
    return code;
×
227
  }
228

229
  SSchemaInfo schemaInfo = {0};
277,320,943✔
230

231
  schemaInfo.tablename = taosStrdup(mr.me.name);
277,319,068✔
232
  schemaInfo.dbname = taosStrdup(dbName);
277,289,607✔
233
  if (schemaInfo.tablename == NULL || schemaInfo.dbname == NULL) {
277,331,055✔
234
    pAPI->metaReaderFn.clearReader(&mr);
125,323✔
235
    cleanupQueriedTableScanInfo(&schemaInfo);
×
236
    return terrno;
×
237
  }
238

239
  if (mr.me.type == TSDB_VIRTUAL_NORMAL_TABLE || mr.me.type == TSDB_VIRTUAL_CHILD_TABLE) {
277,205,732✔
240
    schemaInfo.rversion = mr.me.colRef.version;
305,656✔
241
  }
242

243
  if (mr.me.type == TSDB_SUPER_TABLE) {
277,205,732✔
244
    schemaInfo.sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow);
121,022,620✔
245
    schemaInfo.tversion = mr.me.stbEntry.schemaTag.version;
121,022,620✔
246
  } else if (mr.me.type == TSDB_CHILD_TABLE || mr.me.type == TSDB_VIRTUAL_CHILD_TABLE) {
156,225,796✔
247
    tDecoderClear(&mr.coder);
110,125,090✔
248

249
    tb_uid_t suid = mr.me.ctbEntry.suid;
110,198,771✔
250
    code = pAPI->metaReaderFn.getEntryGetUidCache(&mr, suid);
110,198,771✔
251
    if (code != TSDB_CODE_SUCCESS) {
110,196,955✔
252
      pAPI->metaReaderFn.clearReader(&mr);
×
253
      cleanupQueriedTableScanInfo(&schemaInfo);
×
254
      return code;
×
255
    }
256

257
    schemaInfo.sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow);
110,197,079✔
258
    schemaInfo.tversion = mr.me.stbEntry.schemaTag.version;
110,197,079✔
259
  } else {
260
    schemaInfo.sw = tCloneSSchemaWrapper(&mr.me.ntbEntry.schemaRow);
46,110,043✔
261
  }
262

263
  pAPI->metaReaderFn.clearReader(&mr);
277,329,742✔
264

265
  if (schemaInfo.sw == NULL) {
277,225,866✔
266
    cleanupQueriedTableScanInfo(&schemaInfo);
×
267
    return terrno;
×
268
  }
269

270
  schemaInfo.qsw = extractQueriedColumnSchema(pScanNode);
277,225,866✔
271
  if (schemaInfo.qsw == NULL) {
277,326,932✔
272
    cleanupQueriedTableScanInfo(&schemaInfo);
×
273
    return terrno;
×
274
  }
275

276
  void* p = taosArrayPush(pTaskInfo->schemaInfos, &schemaInfo);
277,326,932✔
277
  if (p == NULL) {
277,347,989✔
278
    cleanupQueriedTableScanInfo(&schemaInfo);
×
279
    return terrno;
×
280
  }
281

282
  return code;
277,347,989✔
283
}
284

285
SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode) {
277,284,078✔
286
  int32_t numOfCols = LIST_LENGTH(pScanNode->pScanCols);
277,284,078✔
287
  int32_t numOfTags = LIST_LENGTH(pScanNode->pScanPseudoCols);
277,324,786✔
288

289
  SSchemaWrapper* pqSw = taosMemoryCalloc(1, sizeof(SSchemaWrapper));
277,311,074✔
290
  if (pqSw == NULL) {
277,244,028✔
291
    return NULL;
×
292
  }
293

294
  pqSw->pSchema = taosMemoryCalloc(numOfCols + numOfTags, sizeof(SSchema));
277,244,028✔
295
  if (pqSw->pSchema == NULL) {
277,117,223✔
296
    taosMemoryFree(pqSw);
×
297
    return NULL;
×
298
  }
299

300
  for (int32_t i = 0; i < numOfCols; ++i) {
1,233,644,752✔
301
    STargetNode* pNode = (STargetNode*)nodesListGetNode(pScanNode->pScanCols, i);
956,261,518✔
302
    SColumnNode* pColNode = (SColumnNode*)pNode->pExpr;
956,223,095✔
303

304
    SSchema* pSchema = &pqSw->pSchema[pqSw->nCols++];
956,244,683✔
305
    pSchema->colId = pColNode->colId;
956,300,289✔
306
    pSchema->type = pColNode->node.resType.type;
956,350,832✔
307
    pSchema->bytes = pColNode->node.resType.bytes;
956,350,772✔
308
    tstrncpy(pSchema->name, pColNode->colName, tListLen(pSchema->name));
956,354,909✔
309
  }
310

311
  // this the tags and pseudo function columns, we only keep the tag columns
312
  for (int32_t i = 0; i < numOfTags; ++i) {
447,531,419✔
313
    STargetNode* pNode = (STargetNode*)nodesListGetNode(pScanNode->pScanPseudoCols, i);
170,164,146✔
314

315
    int32_t type = nodeType(pNode->pExpr);
170,204,434✔
316
    if (type == QUERY_NODE_COLUMN) {
170,231,981✔
317
      SColumnNode* pColNode = (SColumnNode*)pNode->pExpr;
129,056,568✔
318

319
      SSchema* pSchema = &pqSw->pSchema[pqSw->nCols++];
129,040,252✔
320
      pSchema->colId = pColNode->colId;
129,016,277✔
321
      pSchema->type = pColNode->node.resType.type;
129,053,964✔
322
      pSchema->bytes = pColNode->node.resType.bytes;
129,000,438✔
323
      tstrncpy(pSchema->name, pColNode->colName, tListLen(pSchema->name));
129,035,824✔
324
    }
325
  }
326

327
  return pqSw;
277,367,273✔
328
}
329

330
static void cleanupTmqInfo(STmqTaskInfo* pTmqInfo) {
380,903,233✔
331
  tDeleteSchemaWrapper(pTmqInfo->schema);
380,903,233✔
332
  tOffsetDestroy(&pTmqInfo->currentOffset);
380,928,886✔
333
}
380,874,364✔
334

335
static void freeBlock(void* pParam) {
664,243,671✔
336
  SSDataBlock* pBlock = *(SSDataBlock**)pParam;
664,243,671✔
337
  blockDataDestroy(pBlock);
664,253,433✔
338
}
664,246,104✔
339

340

341
void destroySubJobCtx(STaskSubJobCtx* pCtx) {
42,888,829✔
342
  if (pCtx->transporterId > 0) {
42,888,829✔
343
    int32_t ret = asyncFreeConnById(pCtx->rpcHandle, pCtx->transporterId);
9,656✔
344
    if (ret != 0) {
9,656✔
345
      qDebug("%s failed to free subQ rpc handle, code:%s", pCtx->idStr, tstrerror(ret));
×
346
    }
347
    pCtx->transporterId = -1;
9,656✔
348
  }
349

350
  if (pCtx->subEndPoints != NULL) {
42,889,955✔
351
    size_t size = taosArrayGetSize(pCtx->subEndPoints);
42,890,523✔
352
    if (size > 0) {
42,889,955✔
353
      int32_t code = tsem_destroy(&pCtx->ready);
42,890,523✔
354
      if (code != TSDB_CODE_SUCCESS) {
42,890,533✔
355
        qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
×
356
      }
357
      taosArrayDestroy(pCtx->subResNodes);
42,890,533✔
358
    }
359
    if (pCtx->isStream) {
42,887,693✔
360
      taosArrayDestroyP(pCtx->subEndPoints, (FDelete)nodesDestroyNode);
243,032✔
361
    } else {
362
      taosArrayDestroyP(pCtx->subEndPoints, NULL);
42,644,651✔
363
    }
364
    pCtx->subEndPoints = NULL;
42,887,135✔
365
  }
366
  
367
  taosMemoryFreeClear(pCtx);  
42,889,407✔
368
}
42,886,567✔
369

370
void doDestroyTask(SExecTaskInfo* pTaskInfo) {
380,965,862✔
371
  qDebug("%s execTask is freed", GET_TASKID(pTaskInfo));
380,965,862✔
372
  destroyOperator(pTaskInfo->pRoot);
380,965,862✔
373
  pTaskInfo->pRoot = NULL;
380,883,947✔
374

375
  if (pTaskInfo->pSubJobCtx) {
380,901,136✔
376
    int32_t  code = taosRemoveRef(fetchObjRefPool, pTaskInfo->pSubJobCtx->subJobRefId);
42,890,533✔
377
    if (code != TSDB_CODE_SUCCESS) {
42,889,965✔
378
      qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
×
379
    }
380
  }
381

382
  taosArrayDestroyEx(pTaskInfo->schemaInfos, cleanupQueriedTableScanInfo);
380,910,068✔
383
  cleanupTmqInfo(&pTaskInfo->tmqInfo);
380,885,017✔
384

385
  if (!pTaskInfo->localFetch.localExec) {
380,872,865✔
386
    nodesDestroyNode((SNode*)pTaskInfo->pSubplan);
380,906,503✔
387
    pTaskInfo->pSubplan = NULL;
380,892,347✔
388
  }
389

390
  taosArrayDestroyEx(pTaskInfo->pResultBlockList, freeBlock);
380,876,071✔
391
  taosArrayDestroy(pTaskInfo->stopInfo.pStopInfo);
380,880,689✔
392
  if (!pTaskInfo->paramSet) {
380,900,999✔
393
    freeOperatorParam(pTaskInfo->pOpParam, OP_GET_PARAM);
372,162,582✔
394
    pTaskInfo->pOpParam = NULL;
372,171,392✔
395
  }
396
  if (pTaskInfo->ownStreamRtInfo && pTaskInfo->pStreamRuntimeInfo != NULL) {
380,934,976✔
397
    SStreamRuntimeFuncInfo* pRt = &pTaskInfo->pStreamRuntimeInfo->funcInfo;
439,019✔
398

399
    // When isMultiGroupCalc, pStreamPesudoFuncVals is aliased to curGrpCalc->pParams
400
    // inside pGroupCalcInfos.  NULL it out so tDestroyStRtFuncInfo won't free it twice.
401
    if (pRt->isMultiGroupCalc && pRt->pGroupCalcInfos != NULL) {
439,019✔
402
      pRt->pStreamPesudoFuncVals = NULL;
71,862✔
403
      pRt->pStreamPartColVals = NULL;
71,862✔
404
    }
405
    tDestroyStRtFuncInfo(pRt);
439,019✔
406
    taosMemoryFreeClear(pTaskInfo->pStreamRuntimeInfo);
439,019✔
407
  }
408
  taosMemoryFreeClear(pTaskInfo->sql);
380,932,600✔
409
  taosMemoryFreeClear(pTaskInfo->id.str);
380,913,396✔
410
  taosMemoryFreeClear(pTaskInfo);
380,893,980✔
411
}
380,875,338✔
412

413
void buildTaskId(uint64_t taskId, uint64_t queryId, char* dst, int32_t len) {
564,136,849✔
414
  int32_t ret = snprintf(dst, len, "TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, queryId);
564,136,849✔
415
  if (ret < 0) {
564,136,849✔
416
    qError("TID:0x%"PRIx64" QID:0x%"PRIx64" create task id failed,  ignore and continue", taskId, queryId);
×
417
  }
418
}
564,136,849✔
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