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

taosdata / TDengine / #5006

29 Mar 2026 04:32AM UTC coverage: 72.274% (+0.1%) from 72.152%
#5006

push

travis-ci

web-flow
refactor: do some internal refactor for TDgpt. (#34955)

253711 of 351039 relevant lines covered (72.27%)

131490495.89 hits per line

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

89.8
/source/libs/nodes/src/nodesMsgFuncs.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 "nodesUtil.h"
17
#include "plannodes.h"
18
#include "tdatablock.h"
19

20
#ifndef htonll
21

22
#define htonll(x)                                                                                   \
23
  (((int64_t)x & 0x00000000000000ff) << 7 * 8) | (((int64_t)x & 0x000000000000ff00) << 5 * 8) |     \
24
      (((int64_t)x & 0x0000000000ff0000) << 3 * 8) | (((int64_t)x & 0x00000000ff000000) << 1 * 8) | \
25
      (((int64_t)x & 0x000000ff00000000) >> 1 * 8) | (((int64_t)x & 0x0000ff0000000000) >> 3 * 8) | \
26
      (((int64_t)x & 0x00ff000000000000) >> 5 * 8) | (((int64_t)x & 0xff00000000000000) >> 7 * 8)
27

28
#define ntohll(x) htonll(x)
29

30
#endif
31

32
#define NODES_MSG_DEFAULT_LEN 1024
33
#define TLV_TYPE_ARRAY_ELEM   0
34

35
#define tlvForEach(pDecoder, pTlv, code) \
36
  while (TSDB_CODE_SUCCESS == code && TSDB_CODE_SUCCESS == (code = tlvGetNextTlv(pDecoder, &pTlv)) && NULL != pTlv)
37

38
#pragma pack(push, 1)
39

40
typedef struct STlv {
41
  int16_t type;
42
  int32_t len;
43
  char    value[0];
44
} STlv;
45

46
#pragma pack(pop)
47

48
typedef struct STlvEncoder {
49
  int32_t allocSize;
50
  int32_t offset;
51
  char*   pBuf;
52
  int32_t tlvCount;
53
} STlvEncoder;
54

55
typedef struct STlvDecoder {
56
  int32_t     bufSize;
57
  int32_t     offset;
58
  const char* pBuf;
59
} STlvDecoder;
60

61
typedef int32_t (*FToMsg)(const void* pObj, STlvEncoder* pEncoder);
62
typedef int32_t (*FToObject)(STlvDecoder* pDecoder, void* pObj);
63
typedef int32_t (*FMakeObject)(int16_t type, SNode** ppNode);
64
typedef int32_t (*FSetObject)(STlv* pTlv, void* pObj);
65

66
static int32_t nodeToMsg(const void* pObj, STlvEncoder* pEncoder);
67
static int32_t nodeListToMsg(const void* pObj, STlvEncoder* pEncoder);
68
static int32_t SArrayToMsg(const void* pObj, STlvEncoder* pEncoder);
69

70
static int32_t msgToNode(STlvDecoder* pDecoder, void** pObj);
71
static int32_t msgToNodeFromTlv(STlv* pTlv, void** pObj);
72
static int32_t msgToNodeList(STlvDecoder* pDecoder, void** pObj);
73
static int32_t msgToNodeListFromTlv(STlv* pTlv, void** pObj);
74
static int32_t msgToSArray(STlv* pTlv, void** pObj);
75

76

77
static int32_t initTlvEncoder(STlvEncoder* pEncoder) {
511,261,697✔
78
  pEncoder->allocSize = NODES_MSG_DEFAULT_LEN;
511,261,697✔
79
  pEncoder->offset = 0;
511,354,680✔
80
  pEncoder->tlvCount = 0;
511,341,166✔
81
  pEncoder->pBuf = taosMemoryMalloc(pEncoder->allocSize);
511,308,904✔
82
  return NULL == pEncoder->pBuf ? terrno : TSDB_CODE_SUCCESS;
510,481,257✔
83
}
84

85
static void clearTlvEncoder(STlvEncoder* pEncoder) { taosMemoryFree(pEncoder->pBuf); }
510,846,011✔
86

87
static void endTlvEncode(STlvEncoder* pEncoder, char** pMsg, int32_t* pLen) {
510,955,149✔
88
  *pMsg = pEncoder->pBuf;
510,955,149✔
89
  pEncoder->pBuf = NULL;
511,126,087✔
90
  *pLen = pEncoder->offset;
511,118,651✔
91
}
510,914,142✔
92

93
static int32_t tlvEncodeImpl(STlvEncoder* pEncoder, int16_t type, const void* pValue, int32_t len) {
2,147,483,647✔
94
  int32_t tlvLen = sizeof(STlv) + len;
2,147,483,647✔
95
  if (pEncoder->offset + tlvLen > pEncoder->allocSize) {
2,147,483,647✔
96
    pEncoder->allocSize = TMAX(pEncoder->allocSize * 2, pEncoder->allocSize + tlvLen);
230,246,377✔
97
    void* pNewBuf = taosMemoryRealloc(pEncoder->pBuf, pEncoder->allocSize);
230,318,082✔
98
    if (NULL == pNewBuf) {
230,172,816✔
99
      return terrno;
×
100
    }
101
    pEncoder->pBuf = pNewBuf;
230,172,816✔
102
  }
103
  STlv* pTlv = (STlv*)(pEncoder->pBuf + pEncoder->offset);
2,147,483,647✔
104
  pTlv->type = htons(type);
2,147,483,647✔
105
  pTlv->len = htonl(len);
2,147,483,647✔
106
  memcpy(pTlv->value, pValue, len);
2,147,483,647✔
107
  pEncoder->offset += tlvLen;
2,147,483,647✔
108
  ++(pEncoder->tlvCount);
2,147,483,647✔
109
  return TSDB_CODE_SUCCESS;
2,147,483,647✔
110
}
111

112
static int32_t tlvEncodeValueImpl(STlvEncoder* pEncoder, const void* pValue, int32_t len) {
2,147,483,647✔
113
  if (pEncoder->offset + len > pEncoder->allocSize) {
2,147,483,647✔
114
    void* pNewBuf = taosMemoryRealloc(pEncoder->pBuf, pEncoder->allocSize * 2);
231,253,807✔
115
    if (NULL == pNewBuf) {
231,156,667✔
116
      return terrno;
×
117
    }
118
    pEncoder->pBuf = pNewBuf;
231,156,667✔
119
    pEncoder->allocSize = pEncoder->allocSize * 2;
231,098,389✔
120
  }
121
  memcpy(pEncoder->pBuf + pEncoder->offset, pValue, len);
2,147,483,647✔
122
  pEncoder->offset += len;
2,147,483,647✔
123
  return TSDB_CODE_SUCCESS;
2,147,483,647✔
124
}
125

126
static int32_t tlvEncodeI8(STlvEncoder* pEncoder, int16_t type, int8_t value) {
2,147,483,647✔
127
  return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
2,147,483,647✔
128
}
129

130
static int32_t tlvEncodeValueI8(STlvEncoder* pEncoder, int8_t value) {
2,147,483,647✔
131
  return tlvEncodeValueImpl(pEncoder, &value, sizeof(value));
2,147,483,647✔
132
}
133

134
static int32_t tlvEncodeI16(STlvEncoder* pEncoder, int16_t type, int16_t value) {
×
135
  value = htons(value);
×
136
  return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
×
137
}
138

139
static int32_t tlvEncodeValueI16(STlvEncoder* pEncoder, int16_t value) {
2,147,483,647✔
140
  value = htons(value);
2,147,483,647✔
141
  return tlvEncodeValueImpl(pEncoder, &value, sizeof(value));
2,147,483,647✔
142
}
143

144
static int32_t tlvEncodeI32(STlvEncoder* pEncoder, int16_t type, int32_t value) {
2,147,483,647✔
145
  value = htonl(value);
2,147,483,647✔
146
  return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
2,147,483,647✔
147
}
148

149
static int32_t tlvEncodeValueI32(STlvEncoder* pEncoder, int32_t value) {
2,147,483,647✔
150
  value = htonl(value);
2,147,483,647✔
151
  return tlvEncodeValueImpl(pEncoder, &value, sizeof(value));
2,147,483,647✔
152
}
153

154
static int32_t tlvEncodeI64(STlvEncoder* pEncoder, int16_t type, int64_t value) {
494,452,266✔
155
  value = htonll(value);
494,452,266✔
156
  return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
494,452,266✔
157
}
158

159
static int32_t tlvEncodeValueI64(STlvEncoder* pEncoder, int64_t value) {
2,147,483,647✔
160
  value = htonll(value);
2,147,483,647✔
161
  return tlvEncodeValueImpl(pEncoder, &value, sizeof(value));
2,147,483,647✔
162
}
163

164
static int32_t tlvEncodeU8(STlvEncoder* pEncoder, int16_t type, uint8_t value) {
2,147,483,647✔
165
  return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
2,147,483,647✔
166
}
167

168
static int32_t tlvEncodeValueU8(STlvEncoder* pEncoder, uint8_t value) {
2,147,483,647✔
169
  return tlvEncodeValueImpl(pEncoder, &value, sizeof(value));
2,147,483,647✔
170
}
171

172
static int32_t tlvEncodeU16(STlvEncoder* pEncoder, int16_t type, uint16_t value) {
67,261,602✔
173
  value = htons(value);
67,261,602✔
174
  return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
67,261,602✔
175
}
176

177
static int32_t tlvEncodeValueU16(STlvEncoder* pEncoder, uint16_t value) {
680,369,513✔
178
  value = htons(value);
680,369,513✔
179
  return tlvEncodeValueImpl(pEncoder, &value, sizeof(value));
680,369,513✔
180
}
181

182
static int32_t tlvEncodeU64(STlvEncoder* pEncoder, int16_t type, uint64_t value) {
865,558,982✔
183
  value = htonll(value);
865,558,982✔
184
  return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
865,558,982✔
185
}
186

187
static int32_t tlvEncodeValueU64(STlvEncoder* pEncoder, uint64_t value) {
2,147,483,647✔
188
  value = htonll(value);
2,147,483,647✔
189
  return tlvEncodeValueImpl(pEncoder, &value, sizeof(value));
2,147,483,647✔
190
}
191

192
static int32_t tlvEncodeDouble(STlvEncoder* pEncoder, int16_t type, double value) {
25,875,565✔
193
  int64_t temp = *(int64_t*)&value;
25,875,565✔
194
  temp = htonll(temp);
25,886,502✔
195
  return tlvEncodeImpl(pEncoder, type, &temp, sizeof(temp));
25,886,502✔
196
}
197

198
static int32_t tlvEncodeValueDouble(STlvEncoder* pEncoder, double value) {
376,425,758✔
199
  int64_t temp = *(int64_t*)&value;
376,425,758✔
200
  temp = htonll(temp);
376,623,645✔
201
  return tlvEncodeValueImpl(pEncoder, &temp, sizeof(temp));
376,623,645✔
202
}
203

204
static int32_t tlvEncodeEnum(STlvEncoder* pEncoder, int16_t type, int32_t value) {
2,147,483,647✔
205
  value = htonl(value);
2,147,483,647✔
206
  return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
2,147,483,647✔
207
}
208

209
static int32_t tlvEncodeValueEnum(STlvEncoder* pEncoder, int32_t value) {
2,147,483,647✔
210
  value = htonl(value);
2,147,483,647✔
211
  return tlvEncodeValueImpl(pEncoder, &value, sizeof(value));
2,147,483,647✔
212
}
213

214
static int32_t tlvEncodeBool(STlvEncoder* pEncoder, int16_t type, int8_t value) {
2,147,483,647✔
215
  return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
2,147,483,647✔
216
}
217

218
static int32_t tlvEncodeValueBool(STlvEncoder* pEncoder, int8_t value) {
2,147,483,647✔
219
  return tlvEncodeValueImpl(pEncoder, &value, sizeof(value));
2,147,483,647✔
220
}
221

222
static int32_t tlvEncodeCStr(STlvEncoder* pEncoder, int16_t type, const char* pValue) {
2,147,483,647✔
223
  if (NULL == pValue) {
2,147,483,647✔
224
    return TSDB_CODE_SUCCESS;
245,217,649✔
225
  }
226
  return tlvEncodeImpl(pEncoder, type, pValue, strlen(pValue));
1,911,007,958✔
227
}
228

229
static int32_t tlvEncodeValueCStr(STlvEncoder* pEncoder, const char* pValue) {
2,147,483,647✔
230
  int16_t len = strlen(pValue);
2,147,483,647✔
231
  int32_t code = tlvEncodeValueI16(pEncoder, len);
2,147,483,647✔
232
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
233
    code = tlvEncodeValueImpl(pEncoder, pValue, len);
2,147,483,647✔
234
  }
235
  return code;
2,147,483,647✔
236
}
237

238
static int32_t tlvEncodeBinary(STlvEncoder* pEncoder, int16_t type, const void* pValue, int32_t len) {
214,817,596✔
239
  return tlvEncodeImpl(pEncoder, type, pValue, len);
214,817,596✔
240
}
241

242
static int32_t tlvEncodeObj(STlvEncoder* pEncoder, int16_t type, FToMsg func, const void* pObj) {
2,147,483,647✔
243
  if (NULL == pObj) {
2,147,483,647✔
244
    return TSDB_CODE_SUCCESS;
2,147,483,647✔
245
  }
246

247
  if (pEncoder->offset + sizeof(STlv) > pEncoder->allocSize) {
2,147,483,647✔
248
    pEncoder->allocSize = TMAX(pEncoder->allocSize * 2, pEncoder->allocSize + sizeof(STlv));
125,317,935✔
249
    void* pNewBuf = taosMemoryRealloc(pEncoder->pBuf, pEncoder->allocSize);
125,322,348✔
250
    if (NULL == pNewBuf) {
125,233,793✔
251
      return terrno;
×
252
    }
253
    pEncoder->pBuf = pNewBuf;
125,233,793✔
254
  }
255

256
  int32_t start = pEncoder->offset;
2,147,483,647✔
257
  pEncoder->offset += sizeof(STlv);
2,147,483,647✔
258
  int32_t code = func(pObj, pEncoder);
2,147,483,647✔
259
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
260
    STlv* pTlv = (STlv*)(pEncoder->pBuf + start);
2,147,483,647✔
261
    pTlv->type = htons(type);
2,147,483,647✔
262
    pTlv->len = htonl(pEncoder->offset - start - sizeof(STlv));
2,147,483,647✔
263
  }
264
  ++(pEncoder->tlvCount);
2,147,483,647✔
265
  return code;
2,147,483,647✔
266
}
267

268
static int32_t tlvEncodeObjArray(STlvEncoder* pEncoder, int16_t type, FToMsg func, const void* pArray, int32_t itemSize,
35,596,920✔
269
                                 int32_t num) {
270
  int32_t code = TSDB_CODE_SUCCESS;
35,596,920✔
271
  if (num > 0) {
35,596,920✔
272
    int32_t start = pEncoder->offset;
35,610,797✔
273
    pEncoder->offset += sizeof(STlv);
35,624,431✔
274
    for (size_t i = 0; TSDB_CODE_SUCCESS == code && i < num; ++i) {
71,584,113✔
275
      code = tlvEncodeObj(pEncoder, TLV_TYPE_ARRAY_ELEM, func, (const char*)pArray + i * itemSize);
35,971,525✔
276
    }
277
    if (TSDB_CODE_SUCCESS == code) {
35,612,588✔
278
      STlv* pTlv = (STlv*)(pEncoder->pBuf + start);
35,622,693✔
279
      pTlv->type = htons(type);
35,622,669✔
280
      pTlv->len = htonl(pEncoder->offset - start - sizeof(STlv));
35,590,884✔
281
    }
282
  }
283
  return code;
35,582,280✔
284
}
285

286
static int32_t tlvEncodeValueArray(STlvEncoder* pEncoder, FToMsg func, const void* pArray, int32_t itemSize,
752,970,204✔
287
                                   int32_t num) {
288
  int32_t code = tlvEncodeValueI32(pEncoder, num);
752,970,204✔
289
  for (size_t i = 0; TSDB_CODE_SUCCESS == code && i < num; ++i) {
1,433,024,809✔
290
    code = func((const char*)pArray + i * itemSize, pEncoder);
680,129,573✔
291
  }
292
  return code;
752,895,236✔
293
}
294

295
static int32_t tlvGetNextTlv(STlvDecoder* pDecoder, STlv** pTlv) {
2,147,483,647✔
296
  if (pDecoder->offset == pDecoder->bufSize) {
2,147,483,647✔
297
    *pTlv = NULL;
2,147,483,647✔
298
    return TSDB_CODE_SUCCESS;
2,147,483,647✔
299
  }
300

301
  *pTlv = (STlv*)(pDecoder->pBuf + pDecoder->offset);
2,147,483,647✔
302
  (*pTlv)->type = ntohs((*pTlv)->type);
2,147,483,647✔
303
  (*pTlv)->len = ntohl((*pTlv)->len);
2,147,483,647✔
304
  if ((*pTlv)->len + pDecoder->offset > pDecoder->bufSize) {
2,147,483,647✔
305
    return TSDB_CODE_FAILED;
×
306
  }
307
  pDecoder->offset += sizeof(STlv) + (*pTlv)->len;
2,147,483,647✔
308
  return TSDB_CODE_SUCCESS;
2,147,483,647✔
309
}
310

311
static bool tlvDecodeEnd(STlvDecoder* pDecoder) { return pDecoder->offset == pDecoder->bufSize; }
2,147,483,647✔
312

313
static int32_t tlvDecodeImpl(STlv* pTlv, void* pValue, int32_t len) {
2,147,483,647✔
314
  if (pTlv->len != len) {
2,147,483,647✔
315
    return TSDB_CODE_FAILED;
×
316
  }
317
  memcpy(pValue, pTlv->value, len);
2,147,483,647✔
318
  return TSDB_CODE_SUCCESS;
2,147,483,647✔
319
}
320

321
static int32_t tlvDecodeValueImpl(STlvDecoder* pDecoder, void* pValue, int32_t len) {
2,147,483,647✔
322
  // compatible with lower version messages
323
  if (pDecoder->bufSize == pDecoder->offset) {
2,147,483,647✔
324
    memset(pValue, 0, len);
2,147,483,647✔
325
    return TSDB_CODE_SUCCESS;
2,147,483,647✔
326
  }
327
  if (len > pDecoder->bufSize - pDecoder->offset) {
2,147,483,647✔
328
    return TSDB_CODE_FAILED;
×
329
  }
330
  memcpy(pValue, pDecoder->pBuf + pDecoder->offset, len);
2,147,483,647✔
331
  pDecoder->offset += len;
2,147,483,647✔
332
  return TSDB_CODE_SUCCESS;
2,147,483,647✔
333
}
334

335
static int32_t tlvDecodeI8(STlv* pTlv, int8_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); }
2,147,483,647✔
336

337
static int32_t tlvDecodeValueI8(STlvDecoder* pDecoder, int8_t* pValue) {
2,147,483,647✔
338
  return tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue));
2,147,483,647✔
339
}
340

341
static int32_t tlvDecodeI16(STlv* pTlv, int16_t* pValue) {
×
342
  int32_t code = tlvDecodeImpl(pTlv, pValue, sizeof(*pValue));
×
343
  if (TSDB_CODE_SUCCESS == code) {
×
344
    *pValue = ntohs(*pValue);
×
345
  }
346
  return code;
×
347
}
348

349
static int32_t tlvDecodeValueI16(STlvDecoder* pDecoder, int16_t* pValue) {
2,147,483,647✔
350
  int32_t code = tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue));
2,147,483,647✔
351
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
352
    *pValue = ntohs(*pValue);
2,147,483,647✔
353
  }
354
  return code;
2,147,483,647✔
355
}
356

357
static int32_t tlvDecodeI32(STlv* pTlv, int32_t* pValue) {
2,147,483,647✔
358
  int32_t code = tlvDecodeImpl(pTlv, pValue, sizeof(*pValue));
2,147,483,647✔
359
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
360
    *pValue = ntohl(*pValue);
2,147,483,647✔
361
  }
362
  return code;
2,147,483,647✔
363
}
364

365
static int32_t tlvDecodeValueI32(STlvDecoder* pDecoder, int32_t* pValue) {
2,147,483,647✔
366
  int32_t code = tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue));
2,147,483,647✔
367
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
368
    *pValue = ntohl(*pValue);
2,147,483,647✔
369
  }
370
  return code;
2,147,483,647✔
371
}
372

373
static int32_t tlvDecodeI64(STlv* pTlv, int64_t* pValue) {
403,453,463✔
374
  int32_t code = tlvDecodeImpl(pTlv, pValue, sizeof(*pValue));
403,453,463✔
375
  if (TSDB_CODE_SUCCESS == code) {
403,464,031✔
376
    *pValue = ntohll(*pValue);
403,464,960✔
377
  }
378
  return code;
403,448,695✔
379
}
380

381
static int32_t tlvDecodeValueI64(STlvDecoder* pDecoder, int64_t* pValue) {
2,147,483,647✔
382
  int32_t code = tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue));
2,147,483,647✔
383
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
384
#ifndef NO_UNALIGNED_ACCESS
385
    *pValue = ntohll(*pValue);
2,147,483,647✔
386
#else
387
    int64_t value = taosGetInt64Aligned(pValue);
388
    taosSetInt64Aligned(pValue, ntohll(value));
389
#endif
390
  }
391
  return code;
2,147,483,647✔
392
}
393

394
static int32_t tlvDecodeU8(STlv* pTlv, uint8_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); }
2,147,483,647✔
395

396
static int32_t tlvDecodeValueU8(STlvDecoder* pDecoder, uint8_t* pValue) {
2,147,483,647✔
397
  return tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue));
2,147,483,647✔
398
}
399

400
static int32_t tlvDecodeU16(STlv* pTlv, uint16_t* pValue) {
35,228,878✔
401
  int32_t code = tlvDecodeImpl(pTlv, pValue, sizeof(*pValue));
35,228,878✔
402
  if (TSDB_CODE_SUCCESS == code) {
35,228,352✔
403
    *pValue = ntohs(*pValue);
35,228,352✔
404
  }
405
  return code;
35,228,276✔
406
}
407

408
static int32_t tlvDecodeValueU16(STlvDecoder* pDecoder, uint16_t* pValue) {
483,263,190✔
409
  int32_t code = tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue));
483,263,190✔
410
  if (TSDB_CODE_SUCCESS == code) {
483,297,358✔
411
    *pValue = ntohs(*pValue);
483,296,959✔
412
  }
413
  return code;
483,259,709✔
414
}
415

416
static int32_t tlvDecodeU64(STlv* pTlv, uint64_t* pValue) {
607,755,237✔
417
  int32_t code = tlvDecodeImpl(pTlv, pValue, sizeof(*pValue));
607,755,237✔
418
  if (TSDB_CODE_SUCCESS == code) {
607,771,520✔
419
    *pValue = ntohll(*pValue);
607,773,691✔
420
  }
421
  return code;
607,745,051✔
422
}
423

424
static int32_t tlvDecodeValueU64(STlvDecoder* pDecoder, uint64_t* pValue) {
2,147,483,647✔
425
  int32_t code = tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue));
2,147,483,647✔
426
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
427
    *pValue = ntohll(*pValue);
2,147,483,647✔
428
  }
429
  return code;
2,147,483,647✔
430
}
431

432
static int32_t tlvDecodeDouble(STlv* pTlv, double* pValue) {
25,785,522✔
433
  volatile int64_t temp = 0;
25,785,522✔
434
  int32_t code = tlvDecodeI64(pTlv, (int64_t*)&temp);
25,787,638✔
435
  if (TSDB_CODE_SUCCESS == code) {
25,781,208✔
436
    *pValue = *(double*)&temp;
25,781,208✔
437
  }
438
  return code;
25,783,309✔
439
}
440

441
static int32_t tlvDecodeValueDouble(STlvDecoder* pDecoder, double* pValue) {
271,162,646✔
442
  volatile int64_t temp = 0;
271,162,646✔
443
  int32_t code = tlvDecodeValueI64(pDecoder, (int64_t*)&temp);
271,176,433✔
444
  if (TSDB_CODE_SUCCESS == code) {
271,178,372✔
445
    *pValue = *(double*)&temp;
271,177,226✔
446
  }
447
  return code;
271,160,842✔
448
}
449

450
static int32_t convertIntegerType(int32_t value, void* pValue, int16_t len) {
2,147,483,647✔
451
  switch (len) {
2,147,483,647✔
452
    case 1:
2,147,483,647✔
453
      *(int8_t*)pValue = value;
2,147,483,647✔
454
      break;
2,147,483,647✔
455
    case 2:
×
456
      *(int16_t*)pValue = value;
×
457
      break;
×
458
    case 4:
2,147,483,647✔
459
      *(int32_t*)pValue = value;
2,147,483,647✔
460
      break;
2,147,483,647✔
461
    default:
5✔
462
      return TSDB_CODE_FAILED;
5✔
463
  }
464
  return TSDB_CODE_SUCCESS;
2,147,483,647✔
465
}
466

467
static int32_t tlvDecodeBool(STlv* pTlv, bool* pValue) {
2,147,483,647✔
468
  int8_t  value = 0;
2,147,483,647✔
469
  int32_t code = tlvDecodeI8(pTlv, &value);
2,147,483,647✔
470
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
471
    code = convertIntegerType(value, pValue, sizeof(bool));
2,147,483,647✔
472
  }
473
  return code;
2,147,483,647✔
474
}
475

476
static int32_t tlvDecodeValueBool(STlvDecoder* pDecoder, bool* pValue) {
2,147,483,647✔
477
  int8_t  value = 0;
2,147,483,647✔
478
  int32_t code = tlvDecodeValueI8(pDecoder, &value);
2,147,483,647✔
479
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
480
    code = convertIntegerType(value, pValue, sizeof(bool));
2,147,483,647✔
481
  }
482
  return code;
2,147,483,647✔
483
}
484

485
static int32_t tlvDecodeEnum(STlv* pTlv, void* pValue, int16_t len) {
2,147,483,647✔
486
  int32_t value = 0;
2,147,483,647✔
487
  int32_t code = tlvDecodeI32(pTlv, &value);
2,147,483,647✔
488
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
489
    code = convertIntegerType(value, pValue, len);
2,147,483,647✔
490
  }
491
  return code;
2,147,483,647✔
492
}
493

494
static int32_t tlvDecodeValueEnum(STlvDecoder* pDecoder, void* pValue, int16_t len) {
2,147,483,647✔
495
  int32_t value = 0;
2,147,483,647✔
496
  int32_t code = tlvDecodeValueI32(pDecoder, &value);
2,147,483,647✔
497
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
498
    code = convertIntegerType(value, pValue, len);
2,147,483,647✔
499
  }
500
  return code;
2,147,483,647✔
501
}
502

503
static int32_t tlvDecodeCStr(STlv* pTlv, char* pValue, int32_t size) {
1,203,874,255✔
504
  if (pTlv->len > size - 1) {
1,203,874,255✔
505
    return TSDB_CODE_FAILED;
×
506
  }
507
  memcpy(pValue, pTlv->value, pTlv->len);
1,203,912,458✔
508
  return TSDB_CODE_SUCCESS;
1,203,884,829✔
509
}
510

511
static int32_t tlvDecodeValueCStr(STlvDecoder* pDecoder, char* pValue) {
2,147,483,647✔
512
  int16_t len = 0;
2,147,483,647✔
513
  int32_t code = tlvDecodeValueI16(pDecoder, &len);
2,147,483,647✔
514
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
515
    code = tlvDecodeValueImpl(pDecoder, pValue, len);
2,147,483,647✔
516
  }
517
  return code;
2,147,483,647✔
518
}
519

520
static int32_t tlvDecodeCStrP(STlv* pTlv, char** pValue) {
243,614,468✔
521
  *pValue = taosStrndup(pTlv->value, pTlv->len);
243,614,468✔
522
  return NULL == *pValue ? terrno : TSDB_CODE_SUCCESS;
243,602,663✔
523
}
524

525
static int32_t tlvDecodeDynBinary(STlv* pTlv, void** pValue) {
1,449✔
526
  *pValue = taosMemoryMalloc(pTlv->len);
1,449✔
527
  if (NULL == *pValue) {
1,449✔
528
    return terrno;
×
529
  }
530
  memcpy(*pValue, pTlv->value, pTlv->len);
1,449✔
531
  return TSDB_CODE_SUCCESS;
1,449✔
532
}
533

534
static int32_t tlvDecodeBinary(STlv* pTlv, void* pValue) {
167,092,642✔
535
  memcpy(pValue, pTlv->value, pTlv->len);
167,092,642✔
536
  return TSDB_CODE_SUCCESS;
167,093,458✔
537
}
538

539
static int32_t tlvDecodeObjFromTlv(STlv* pTlv, FToObject func, void* pObj) {
2,147,483,647✔
540
  STlvDecoder decoder = {.bufSize = pTlv->len, .offset = 0, .pBuf = pTlv->value};
2,147,483,647✔
541
  return func(&decoder, pObj);
2,147,483,647✔
542
}
543

544
static int32_t tlvDecodeObj(STlvDecoder* pDecoder, FToObject func, void* pObj) {
×
545
  STlv*   pTlv = NULL;
×
546
  int32_t code = tlvGetNextTlv(pDecoder, &pTlv);
×
547
  if (TSDB_CODE_SUCCESS == code) {
×
548
    code = tlvDecodeObjFromTlv(pTlv, func, pObj);
×
549
  }
550
  return code;
×
551
}
552

553
static int32_t tlvDecodeObjArray(STlvDecoder* pDecoder, FToObject func, void* pArray, int32_t itemSize) {
18,675,305✔
554
  int32_t code = TSDB_CODE_SUCCESS;
18,675,305✔
555
  int32_t i = 0;
18,675,305✔
556
  STlv*   pTlv = NULL;
18,675,305✔
557
  tlvForEach(pDecoder, pTlv, code) { code = tlvDecodeObjFromTlv(pTlv, func, (char*)pArray + itemSize * i++); }
37,679,021✔
558
  return code;
18,674,703✔
559
}
560

561
static int32_t tlvDecodeValueArray(STlvDecoder* pDecoder, FToObject func, void* pArray, int32_t itemSize,
538,473,927✔
562
                                   int32_t* pNum) {
563
  int32_t code = tlvDecodeValueI32(pDecoder, pNum);
538,473,927✔
564
  for (size_t i = 0; TSDB_CODE_SUCCESS == code && i < *pNum; ++i) {
1,021,784,282✔
565
    code = func(pDecoder, (char*)pArray + i * itemSize);
483,292,294✔
566
  }
567
  return code;
538,493,474✔
568
}
569

570
static int32_t tlvDecodeObjArrayFromTlv(STlv* pTlv, FToObject func, void* pArray, int32_t itemSize) {
18,675,305✔
571
  STlvDecoder decoder = {.bufSize = pTlv->len, .offset = 0, .pBuf = pTlv->value};
18,675,305✔
572
  return tlvDecodeObjArray(&decoder, func, pArray, itemSize);
18,675,305✔
573
}
574

575
static int32_t tlvDecodeDynObjFromTlv(STlv* pTlv, FMakeObject makeFunc, FToObject toFunc, void** pObj) {
2,147,483,647✔
576
  int32_t code = makeFunc(pTlv->type, (SNode**)pObj);
2,147,483,647✔
577
  if (NULL == *pObj) {
2,147,483,647✔
578
    return code;
×
579
  }
580
  return tlvDecodeObjFromTlv(pTlv, toFunc, *pObj);
2,147,483,647✔
581
}
582

583
static int32_t tlvDecodeDynObj(STlvDecoder* pDecoder, FMakeObject makeFunc, FToObject toFunc, void** pObj) {
2,147,483,647✔
584
  STlv*   pTlv = NULL;
2,147,483,647✔
585
  int32_t code = tlvGetNextTlv(pDecoder, &pTlv);
2,147,483,647✔
586
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
587
    code = tlvDecodeDynObjFromTlv(pTlv, makeFunc, toFunc, pObj);
2,147,483,647✔
588
  }
589
  return code;
2,147,483,647✔
590
}
591

592
enum { DATA_TYPE_CODE_TYPE = 1, DATA_TYPE_CODE_PRECISION, DATA_TYPE_CODE_SCALE, DATA_TYPE_CODE_BYTES };
593

594
static int32_t dataTypeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,147,483,647✔
595
  const SDataType* pNode = (const SDataType*)pObj;
2,147,483,647✔
596

597
  int32_t code = tlvEncodeValueI8(pEncoder, pNode->type);
2,147,483,647✔
598
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
599
    code = tlvEncodeValueU8(pEncoder, pNode->precision);
2,147,483,647✔
600
  }
601
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
602
    code = tlvEncodeValueU8(pEncoder, pNode->scale);
2,147,483,647✔
603
  }
604
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
605
    code = tlvEncodeValueI32(pEncoder, pNode->bytes);
2,147,483,647✔
606
  }
607

608
  return code;
2,147,483,647✔
609
}
610

611
static int32_t dataTypeToMsg(const void* pObj, STlvEncoder* pEncoder) {
1,666,093,066✔
612
  const SDataType* pNode = (const SDataType*)pObj;
1,666,093,066✔
613

614
  int32_t code = tlvEncodeI8(pEncoder, DATA_TYPE_CODE_TYPE, pNode->type);
1,666,093,066✔
615
  if (TSDB_CODE_SUCCESS == code) {
1,666,648,065✔
616
    code = tlvEncodeU8(pEncoder, DATA_TYPE_CODE_PRECISION, pNode->precision);
1,666,677,492✔
617
  }
618
  if (TSDB_CODE_SUCCESS == code) {
1,667,242,424✔
619
    code = tlvEncodeU8(pEncoder, DATA_TYPE_CODE_SCALE, pNode->scale);
1,667,251,446✔
620
  }
621
  if (TSDB_CODE_SUCCESS == code) {
1,667,302,441✔
622
    code = tlvEncodeI32(pEncoder, DATA_TYPE_CODE_BYTES, pNode->bytes);
1,667,313,847✔
623
  }
624

625
  return code;
1,667,290,080✔
626
}
627

628
static int32_t msgToDataTypeInline(STlvDecoder* pDecoder, void* pObj) {
2,147,483,647✔
629
  SDataType* pNode = (SDataType*)pObj;
2,147,483,647✔
630

631
  int32_t code = tlvDecodeValueI8(pDecoder, &pNode->type);
2,147,483,647✔
632
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
633
    code = tlvDecodeValueU8(pDecoder, &pNode->precision);
2,147,483,647✔
634
  }
635
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
636
    code = tlvDecodeValueU8(pDecoder, &pNode->scale);
2,147,483,647✔
637
  }
638
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
639
    code = tlvDecodeValueI32(pDecoder, &pNode->bytes);
2,147,483,647✔
640
  }
641

642
  return code;
2,147,483,647✔
643
}
644

645
static int32_t msgToDataType(STlvDecoder* pDecoder, void* pObj) {
1,322,291,637✔
646
  SDataType* pNode = (SDataType*)pObj;
1,322,291,637✔
647

648
  int32_t code = TSDB_CODE_SUCCESS;
1,322,291,637✔
649
  STlv*   pTlv = NULL;
1,322,291,637✔
650
  tlvForEach(pDecoder, pTlv, code) {
2,147,483,647✔
651
    switch (pTlv->type) {
2,147,483,647✔
652
      case DATA_TYPE_CODE_TYPE:
1,322,321,791✔
653
        code = tlvDecodeI8(pTlv, &pNode->type);
1,322,321,791✔
654
        break;
1,322,286,077✔
655
      case DATA_TYPE_CODE_PRECISION:
1,322,333,072✔
656
        code = tlvDecodeU8(pTlv, &pNode->precision);
1,322,333,072✔
657
        break;
1,322,327,928✔
658
      case DATA_TYPE_CODE_SCALE:
1,322,343,993✔
659
        code = tlvDecodeU8(pTlv, &pNode->scale);
1,322,343,993✔
660
        break;
1,322,337,470✔
661
      case DATA_TYPE_CODE_BYTES:
1,322,190,436✔
662
        code = tlvDecodeI32(pTlv, &pNode->bytes);
1,322,190,436✔
663
        break;
1,322,318,273✔
664
      default:
×
665
        break;
×
666
    }
667
  }
668

669
  return code;
1,322,059,232✔
670
}
671

672
enum { EXPR_CODE_RES_TYPE = 1, EXPR_CODE_BIND_TUPLE_FUNC_IDX, EXPR_CODE_TUPLE_FUNC_IDX, EXPR_CODE_HAS_NULL };
673

674
static int32_t exprNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
1,666,195,473✔
675
  const SExprNode* pNode = (const SExprNode*)pObj;
1,666,195,473✔
676
  int32_t          code = tlvEncodeObj(pEncoder, EXPR_CODE_RES_TYPE, dataTypeToMsg, &pNode->resType);
1,666,195,473✔
677
  if (TSDB_CODE_SUCCESS == code) {
1,667,185,960✔
678
    code = tlvEncodeBool(pEncoder, EXPR_CODE_HAS_NULL, pNode->hasNull);
1,667,212,317✔
679
  }
680
  if (TSDB_CODE_SUCCESS == code) {
1,667,294,037✔
681
    code = tlvEncodeI32(pEncoder, EXPR_CODE_BIND_TUPLE_FUNC_IDX, pNode->relatedTo);
1,667,299,571✔
682
  }
683
  if (TSDB_CODE_SUCCESS == code) {
1,667,315,408✔
684
    code = tlvEncodeI32(pEncoder, EXPR_CODE_TUPLE_FUNC_IDX, pNode->bindExprID);
1,667,322,412✔
685
  }
686
  return code;
1,667,332,394✔
687
}
688

689
static int32_t msgToExprNode(STlvDecoder* pDecoder, void* pObj) {
1,322,282,262✔
690
  SExprNode* pNode = (SExprNode*)pObj;
1,322,282,262✔
691

692
  int32_t code = TSDB_CODE_SUCCESS;
1,322,282,262✔
693
  STlv*   pTlv = NULL;
1,322,282,262✔
694
  tlvForEach(pDecoder, pTlv, code) {
2,147,483,647✔
695
    switch (pTlv->type) {
2,147,483,647✔
696
      case EXPR_CODE_RES_TYPE:
1,322,342,312✔
697
        code = tlvDecodeObjFromTlv(pTlv, msgToDataType, &pNode->resType);
1,322,342,312✔
698
        break;
1,322,307,332✔
699
      case EXPR_CODE_BIND_TUPLE_FUNC_IDX:
1,322,335,515✔
700
        code = tlvDecodeI32(pTlv, &pNode->relatedTo);
1,322,335,515✔
701
        break;
1,322,318,985✔
702
      case EXPR_CODE_TUPLE_FUNC_IDX:
1,322,328,539✔
703
        code = tlvDecodeI32(pTlv, &pNode->bindExprID);
1,322,328,539✔
704
        break;
1,322,323,081✔
705
      case EXPR_CODE_HAS_NULL:
1,322,210,231✔
706
        code = tlvDecodeBool(pTlv, &pNode->hasNull);
1,322,210,231✔
707
        break;
1,322,318,073✔
708
      default:
×
709
        break;
×
710
    }
711
  }
712

713
  return code;
1,322,797,533✔
714
}
715

716
enum { COLUMN_CODE_INLINE_ATTRS = 1 };
717

718
static int32_t columnNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,147,483,647✔
719
  const SColumnNode* pNode = (const SColumnNode*)pObj;
2,147,483,647✔
720

721
  int32_t code = dataTypeInlineToMsg(&pNode->node.resType, pEncoder);
2,147,483,647✔
722
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
723
    code = tlvEncodeValueI32(pEncoder, pNode->node.relatedTo);
2,147,483,647✔
724
  }
725
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
726
    code = tlvEncodeValueI32(pEncoder, pNode->node.bindExprID);
2,147,483,647✔
727
  }
728
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
729
    code = tlvEncodeValueU64(pEncoder, pNode->tableId);
2,147,483,647✔
730
  }
731
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
732
    code = tlvEncodeValueI8(pEncoder, pNode->tableType);
2,147,483,647✔
733
  }
734
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
735
    code = tlvEncodeValueI16(pEncoder, pNode->colId);
2,147,483,647✔
736
  }
737
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
738
    code = tlvEncodeValueEnum(pEncoder, pNode->colType);
2,147,483,647✔
739
  }
740
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
741
    code = tlvEncodeValueCStr(pEncoder, pNode->dbName);
2,147,483,647✔
742
  }
743
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
744
    code = tlvEncodeValueCStr(pEncoder, pNode->tableName);
2,147,483,647✔
745
  }
746
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
747
    code = tlvEncodeValueCStr(pEncoder, pNode->tableAlias);
2,147,483,647✔
748
  }
749
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
750
    code = tlvEncodeValueCStr(pEncoder, pNode->colName);
2,147,483,647✔
751
  }
752
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
753
    code = tlvEncodeValueI64(pEncoder, pNode->dataBlockId);
2,147,483,647✔
754
  }
755
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
756
    code = tlvEncodeValueI16(pEncoder, pNode->slotId);
2,147,483,647✔
757
  }
758
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
759
    code = tlvEncodeValueBool(pEncoder, pNode->tableHasPk);
2,147,483,647✔
760
  }
761
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
762
    code = tlvEncodeValueBool(pEncoder, pNode->isPk);
2,147,483,647✔
763
  }  
764
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
765
    code = tlvEncodeValueI16(pEncoder, pNode->numOfPKs);
2,147,483,647✔
766
  }
767
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
768
    code = tlvEncodeValueBool(pEncoder, pNode->isPrimTs);
2,147,483,647✔
769
  }
770
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
771
    code = tlvEncodeValueBool(pEncoder, pNode->hasDep);
2,147,483,647✔
772
  }
773
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
774
    code = tlvEncodeValueBool(pEncoder, pNode->hasRef);
2,147,483,647✔
775
  }
776
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
777
    code = tlvEncodeValueCStr(pEncoder, pNode->refDbName);
2,147,483,647✔
778
  }
779
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
780
    code = tlvEncodeValueCStr(pEncoder, pNode->refTableName);
2,147,483,647✔
781
  }
782
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
783
    code = tlvEncodeValueCStr(pEncoder, pNode->refColName);
2,147,483,647✔
784
  }
785
  return code;
2,147,483,647✔
786
}
787

788
static int32_t columnNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,147,483,647✔
789
  return tlvEncodeObj(pEncoder, COLUMN_CODE_INLINE_ATTRS, columnNodeInlineToMsg, pObj);
2,147,483,647✔
790
}
791

792
static int32_t msgToColumnNodeInline(STlvDecoder* pDecoder, void* pObj) {
2,147,483,647✔
793
  SColumnNode* pNode = (SColumnNode*)pObj;
2,147,483,647✔
794

795
  int32_t code = msgToDataTypeInline(pDecoder, &pNode->node.resType);
2,147,483,647✔
796
    if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
797
    code = tlvDecodeValueI32(pDecoder, &pNode->node.relatedTo);
2,147,483,647✔
798
  }
799
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
800
    code = tlvDecodeValueI32(pDecoder, &pNode->node.bindExprID);
2,147,483,647✔
801
  }
802
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
803
    code = tlvDecodeValueU64(pDecoder, &pNode->tableId);
2,147,483,647✔
804
  }
805
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
806
    code = tlvDecodeValueI8(pDecoder, &pNode->tableType);
2,147,483,647✔
807
  }
808
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
809
    code = tlvDecodeValueI16(pDecoder, &pNode->colId);
2,147,483,647✔
810
  }
811
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
812
    code = tlvDecodeValueEnum(pDecoder, &pNode->colType, sizeof(pNode->colType));
2,147,483,647✔
813
  }
814
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
815
    code = tlvDecodeValueCStr(pDecoder, pNode->dbName);
2,147,483,647✔
816
  }
817
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
818
    code = tlvDecodeValueCStr(pDecoder, pNode->tableName);
2,147,483,647✔
819
  }
820
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
821
    code = tlvDecodeValueCStr(pDecoder, pNode->tableAlias);
2,147,483,647✔
822
  }
823
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
824
    code = tlvDecodeValueCStr(pDecoder, pNode->colName);
2,147,483,647✔
825
  }
826
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
827
    code = tlvDecodeValueI64(pDecoder, &pNode->dataBlockId);
2,147,483,647✔
828
  }
829
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
830
    code = tlvDecodeValueI16(pDecoder, &pNode->slotId);
2,147,483,647✔
831
  }
832
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
833
    code = tlvDecodeValueBool(pDecoder, &pNode->tableHasPk);
2,147,483,647✔
834
  }
835
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
836
    code = tlvDecodeValueBool(pDecoder, &pNode->isPk);
2,147,483,647✔
837
  }  
838
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
839
    code = tlvDecodeValueI16(pDecoder, &pNode->numOfPKs);
2,147,483,647✔
840
  }
841
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
842
    code = tlvDecodeValueBool(pDecoder, &pNode->isPrimTs);
2,147,483,647✔
843
  }
844
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
845
    code = tlvDecodeValueBool(pDecoder, &pNode->hasDep);
2,147,483,647✔
846
  }
847
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
848
    code = tlvDecodeValueBool(pDecoder, &pNode->hasRef);
2,147,483,647✔
849
  }
850
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
851
    code = tlvDecodeValueCStr(pDecoder, pNode->refDbName);
2,147,483,647✔
852
  }
853
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
854
    code = tlvDecodeValueCStr(pDecoder, pNode->refTableName);
2,147,483,647✔
855
  }
856
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
857
    code = tlvDecodeValueCStr(pDecoder, pNode->refColName);
2,147,483,647✔
858
  }
859
  return code;
2,147,483,647✔
860
}
861

862
static int32_t msgToColumnNode(STlvDecoder* pDecoder, void* pObj) {
2,147,483,647✔
863
  SColumnNode* pNode = (SColumnNode*)pObj;
2,147,483,647✔
864

865
  int32_t code = TSDB_CODE_SUCCESS;
2,147,483,647✔
866
  STlv*   pTlv = NULL;
2,147,483,647✔
867
  tlvForEach(pDecoder, pTlv, code) {
2,147,483,647✔
868
    switch (pTlv->type) {
2,147,483,647✔
869
      case COLUMN_CODE_INLINE_ATTRS:
2,147,483,647✔
870
        code = tlvDecodeObjFromTlv(pTlv, msgToColumnNodeInline, pNode);
2,147,483,647✔
871
        break;
2,147,483,647✔
872
      default:
×
873
        break;
×
874
    }
875
  }
876

877
  return code;
2,147,483,647✔
878
}
879

880
enum {
881
  VALUE_CODE_EXPR_BASE = 1,
882
  VALUE_CODE_LITERAL,
883
  VALUE_CODE_FLAG,
884
  VALUE_CODE_TRANSLATE,
885
  VALUE_CODE_NOT_RESERVED,
886
  VALUE_CODE_IS_NULL,
887
  VALUE_CODE_DATUM
888
};
889

890
static int32_t datumToMsg(const void* pObj, STlvEncoder* pEncoder) {
463,402,827✔
891
  const SValueNode* pNode = (const SValueNode*)pObj;
463,402,827✔
892

893
  int32_t code = TSDB_CODE_SUCCESS;
463,402,827✔
894
  switch (pNode->node.resType.type) {
463,402,827✔
895
    case TSDB_DATA_TYPE_NULL:
×
896
      break;
×
897
    case TSDB_DATA_TYPE_BOOL:
17,767,474✔
898
      code = tlvEncodeBool(pEncoder, VALUE_CODE_DATUM, pNode->datum.b);
17,767,474✔
899
      break;
17,781,420✔
900
    case TSDB_DATA_TYPE_TINYINT:
346,996,226✔
901
    case TSDB_DATA_TYPE_SMALLINT:
902
    case TSDB_DATA_TYPE_INT:
903
    case TSDB_DATA_TYPE_BIGINT:
904
    case TSDB_DATA_TYPE_TIMESTAMP:
905
      code = tlvEncodeI64(pEncoder, VALUE_CODE_DATUM, pNode->datum.i);
346,996,226✔
906
      break;
347,437,699✔
907
    case TSDB_DATA_TYPE_UTINYINT:
16,318✔
908
    case TSDB_DATA_TYPE_USMALLINT:
909
    case TSDB_DATA_TYPE_UINT:
910
    case TSDB_DATA_TYPE_UBIGINT:
911
      code = tlvEncodeU64(pEncoder, VALUE_CODE_DATUM, pNode->datum.u);
16,318✔
912
      break;
16,318✔
913
    case TSDB_DATA_TYPE_FLOAT:
25,817,827✔
914
    case TSDB_DATA_TYPE_DOUBLE:
915
      code = tlvEncodeDouble(pEncoder, VALUE_CODE_DATUM, pNode->datum.d);
25,817,827✔
916
      break;
25,882,507✔
917
    case TSDB_DATA_TYPE_VARCHAR:
72,127,429✔
918
    case TSDB_DATA_TYPE_VARBINARY:
919
    case TSDB_DATA_TYPE_NCHAR:
920
    case TSDB_DATA_TYPE_GEOMETRY:
921
      code = tlvEncodeBinary(pEncoder, VALUE_CODE_DATUM, pNode->datum.p, varDataTLen(pNode->datum.p));
72,127,429✔
922
      break;
72,322,422✔
923
    case TSDB_DATA_TYPE_JSON:
1,452✔
924
      code = tlvEncodeBinary(pEncoder, VALUE_CODE_DATUM, pNode->datum.p, getJsonValueLen(pNode->datum.p));
1,452✔
925
      break;
1,452✔
926
    case TSDB_DATA_TYPE_DECIMAL:
2,461✔
927
      code = tlvEncodeBinary(pEncoder, VALUE_CODE_DATUM, pNode->datum.p, pNode->node.resType.bytes);
2,461✔
928
      break;
2,461✔
929
    case TSDB_DATA_TYPE_DECIMAL64:
194✔
930
      code = tlvEncodeI64(pEncoder, VALUE_CODE_DATUM, pNode->datum.i);
194✔
931
      break;
194✔
932
    case TSDB_DATA_TYPE_BLOB:
×
933
      code = tlvEncodeBinary(pEncoder, VALUE_CODE_DATUM, pNode->datum.p, blobDataTLen(pNode->datum.p));
×
934
      break;
×
935
      // todo
936
    default:
4,575✔
937
      break;
4,575✔
938
  }
939

940
  return code;
463,422,459✔
941
}
942

943
static int32_t valueNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
555,073,610✔
944
  const SValueNode* pNode = (const SValueNode*)pObj;
555,073,610✔
945

946
  int32_t code = tlvEncodeObj(pEncoder, VALUE_CODE_EXPR_BASE, exprNodeToMsg, pNode);
555,073,610✔
947
  if (TSDB_CODE_SUCCESS == code) {
555,373,619✔
948
    code = tlvEncodeCStr(pEncoder, VALUE_CODE_LITERAL, pNode->literal);
555,377,103✔
949
  }
950
  if (TSDB_CODE_SUCCESS == code) {
555,344,368✔
951
    code = tlvEncodeI32(pEncoder, VALUE_CODE_FLAG, pNode->flag);
555,323,452✔
952
  }
953
  if (TSDB_CODE_SUCCESS == code) {
555,294,726✔
954
    code = tlvEncodeBool(pEncoder, VALUE_CODE_TRANSLATE, pNode->translate);
555,274,689✔
955
  }
956
  if (TSDB_CODE_SUCCESS == code) {
555,396,638✔
957
    code = tlvEncodeBool(pEncoder, VALUE_CODE_NOT_RESERVED, pNode->notReserved);
555,377,432✔
958
  }
959
  if (TSDB_CODE_SUCCESS == code) {
555,194,351✔
960
    code = tlvEncodeBool(pEncoder, VALUE_CODE_IS_NULL, pNode->isNull);
555,175,714✔
961
  }
962
  if (TSDB_CODE_SUCCESS == code && !pNode->isNull && !IS_VAL_UNSET(pNode->flag)) {
555,397,387✔
963
    code = datumToMsg(pNode, pEncoder);
463,466,632✔
964
  }
965

966
  return code;
555,159,530✔
967
}
968

969
static int32_t msgToDatum(STlv* pTlv, void* pObj) {
387,702,710✔
970
  SValueNode* pNode = (SValueNode*)pObj;
387,702,710✔
971

972
  int32_t code = TSDB_CODE_SUCCESS;
387,702,710✔
973
  switch (pNode->node.resType.type) {
387,702,710✔
974
    case TSDB_DATA_TYPE_NULL:
×
975
      break;
×
976
    case TSDB_DATA_TYPE_BOOL:
17,713,029✔
977
      code = tlvDecodeBool(pTlv, &pNode->datum.b);
17,713,029✔
978
      *(bool*)&pNode->typeData = pNode->datum.b;
17,715,375✔
979
      break;
17,714,693✔
980
    case TSDB_DATA_TYPE_TINYINT:
151,564,216✔
981
      code = tlvDecodeI64(pTlv, &pNode->datum.i);
151,564,216✔
982
      *(int8_t*)&pNode->typeData = pNode->datum.i;
151,576,109✔
983
      break;
151,581,090✔
984
    case TSDB_DATA_TYPE_SMALLINT:
8,525,152✔
985
      code = tlvDecodeI64(pTlv, &pNode->datum.i);
8,525,152✔
986
      *(int16_t*)&pNode->typeData = pNode->datum.i;
8,527,252✔
987
      break;
8,529,820✔
988
    case TSDB_DATA_TYPE_INT:
15,164,516✔
989
      code = tlvDecodeI64(pTlv, &pNode->datum.i);
15,164,516✔
990
      *(int32_t*)&pNode->typeData = pNode->datum.i;
15,164,118✔
991
      break;
15,166,168✔
992
    case TSDB_DATA_TYPE_BIGINT:
102,828,759✔
993
      code = tlvDecodeI64(pTlv, &pNode->datum.i);
102,828,759✔
994
      *(int64_t*)&pNode->typeData = pNode->datum.i;
102,830,644✔
995
      break;
102,846,041✔
996
    case TSDB_DATA_TYPE_TIMESTAMP:
9,436,786✔
997
      code = tlvDecodeI64(pTlv, &pNode->datum.i);
9,436,786✔
998
      *(int64_t*)&pNode->typeData = pNode->datum.i;
9,436,786✔
999
      break;
9,436,786✔
1000
    case TSDB_DATA_TYPE_UTINYINT:
6,322✔
1001
      code = tlvDecodeU64(pTlv, &pNode->datum.u);
6,322✔
1002
      *(uint8_t*)&pNode->typeData = pNode->datum.u;
6,322✔
1003
      break;
6,322✔
1004
    case TSDB_DATA_TYPE_USMALLINT:
1,284✔
1005
      code = tlvDecodeU64(pTlv, &pNode->datum.u);
1,284✔
1006
      *(uint16_t*)&pNode->typeData = pNode->datum.u;
1,284✔
1007
      break;
1,284✔
1008
    case TSDB_DATA_TYPE_UINT:
2,282✔
1009
      code = tlvDecodeU64(pTlv, &pNode->datum.u);
2,282✔
1010
      *(uint32_t*)&pNode->typeData = pNode->datum.u;
2,282✔
1011
      break;
2,282✔
1012
    case TSDB_DATA_TYPE_UBIGINT:
6,414✔
1013
      code = tlvDecodeU64(pTlv, &pNode->datum.u);
6,414✔
1014
      *(uint64_t*)&pNode->typeData = pNode->datum.u;
6,414✔
1015
      break;
6,414✔
1016
    case TSDB_DATA_TYPE_FLOAT:
1,353,718✔
1017
      code = tlvDecodeDouble(pTlv, &pNode->datum.d);
1,353,718✔
1018
      *(float*)&pNode->typeData = pNode->datum.d;
1,353,718✔
1019
      break;
1,353,718✔
1020
    case TSDB_DATA_TYPE_DOUBLE:
24,430,568✔
1021
      code = tlvDecodeDouble(pTlv, &pNode->datum.d);
24,430,568✔
1022
      *(double*)&pNode->typeData = pNode->datum.d;
24,424,318✔
1023
      break;
24,431,565✔
1024
    case TSDB_DATA_TYPE_NCHAR:
56,625,699✔
1025
    case TSDB_DATA_TYPE_VARCHAR:
1026
    case TSDB_DATA_TYPE_VARBINARY:
1027
    case TSDB_DATA_TYPE_GEOMETRY: {
1028
      if (pTlv->len > pNode->node.resType.bytes + VARSTR_HEADER_SIZE) {
56,625,699✔
1029
        code = TSDB_CODE_FAILED;
×
1030
        break;
×
1031
      }
1032
      pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + 1);
56,616,357✔
1033
      if (NULL == pNode->datum.p) {
56,625,475✔
1034
        code = terrno;
×
1035
        break;
×
1036
      }
1037
      code = tlvDecodeBinary(pTlv, pNode->datum.p);
56,615,524✔
1038
      if (TSDB_CODE_SUCCESS == code) {
56,623,049✔
1039
        varDataSetLen(pNode->datum.p, pTlv->len - VARSTR_HEADER_SIZE);
56,623,575✔
1040
      }
1041
      break;
56,615,423✔
1042
    }
1043
    case TSDB_DATA_TYPE_JSON: {
1,449✔
1044
      if (pTlv->len <= 0 || pTlv->len > TSDB_MAX_JSON_TAG_LEN) {
1,449✔
1045
        code = TSDB_CODE_FAILED;
×
1046
        break;
×
1047
      }
1048
      code = tlvDecodeDynBinary(pTlv, (void**)&pNode->datum.p);
1,449✔
1049
      break;
1,449✔
1050
    }
1051
    case TSDB_DATA_TYPE_DECIMAL:
2,259✔
1052
      pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes);
2,259✔
1053
      if (!pNode->datum.p) {
2,259✔
1054
        code = terrno;
×
1055
        break;
×
1056
      }
1057
      code = tlvDecodeBinary(pTlv, pNode->datum.p);
2,259✔
1058
      break;
2,259✔
1059
    case TSDB_DATA_TYPE_DECIMAL64:
×
1060
      code = tlvDecodeI64(pTlv, &pNode->datum.i);
×
1061
      *(int64_t*)&pNode->typeData = pNode->datum.i;
×
1062
      break;
×
1063
    case TSDB_DATA_TYPE_BLOB:
×
1064
      if (pTlv->len > pNode->node.resType.bytes + BLOBSTR_HEADER_SIZE) {
×
1065
        code = TSDB_CODE_FAILED;
×
1066
        break;
×
1067
      }
1068
      pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + 1);
×
1069
      if (NULL == pNode->datum.p) {
×
1070
        code = terrno;
×
1071
        break;
×
1072
      }
1073
      code = tlvDecodeBinary(pTlv, pNode->datum.p);
×
1074
      if (TSDB_CODE_SUCCESS == code) {
×
1075
        blobDataSetLen(pNode->datum.p, pTlv->len - BLOBSTR_HEADER_SIZE);
×
1076
      }
1077
      break;
×
1078
      // todo
1079
    default:
×
1080
      break;
×
1081
  }
1082

1083
  return code;
387,693,667✔
1084
}
1085

1086
static int32_t msgToValueNode(STlvDecoder* pDecoder, void* pObj) {
417,494,645✔
1087
  SValueNode* pNode = (SValueNode*)pObj;
417,494,645✔
1088

1089
  int32_t code = TSDB_CODE_SUCCESS;
417,494,645✔
1090
  STlv*   pTlv = NULL;
417,494,645✔
1091
  tlvForEach(pDecoder, pTlv, code) {
2,147,483,647✔
1092
    switch (pTlv->type) {
2,147,483,647✔
1093
      case VALUE_CODE_EXPR_BASE:
417,478,075✔
1094
        code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
417,478,075✔
1095
        break;
417,507,345✔
1096
      case VALUE_CODE_LITERAL:
243,631,457✔
1097
        code = tlvDecodeCStrP(pTlv, &pNode->literal);
243,631,457✔
1098
        break;
243,578,558✔
1099
      case VALUE_CODE_FLAG:
417,503,312✔
1100
        code = tlvDecodeI32(pTlv, &pNode->flag);
417,503,312✔
1101
        break;
417,481,454✔
1102
      case VALUE_CODE_TRANSLATE:
417,509,028✔
1103
        code = tlvDecodeBool(pTlv, &pNode->translate);
417,509,028✔
1104
        break;
417,505,448✔
1105
      case VALUE_CODE_NOT_RESERVED:
417,513,398✔
1106
        code = tlvDecodeBool(pTlv, &pNode->notReserved);
417,513,398✔
1107
        break;
417,512,700✔
1108
      case VALUE_CODE_IS_NULL:
417,486,022✔
1109
        code = tlvDecodeBool(pTlv, &pNode->isNull);
417,486,022✔
1110
        break;
417,509,139✔
1111
      case VALUE_CODE_DATUM:
387,731,928✔
1112
        code = msgToDatum(pTlv, pNode);
387,731,928✔
1113
        break;
387,691,020✔
1114
      default:
×
1115
        break;
×
1116
    }
1117
  }
1118

1119
  return code;
417,622,547✔
1120
}
1121

1122
enum {
1123
  REMOTE_VALUE_CODE_VAL = 1,
1124
  REMOTE_VALUE_CODE_VAL_SET,
1125
  REMOTE_VALUE_CODE_SUBQ_IDX
1126
};
1127

1128
static int32_t remoteValueNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
61,493,659✔
1129
  const SRemoteValueNode* pNode = (const SRemoteValueNode*)pObj;
61,493,659✔
1130

1131
  int32_t code = tlvEncodeObj(pEncoder, REMOTE_VALUE_CODE_VAL, valueNodeToMsg, pNode);
61,493,659✔
1132
/*
1133
  if (TSDB_CODE_SUCCESS == code) {
1134
    code = tlvEncodeBool(pEncoder, REMOTE_VALUE_CODE_VAL_SET, pNode->valSet);
1135
  }
1136
*/
1137
  if (TSDB_CODE_SUCCESS == code) {
61,522,667✔
1138
    code = tlvEncodeI32(pEncoder, REMOTE_VALUE_CODE_SUBQ_IDX, pNode->subQIdx);
61,524,517✔
1139
  }
1140

1141
  return code;
61,526,119✔
1142
}
1143

1144

1145
static int32_t msgToRemoteValueNode(STlvDecoder* pDecoder, void* pObj) {
5,247,805✔
1146
  SRemoteValueNode* pNode = (SRemoteValueNode*)pObj;
5,247,805✔
1147

1148
  int32_t code = TSDB_CODE_SUCCESS;
5,247,805✔
1149
  STlv*   pTlv = NULL;
5,247,805✔
1150
  tlvForEach(pDecoder, pTlv, code) {
15,744,523✔
1151
    switch (pTlv->type) {
10,496,718✔
1152
      case REMOTE_VALUE_CODE_VAL:
5,247,805✔
1153
        code = tlvDecodeObjFromTlv(pTlv, msgToValueNode, &pNode->val);
5,247,805✔
1154
        break;
5,248,359✔
1155
/*
1156
      case REMOTE_VALUE_CODE_VAL_SET:
1157
        code = tlvDecodeBool(pTlv, &pNode->valSet);
1158
        break;
1159
*/
1160
      case REMOTE_VALUE_CODE_SUBQ_IDX:
5,248,370✔
1161
        code = tlvDecodeI32(pTlv, &pNode->subQIdx);
5,248,370✔
1162
        break;
5,248,359✔
1163
      default:
×
1164
        break;
×
1165
    }
1166
  }
1167

1168
  return code;
5,247,805✔
1169
}
1170

1171
enum {
1172
  REMOTE_VALUELIST_CODE_EXPR = 1,
1173
  REMOTE_VALUELIST_CODE_FLAG,
1174
  REMOTE_VALUELIST_CODE_SUBQ_IDX
1175
};
1176

1177
static int32_t remoteValueListNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
18,288,976✔
1178
  const SRemoteValueListNode* pNode = (const SRemoteValueListNode*)pObj;
18,288,976✔
1179

1180
  int32_t code = tlvEncodeObj(pEncoder, REMOTE_VALUELIST_CODE_EXPR, exprNodeToMsg, pNode);
18,288,976✔
1181
  if (TSDB_CODE_SUCCESS == code) {
18,297,001✔
1182
    code = tlvEncodeI32(pEncoder, REMOTE_VALUELIST_CODE_FLAG, pNode->flag);
18,297,001✔
1183
  }
1184
  if (TSDB_CODE_SUCCESS == code) {
18,295,486✔
1185
    code = tlvEncodeI32(pEncoder, REMOTE_VALUELIST_CODE_SUBQ_IDX, pNode->subQIdx);
18,292,752✔
1186
  }
1187

1188
  return code;
18,296,568✔
1189
}
1190

1191

1192
static int32_t msgToRemoteValueListNode(STlvDecoder* pDecoder, void* pObj) {
11,964,692✔
1193
  SRemoteValueListNode* pNode = (SRemoteValueListNode*)pObj;
11,964,692✔
1194

1195
  int32_t code = TSDB_CODE_SUCCESS;
11,964,692✔
1196
  STlv*   pTlv = NULL;
11,964,692✔
1197
  tlvForEach(pDecoder, pTlv, code) {
47,858,768✔
1198
    switch (pTlv->type) {
35,894,076✔
1199
      case REMOTE_VALUELIST_CODE_EXPR:
11,964,692✔
1200
        code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
11,964,692✔
1201
        break;
11,964,692✔
1202
      case REMOTE_VALUELIST_CODE_FLAG:
11,964,692✔
1203
        code = tlvDecodeI32(pTlv, &pNode->flag);
11,964,692✔
1204
        break;
11,964,692✔
1205
      case REMOTE_VALUELIST_CODE_SUBQ_IDX:
11,964,692✔
1206
        code = tlvDecodeI32(pTlv, &pNode->subQIdx);
11,964,692✔
1207
        break;
11,964,692✔
1208
      default:
×
1209
        break;
×
1210
    }
1211
  }
1212

1213
  return code;
11,964,692✔
1214
}
1215

1216
enum {
1217
  REMOTE_ROW_CODE_VAL = 1,
1218
  REMOTE_ROW_CODE_IS_MIN,
1219
  REMOTE_ROW_CODE_VAL_SET,
1220
  REMOTE_ROW_CODE_HAS_VALUE,
1221
  REMOTE_ROW_CODE_HAS_NULL,
1222
  REMOTE_ROW_CODE_SUBQ_IDX
1223
};
1224

1225
static int32_t remoteRowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
23,249,661✔
1226
  const SRemoteRowNode* pNode = (const SRemoteRowNode*)pObj;
23,249,661✔
1227

1228
  int32_t code = tlvEncodeObj(pEncoder, REMOTE_ROW_CODE_VAL, valueNodeToMsg, pNode);
23,249,661✔
1229
  if (TSDB_CODE_SUCCESS == code) {
23,251,137✔
1230
    code = tlvEncodeBool(pEncoder, REMOTE_ROW_CODE_IS_MIN, pNode->isMinVal);
23,251,137✔
1231
  }
1232
  if (TSDB_CODE_SUCCESS == code) {
23,250,965✔
1233
    code = tlvEncodeBool(pEncoder, REMOTE_ROW_CODE_VAL_SET, pNode->valSet);
23,250,451✔
1234
  }
1235
  if (TSDB_CODE_SUCCESS == code) {
23,251,397✔
1236
    code = tlvEncodeBool(pEncoder, REMOTE_ROW_CODE_HAS_VALUE, pNode->hasValue);
23,250,881✔
1237
  }
1238
  if (TSDB_CODE_SUCCESS == code) {
23,250,969✔
1239
    code = tlvEncodeBool(pEncoder, REMOTE_ROW_CODE_HAS_NULL, pNode->hasNull);
23,250,453✔
1240
  }
1241
  if (TSDB_CODE_SUCCESS == code) {
23,251,821✔
1242
    code = tlvEncodeI32(pEncoder, REMOTE_ROW_CODE_SUBQ_IDX, pNode->subQIdx);
23,251,305✔
1243
  }
1244

1245
  return code;
23,251,049✔
1246
}
1247

1248

1249
static int32_t msgToRemoteRowNode(STlvDecoder* pDecoder, void* pObj) {
21,728,295✔
1250
  SRemoteRowNode* pNode = (SRemoteRowNode*)pObj;
21,728,295✔
1251

1252
  int32_t code = TSDB_CODE_SUCCESS;
21,728,295✔
1253
  STlv*   pTlv = NULL;
21,728,295✔
1254
  tlvForEach(pDecoder, pTlv, code) {
152,097,522✔
1255
    switch (pTlv->type) {
130,369,227✔
1256
      case REMOTE_ROW_CODE_VAL:
21,727,752✔
1257
        code = tlvDecodeObjFromTlv(pTlv, msgToValueNode, &pNode->val);
21,727,752✔
1258
        break;
21,728,295✔
1259
      case REMOTE_ROW_CODE_IS_MIN:
21,728,295✔
1260
        code = tlvDecodeBool(pTlv, &pNode->isMinVal);
21,728,295✔
1261
        break;
21,728,295✔
1262
      case REMOTE_ROW_CODE_VAL_SET:
21,728,295✔
1263
        code = tlvDecodeBool(pTlv, &pNode->valSet);
21,728,295✔
1264
        break;
21,727,752✔
1265
      case REMOTE_ROW_CODE_HAS_VALUE:
21,728,295✔
1266
        code = tlvDecodeBool(pTlv, &pNode->hasValue);
21,728,295✔
1267
        break;
21,728,295✔
1268
      case REMOTE_ROW_CODE_HAS_NULL:
21,728,295✔
1269
        code = tlvDecodeBool(pTlv, &pNode->hasNull);
21,728,295✔
1270
        break;
21,728,295✔
1271
      case REMOTE_ROW_CODE_SUBQ_IDX:
21,727,752✔
1272
        code = tlvDecodeI32(pTlv, &pNode->subQIdx);
21,727,752✔
1273
        break;
21,728,295✔
1274
      default:
×
1275
        break;
×
1276
    }
1277
  }
1278

1279
  return code;
21,728,295✔
1280
}
1281

1282
static int32_t remoteZeroRowsNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
1,309,578✔
1283
  return remoteValueNodeToMsg(pObj, pEncoder);
1,309,578✔
1284
}
1285

1286

1287
static int32_t msgToRemoteZeroRowsNode(STlvDecoder* pDecoder, void* pObj) {
380,395✔
1288
  return msgToRemoteValueNode(pDecoder, pObj);
380,395✔
1289
}
1290

1291

1292
enum { OPERATOR_CODE_EXPR_BASE = 1, OPERATOR_CODE_OP_TYPE, OPERATOR_CODE_LEFT, OPERATOR_CODE_RIGHT, OPERATOR_CODE_FLAG };
1293

1294
static int32_t operatorNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
321,181,203✔
1295
  const SOperatorNode* pNode = (const SOperatorNode*)pObj;
321,181,203✔
1296

1297
  int32_t code = tlvEncodeObj(pEncoder, OPERATOR_CODE_EXPR_BASE, exprNodeToMsg, pNode);
321,181,203✔
1298
  if (TSDB_CODE_SUCCESS == code) {
321,368,615✔
1299
    code = tlvEncodeEnum(pEncoder, OPERATOR_CODE_OP_TYPE, pNode->opType);
321,367,549✔
1300
  }
1301
  if (TSDB_CODE_SUCCESS == code) {
321,352,501✔
1302
    code = tlvEncodeI32(pEncoder, OPERATOR_CODE_FLAG, pNode->flag);
321,352,617✔
1303
  }
1304
  if (TSDB_CODE_SUCCESS == code) {
321,364,382✔
1305
    code = tlvEncodeObj(pEncoder, OPERATOR_CODE_LEFT, nodeToMsg, pNode->pLeft);
321,364,728✔
1306
  }
1307
  if (TSDB_CODE_SUCCESS == code) {
321,305,825✔
1308
    code = tlvEncodeObj(pEncoder, OPERATOR_CODE_RIGHT, nodeToMsg, pNode->pRight);
321,300,149✔
1309
  }
1310

1311
  return code;
321,290,752✔
1312
}
1313

1314
static int32_t msgToOperatorNode(STlvDecoder* pDecoder, void* pObj) {
262,040,921✔
1315
  SOperatorNode* pNode = (SOperatorNode*)pObj;
262,040,921✔
1316

1317
  int32_t code = TSDB_CODE_SUCCESS;
262,040,921✔
1318
  STlv*   pTlv = NULL;
262,040,921✔
1319
  tlvForEach(pDecoder, pTlv, code) {
1,535,928,026✔
1320
    switch (pTlv->type) {
1,273,916,068✔
1321
      case OPERATOR_CODE_EXPR_BASE:
262,039,364✔
1322
        code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
262,039,364✔
1323
        break;
262,039,402✔
1324
      case OPERATOR_CODE_OP_TYPE:
262,050,497✔
1325
        code = tlvDecodeEnum(pTlv, &pNode->opType, sizeof(pNode->opType));
262,050,497✔
1326
        break;
262,046,451✔
1327
      case OPERATOR_CODE_FLAG:
262,041,566✔
1328
        code = tlvDecodeI32(pTlv, &pNode->flag);
262,041,566✔
1329
        break;
262,040,275✔
1330
      case OPERATOR_CODE_LEFT:
262,048,367✔
1331
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pLeft);
262,048,367✔
1332
        break;
262,041,959✔
1333
      case OPERATOR_CODE_RIGHT:
225,737,535✔
1334
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pRight);
225,737,535✔
1335
        break;
225,715,099✔
1336
      default:
×
1337
        break;
×
1338
    }
1339
  }
1340

1341
  return code;
262,114,753✔
1342
}
1343

1344
enum { LOGIC_COND_CODE_EXPR_BASE = 1, LOGIC_COND_CODE_COND_TYPE, LOGIC_COND_CODE_PARAMETERS };
1345

1346
static int32_t logicConditionNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
48,466,790✔
1347
  const SLogicConditionNode* pNode = (const SLogicConditionNode*)pObj;
48,466,790✔
1348

1349
  int32_t code = tlvEncodeObj(pEncoder, LOGIC_COND_CODE_EXPR_BASE, exprNodeToMsg, pNode);
48,466,790✔
1350
  if (TSDB_CODE_SUCCESS == code) {
48,497,865✔
1351
    code = tlvEncodeEnum(pEncoder, LOGIC_COND_CODE_COND_TYPE, pNode->condType);
48,497,865✔
1352
  }
1353
  if (TSDB_CODE_SUCCESS == code) {
48,488,933✔
1354
    code = tlvEncodeObj(pEncoder, LOGIC_COND_CODE_PARAMETERS, nodeListToMsg, pNode->pParameterList);
48,488,933✔
1355
  }
1356

1357
  return code;
48,495,757✔
1358
}
1359

1360
static int32_t msgToLogicConditionNode(STlvDecoder* pDecoder, void* pObj) {
44,500,285✔
1361
  SLogicConditionNode* pNode = (SLogicConditionNode*)pObj;
44,500,285✔
1362

1363
  int32_t code = TSDB_CODE_SUCCESS;
44,500,285✔
1364
  STlv*   pTlv = NULL;
44,500,285✔
1365
  tlvForEach(pDecoder, pTlv, code) {
178,011,538✔
1366
    switch (pTlv->type) {
133,511,099✔
1367
      case LOGIC_COND_CODE_EXPR_BASE:
44,502,368✔
1368
        code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
44,502,368✔
1369
        break;
44,504,591✔
1370
      case LOGIC_COND_CODE_COND_TYPE:
44,504,591✔
1371
        code = tlvDecodeEnum(pTlv, &pNode->condType, sizeof(pNode->condType));
44,504,591✔
1372
        break;
44,501,712✔
1373
      case LOGIC_COND_CODE_PARAMETERS:
44,504,666✔
1374
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pParameterList);
44,504,666✔
1375
        break;
44,503,138✔
1376
      default:
×
1377
        break;
×
1378
    }
1379
  }
1380

1381
  return code;
44,509,905✔
1382
}
1383

1384
enum {
1385
  FUNCTION_CODE_EXPR_BASE = 1,
1386
  FUNCTION_CODE_FUNCTION_NAME,
1387
  FUNCTION_CODE_FUNCTION_ID,
1388
  FUNCTION_CODE_FUNCTION_TYPE,
1389
  FUNCTION_CODE_PARAMETERS,
1390
  FUNCTION_CODE_UDF_BUF_SIZE,
1391
  FUNCTION_NODE_HAS_PK,
1392
  FUNCTION_NODE_PK_BYTES,
1393
  FUNCTION_CODE_IS_MERGE_FUNC,
1394
  FUNCTION_CODE_MERGE_FUNC_OF,
1395
  FUNCTION_CODE_TRIM_TYPE,
1396
  FUNCTION_SRC_FUNC_INPUT_TYPE,
1397
};
1398

1399
static int32_t functionNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
698,047,366✔
1400
  const SFunctionNode* pNode = (const SFunctionNode*)pObj;
698,047,366✔
1401

1402
  int32_t code = tlvEncodeObj(pEncoder, FUNCTION_CODE_EXPR_BASE, exprNodeToMsg, pNode);
698,047,366✔
1403
  if (TSDB_CODE_SUCCESS == code) {
698,526,763✔
1404
    code = tlvEncodeCStr(pEncoder, FUNCTION_CODE_FUNCTION_NAME, pNode->functionName);
698,538,124✔
1405
  }
1406
  if (TSDB_CODE_SUCCESS == code) {
698,580,963✔
1407
    code = tlvEncodeI32(pEncoder, FUNCTION_CODE_FUNCTION_ID, pNode->funcId);
698,568,716✔
1408
  }
1409
  if (TSDB_CODE_SUCCESS == code) {
698,587,551✔
1410
    code = tlvEncodeI32(pEncoder, FUNCTION_CODE_FUNCTION_TYPE, pNode->funcType);
698,576,210✔
1411
  }
1412
  if (TSDB_CODE_SUCCESS == code) {
698,609,297✔
1413
    code = tlvEncodeObj(pEncoder, FUNCTION_CODE_PARAMETERS, nodeListToMsg, pNode->pParameterList);
698,598,277✔
1414
  }
1415
  if (TSDB_CODE_SUCCESS == code) {
698,268,493✔
1416
    code = tlvEncodeI32(pEncoder, FUNCTION_CODE_UDF_BUF_SIZE, pNode->udfBufSize);
698,257,607✔
1417
  }
1418
  if (TSDB_CODE_SUCCESS == code) {
698,567,967✔
1419
    code = tlvEncodeBool(pEncoder, FUNCTION_NODE_HAS_PK, pNode->hasPk);
698,546,405✔
1420
  }
1421
  if (TSDB_CODE_SUCCESS == code) {
698,604,820✔
1422
    code = tlvEncodeI32(pEncoder, FUNCTION_NODE_PK_BYTES, pNode->pkBytes);
698,584,293✔
1423
  }  
1424
  if (TSDB_CODE_SUCCESS == code) {
698,601,354✔
1425
    code = tlvEncodeBool(pEncoder, FUNCTION_CODE_IS_MERGE_FUNC, pNode->hasOriginalFunc);
698,581,288✔
1426
  }
1427
  if (TSDB_CODE_SUCCESS == code) {
698,616,253✔
1428
    code = tlvEncodeI32(pEncoder, FUNCTION_CODE_MERGE_FUNC_OF, pNode->originalFuncId);
698,596,594✔
1429
  }
1430
  if (TSDB_CODE_SUCCESS == code) {
698,616,626✔
1431
    code = tlvEncodeEnum(pEncoder, FUNCTION_CODE_TRIM_TYPE, pNode->trimType);
698,590,387✔
1432
  }
1433
  if (TSDB_CODE_SUCCESS == code) {
698,628,765✔
1434
    code = tlvEncodeObj(pEncoder, FUNCTION_SRC_FUNC_INPUT_TYPE, dataTypeInlineToMsg, &pNode->srcFuncInputType);
698,602,536✔
1435
  }
1436

1437
  return code;
698,322,636✔
1438
}
1439

1440
static int32_t msgToFunctionNode(STlvDecoder* pDecoder, void* pObj) {
575,647,147✔
1441
  SFunctionNode* pNode = (SFunctionNode*)pObj;
575,647,147✔
1442

1443
  int32_t code = TSDB_CODE_SUCCESS;
575,647,147✔
1444
  STlv*   pTlv = NULL;
575,647,147✔
1445
  tlvForEach(pDecoder, pTlv, code) {
2,147,483,647✔
1446
    switch (pTlv->type) {
2,147,483,647✔
1447
      case FUNCTION_CODE_EXPR_BASE:
575,663,175✔
1448
        code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
575,663,175✔
1449
        break;
575,642,044✔
1450
      case FUNCTION_CODE_FUNCTION_NAME:
575,666,093✔
1451
        code = tlvDecodeCStr(pTlv, pNode->functionName, sizeof(pNode->functionName));
575,666,093✔
1452
        break;
575,635,179✔
1453
      case FUNCTION_CODE_FUNCTION_ID:
575,655,140✔
1454
        code = tlvDecodeI32(pTlv, &pNode->funcId);
575,655,140✔
1455
        break;
575,658,271✔
1456
      case FUNCTION_CODE_FUNCTION_TYPE:
575,676,598✔
1457
        code = tlvDecodeI32(pTlv, &pNode->funcType);
575,676,598✔
1458
        break;
575,674,314✔
1459
      case FUNCTION_CODE_PARAMETERS:
477,447,827✔
1460
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pParameterList);
477,447,827✔
1461
        break;
477,435,655✔
1462
      case FUNCTION_CODE_UDF_BUF_SIZE:
575,664,946✔
1463
        code = tlvDecodeI32(pTlv, &pNode->udfBufSize);
575,664,946✔
1464
        break;
575,668,673✔
1465
      case FUNCTION_NODE_HAS_PK:
575,679,566✔
1466
        code = tlvDecodeBool(pTlv, &pNode->hasPk);
575,679,566✔
1467
        break;
575,669,931✔
1468
      case FUNCTION_NODE_PK_BYTES:
575,681,457✔
1469
        code = tlvDecodeI32(pTlv, &pNode->pkBytes);
575,681,457✔
1470
        break;  
575,672,545✔
1471
      case FUNCTION_CODE_IS_MERGE_FUNC:
575,678,369✔
1472
        code = tlvDecodeBool(pTlv, &pNode->hasOriginalFunc);
575,678,369✔
1473
        break;
575,655,142✔
1474
      case FUNCTION_CODE_MERGE_FUNC_OF:
575,684,323✔
1475
        code = tlvDecodeI32(pTlv, &pNode->originalFuncId);
575,684,323✔
1476
        break;
575,672,763✔
1477
      case FUNCTION_CODE_TRIM_TYPE:
575,672,426✔
1478
        code = tlvDecodeEnum(pTlv, &pNode->trimType, sizeof(pNode->trimType));
575,672,426✔
1479
        break;
575,661,359✔
1480
      case FUNCTION_SRC_FUNC_INPUT_TYPE:
575,680,419✔
1481
        code = tlvDecodeObjFromTlv(pTlv, msgToDataTypeInline, &pNode->srcFuncInputType);
575,680,419✔
1482
      default:
575,661,468✔
1483
        break;
575,661,468✔
1484
    }
1485
  }
1486

1487
  return code;
578,536,679✔
1488
}
1489

1490
enum { ORDER_BY_EXPR_CODE_EXPR = 1, ORDER_BY_EXPR_CODE_ORDER, ORDER_BY_EXPR_CODE_NULL_ORDER };
1491

1492
static int32_t orderByExprNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
92,544,039✔
1493
  const SOrderByExprNode* pNode = (const SOrderByExprNode*)pObj;
92,544,039✔
1494

1495
  int32_t code = tlvEncodeObj(pEncoder, ORDER_BY_EXPR_CODE_EXPR, nodeToMsg, pNode->pExpr);
92,544,039✔
1496
  if (TSDB_CODE_SUCCESS == code) {
92,570,065✔
1497
    code = tlvEncodeEnum(pEncoder, ORDER_BY_EXPR_CODE_ORDER, pNode->order);
92,570,182✔
1498
  }
1499
  if (TSDB_CODE_SUCCESS == code) {
92,570,459✔
1500
    code = tlvEncodeEnum(pEncoder, ORDER_BY_EXPR_CODE_NULL_ORDER, pNode->nullOrder);
92,569,552✔
1501
  }
1502

1503
  return code;
92,570,466✔
1504
}
1505

1506
static int32_t msgToOrderByExprNode(STlvDecoder* pDecoder, void* pObj) {
60,725,055✔
1507
  SOrderByExprNode* pNode = (SOrderByExprNode*)pObj;
60,725,055✔
1508

1509
  int32_t code = TSDB_CODE_SUCCESS;
60,725,055✔
1510
  STlv*   pTlv = NULL;
60,725,055✔
1511
  tlvForEach(pDecoder, pTlv, code) {
242,910,003✔
1512
    switch (pTlv->type) {
182,183,526✔
1513
      case ORDER_BY_EXPR_CODE_EXPR:
60,727,169✔
1514
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pExpr);
60,727,169✔
1515
        break;
60,727,656✔
1516
      case ORDER_BY_EXPR_CODE_ORDER:
60,728,194✔
1517
        code = tlvDecodeEnum(pTlv, &pNode->order, sizeof(pNode->order));
60,728,194✔
1518
        break;
60,728,194✔
1519
      case ORDER_BY_EXPR_CODE_NULL_ORDER:
60,728,163✔
1520
        code = tlvDecodeEnum(pTlv, &pNode->nullOrder, sizeof(pNode->nullOrder));
60,728,163✔
1521
        break;
60,728,194✔
1522
      default:
×
1523
        break;
×
1524
    }
1525
  }
1526

1527
  return code;
60,725,276✔
1528
}
1529

1530
enum { LIMIT_CODE_LIMIT = 1, LIMIT_CODE_OFFSET };
1531

1532
static int32_t limitNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
41,243,110✔
1533
  const SLimitNode* pNode = (const SLimitNode*)pObj;
41,243,110✔
1534

1535
  int32_t code = tlvEncodeObj(pEncoder, LIMIT_CODE_LIMIT, nodeToMsg, pNode->limit);
41,243,110✔
1536
  if (TSDB_CODE_SUCCESS == code && pNode->offset) {
41,262,915✔
1537
    code = tlvEncodeObj(pEncoder, LIMIT_CODE_OFFSET, nodeToMsg, pNode->offset);
11,159,963✔
1538
  }
1539

1540
  return code;
41,256,255✔
1541
}
1542

1543
static int32_t msgToLimitNode(STlvDecoder* pDecoder, void* pObj) {
34,881,436✔
1544
  SLimitNode* pNode = (SLimitNode*)pObj;
34,881,436✔
1545

1546
  int32_t code = TSDB_CODE_SUCCESS;
34,881,436✔
1547
  STlv*   pTlv = NULL;
34,881,436✔
1548
  tlvForEach(pDecoder, pTlv, code) {
80,804,015✔
1549
    switch (pTlv->type) {
45,921,059✔
1550
      case LIMIT_CODE_LIMIT:
34,885,021✔
1551
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->limit);
34,885,021✔
1552
        break;
34,884,286✔
1553
      case LIMIT_CODE_OFFSET:
11,036,038✔
1554
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->offset);
11,036,038✔
1555
        break;
11,034,965✔
1556
      default:
×
1557
        break;
×
1558
    }
1559
  }
1560

1561
  return code;
34,882,303✔
1562
}
1563

1564
enum { NAME_CODE_TYPE = 1, NAME_CODE_ACCT_ID, NAME_CODE_DB_NAME, NAME_CODE_TABLE_NAME };
1565

1566
static int32_t nameToMsg(const void* pObj, STlvEncoder* pEncoder) {
427,502,331✔
1567
  const SName* pNode = (const SName*)pObj;
427,502,331✔
1568

1569
  int32_t code = tlvEncodeU8(pEncoder, NAME_CODE_TYPE, pNode->type);
427,502,331✔
1570
  if (TSDB_CODE_SUCCESS == code) {
427,934,491✔
1571
    code = tlvEncodeI32(pEncoder, NAME_CODE_ACCT_ID, pNode->acctId);
427,937,368✔
1572
  }
1573
  if (TSDB_CODE_SUCCESS == code) {
427,956,820✔
1574
    code = tlvEncodeCStr(pEncoder, NAME_CODE_DB_NAME, pNode->dbname);
427,877,511✔
1575
  }
1576
  if (TSDB_CODE_SUCCESS == code) {
427,749,045✔
1577
    code = tlvEncodeCStr(pEncoder, NAME_CODE_TABLE_NAME, pNode->tname);
427,676,754✔
1578
  }
1579

1580
  return code;
427,978,258✔
1581
}
1582

1583
static int32_t msgToName(STlvDecoder* pDecoder, void* pObj) {
300,492,577✔
1584
  SName* pNode = (SName*)pObj;
300,492,577✔
1585

1586
  int32_t code = TSDB_CODE_SUCCESS;
300,492,577✔
1587
  STlv*   pTlv = NULL;
300,492,577✔
1588
  tlvForEach(pDecoder, pTlv, code) {
1,502,571,888✔
1589
    switch (pTlv->type) {
1,202,080,972✔
1590
      case NAME_CODE_TYPE:
300,512,715✔
1591
        code = tlvDecodeU8(pTlv, &pNode->type);
300,512,715✔
1592
        break;
300,515,945✔
1593
      case NAME_CODE_ACCT_ID:
300,525,005✔
1594
        code = tlvDecodeI32(pTlv, &pNode->acctId);
300,525,005✔
1595
        break;
300,523,643✔
1596
      case NAME_CODE_DB_NAME:
300,527,488✔
1597
        code = tlvDecodeCStr(pTlv, pNode->dbname, sizeof(pNode->dbname));
300,527,488✔
1598
        break;
300,503,546✔
1599
      case NAME_CODE_TABLE_NAME:
300,519,530✔
1600
        code = tlvDecodeCStr(pTlv, pNode->tname, sizeof(pNode->tname));
300,519,530✔
1601
        break;
300,522,883✔
1602
      default:
×
1603
        break;
×
1604
    }
1605
  }
1606

1607
  return code;
300,541,816✔
1608
}
1609

1610
enum { TIME_WINDOW_CODE_START_KEY = 1, TIME_WINDOW_CODE_END_KEY };
1611

1612
static int32_t timeWindowToMsg(const void* pObj, STlvEncoder* pEncoder) {
23,012,639✔
1613
  const STimeWindow* pNode = (const STimeWindow*)pObj;
23,012,639✔
1614

1615
  int32_t code = tlvEncodeI64(pEncoder, TIME_WINDOW_CODE_START_KEY, pNode->skey);
23,012,639✔
1616
  if (TSDB_CODE_SUCCESS == code) {
23,022,068✔
1617
    code = tlvEncodeI64(pEncoder, TIME_WINDOW_CODE_END_KEY, pNode->ekey);
23,022,432✔
1618
  }
1619

1620
  return code;
23,025,279✔
1621
}
1622

1623
static int32_t msgToTimeWindow(STlvDecoder* pDecoder, void* pObj) {
15,111,504✔
1624
  STimeWindow* pNode = (STimeWindow*)pObj;
15,111,504✔
1625

1626
  int32_t code = TSDB_CODE_SUCCESS;
15,111,504✔
1627
  STlv*   pTlv = NULL;
15,111,504✔
1628
  tlvForEach(pDecoder, pTlv, code) {
45,335,142✔
1629
    switch (pTlv->type) {
30,223,391✔
1630
      case TIME_WINDOW_CODE_START_KEY:
15,111,076✔
1631
        code = tlvDecodeI64(pTlv, &pNode->skey);
15,111,076✔
1632
        break;
15,111,605✔
1633
      case TIME_WINDOW_CODE_END_KEY:
15,112,315✔
1634
        code = tlvDecodeI64(pTlv, &pNode->ekey);
15,112,315✔
1635
        break;
15,112,033✔
1636
      default:
×
1637
        break;
×
1638
    }
1639
  }
1640

1641
  return code;
15,111,454✔
1642
}
1643

1644
enum { NODE_LIST_CODE_EXPR_BASE = 1, NODE_LIST_CODE_NODE_LIST };
1645

1646
static int32_t nodeListNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
11,086,955✔
1647
  const SNodeListNode* pNode = (const SNodeListNode*)pObj;
11,086,955✔
1648

1649
  int32_t code = tlvEncodeObj(pEncoder, NODE_LIST_CODE_EXPR_BASE, exprNodeToMsg, pNode);
11,086,955✔
1650
  if (TSDB_CODE_SUCCESS == code) {
11,104,363✔
1651
    code = tlvEncodeObj(pEncoder, NODE_LIST_CODE_NODE_LIST, nodeListToMsg, pNode->pNodeList);
11,104,363✔
1652
  }
1653

1654
  return code;
11,101,117✔
1655
}
1656

1657
static int32_t msgToNodeListNode(STlvDecoder* pDecoder, void* pObj) {
7,570,224✔
1658
  SNodeListNode* pNode = (SNodeListNode*)pObj;
7,570,224✔
1659

1660
  int32_t code = TSDB_CODE_SUCCESS;
7,570,224✔
1661
  STlv*   pTlv = NULL;
7,570,224✔
1662
  tlvForEach(pDecoder, pTlv, code) {
22,711,732✔
1663
    switch (pTlv->type) {
15,141,508✔
1664
      case NODE_LIST_CODE_EXPR_BASE:
7,570,754✔
1665
        code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
7,570,754✔
1666
        break;
7,570,754✔
1667
      case NODE_LIST_CODE_NODE_LIST:
7,570,754✔
1668
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pNodeList);
7,570,754✔
1669
        break;
7,570,754✔
1670
      default:
×
1671
        break;
×
1672
    }
1673
  }
1674

1675
  return code;
7,571,284✔
1676
}
1677

1678
enum { TARGET_CODE_INLINE_ATTRS = 1, TARGET_CODE_EXPR };
1679

1680
static int32_t targetNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,147,483,647✔
1681
  const STargetNode* pNode = (const STargetNode*)pObj;
2,147,483,647✔
1682

1683
  int32_t code = tlvEncodeValueI64(pEncoder, pNode->dataBlockId);
2,147,483,647✔
1684
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
1685
    code = tlvEncodeValueI16(pEncoder, pNode->slotId);
2,147,483,647✔
1686
  }
1687

1688
  return code;
2,147,483,647✔
1689
}
1690

1691
static int32_t targetNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,147,483,647✔
1692
  const STargetNode* pNode = (const STargetNode*)pObj;
2,147,483,647✔
1693

1694
  int32_t code = tlvEncodeObj(pEncoder, TARGET_CODE_INLINE_ATTRS, targetNodeInlineToMsg, pNode);
2,147,483,647✔
1695
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
1696
    code = tlvEncodeObj(pEncoder, TARGET_CODE_EXPR, nodeToMsg, pNode->pExpr);
2,147,483,647✔
1697
  }
1698

1699
  return code;
2,147,483,647✔
1700
}
1701

1702
static int32_t msgToTargetNodeInline(STlvDecoder* pDecoder, void* pObj) {
2,147,483,647✔
1703
  STargetNode* pNode = (STargetNode*)pObj;
2,147,483,647✔
1704

1705
  int32_t code = tlvDecodeValueI64(pDecoder, &pNode->dataBlockId);
2,147,483,647✔
1706
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
1707
    code = tlvDecodeValueI16(pDecoder, &pNode->slotId);
2,147,483,647✔
1708
  }
1709

1710
  return code;
2,147,483,647✔
1711
}
1712

1713
static int32_t msgToTargetNode(STlvDecoder* pDecoder, void* pObj) {
2,147,483,647✔
1714
  STargetNode* pNode = (STargetNode*)pObj;
2,147,483,647✔
1715

1716
  int32_t code = TSDB_CODE_SUCCESS;
2,147,483,647✔
1717
  STlv*   pTlv = NULL;
2,147,483,647✔
1718
  tlvForEach(pDecoder, pTlv, code) {
2,147,483,647✔
1719
    switch (pTlv->type) {
2,147,483,647✔
1720
      case TARGET_CODE_INLINE_ATTRS:
2,147,483,647✔
1721
        code = tlvDecodeObjFromTlv(pTlv, msgToTargetNodeInline, pNode);
2,147,483,647✔
1722
        break;
2,147,483,647✔
1723
      case TARGET_CODE_EXPR:
2,147,483,647✔
1724
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pExpr);
2,147,483,647✔
1725
        break;
2,147,483,647✔
1726
      default:
×
1727
        break;
×
1728
    }
1729
  }
1730

1731
  return code;
2,147,483,647✔
1732
}
1733

1734
enum { TIME_RANGE_CODE_START = 1,
1735
       TIME_RANGE_CODE_END,
1736
       TIME_RANGE_CODE_NEED_CALC };
1737

1738
static int32_t timeRangeNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
×
1739
  const STimeRangeNode* pNode = (const STimeRangeNode*)pObj;
×
1740

1741
  int32_t code = tlvEncodeObj(pEncoder, TIME_RANGE_CODE_START, nodeToMsg, pNode->pStart);
×
1742
  if (TSDB_CODE_SUCCESS == code) {
×
1743
    code = tlvEncodeObj(pEncoder, TIME_RANGE_CODE_END, nodeToMsg, pNode->pEnd);
×
1744
  }
1745
  if (TSDB_CODE_SUCCESS == code) {
×
1746
    code = tlvEncodeBool(pEncoder, TIME_RANGE_CODE_NEED_CALC, pNode->needCalc);
×
1747
  }
1748

1749
  return code;
×
1750
}
1751

1752
static int32_t msgToTimeRangeNode(STlvDecoder* pDecoder, void* pObj) {
×
1753
  STimeRangeNode* pNode = (STimeRangeNode*)pObj;
×
1754

1755
  int32_t code = TSDB_CODE_SUCCESS;
×
1756
  STlv*   pTlv = NULL;
×
1757
  tlvForEach(pDecoder, pTlv, code) {
×
1758
    switch (pTlv->type) {
×
1759
      case TIME_RANGE_CODE_START:
×
1760
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pStart);
×
1761
        break;
×
1762
      case TIME_RANGE_CODE_END:
×
1763
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pEnd);
×
1764
        break;
×
1765
      case TIME_RANGE_CODE_NEED_CALC:
×
1766
        code = tlvDecodeBool(pTlv, &pNode->needCalc);
×
1767
        break;
×
1768
      default:
×
1769
        break;
×
1770
    }
1771
  }
1772

1773
  return code;
×
1774
}
1775

1776
enum { DATA_BLOCK_DESC_CODE_INLINE_ATTRS = 1, DATA_BLOCK_DESC_CODE_SLOTS };
1777

1778
static int32_t dataBlockDescNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
1,588,555,944✔
1779
  const SDataBlockDescNode* pNode = (const SDataBlockDescNode*)pObj;
1,588,555,944✔
1780

1781
  int32_t code = tlvEncodeValueI64(pEncoder, pNode->dataBlockId);
1,588,555,944✔
1782
  if (TSDB_CODE_SUCCESS == code) {
1,587,249,199✔
1783
    code = tlvEncodeValueI32(pEncoder, pNode->totalRowSize);
1,587,268,518✔
1784
  }
1785
  if (TSDB_CODE_SUCCESS == code) {
1,589,166,775✔
1786
    code = tlvEncodeValueI32(pEncoder, pNode->outputRowSize);
1,589,178,334✔
1787
  }
1788
  if (TSDB_CODE_SUCCESS == code) {
1,589,284,808✔
1789
    code = tlvEncodeValueU8(pEncoder, pNode->precision);
1,589,301,339✔
1790
  }
1791

1792
  return code;
1,589,391,159✔
1793
}
1794

1795
static int32_t dataBlockDescNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
1,588,284,197✔
1796
  const SDataBlockDescNode* pNode = (const SDataBlockDescNode*)pObj;
1,588,284,197✔
1797

1798
  int32_t code = tlvEncodeObj(pEncoder, DATA_BLOCK_DESC_CODE_INLINE_ATTRS, dataBlockDescNodeInlineToMsg, pNode);
1,588,284,197✔
1799
  if (TSDB_CODE_SUCCESS == code) {
1,589,397,774✔
1800
    code = tlvEncodeObj(pEncoder, DATA_BLOCK_DESC_CODE_SLOTS, nodeListToMsg, pNode->pSlots);
1,589,405,439✔
1801
  }
1802

1803
  return code;
1,589,524,140✔
1804
}
1805

1806
static int32_t msgToDataBlockDescNodeInline(STlvDecoder* pDecoder, void* pObj) {
1,127,435,061✔
1807
  SDataBlockDescNode* pNode = (SDataBlockDescNode*)pObj;
1,127,435,061✔
1808

1809
  int32_t code = tlvDecodeValueI64(pDecoder, &pNode->dataBlockId);
1,127,435,061✔
1810
  if (TSDB_CODE_SUCCESS == code) {
1,127,326,070✔
1811
    code = tlvDecodeValueI32(pDecoder, &pNode->totalRowSize);
1,127,328,361✔
1812
  }
1813
  if (TSDB_CODE_SUCCESS == code) {
1,127,413,590✔
1814
    code = tlvDecodeValueI32(pDecoder, &pNode->outputRowSize);
1,127,413,590✔
1815
  }
1816
  if (TSDB_CODE_SUCCESS == code) {
1,127,437,955✔
1817
    code = tlvDecodeValueU8(pDecoder, &pNode->precision);
1,127,437,955✔
1818
  }
1819

1820
  return code;
1,127,410,722✔
1821
}
1822

1823
static int32_t msgToDataBlockDescNode(STlvDecoder* pDecoder, void* pObj) {
1,127,424,010✔
1824
  SDataBlockDescNode* pNode = (SDataBlockDescNode*)pObj;
1,127,424,010✔
1825

1826
  int32_t code = TSDB_CODE_SUCCESS;
1,127,424,010✔
1827
  STlv*   pTlv = NULL;
1,127,424,010✔
1828
  tlvForEach(pDecoder, pTlv, code) {
2,147,483,647✔
1829
    switch (pTlv->type) {
2,147,483,647✔
1830
      case DATA_BLOCK_DESC_CODE_INLINE_ATTRS:
1,127,468,273✔
1831
        code = tlvDecodeObjFromTlv(pTlv, msgToDataBlockDescNodeInline, pNode);
1,127,468,273✔
1832
        break;
1,127,411,618✔
1833
      case DATA_BLOCK_DESC_CODE_SLOTS:
1,127,465,026✔
1834
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pSlots);
1,127,465,026✔
1835
        break;
1,127,430,420✔
1836
      default:
×
1837
        break;
×
1838
    }
1839
  }
1840

1841
  return code;
1,127,527,096✔
1842
}
1843

1844
enum { SLOT_DESC_CODE_INLINE_ATTRS = 1 };
1845

1846
static int32_t slotDescNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,147,483,647✔
1847
  const SSlotDescNode* pNode = (const SSlotDescNode*)pObj;
2,147,483,647✔
1848

1849
  int32_t code = tlvEncodeValueI16(pEncoder, pNode->slotId);
2,147,483,647✔
1850
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
1851
    code = dataTypeInlineToMsg(&pNode->dataType, pEncoder);
2,147,483,647✔
1852
  }
1853
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
1854
    code = tlvEncodeValueBool(pEncoder, pNode->reserve);
2,147,483,647✔
1855
  }
1856
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
1857
    code = tlvEncodeValueBool(pEncoder, pNode->output);
2,147,483,647✔
1858
  }
1859
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
1860
    code = tlvEncodeValueBool(pEncoder, pNode->tag);
2,147,483,647✔
1861
  }
1862

1863
  return code;
2,147,483,647✔
1864
}
1865

1866
static int32_t slotDescNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,147,483,647✔
1867
  return tlvEncodeObj(pEncoder, SLOT_DESC_CODE_INLINE_ATTRS, slotDescNodeInlineToMsg, pObj);
2,147,483,647✔
1868
}
1869

1870
static int32_t msgToSlotDescNodeInline(STlvDecoder* pDecoder, void* pObj) {
2,147,483,647✔
1871
  SSlotDescNode* pNode = (SSlotDescNode*)pObj;
2,147,483,647✔
1872

1873
  int32_t code = tlvDecodeValueI16(pDecoder, &pNode->slotId);
2,147,483,647✔
1874
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
1875
    code = msgToDataTypeInline(pDecoder, &pNode->dataType);
2,147,483,647✔
1876
  }
1877
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
1878
    code = tlvDecodeValueBool(pDecoder, &pNode->reserve);
2,147,483,647✔
1879
  }
1880
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
1881
    code = tlvDecodeValueBool(pDecoder, &pNode->output);
2,147,483,647✔
1882
  }
1883
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
1884
    code = tlvDecodeValueBool(pDecoder, &pNode->tag);
2,147,483,647✔
1885
  }
1886

1887
  return code;
2,147,483,647✔
1888
}
1889

1890
static int32_t msgToSlotDescNode(STlvDecoder* pDecoder, void* pObj) {
2,147,483,647✔
1891
  SSlotDescNode* pNode = (SSlotDescNode*)pObj;
2,147,483,647✔
1892

1893
  int32_t code = TSDB_CODE_SUCCESS;
2,147,483,647✔
1894
  STlv*   pTlv = NULL;
2,147,483,647✔
1895
  tlvForEach(pDecoder, pTlv, code) {
2,147,483,647✔
1896
    switch (pTlv->type) {
2,147,483,647✔
1897
      case SLOT_DESC_CODE_INLINE_ATTRS:
2,147,483,647✔
1898
        code = tlvDecodeObjFromTlv(pTlv, msgToSlotDescNodeInline, pNode);
2,147,483,647✔
1899
        break;
2,147,483,647✔
1900
      default:
×
1901
        break;
×
1902
    }
1903
  }
1904

1905
  return code;
2,147,483,647✔
1906
}
1907

1908
enum { EP_CODE_FQDN = 1, EP_CODE_port };
1909

1910
static int32_t epInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
680,174,488✔
1911
  const SEp* pNode = (const SEp*)pObj;
680,174,488✔
1912

1913
  int32_t code = tlvEncodeValueCStr(pEncoder, pNode->fqdn);
680,174,488✔
1914
  if (TSDB_CODE_SUCCESS == code) {
680,396,077✔
1915
    code = tlvEncodeValueU16(pEncoder, pNode->port);
680,398,757✔
1916
  }
1917

1918
  return code;
680,156,283✔
1919
}
1920

1921
static int32_t epToMsg(const void* pObj, STlvEncoder* pEncoder) {
35,955,077✔
1922
  const SEp* pNode = (const SEp*)pObj;
35,955,077✔
1923

1924
  int32_t code = tlvEncodeCStr(pEncoder, EP_CODE_FQDN, pNode->fqdn);
35,955,077✔
1925
  if (TSDB_CODE_SUCCESS == code) {
35,995,662✔
1926
    code = tlvEncodeU16(pEncoder, EP_CODE_port, pNode->port);
35,995,662✔
1927
  }
1928

1929
  return code;
35,992,784✔
1930
}
1931

1932
static int32_t msgToEpInline(STlvDecoder* pDecoder, void* pObj) {
483,255,736✔
1933
  SEp* pNode = (SEp*)pObj;
483,255,736✔
1934

1935
  int32_t code = tlvDecodeValueCStr(pDecoder, pNode->fqdn);
483,255,736✔
1936
  if (TSDB_CODE_SUCCESS == code) {
483,297,535✔
1937
    code = tlvDecodeValueU16(pDecoder, &pNode->port);
483,296,625✔
1938
  }
1939

1940
  return code;
483,276,132✔
1941
}
1942

1943
static int32_t msgToEp(STlvDecoder* pDecoder, void* pObj) {
19,005,446✔
1944
  SEp* pNode = (SEp*)pObj;
19,005,446✔
1945

1946
  int32_t code = TSDB_CODE_SUCCESS;
19,005,446✔
1947
  STlv*   pTlv = NULL;
19,005,446✔
1948
  tlvForEach(pDecoder, pTlv, code) {
57,013,556✔
1949
    switch (pTlv->type) {
38,009,840✔
1950
      case EP_CODE_FQDN:
19,004,920✔
1951
        code = tlvDecodeCStr(pTlv, pNode->fqdn, sizeof(pNode->fqdn));
19,004,920✔
1952
        break;
19,003,792✔
1953
      case EP_CODE_port:
19,004,920✔
1954
        code = tlvDecodeU16(pTlv, &pNode->port);
19,004,920✔
1955
        break;
19,004,844✔
1956
      default:
×
1957
        break;
×
1958
    }
1959
  }
1960

1961
  return code;
19,005,370✔
1962
}
1963

1964
enum { EP_SET_CODE_IN_USE = 1, EP_SET_CODE_NUM_OF_EPS, EP_SET_CODE_EPS };
1965

1966
static int32_t epSetInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
752,949,500✔
1967
  const SEpSet* pNode = (const SEpSet*)pObj;
752,949,500✔
1968

1969
  int32_t code = tlvEncodeValueI8(pEncoder, pNode->inUse);
752,949,500✔
1970
  if (TSDB_CODE_SUCCESS == code) {
753,044,478✔
1971
    code = tlvEncodeValueArray(pEncoder, epInlineToMsg, pNode->eps, sizeof(SEp), pNode->numOfEps);
753,064,156✔
1972
  }
1973

1974
  return code;
752,864,745✔
1975
}
1976

1977
static int32_t epSetToMsg(const void* pObj, STlvEncoder* pEncoder) {
35,600,801✔
1978
  const SEpSet* pNode = (const SEpSet*)pObj;
35,600,801✔
1979

1980
  int32_t code = tlvEncodeI8(pEncoder, EP_SET_CODE_IN_USE, pNode->inUse);
35,600,801✔
1981
  if (TSDB_CODE_SUCCESS == code) {
35,629,422✔
1982
    code = tlvEncodeI8(pEncoder, EP_SET_CODE_NUM_OF_EPS, pNode->numOfEps);
35,628,936✔
1983
  }
1984
  if (TSDB_CODE_SUCCESS == code) {
35,628,042✔
1985
    code = tlvEncodeObjArray(pEncoder, EP_SET_CODE_EPS, epToMsg, pNode->eps, sizeof(SEp), pNode->numOfEps);
35,628,042✔
1986
  }
1987

1988
  return code;
35,579,805✔
1989
}
1990

1991
static int32_t msgToEpSetInline(STlvDecoder* pDecoder, void* pObj) {
538,476,861✔
1992
  SEpSet* pNode = (SEpSet*)pObj;
538,476,861✔
1993

1994
  int32_t code = tlvDecodeValueI8(pDecoder, &pNode->inUse);
538,476,861✔
1995
  if (TSDB_CODE_SUCCESS == code) {
538,509,039✔
1996
    int32_t numOfEps = 0;
538,508,501✔
1997
    code = tlvDecodeValueArray(pDecoder, msgToEpInline, pNode->eps, sizeof(SEp), &numOfEps);
538,509,113✔
1998
    pNode->numOfEps = numOfEps;
538,493,142✔
1999
  }
2000

2001
  return code;
538,496,256✔
2002
}
2003

2004
static int32_t msgToEpSet(STlvDecoder* pDecoder, void* pObj) {
18,675,831✔
2005
  SEpSet* pNode = (SEpSet*)pObj;
18,675,831✔
2006

2007
  int32_t code = TSDB_CODE_SUCCESS;
18,675,831✔
2008
  STlv*   pTlv = NULL;
18,675,831✔
2009
  tlvForEach(pDecoder, pTlv, code) {
74,700,618✔
2010
    switch (pTlv->type) {
56,025,915✔
2011
      case EP_SET_CODE_IN_USE:
18,674,779✔
2012
        code = tlvDecodeI8(pTlv, &pNode->inUse);
18,674,779✔
2013
        break;
18,674,253✔
2014
      case EP_SET_CODE_NUM_OF_EPS:
18,675,305✔
2015
        code = tlvDecodeI8(pTlv, &pNode->numOfEps);
18,675,305✔
2016
        break;
18,675,305✔
2017
      case EP_SET_CODE_EPS:
18,676,357✔
2018
        code = tlvDecodeObjArrayFromTlv(pTlv, msgToEp, pNode->eps, sizeof(SEp));
18,676,357✔
2019
        break;
18,675,229✔
2020
      default:
×
2021
        break;
×
2022
    }
2023
  }
2024

2025
  return code;
18,674,703✔
2026
}
2027

2028
enum { QUERY_NODE_ADDR_CODE_NODE_ID = 1, QUERY_NODE_ADDR_CODE_EP_SET };
2029

2030
static int32_t queryNodeAddrInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
752,950,111✔
2031
  const SQueryNodeAddr* pNode = (const SQueryNodeAddr*)pObj;
752,950,111✔
2032

2033
  int32_t code = tlvEncodeValueI32(pEncoder, pNode->nodeId);
752,950,111✔
2034
  if (TSDB_CODE_SUCCESS == code) {
752,949,140✔
2035
    code = epSetInlineToMsg(&pNode->epSet, pEncoder);
752,954,521✔
2036
  }
2037

2038
  return code;
752,861,151✔
2039
}
2040

2041
static int32_t queryNodeAddrToMsg(const void* pObj, STlvEncoder* pEncoder) {
×
2042
  const SQueryNodeAddr* pNode = (const SQueryNodeAddr*)pObj;
×
2043

2044
  int32_t code = tlvEncodeI32(pEncoder, QUERY_NODE_ADDR_CODE_NODE_ID, pNode->nodeId);
×
2045
  if (TSDB_CODE_SUCCESS == code) {
×
2046
    code = tlvEncodeObj(pEncoder, QUERY_NODE_ADDR_CODE_EP_SET, epSetToMsg, &pNode->epSet);
×
2047
  }
2048

2049
  return code;
×
2050
}
2051

2052
static int32_t msgToQueryNodeAddrInline(STlvDecoder* pDecoder, void* pObj) {
538,468,707✔
2053
  SQueryNodeAddr* pNode = (SQueryNodeAddr*)pObj;
538,468,707✔
2054

2055
  int32_t code = tlvDecodeValueI32(pDecoder, &pNode->nodeId);
538,468,707✔
2056
  if (TSDB_CODE_SUCCESS == code) {
538,508,903✔
2057
    code = msgToEpSetInline(pDecoder, &pNode->epSet);
538,508,903✔
2058
  }
2059

2060
  return code;
538,493,201✔
2061
}
2062

2063
static int32_t msgToQueryNodeAddr(STlvDecoder* pDecoder, void* pObj) {
×
2064
  SQueryNodeAddr* pNode = (SQueryNodeAddr*)pObj;
×
2065

2066
  int32_t code = TSDB_CODE_SUCCESS;
×
2067
  STlv*   pTlv = NULL;
×
2068
  tlvForEach(pDecoder, pTlv, code) {
×
2069
    switch (pTlv->type) {
×
2070
      case QUERY_NODE_ADDR_CODE_NODE_ID:
×
2071
        code = tlvDecodeI32(pTlv, &pNode->nodeId);
×
2072
        break;
×
2073
      case QUERY_NODE_ADDR_CODE_EP_SET:
×
2074
        code = tlvDecodeObjFromTlv(pTlv, msgToEpSet, &pNode->epSet);
×
2075
        break;
×
2076
    }
2077
  }
2078

2079
  return code;
×
2080
}
2081

2082
enum { DOWNSTREAM_SOURCE_CODE_INLINE_ATTRS = 1 };
2083

2084
static int32_t downstreamSourceNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
241,845,026✔
2085
  const SDownstreamSourceNode* pNode = (const SDownstreamSourceNode*)pObj;
241,845,026✔
2086

2087
  int32_t code = queryNodeAddrInlineToMsg(&pNode->addr, pEncoder);
241,845,026✔
2088
  if (TSDB_CODE_SUCCESS == code) {
241,845,312✔
2089
    code = tlvEncodeValueU64(pEncoder, pNode->taskId);
241,843,719✔
2090
  }
2091
  if (TSDB_CODE_SUCCESS == code) {
241,846,003✔
2092
    code = tlvEncodeValueU64(pEncoder, pNode->sId);
241,846,003✔
2093
  }
2094
  if (TSDB_CODE_SUCCESS == code) {
241,845,285✔
2095
    code = tlvEncodeValueI32(pEncoder, pNode->execId);
241,845,285✔
2096
  }
2097
  if (TSDB_CODE_SUCCESS == code) {
241,846,820✔
2098
    code = tlvEncodeValueI32(pEncoder, pNode->fetchMsgType);
241,846,396✔
2099
  }
2100
  if (TSDB_CODE_SUCCESS == code) {
241,847,251✔
2101
    code = tlvEncodeValueU64(pEncoder, pNode->clientId);
241,846,827✔
2102
  }
2103

2104
  return code;
241,846,201✔
2105
}
2106

2107
static int32_t downstreamSourceNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
241,846,009✔
2108
  return tlvEncodeObj(pEncoder, DOWNSTREAM_SOURCE_CODE_INLINE_ATTRS, downstreamSourceNodeInlineToMsg, pObj);
241,846,009✔
2109
}
2110

2111
static int32_t msgToDownstreamSourceNodeInlineToMsg(STlvDecoder* pDecoder, void* pObj) {
179,581,742✔
2112
  SDownstreamSourceNode* pNode = (SDownstreamSourceNode*)pObj;
179,581,742✔
2113

2114
  int32_t code = msgToQueryNodeAddrInline(pDecoder, &pNode->addr);
179,581,742✔
2115
  if (TSDB_CODE_SUCCESS == code) {
179,582,280✔
2116
    code = tlvDecodeValueU64(pDecoder, &pNode->taskId);
179,581,742✔
2117
  }
2118
  if (TSDB_CODE_SUCCESS == code) {
179,581,742✔
2119
    code = tlvDecodeValueU64(pDecoder, &pNode->sId);
179,581,742✔
2120
  }
2121
  if (TSDB_CODE_SUCCESS == code) {
179,581,372✔
2122
    code = tlvDecodeValueI32(pDecoder, &pNode->execId);
179,581,372✔
2123
  }
2124
  if (TSDB_CODE_SUCCESS == code) {
179,582,280✔
2125
    code = tlvDecodeValueI32(pDecoder, &pNode->fetchMsgType);
179,582,280✔
2126
  }
2127
  if (TSDB_CODE_SUCCESS == code && !tlvDecodeEnd(pDecoder)) {
179,582,280✔
2128
    code = tlvDecodeValueU64(pDecoder, &pNode->clientId);
179,581,742✔
2129
  }
2130

2131
  return code;
179,582,280✔
2132
}
2133

2134
static int32_t msgToDownstreamSourceNode(STlvDecoder* pDecoder, void* pObj) {
179,581,742✔
2135
  SDownstreamSourceNode* pNode = (SDownstreamSourceNode*)pObj;
179,581,742✔
2136

2137
  int32_t code = TSDB_CODE_SUCCESS;
179,581,742✔
2138
  STlv*   pTlv = NULL;
179,581,742✔
2139
  tlvForEach(pDecoder, pTlv, code) {
359,163,644✔
2140
    switch (pTlv->type) {
179,582,280✔
2141
      case DOWNSTREAM_SOURCE_CODE_INLINE_ATTRS:
179,582,280✔
2142
        code = tlvDecodeObjFromTlv(pTlv, msgToDownstreamSourceNodeInlineToMsg, pNode);
179,582,280✔
2143
        break;
179,582,280✔
2144
      default:
×
2145
        break;
×
2146
    }
2147
  }
2148

2149
  return code;
179,582,313✔
2150
}
2151

2152
enum { WHEN_THEN_CODE_EXPR_BASE = 1, WHEN_THEN_CODE_WHEN, WHEN_THEN_CODE_THEN };
2153

2154
static int32_t whenThenNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
7,159,302✔
2155
  const SWhenThenNode* pNode = (const SWhenThenNode*)pObj;
7,159,302✔
2156

2157
  int32_t code = tlvEncodeObj(pEncoder, WHEN_THEN_CODE_EXPR_BASE, exprNodeToMsg, pNode);
7,159,302✔
2158
  if (TSDB_CODE_SUCCESS == code) {
7,160,362✔
2159
    code = tlvEncodeObj(pEncoder, WHEN_THEN_CODE_WHEN, nodeToMsg, pNode->pWhen);
7,160,362✔
2160
  }
2161
  if (TSDB_CODE_SUCCESS == code) {
7,160,446✔
2162
    code = tlvEncodeObj(pEncoder, WHEN_THEN_CODE_THEN, nodeToMsg, pNode->pThen);
7,160,446✔
2163
  }
2164

2165
  return code;
7,160,446✔
2166
}
2167

2168
static int32_t msgToWhenThenNode(STlvDecoder* pDecoder, void* pObj) {
1,621,401✔
2169
  SWhenThenNode* pNode = (SWhenThenNode*)pObj;
1,621,401✔
2170

2171
  int32_t code = TSDB_CODE_SUCCESS;
1,621,401✔
2172
  STlv*   pTlv = NULL;
1,621,401✔
2173
  tlvForEach(pDecoder, pTlv, code) {
6,485,604✔
2174
    switch (pTlv->type) {
4,864,203✔
2175
      case WHEN_THEN_CODE_EXPR_BASE:
1,621,401✔
2176
        code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
1,621,401✔
2177
        break;
1,621,401✔
2178
      case WHEN_THEN_CODE_WHEN:
1,621,401✔
2179
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pWhen);
1,621,401✔
2180
        break;
1,621,401✔
2181
      case WHEN_THEN_CODE_THEN:
1,621,401✔
2182
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pThen);
1,621,401✔
2183
        break;
1,621,401✔
2184
      default:
×
2185
        break;
×
2186
    }
2187
  }
2188

2189
  return code;
1,621,401✔
2190
}
2191

2192
enum { CASE_WHEN_CODE_EXPR_BASE = 1, CASE_WHEN_CODE_CASE, CASE_WHEN_CODE_ELSE, CASE_WHEN_CODE_WHEN_THEN_LIST };
2193

2194
static int32_t caseWhenNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
6,977,767✔
2195
  const SCaseWhenNode* pNode = (const SCaseWhenNode*)pObj;
6,977,767✔
2196

2197
  int32_t code = tlvEncodeObj(pEncoder, CASE_WHEN_CODE_EXPR_BASE, exprNodeToMsg, pNode);
6,977,767✔
2198
  if (TSDB_CODE_SUCCESS == code) {
6,978,443✔
2199
    code = tlvEncodeObj(pEncoder, CASE_WHEN_CODE_CASE, nodeToMsg, pNode->pCase);
6,978,443✔
2200
  }
2201
  if (TSDB_CODE_SUCCESS == code) {
6,977,913✔
2202
    code = tlvEncodeObj(pEncoder, CASE_WHEN_CODE_ELSE, nodeToMsg, pNode->pElse);
6,977,820✔
2203
  }
2204
  if (TSDB_CODE_SUCCESS == code) {
6,978,461✔
2205
    code = tlvEncodeObj(pEncoder, CASE_WHEN_CODE_WHEN_THEN_LIST, nodeListToMsg, pNode->pWhenThenList);
6,978,368✔
2206
  }
2207

2208
  return code;
6,978,368✔
2209
}
2210

2211
static int32_t msgToCaseWhenNode(STlvDecoder* pDecoder, void* pObj) {
1,440,469✔
2212
  SCaseWhenNode* pNode = (SCaseWhenNode*)pObj;
1,440,469✔
2213

2214
  int32_t code = TSDB_CODE_SUCCESS;
1,440,469✔
2215
  STlv*   pTlv = NULL;
1,440,469✔
2216
  tlvForEach(pDecoder, pTlv, code) {
5,842,950✔
2217
    switch (pTlv->type) {
4,402,481✔
2218
      case CASE_WHEN_CODE_EXPR_BASE:
1,440,469✔
2219
        code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
1,440,469✔
2220
        break;
1,440,469✔
2221
      case CASE_WHEN_CODE_CASE:
140,794✔
2222
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pCase);
140,794✔
2223
        break;
140,794✔
2224
      case CASE_WHEN_CODE_ELSE:
1,380,749✔
2225
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pElse);
1,380,749✔
2226
        break;
1,380,749✔
2227
      case CASE_WHEN_CODE_WHEN_THEN_LIST:
1,440,469✔
2228
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pWhenThenList);
1,440,469✔
2229
        break;
1,440,469✔
2230
      default:
×
2231
        break;
×
2232
    }
2233
  }
2234

2235
  return code;
1,440,469✔
2236
}
2237

2238
enum { WINDOW_OFFSET_CODE_START_OFFSET = 1, WINDOW_OFFSET_CODE_END_OFFSET };
2239

2240
static int32_t windowOffsetNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
325,560✔
2241
  const SWindowOffsetNode* pNode = (const SWindowOffsetNode*)pObj;
325,560✔
2242

2243
  int32_t code = tlvEncodeObj(pEncoder, WINDOW_OFFSET_CODE_START_OFFSET, nodeToMsg, pNode->pStartOffset);
325,560✔
2244
  if (TSDB_CODE_SUCCESS == code) {
325,560✔
2245
    code = tlvEncodeObj(pEncoder, WINDOW_OFFSET_CODE_END_OFFSET, nodeToMsg, pNode->pEndOffset);
325,560✔
2246
  }
2247

2248
  return code;
325,560✔
2249
}
2250

2251
static int32_t msgToWindowOffsetNode(STlvDecoder* pDecoder, void* pObj) {
327,012✔
2252
  SWindowOffsetNode* pNode = (SWindowOffsetNode*)pObj;
327,012✔
2253

2254
  int32_t code = TSDB_CODE_SUCCESS;
327,012✔
2255
  STlv*   pTlv = NULL;
327,012✔
2256
  tlvForEach(pDecoder, pTlv, code) {
981,036✔
2257
    switch (pTlv->type) {
654,024✔
2258
      case WINDOW_OFFSET_CODE_START_OFFSET:
327,012✔
2259
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pStartOffset);
327,012✔
2260
        break;
327,012✔
2261
      case WINDOW_OFFSET_CODE_END_OFFSET:
327,012✔
2262
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pEndOffset);
327,012✔
2263
        break;
327,012✔
2264
      default:
×
2265
        break;
×
2266
    }
2267
  }
2268

2269
  return code;
327,012✔
2270
}
2271

2272

2273
enum {
2274
  PHY_NODE_CODE_OUTPUT_DESC = 1,
2275
  PHY_NODE_CODE_CONDITIONS,
2276
  PHY_NODE_CODE_CHILDREN,
2277
  PHY_NODE_CODE_LIMIT,
2278
  PHY_NODE_CODE_SLIMIT,
2279
  PHY_NODE_CODE_INPUT_TS_ORDER,
2280
  PHY_NODE_CODE_OUTPUT_TS_ORDER,
2281
  PHY_NODE_CODE_DYNAMIC_OP,
2282
  PHY_NODE_CODE_FORCE_NONBLOCKING_OPTR
2283
};
2284

2285
static int32_t physiNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
1,077,495,522✔
2286
  const SPhysiNode* pNode = (const SPhysiNode*)pObj;
1,077,495,522✔
2287

2288
  int32_t code = tlvEncodeObj(pEncoder, PHY_NODE_CODE_OUTPUT_DESC, nodeToMsg, pNode->pOutputDataBlockDesc);
1,077,495,522✔
2289
  if (TSDB_CODE_SUCCESS == code) {
1,078,300,694✔
2290
    code = tlvEncodeObj(pEncoder, PHY_NODE_CODE_CONDITIONS, nodeToMsg, pNode->pConditions);
1,078,156,128✔
2291
  }
2292
  if (TSDB_CODE_SUCCESS == code) {
1,078,215,523✔
2293
    code = tlvEncodeObj(pEncoder, PHY_NODE_CODE_CHILDREN, nodeListToMsg, pNode->pChildren);
1,078,225,145✔
2294
  }
2295
  if (TSDB_CODE_SUCCESS == code) {
1,077,967,712✔
2296
    code = tlvEncodeObj(pEncoder, PHY_NODE_CODE_LIMIT, nodeToMsg, pNode->pLimit);
1,077,987,438✔
2297
  }
2298
  if (TSDB_CODE_SUCCESS == code) {
1,077,701,752✔
2299
    code = tlvEncodeObj(pEncoder, PHY_NODE_CODE_SLIMIT, nodeToMsg, pNode->pSlimit);
1,077,701,062✔
2300
  }
2301
  if (TSDB_CODE_SUCCESS == code) {
1,077,489,595✔
2302
    code = tlvEncodeEnum(pEncoder, PHY_NODE_CODE_INPUT_TS_ORDER, pNode->inputTsOrder);
1,077,497,579✔
2303
  }
2304
  if (TSDB_CODE_SUCCESS == code) {
1,077,259,277✔
2305
    code = tlvEncodeEnum(pEncoder, PHY_NODE_CODE_OUTPUT_TS_ORDER, pNode->outputTsOrder);
1,077,269,308✔
2306
  }
2307
  if (TSDB_CODE_SUCCESS == code) {
1,078,284,181✔
2308
    code = tlvEncodeBool(pEncoder, PHY_NODE_CODE_DYNAMIC_OP, pNode->dynamicOp);
1,078,297,115✔
2309
  }
2310
  if (TSDB_CODE_SUCCESS == code) { 
1,078,342,124✔
2311
    code = tlvEncodeBool(pEncoder, PHY_NODE_CODE_FORCE_NONBLOCKING_OPTR, pNode->forceCreateNonBlockingOptr);
1,078,329,005✔
2312
  }
2313

2314
  return code;
1,078,398,947✔
2315
}
2316

2317
static int32_t msgToPhysiNode(STlvDecoder* pDecoder, void* pObj) {
768,456,599✔
2318
  SPhysiNode* pNode = (SPhysiNode*)pObj;
768,456,599✔
2319

2320
  int32_t code = TSDB_CODE_SUCCESS;
768,456,599✔
2321
  STlv*   pTlv = NULL;
768,456,599✔
2322
  tlvForEach(pDecoder, pTlv, code) {
2,147,483,647✔
2323
    switch (pTlv->type) {
2,147,483,647✔
2324
      case PHY_NODE_CODE_OUTPUT_DESC:
768,448,018✔
2325
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pOutputDataBlockDesc);
768,448,018✔
2326
        break;
768,504,395✔
2327
      case PHY_NODE_CODE_CONDITIONS:
99,432,078✔
2328
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pConditions);
99,432,078✔
2329
        break;
99,426,880✔
2330
      case PHY_NODE_CODE_CHILDREN:
359,560,741✔
2331
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pChildren);
359,560,741✔
2332
        break;
359,562,774✔
2333
      case PHY_NODE_CODE_LIMIT:
32,068,304✔
2334
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pLimit);
32,068,304✔
2335
        break;
32,066,662✔
2336
      case PHY_NODE_CODE_SLIMIT:
2,657,159✔
2337
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pSlimit);
2,657,159✔
2338
        break;
2,657,159✔
2339
      case PHY_NODE_CODE_INPUT_TS_ORDER:
768,537,013✔
2340
        code = tlvDecodeEnum(pTlv, &pNode->inputTsOrder, sizeof(pNode->inputTsOrder));
768,537,013✔
2341
        break;
768,518,726✔
2342
      case PHY_NODE_CODE_OUTPUT_TS_ORDER:
768,559,576✔
2343
        code = tlvDecodeEnum(pTlv, &pNode->outputTsOrder, sizeof(pNode->outputTsOrder));
768,559,576✔
2344
        break;
768,558,356✔
2345
      case PHY_NODE_CODE_DYNAMIC_OP:
768,559,923✔
2346
        code = tlvDecodeBool(pTlv, &pNode->dynamicOp);
768,559,923✔
2347
        break;
768,535,251✔
2348
      case PHY_NODE_CODE_FORCE_NONBLOCKING_OPTR:
768,659,133✔
2349
        code = tlvDecodeBool(pTlv, &pNode->forceCreateNonBlockingOptr);
768,659,133✔
2350
        break;
768,561,804✔
2351
      default:
×
2352
        break;
×
2353
    }
2354
  }
2355

2356
  return code;
768,597,764✔
2357
}
2358

2359
enum {
2360
  PHY_SCAN_CODE_BASE_NODE = 1,
2361
  PHY_SCAN_CODE_SCAN_COLS,
2362
  PHY_SCAN_CODE_SCAN_PSEUDO_COLS,
2363
  PHY_SCAN_CODE_BASE_UID,
2364
  PHY_SCAN_CODE_BASE_SUID,
2365
  PHY_SCAN_CODE_BASE_TABLE_TYPE,
2366
  PHY_SCAN_CODE_BASE_TABLE_NAME,
2367
  PHY_SCAN_CODE_BASE_GROUP_ORDER_SCAN,
2368
  PHY_SCAN_CODE_BASE_VIRTUAL_STABLE_SCAN
2369
};
2370

2371
static int32_t physiScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
427,550,987✔
2372
  const SScanPhysiNode* pNode = (const SScanPhysiNode*)pObj;
427,550,987✔
2373

2374
  int32_t code = tlvEncodeObj(pEncoder, PHY_SCAN_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
427,550,987✔
2375
  if (TSDB_CODE_SUCCESS == code) {
427,954,672✔
2376
    code = tlvEncodeObj(pEncoder, PHY_SCAN_CODE_SCAN_COLS, nodeListToMsg, pNode->pScanCols);
427,961,928✔
2377
  }
2378
  if (TSDB_CODE_SUCCESS == code) {
427,942,258✔
2379
    code = tlvEncodeObj(pEncoder, PHY_SCAN_CODE_SCAN_PSEUDO_COLS, nodeListToMsg, pNode->pScanPseudoCols);
427,903,219✔
2380
  }
2381
  if (TSDB_CODE_SUCCESS == code) {
427,974,956✔
2382
    code = tlvEncodeU64(pEncoder, PHY_SCAN_CODE_BASE_UID, pNode->uid);
427,941,694✔
2383
  }
2384
  if (TSDB_CODE_SUCCESS == code) {
427,720,057✔
2385
    code = tlvEncodeU64(pEncoder, PHY_SCAN_CODE_BASE_SUID, pNode->suid);
427,688,498✔
2386
  }
2387
  if (TSDB_CODE_SUCCESS == code) {
427,985,303✔
2388
    code = tlvEncodeI8(pEncoder, PHY_SCAN_CODE_BASE_TABLE_TYPE, pNode->tableType);
427,954,300✔
2389
  }
2390
  if (TSDB_CODE_SUCCESS == code) {
428,002,046✔
2391
    code = tlvEncodeObj(pEncoder, PHY_SCAN_CODE_BASE_TABLE_NAME, nameToMsg, &pNode->tableName);
427,915,665✔
2392
  }
2393
  if (TSDB_CODE_SUCCESS == code) {
428,049,586✔
2394
    code = tlvEncodeBool(pEncoder, PHY_SCAN_CODE_BASE_GROUP_ORDER_SCAN, pNode->groupOrderScan);
427,963,674✔
2395
  }
2396
  if (TSDB_CODE_SUCCESS == code) {
428,075,395✔
2397
    code = tlvEncodeBool(pEncoder, PHY_SCAN_CODE_BASE_VIRTUAL_STABLE_SCAN, pNode->virtualStableScan);
427,990,568✔
2398
  }
2399

2400
  return code;
428,006,778✔
2401
}
2402

2403
static int32_t msgToPhysiScanNode(STlvDecoder* pDecoder, void* pObj) {
300,475,387✔
2404
  SScanPhysiNode* pNode = (SScanPhysiNode*)pObj;
300,475,387✔
2405

2406
  int32_t code = TSDB_CODE_SUCCESS;
300,475,387✔
2407
  STlv*   pTlv = NULL;
300,475,387✔
2408
  tlvForEach(pDecoder, pTlv, code) {
2,147,483,647✔
2409
    switch (pTlv->type) {
2,147,483,647✔
2410
      case PHY_SCAN_CODE_BASE_NODE:
300,461,922✔
2411
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
300,461,922✔
2412
        break;
300,514,988✔
2413
      case PHY_SCAN_CODE_SCAN_COLS:
292,563,878✔
2414
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pScanCols);
292,563,878✔
2415
        break;
292,596,461✔
2416
      case PHY_SCAN_CODE_SCAN_PSEUDO_COLS:
76,468,699✔
2417
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pScanPseudoCols);
76,468,699✔
2418
        break;
76,467,069✔
2419
      case PHY_SCAN_CODE_BASE_UID:
300,522,470✔
2420
        code = tlvDecodeU64(pTlv, &pNode->uid);
300,522,470✔
2421
        break;
300,491,651✔
2422
      case PHY_SCAN_CODE_BASE_SUID:
300,527,918✔
2423
        code = tlvDecodeU64(pTlv, &pNode->suid);
300,527,918✔
2424
        break;
300,526,065✔
2425
      case PHY_SCAN_CODE_BASE_TABLE_TYPE:
300,528,567✔
2426
        code = tlvDecodeI8(pTlv, &pNode->tableType);
300,528,567✔
2427
        break;
300,497,152✔
2428
      case PHY_SCAN_CODE_BASE_TABLE_NAME:
300,527,251✔
2429
        code = tlvDecodeObjFromTlv(pTlv, msgToName, &pNode->tableName);
300,527,251✔
2430
        break;
300,523,436✔
2431
      case PHY_SCAN_CODE_BASE_GROUP_ORDER_SCAN:
300,527,643✔
2432
        code = tlvDecodeBool(pTlv, &pNode->groupOrderScan);
300,527,643✔
2433
        break;
300,527,480✔
2434
      case PHY_SCAN_CODE_BASE_VIRTUAL_STABLE_SCAN:
300,528,273✔
2435
        code = tlvDecodeBool(pTlv, &pNode->virtualStableScan);
300,528,273✔
2436
      default:
300,525,587✔
2437
        break;
300,525,587✔
2438
    }
2439
  }
2440

2441
  return code;
300,600,151✔
2442
}
2443

2444
enum {
2445
  PHY_VIRTUAL_TABLE_SCAN_CODE_SCAN = 1,
2446
  PHY_VIRTUAL_TABLE_SCAN_CODE_GROUPTAGS,
2447
  PHY_VIRTUAL_TABLE_SCAN_CODE_GROUP_SORT,
2448
  PHY_VIRTUAL_TABLE_SCAN_CODE_ONLY_TS,
2449
  PHY_VIRTUAL_TABLE_SCAN_CODE_TARGETS,
2450
  PHY_VIRTUAL_TABLE_SCAN_CODE_TAGS,
2451
  PHY_VIRTUAL_TABLE_SCAN_CODE_SUBTABLE,
2452
  PHY_VIRTUAL_TABLE_SCAN_CODE_IGNORE_EXPIRED,
2453
  PHY_VIRTUAL_TABLE_SCAN_CODE_IGNORE_CHECK_UPDATE,
2454
};
2455

2456
static int32_t physiVirtualTableScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
4,264,891✔
2457
  const SVirtualScanPhysiNode* pNode = (const SVirtualScanPhysiNode *)pObj;
4,264,891✔
2458

2459
  int32_t code = tlvEncodeObj(pEncoder, PHY_VIRTUAL_TABLE_SCAN_CODE_SCAN, physiScanNodeToMsg, &pNode->scan);
4,264,891✔
2460

2461
  if (TSDB_CODE_SUCCESS == code) {
4,264,891✔
2462
    code = tlvEncodeObj(pEncoder, PHY_VIRTUAL_TABLE_SCAN_CODE_GROUPTAGS, nodeListToMsg, pNode->pGroupTags);
4,264,891✔
2463
  }
2464

2465
  if (TSDB_CODE_SUCCESS == code) {
4,264,891✔
2466
    code = tlvEncodeBool(pEncoder, PHY_VIRTUAL_TABLE_SCAN_CODE_GROUP_SORT, pNode->groupSort);
4,264,891✔
2467
  }
2468

2469
  if (TSDB_CODE_SUCCESS == code) {
4,264,891✔
2470
    code = tlvEncodeBool(pEncoder, PHY_VIRTUAL_TABLE_SCAN_CODE_ONLY_TS, pNode->scanAllCols);
4,264,891✔
2471
  }
2472

2473
  if (TSDB_CODE_SUCCESS == code) {
4,264,891✔
2474
    code = tlvEncodeObj(pEncoder, PHY_VIRTUAL_TABLE_SCAN_CODE_TARGETS, nodeListToMsg, pNode->pTargets);
4,264,891✔
2475
  }
2476

2477
  if (TSDB_CODE_SUCCESS == code) {
4,264,891✔
2478
    code = tlvEncodeObj(pEncoder, PHY_VIRTUAL_TABLE_SCAN_CODE_TAGS, nodeListToMsg, pNode->pTags);
4,264,891✔
2479
  }
2480

2481
  if (TSDB_CODE_SUCCESS == code) {
4,264,891✔
2482
    code = tlvEncodeObj(pEncoder, PHY_VIRTUAL_TABLE_SCAN_CODE_SUBTABLE, nodeToMsg, pNode->pSubtable);
4,264,891✔
2483
  }
2484

2485
  if (TSDB_CODE_SUCCESS == code) {
4,264,891✔
2486
    code = tlvEncodeI8(pEncoder, PHY_VIRTUAL_TABLE_SCAN_CODE_IGNORE_EXPIRED, pNode->igExpired);
4,264,891✔
2487
  }
2488

2489
  if (TSDB_CODE_SUCCESS == code) {
4,264,891✔
2490
    code = tlvEncodeI8(pEncoder, PHY_VIRTUAL_TABLE_SCAN_CODE_IGNORE_CHECK_UPDATE, pNode->igCheckUpdate);
4,264,891✔
2491
  }
2492

2493
  return code;
4,264,891✔
2494
}
2495

2496
static int32_t msgToPhysiVirtualTableScanNode(STlvDecoder* pDecoder, void* pObj) {
3,874,185✔
2497
  SVirtualScanPhysiNode* pNode = (SVirtualScanPhysiNode*)pObj;
3,874,185✔
2498

2499
  int32_t code = TSDB_CODE_SUCCESS;
3,874,185✔
2500
  STlv*   pTlv = NULL;
3,874,185✔
2501
  tlvForEach(pDecoder, pTlv, code) {
27,115,620✔
2502
    switch (pTlv->type) {
23,241,435✔
2503
      case PHY_VIRTUAL_TABLE_SCAN_CODE_SCAN:
3,874,185✔
2504
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiScanNode, &pNode->scan);
3,874,185✔
2505
        break;
3,874,185✔
2506
      case PHY_VIRTUAL_TABLE_SCAN_CODE_GROUPTAGS:
×
2507
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pGroupTags);
×
2508
        break;
×
2509
      case PHY_VIRTUAL_TABLE_SCAN_CODE_GROUP_SORT:
3,874,185✔
2510
        code = tlvDecodeBool(pTlv, &pNode->groupSort);
3,874,185✔
2511
        break;
3,874,185✔
2512
      case PHY_VIRTUAL_TABLE_SCAN_CODE_ONLY_TS:
3,874,185✔
2513
        code = tlvDecodeBool(pTlv, &pNode->scanAllCols);
3,874,185✔
2514
        break;
3,874,185✔
2515
      case PHY_VIRTUAL_TABLE_SCAN_CODE_TARGETS:
3,870,510✔
2516
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTargets);
3,870,510✔
2517
        break;
3,870,510✔
2518
      case PHY_VIRTUAL_TABLE_SCAN_CODE_TAGS:
×
2519
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTags);
×
2520
        break;
×
2521
      case PHY_VIRTUAL_TABLE_SCAN_CODE_SUBTABLE:
×
2522
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pSubtable);
×
2523
        break;
×
2524
      case PHY_VIRTUAL_TABLE_SCAN_CODE_IGNORE_EXPIRED:
3,874,185✔
2525
        code = tlvDecodeI8(pTlv, &pNode->igExpired);
3,874,185✔
2526
        break;
3,874,185✔
2527
      case PHY_VIRTUAL_TABLE_SCAN_CODE_IGNORE_CHECK_UPDATE:
3,874,185✔
2528
        code = tlvDecodeI8(pTlv, &pNode->igCheckUpdate);
3,874,185✔
2529
        break;
3,874,185✔
2530
      default:
×
2531
        break;
×
2532
    }
2533
  }
2534

2535
  return code;
3,874,185✔
2536
}
2537

2538
enum {
2539
  PHY_TAG_SCAN_CODE_SCAN = 1,
2540
  PHY_TAG_SCAN_CODE_ONLY_META_CTB_IDX
2541
};
2542

2543
static int32_t physiTagScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
14,296,048✔
2544
  const STagScanPhysiNode* pNode = (const STagScanPhysiNode*)pObj;
14,296,048✔
2545

2546
  int32_t code = tlvEncodeObj(pEncoder, PHY_TAG_SCAN_CODE_SCAN, physiScanNodeToMsg, &pNode->scan);
14,296,048✔
2547

2548
  if (TSDB_CODE_SUCCESS == code) {
14,316,891✔
2549
    code = tlvEncodeBool(pEncoder, PHY_TAG_SCAN_CODE_ONLY_META_CTB_IDX, pNode->onlyMetaCtbIdx);
14,316,363✔
2550
  }
2551
  return code;
14,317,973✔
2552
}
2553

2554
static int32_t msgToPhysiTagScanNode(STlvDecoder* pDecoder, void* pObj) {
7,983,207✔
2555
  STagScanPhysiNode* pNode = (STagScanPhysiNode*)pObj;
7,983,207✔
2556

2557
  int32_t code = TSDB_CODE_SUCCESS;
7,983,207✔
2558
  STlv*   pTlv = NULL;
7,983,207✔
2559
  tlvForEach(pDecoder, pTlv, code) {
23,951,459✔
2560
    switch (pTlv->type) {
15,967,852✔
2561
      case PHY_TAG_SCAN_CODE_SCAN:
7,983,737✔
2562
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiScanNode, &pNode->scan);
7,983,737✔
2563
        break;
7,983,607✔
2564
      case PHY_TAG_SCAN_CODE_ONLY_META_CTB_IDX:
7,984,115✔
2565
        code = tlvDecodeBool(pTlv, &pNode->onlyMetaCtbIdx);
7,984,115✔
2566
        break;
7,984,115✔
2567
      default:
×
2568
        break;
×
2569
    }
2570
  }
2571

2572
  return code;
7,983,847✔
2573
}
2574

2575
enum {
2576
  PHY_LAST_ROW_SCAN_CODE_SCAN = 1,
2577
  PHY_LAST_ROW_SCAN_CODE_GROUP_TAGS,
2578
  PHY_LAST_ROW_SCAN_CODE_GROUP_SORT,
2579
  PHY_LAST_ROW_SCAN_CODE_IGNULL,
2580
  PHY_LAST_ROW_SCAN_CODE_TARGETS,
2581
  PHY_LAST_ROW_SCAN_CODE_FUNCTYPES
2582
};
2583

2584
static int32_t physiLastRowScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
1,236,375✔
2585
  const SLastRowScanPhysiNode* pNode = (const SLastRowScanPhysiNode*)pObj;
1,236,375✔
2586

2587
  int32_t code = tlvEncodeObj(pEncoder, PHY_LAST_ROW_SCAN_CODE_SCAN, physiScanNodeToMsg, &pNode->scan);
1,236,375✔
2588
  if (TSDB_CODE_SUCCESS == code) {
1,237,575✔
2589
    code = tlvEncodeObj(pEncoder, PHY_LAST_ROW_SCAN_CODE_GROUP_TAGS, nodeListToMsg, pNode->pGroupTags);
1,237,575✔
2590
  }
2591
  if (TSDB_CODE_SUCCESS == code) {
1,237,461✔
2592
    code = tlvEncodeBool(pEncoder, PHY_LAST_ROW_SCAN_CODE_GROUP_SORT, pNode->groupSort);
1,237,463✔
2593
  }
2594
  if (TSDB_CODE_SUCCESS == code) {
1,237,538✔
2595
    code = tlvEncodeBool(pEncoder, PHY_LAST_ROW_SCAN_CODE_IGNULL, pNode->ignoreNull);
1,237,540✔
2596
  }
2597
  if (TSDB_CODE_SUCCESS == code) {
1,237,573✔
2598
    code = tlvEncodeObj(pEncoder, PHY_LAST_ROW_SCAN_CODE_TARGETS, nodeListToMsg, pNode->pTargets);
1,237,575✔
2599
  }
2600
  if (TSDB_CODE_SUCCESS == code) {
1,237,462✔
2601
    code = tlvEncodeObj(pEncoder, PHY_LAST_ROW_SCAN_CODE_FUNCTYPES, SArrayToMsg, pNode->pFuncTypes);
1,237,499✔
2602
  }
2603

2604
  return code;
1,237,502✔
2605
}
2606

2607
static int32_t msgToPhysiLastRowScanNode(STlvDecoder* pDecoder, void* pObj) {
1,232,936✔
2608
  SLastRowScanPhysiNode* pNode = (SLastRowScanPhysiNode*)pObj;
1,232,936✔
2609

2610
  int32_t code = TSDB_CODE_SUCCESS;
1,232,936✔
2611
  STlv*   pTlv = NULL;
1,232,936✔
2612
  tlvForEach(pDecoder, pTlv, code) {
6,290,152✔
2613
    switch (pTlv->type) {
5,057,216✔
2614
      case PHY_LAST_ROW_SCAN_CODE_SCAN:
1,232,936✔
2615
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiScanNode, &pNode->scan);
1,232,936✔
2616
        break;
1,232,936✔
2617
      case PHY_LAST_ROW_SCAN_CODE_GROUP_TAGS:
155,193✔
2618
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pGroupTags);
155,193✔
2619
        break;
155,193✔
2620
      case PHY_LAST_ROW_SCAN_CODE_GROUP_SORT:
1,232,936✔
2621
        code = tlvDecodeBool(pTlv, &pNode->groupSort);
1,232,936✔
2622
        break;
1,232,936✔
2623
      case PHY_LAST_ROW_SCAN_CODE_IGNULL:
1,232,936✔
2624
        code = tlvDecodeBool(pTlv, &pNode->ignoreNull);
1,232,936✔
2625
        break;
1,232,936✔
2626
      case PHY_LAST_ROW_SCAN_CODE_TARGETS:
1,203,215✔
2627
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTargets);
1,203,215✔
2628
        break;
1,203,215✔
2629
      case PHY_LAST_ROW_SCAN_CODE_FUNCTYPES:
×
2630
        code = msgToSArray(pTlv, (void**)&pNode->pFuncTypes);
×
2631
        break;
×
2632

2633
      default:
×
2634
        break;
×
2635
    }
2636
  }
2637

2638
  return code;
1,233,099✔
2639
}
2640

2641
enum {
2642
  PHY_TABLE_SCAN_CODE_SCAN = 1,
2643
  PHY_TABLE_SCAN_CODE_INLINE_ATTRS,
2644
  PHY_TABLE_SCAN_CODE_DYN_SCAN_FUNCS,
2645
  PHY_TABLE_SCAN_CODE_GROUP_TAGS,
2646
  PHY_TABLE_SCAN_CODE_TAGS,
2647
  PHY_TABLE_SCAN_CODE_SUBTABLE,
2648
  PHY_TABLE_SCAN_CODE_TIME_RANGE_EXPR,
2649
  PHY_TABLE_SCAN_CODE_EXT_SCAN_RANGE,
2650
  PHY_TABLE_SCAN_CODE_EXT_TIME_RANGE_EXPR,
2651
  PHY_TABLE_SCAN_CODE_PRIM_COND_EXPR,
2652
};
2653

2654
static int32_t physiTableScanNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
376,390,511✔
2655
  const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj;
376,390,511✔
2656

2657
  int32_t code = tlvEncodeValueU8(pEncoder, pNode->scanSeq[0]);
376,390,511✔
2658
  if (TSDB_CODE_SUCCESS == code) {
376,636,706✔
2659
    code = tlvEncodeValueU8(pEncoder, pNode->scanSeq[1]);
376,350,943✔
2660
  }
2661
  if (TSDB_CODE_SUCCESS == code) {
376,643,029✔
2662
    code = tlvEncodeValueI64(pEncoder, pNode->scanRange.skey);
376,566,928✔
2663
  }
2664
  if (TSDB_CODE_SUCCESS == code) {
376,696,895✔
2665
    code = tlvEncodeValueI64(pEncoder, pNode->scanRange.ekey);
376,625,753✔
2666
  }
2667
  if (TSDB_CODE_SUCCESS == code) {
376,682,767✔
2668
    code = tlvEncodeValueDouble(pEncoder, pNode->ratio);
376,611,769✔
2669
  }
2670
  if (TSDB_CODE_SUCCESS == code) {
376,111,991✔
2671
    code = tlvEncodeValueI32(pEncoder, pNode->dataRequired);
376,044,904✔
2672
  }
2673
  if (TSDB_CODE_SUCCESS == code) {
376,756,171✔
2674
    code = tlvEncodeValueBool(pEncoder, pNode->groupSort);
376,600,955✔
2675
  }
2676
  if (TSDB_CODE_SUCCESS == code) {
376,807,206✔
2677
    code = tlvEncodeValueI64(pEncoder, pNode->interval);
376,666,832✔
2678
  }
2679
  if (TSDB_CODE_SUCCESS == code) {
376,815,255✔
2680
    code = tlvEncodeValueI64(pEncoder, pNode->offset);
376,674,486✔
2681
  }
2682
  if (TSDB_CODE_SUCCESS == code) {
376,897,652✔
2683
    code = tlvEncodeValueI64(pEncoder, pNode->sliding);
376,757,692✔
2684
  }
2685
  if (TSDB_CODE_SUCCESS == code) {
376,850,964✔
2686
    code = tlvEncodeValueI8(pEncoder, pNode->intervalUnit);
376,650,452✔
2687
  }
2688
  if (TSDB_CODE_SUCCESS == code) {
376,944,321✔
2689
    code = tlvEncodeValueI8(pEncoder, pNode->slidingUnit);
376,752,006✔
2690
  }
2691
  if (TSDB_CODE_SUCCESS == code) {
376,897,126✔
2692
    code = tlvEncodeValueI8(pEncoder, pNode->triggerType);
376,704,643✔
2693
  }
2694
  if (TSDB_CODE_SUCCESS == code) {
376,962,494✔
2695
    code = tlvEncodeValueI64(pEncoder, pNode->watermark);
376,769,373✔
2696
  }
2697
  if (TSDB_CODE_SUCCESS == code) {
376,919,654✔
2698
    code = tlvEncodeValueI8(pEncoder, pNode->igExpired);
376,650,650✔
2699
  }
2700
  if (TSDB_CODE_SUCCESS == code) {
376,934,245✔
2701
    code = tlvEncodeValueBool(pEncoder, pNode->assignBlockUid);
376,678,298✔
2702
  }
2703
  if (TSDB_CODE_SUCCESS == code) {
376,929,548✔
2704
    code = tlvEncodeValueI8(pEncoder, pNode->igCheckUpdate);
376,675,474✔
2705
  }
2706
  if (TSDB_CODE_SUCCESS == code) {
376,914,920✔
2707
    code = tlvEncodeValueBool(pEncoder, pNode->filesetDelimited);
376,661,956✔
2708
  }
2709
  if (TSDB_CODE_SUCCESS == code) {
376,933,413✔
2710
    code = tlvEncodeValueBool(pEncoder, pNode->needCountEmptyTable);
376,575,811✔
2711
  }
2712
  if (TSDB_CODE_SUCCESS == code) {
377,120,616✔
2713
    code = tlvEncodeValueBool(pEncoder, pNode->paraTablesSort);
376,772,155✔
2714
  }
2715
  if (TSDB_CODE_SUCCESS == code) {
377,068,947✔
2716
    code = tlvEncodeValueBool(pEncoder, pNode->smallDataTsSort);
376,729,245✔
2717
  }
2718
  return code;
376,797,742✔
2719
}
2720

2721
static int32_t physiTableScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
376,497,922✔
2722
  const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj;
376,497,922✔
2723

2724
  int32_t code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_SCAN, physiScanNodeToMsg, &pNode->scan);
376,497,922✔
2725
  if (TSDB_CODE_SUCCESS == code) {
376,856,433✔
2726
    code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_INLINE_ATTRS, physiTableScanNodeInlineToMsg, pNode);
376,864,938✔
2727
  }
2728
  if (TSDB_CODE_SUCCESS == code) {
376,785,327✔
2729
    code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_EXT_SCAN_RANGE, timeWindowToMsg, pNode->pExtScanRange);
376,792,937✔
2730
  }
2731
  if (TSDB_CODE_SUCCESS == code) {
376,380,798✔
2732
    code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_DYN_SCAN_FUNCS, nodeListToMsg, pNode->pDynamicScanFuncs);
376,384,762✔
2733
  }
2734
  if (TSDB_CODE_SUCCESS == code) {
376,331,308✔
2735
    code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_GROUP_TAGS, nodeListToMsg, pNode->pGroupTags);
376,215,293✔
2736
  }
2737
  if (TSDB_CODE_SUCCESS == code) {
376,430,386✔
2738
    code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_TAGS, nodeListToMsg, pNode->pTags);
376,369,225✔
2739
  }
2740
  if (TSDB_CODE_SUCCESS == code) {
376,003,841✔
2741
    code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_SUBTABLE, nodeToMsg, pNode->pSubtable);
375,949,795✔
2742
  }
2743
  if (TSDB_CODE_SUCCESS == code) {
376,109,699✔
2744
    code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_TIME_RANGE_EXPR, nodeToMsg, pNode->pTimeRange);
376,058,826✔
2745
  }
2746
  if (TSDB_CODE_SUCCESS == code) {
375,794,819✔
2747
    code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_EXT_TIME_RANGE_EXPR, nodeToMsg, pNode->pExtTimeRange);
375,745,159✔
2748
  }
2749
  if (TSDB_CODE_SUCCESS == code) {
375,948,848✔
2750
    code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_PRIM_COND_EXPR, nodeToMsg, pNode->pPrimaryCond);
375,901,404✔
2751
  }
2752

2753
  return code;
375,615,631✔
2754
}
2755

2756
static int32_t msgToPhysiTableScanNodeInline(STlvDecoder* pDecoder, void* pObj) {
271,165,805✔
2757
  STableScanPhysiNode* pNode = (STableScanPhysiNode*)pObj;
271,165,805✔
2758

2759
  int32_t code = tlvDecodeValueU8(pDecoder, pNode->scanSeq);
271,165,805✔
2760
  if (TSDB_CODE_SUCCESS == code) {
271,198,753✔
2761
    code = tlvDecodeValueU8(pDecoder, pNode->scanSeq + 1);
271,156,540✔
2762
  }
2763
  if (TSDB_CODE_SUCCESS == code) {
271,194,452✔
2764
    code = tlvDecodeValueI64(pDecoder, &pNode->scanRange.skey);
271,194,452✔
2765
  }
2766
  if (TSDB_CODE_SUCCESS == code) {
271,173,381✔
2767
    code = tlvDecodeValueI64(pDecoder, &pNode->scanRange.ekey);
271,173,381✔
2768
  }
2769
  if (TSDB_CODE_SUCCESS == code) {
271,187,758✔
2770
    code = tlvDecodeValueDouble(pDecoder, &pNode->ratio);
271,187,758✔
2771
  }
2772
  if (TSDB_CODE_SUCCESS == code) {
271,144,349✔
2773
    code = tlvDecodeValueI32(pDecoder, &pNode->dataRequired);
271,144,349✔
2774
  }
2775
  if (TSDB_CODE_SUCCESS == code) {
271,197,802✔
2776
    code = tlvDecodeValueBool(pDecoder, &pNode->groupSort);
271,197,802✔
2777
  }
2778
  if (TSDB_CODE_SUCCESS == code) {
271,161,867✔
2779
    code = tlvDecodeValueI64(pDecoder, &pNode->interval);
271,161,867✔
2780
  }
2781
  if (TSDB_CODE_SUCCESS == code) {
271,206,309✔
2782
    code = tlvDecodeValueI64(pDecoder, &pNode->offset);
271,206,309✔
2783
  }
2784
  if (TSDB_CODE_SUCCESS == code) {
271,165,232✔
2785
    code = tlvDecodeValueI64(pDecoder, &pNode->sliding);
271,165,232✔
2786
  }
2787
  if (TSDB_CODE_SUCCESS == code) {
271,195,896✔
2788
    code = tlvDecodeValueI8(pDecoder, &pNode->intervalUnit);
271,195,896✔
2789
  }
2790
  if (TSDB_CODE_SUCCESS == code) {
271,164,874✔
2791
    code = tlvDecodeValueI8(pDecoder, &pNode->slidingUnit);
271,164,874✔
2792
  }
2793
  if (TSDB_CODE_SUCCESS == code) {
271,201,591✔
2794
    code = tlvDecodeValueI8(pDecoder, &pNode->triggerType);
271,201,591✔
2795
  }
2796
  if (TSDB_CODE_SUCCESS == code) {
271,166,476✔
2797
    code = tlvDecodeValueI64(pDecoder, &pNode->watermark);
271,166,476✔
2798
  }
2799
  if (TSDB_CODE_SUCCESS == code) {
271,205,300✔
2800
    code = tlvDecodeValueI8(pDecoder, &pNode->igExpired);
271,205,300✔
2801
  }
2802
  if (TSDB_CODE_SUCCESS == code) {
271,164,548✔
2803
    code = tlvDecodeValueBool(pDecoder, &pNode->assignBlockUid);
271,164,548✔
2804
  }
2805
  if (TSDB_CODE_SUCCESS == code) {
271,201,073✔
2806
    code = tlvDecodeValueI8(pDecoder, &pNode->igCheckUpdate);
271,201,073✔
2807
  }
2808
  if (TSDB_CODE_SUCCESS == code) {
271,168,799✔
2809
    code = tlvDecodeValueBool(pDecoder, &pNode->filesetDelimited);
271,168,799✔
2810
  }
2811
  if (TSDB_CODE_SUCCESS == code) {
271,205,016✔
2812
    code = tlvDecodeValueBool(pDecoder, &pNode->needCountEmptyTable);
271,205,016✔
2813
  }
2814
  if (TSDB_CODE_SUCCESS == code) {
271,161,103✔
2815
    code = tlvDecodeValueBool(pDecoder, &pNode->paraTablesSort);
271,161,103✔
2816
  }
2817
  if (TSDB_CODE_SUCCESS == code) {
271,202,932✔
2818
    code = tlvDecodeValueBool(pDecoder, &pNode->smallDataTsSort);
271,202,932✔
2819
  }
2820
  return code;
271,163,829✔
2821
}
2822

2823
static int32_t msgToPhysiTableScanNode(STlvDecoder* pDecoder, void* pObj) {
271,175,051✔
2824
  STableScanPhysiNode* pNode = (STableScanPhysiNode*)pObj;
271,175,051✔
2825

2826
  int32_t code = TSDB_CODE_SUCCESS;
271,175,051✔
2827
  STlv*   pTlv = NULL;
271,175,051✔
2828
  tlvForEach(pDecoder, pTlv, code) {
858,444,092✔
2829
    switch (pTlv->type) {
587,298,327✔
2830
      case PHY_TABLE_SCAN_CODE_SCAN:
271,155,741✔
2831
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiScanNode, &pNode->scan);
271,155,741✔
2832
        break;
271,193,485✔
2833
      case PHY_TABLE_SCAN_CODE_INLINE_ATTRS:
271,169,460✔
2834
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiTableScanNodeInline, pNode);
271,169,460✔
2835
        break;
271,179,384✔
2836
      case PHY_TABLE_SCAN_CODE_DYN_SCAN_FUNCS:
×
2837
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pDynamicScanFuncs);
×
2838
        break;
×
2839
      case PHY_TABLE_SCAN_CODE_GROUP_TAGS:
40,338,907✔
2840
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pGroupTags);
40,338,907✔
2841
        break;
40,330,078✔
2842
      case PHY_TABLE_SCAN_CODE_TAGS:
×
2843
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTags);
×
2844
        break;
×
2845
      case PHY_TABLE_SCAN_CODE_SUBTABLE:
×
2846
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pSubtable);
×
2847
        break;
×
2848
      case PHY_TABLE_SCAN_CODE_TIME_RANGE_EXPR:
×
2849
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTimeRange);
×
2850
        break;
×
2851
      case PHY_TABLE_SCAN_CODE_EXT_SCAN_RANGE:
3,904,148✔
2852
        pNode->pExtScanRange = taosMemoryMalloc(sizeof(*pNode->pExtScanRange));
3,904,148✔
2853
        if (NULL == pNode->pExtScanRange) {
3,904,148✔
2854
          code = terrno;
×
2855
          break;
×
2856
        }
2857
        code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, pNode->pExtScanRange);
3,904,148✔
2858
        break;
3,904,148✔
2859
      case PHY_TABLE_SCAN_CODE_EXT_TIME_RANGE_EXPR:
×
2860
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pExtTimeRange);
×
2861
        break;
×
2862
      case PHY_TABLE_SCAN_CODE_PRIM_COND_EXPR:
727,146✔
2863
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pPrimaryCond);
727,146✔
2864
        break;
648,156✔
2865
      default:
×
2866
        break;
×
2867
    }
2868
  }
2869

2870
  return code;
271,215,514✔
2871
}
2872

2873
enum {
2874
  PHY_SYSTABLE_SCAN_CODE_SCAN = 1,
2875
  PHY_SYSTABLE_SCAN_CODE_MGMT_EP_SET,
2876
  PHY_SYSTABLE_SCAN_CODE_SHOW_REWRITE,
2877
  PHY_SYSTABLE_SCAN_CODE_ACCOUNT_ID,
2878
  PHY_SYSTABLE_SCAN_CODE_SYS_INFO,
2879
  PHY_SYSTABLE_SCAN_CODE_PRIV_INFO,
2880
};
2881

2882
static int32_t physiSysTableScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
31,275,866✔
2883
  const SSystemTableScanPhysiNode* pNode = (const SSystemTableScanPhysiNode*)pObj;
31,275,866✔
2884

2885
  int32_t code = tlvEncodeObj(pEncoder, PHY_SYSTABLE_SCAN_CODE_SCAN, physiScanNodeToMsg, &pNode->scan);
31,275,866✔
2886
  if (TSDB_CODE_SUCCESS == code) {
31,300,904✔
2887
    code = tlvEncodeObj(pEncoder, PHY_SYSTABLE_SCAN_CODE_MGMT_EP_SET, epSetToMsg, &pNode->mgmtEpSet);
31,300,904✔
2888
  }
2889
  if (TSDB_CODE_SUCCESS == code) {
31,249,206✔
2890
    code = tlvEncodeBool(pEncoder, PHY_SYSTABLE_SCAN_CODE_SHOW_REWRITE, pNode->showRewrite);
31,249,206✔
2891
  }
2892
  if (TSDB_CODE_SUCCESS == code) {
31,299,421✔
2893
    code = tlvEncodeI32(pEncoder, PHY_SYSTABLE_SCAN_CODE_ACCOUNT_ID, pNode->accountId);
31,299,421✔
2894
  }
2895
  if (TSDB_CODE_SUCCESS == code) {
31,300,482✔
2896
    code = tlvEncodeBool(pEncoder, PHY_SYSTABLE_SCAN_CODE_SYS_INFO, pNode->sysInfo);
31,300,482✔
2897
  }
2898
  if (TSDB_CODE_SUCCESS == code) {
31,302,502✔
2899
    code = tlvEncodeU16(pEncoder, PHY_SYSTABLE_SCAN_CODE_PRIV_INFO, pNode->privInfo);
31,302,502✔
2900
  }
2901

2902
  return code;
31,302,421✔
2903
}
2904

2905
static int32_t msgToPhysiSysTableScanNode(STlvDecoder* pDecoder, void* pObj) {
16,222,806✔
2906
  SSystemTableScanPhysiNode* pNode = (SSystemTableScanPhysiNode*)pObj;
16,222,806✔
2907

2908
  int32_t code = TSDB_CODE_SUCCESS;
16,222,806✔
2909
  STlv*   pTlv = NULL;
16,222,806✔
2910
  tlvForEach(pDecoder, pTlv, code) {
113,562,270✔
2911
    switch (pTlv->type) {
97,340,066✔
2912
      case PHY_SYSTABLE_SCAN_CODE_SCAN:
16,221,654✔
2913
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiScanNode, &pNode->scan);
16,221,654✔
2914
        break;
16,222,906✔
2915
      case PHY_SYSTABLE_SCAN_CODE_MGMT_EP_SET:
16,222,304✔
2916
        code = tlvDecodeObjFromTlv(pTlv, msgToEpSet, &pNode->mgmtEpSet);
16,222,304✔
2917
        break;
16,222,830✔
2918
      case PHY_SYSTABLE_SCAN_CODE_SHOW_REWRITE:
16,223,432✔
2919
        code = tlvDecodeBool(pTlv, &pNode->showRewrite);
16,223,432✔
2920
        break;
16,223,432✔
2921
      case PHY_SYSTABLE_SCAN_CODE_ACCOUNT_ID:
16,223,432✔
2922
        code = tlvDecodeI32(pTlv, &pNode->accountId);
16,223,432✔
2923
        break;
16,223,432✔
2924
      case PHY_SYSTABLE_SCAN_CODE_SYS_INFO:
16,223,432✔
2925
        code = tlvDecodeBool(pTlv, &pNode->sysInfo);
16,223,432✔
2926
        break;
16,223,432✔
2927
      case PHY_SYSTABLE_SCAN_CODE_PRIV_INFO:
16,223,432✔
2928
        code = tlvDecodeU16(pTlv, &pNode->privInfo);
16,223,432✔
2929
      default:
16,223,432✔
2930
        break;
16,223,432✔
2931
    }
2932
  }
2933

2934
  return code;
16,222,622✔
2935
}
2936

2937
enum {
2938
  PHY_PROJECT_CODE_BASE_NODE = 1,
2939
  PHY_PROJECT_CODE_PROJECTIONS,
2940
  PHY_PROJECT_CODE_MERGE_DATA_BLOCK,
2941
  PHY_PROJECT_CODE_IGNORE_GROUP_ID,
2942
  PHY_PROJECT_CODE_INPUT_IGNORE_GROUP
2943
};
2944

2945
static int32_t physiProjectNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
208,675,617✔
2946
  const SProjectPhysiNode* pNode = (const SProjectPhysiNode*)pObj;
208,675,617✔
2947

2948
  int32_t code = tlvEncodeObj(pEncoder, PHY_PROJECT_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
208,675,617✔
2949
  if (TSDB_CODE_SUCCESS == code) {
208,790,570✔
2950
    code = tlvEncodeObj(pEncoder, PHY_PROJECT_CODE_PROJECTIONS, nodeListToMsg, pNode->pProjections);
208,794,414✔
2951
  }
2952
  if (TSDB_CODE_SUCCESS == code) {
208,785,859✔
2953
    code = tlvEncodeBool(pEncoder, PHY_PROJECT_CODE_MERGE_DATA_BLOCK, pNode->mergeDataBlock);
208,788,820✔
2954
  }
2955
  if (TSDB_CODE_SUCCESS == code) {
208,791,393✔
2956
    code = tlvEncodeBool(pEncoder, PHY_PROJECT_CODE_IGNORE_GROUP_ID, pNode->ignoreGroupId);
208,794,833✔
2957
  }
2958
  if (TSDB_CODE_SUCCESS == code) {
208,795,425✔
2959
    code = tlvEncodeBool(pEncoder, PHY_PROJECT_CODE_INPUT_IGNORE_GROUP, pNode->inputIgnoreGroup);
208,767,609✔
2960
  }
2961

2962
  return code;
208,779,268✔
2963
}
2964

2965
static int32_t msgToPhysiProjectNode(STlvDecoder* pDecoder, void* pObj) {
146,171,714✔
2966
  SProjectPhysiNode* pNode = (SProjectPhysiNode*)pObj;
146,171,714✔
2967

2968
  int32_t code = TSDB_CODE_SUCCESS;
146,171,714✔
2969
  STlv*   pTlv = NULL;
146,171,714✔
2970
  tlvForEach(pDecoder, pTlv, code) {
877,084,539✔
2971
    switch (pTlv->type) {
730,913,417✔
2972
      case PHY_PROJECT_CODE_BASE_NODE:
146,149,209✔
2973
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
146,149,209✔
2974
        break;
146,181,945✔
2975
      case PHY_PROJECT_CODE_PROJECTIONS:
146,181,426✔
2976
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pProjections);
146,181,426✔
2977
        break;
146,182,451✔
2978
      case PHY_PROJECT_CODE_MERGE_DATA_BLOCK:
146,182,730✔
2979
        code = tlvDecodeBool(pTlv, &pNode->mergeDataBlock);
146,182,730✔
2980
        break;
146,182,275✔
2981
      case PHY_PROJECT_CODE_IGNORE_GROUP_ID:
146,183,383✔
2982
        code = tlvDecodeBool(pTlv, &pNode->ignoreGroupId);
146,183,383✔
2983
        break;
146,183,383✔
2984
      case PHY_PROJECT_CODE_INPUT_IGNORE_GROUP:
146,212,673✔
2985
        code = tlvDecodeBool(pTlv, &pNode->inputIgnoreGroup);
146,212,673✔
2986
        break;
146,182,286✔
2987
      default:
×
2988
        break;
×
2989
    }
2990
  }
2991

2992
  return code;
146,176,878✔
2993
}
2994

2995
enum {
2996
  PHY_SORT_MERGE_JOIN_CODE_BASE_NODE = 1,
2997
  PHY_SORT_MERGE_JOIN_CODE_JOIN_TYPE,
2998
  PHY_SORT_MERGE_JOIN_CODE_SUB_TYPE,
2999
  PHY_SORT_MERGE_JOIN_CODE_WINDOW_OFFSET,
3000
  PHY_SORT_MERGE_JOIN_CODE_JOIN_LIMIT,
3001
  PHY_SORT_MERGE_JOIN_CODE_ASOF_OP,
3002
  PHY_SORT_MERGE_JOIN_CODE_LEFT_PRIM_EXPR,  
3003
  PHY_SORT_MERGE_JOIN_CODE_RIGHT_PRIM_EXPR,  
3004
  PHY_SORT_MERGE_JOIN_CODE_LEFT_PRIM_SLOT_ID,  
3005
  PHY_SORT_MERGE_JOIN_CODE_RIGHT_PRIM_SLOT_ID,
3006
  PHY_SORT_MERGE_JOIN_CODE_LEFT_EQ_COLS,  
3007
  PHY_SORT_MERGE_JOIN_CODE_RIGHT_EQ_COLS,
3008
  PHY_SORT_MERGE_JOIN_CODE_FULL_ON_CONDITIONS,
3009
  PHY_SORT_MERGE_JOIN_CODE_TARGETS,
3010
  PHY_SORT_MERGE_JOIN_CODE_COL_ON_CONDITIONS,
3011
  PHY_SORT_MERGE_JOIN_CODE_INPUT_ROW_NUM0,
3012
  PHY_SORT_MERGE_JOIN_CODE_INPUT_ROW_SIZE0,
3013
  PHY_SORT_MERGE_JOIN_CODE_INPUT_ROW_NUM1,
3014
  PHY_SORT_MERGE_JOIN_CODE_INPUT_ROW_SIZE1,
3015
  PHY_SORT_MERGE_JOIN_CODE_SEQ_WIN_GROUP,
3016
  PHY_SORT_MERGE_JOIN_CODE_GROUP_JOIN
3017
};
3018

3019
static int32_t physiMergeJoinNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
15,872,579✔
3020
  const SSortMergeJoinPhysiNode* pNode = (const SSortMergeJoinPhysiNode*)pObj;
15,872,579✔
3021

3022
  int32_t code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
15,872,579✔
3023
  if (TSDB_CODE_SUCCESS == code) {
15,872,665✔
3024
    code = tlvEncodeEnum(pEncoder, PHY_SORT_MERGE_JOIN_CODE_JOIN_TYPE, pNode->joinType);
15,872,665✔
3025
  }
3026
  if (TSDB_CODE_SUCCESS == code) {
15,872,665✔
3027
    code = tlvEncodeEnum(pEncoder, PHY_SORT_MERGE_JOIN_CODE_SUB_TYPE, pNode->subType);
15,872,665✔
3028
  }
3029
  if (TSDB_CODE_SUCCESS == code) {
15,872,665✔
3030
    code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_WINDOW_OFFSET, nodeToMsg, pNode->pWindowOffset);
15,872,665✔
3031
  }
3032
  if (TSDB_CODE_SUCCESS == code) {
15,872,665✔
3033
    code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_JOIN_LIMIT, nodeToMsg, pNode->pJLimit);
15,872,665✔
3034
  }
3035
  if (TSDB_CODE_SUCCESS == code) {
15,872,665✔
3036
    code = tlvEncodeI32(pEncoder, PHY_SORT_MERGE_JOIN_CODE_ASOF_OP, pNode->asofOpType);
15,872,665✔
3037
  }  
3038
  if (TSDB_CODE_SUCCESS == code) {
15,872,588✔
3039
    code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_LEFT_PRIM_EXPR, nodeToMsg, pNode->leftPrimExpr);
15,872,588✔
3040
  }
3041
  if (TSDB_CODE_SUCCESS == code) {
15,872,665✔
3042
    code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_RIGHT_PRIM_EXPR, nodeToMsg, pNode->rightPrimExpr);
15,872,665✔
3043
  }  
3044
  if (TSDB_CODE_SUCCESS == code) {
15,872,665✔
3045
    code = tlvEncodeI32(pEncoder, PHY_SORT_MERGE_JOIN_CODE_LEFT_PRIM_SLOT_ID, pNode->leftPrimSlotId);
15,872,665✔
3046
  }  
3047
  if (TSDB_CODE_SUCCESS == code) {
15,872,665✔
3048
    code = tlvEncodeI32(pEncoder, PHY_SORT_MERGE_JOIN_CODE_RIGHT_PRIM_SLOT_ID, pNode->rightPrimSlotId);
15,872,665✔
3049
  }  
3050
  if (TSDB_CODE_SUCCESS == code) {
15,872,160✔
3051
    code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_LEFT_EQ_COLS, nodeListToMsg, pNode->pEqLeft);
15,872,160✔
3052
  }
3053
  if (TSDB_CODE_SUCCESS == code) {
15,872,160✔
3054
    code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_RIGHT_EQ_COLS, nodeListToMsg, pNode->pEqRight);
15,872,160✔
3055
  }
3056
  if (TSDB_CODE_SUCCESS == code) {
15,871,655✔
3057
    code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_COL_ON_CONDITIONS, nodeToMsg, pNode->pColOnCond);
15,871,655✔
3058
  }
3059
  if (TSDB_CODE_SUCCESS == code) {
15,871,261✔
3060
    code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_FULL_ON_CONDITIONS, nodeToMsg, pNode->pFullOnCond);
15,871,261✔
3061
  }
3062
  if (TSDB_CODE_SUCCESS == code) {
15,871,261✔
3063
    code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_TARGETS, nodeListToMsg, pNode->pTargets);
15,871,184✔
3064
  }
3065
  if (TSDB_CODE_SUCCESS == code) {
15,872,742✔
3066
    code = tlvEncodeI64(pEncoder, PHY_SORT_MERGE_JOIN_CODE_INPUT_ROW_NUM0, pNode->inputStat[0].inputRowNum);
15,872,665✔
3067
  }
3068
  if (TSDB_CODE_SUCCESS == code) {
15,872,742✔
3069
    code = tlvEncodeI64(pEncoder, PHY_SORT_MERGE_JOIN_CODE_INPUT_ROW_NUM1, pNode->inputStat[1].inputRowNum);
15,872,665✔
3070
  }
3071
  if (TSDB_CODE_SUCCESS == code) {
15,872,656✔
3072
    code = tlvEncodeI32(pEncoder, PHY_SORT_MERGE_JOIN_CODE_INPUT_ROW_SIZE0, pNode->inputStat[0].inputRowSize);
15,872,579✔
3073
  }
3074
  if (TSDB_CODE_SUCCESS == code) {
15,872,742✔
3075
    code = tlvEncodeI32(pEncoder, PHY_SORT_MERGE_JOIN_CODE_INPUT_ROW_SIZE1, pNode->inputStat[1].inputRowSize);
15,872,579✔
3076
  }
3077
  if (TSDB_CODE_SUCCESS == code) {
15,872,828✔
3078
    code = tlvEncodeBool(pEncoder, PHY_SORT_MERGE_JOIN_CODE_SEQ_WIN_GROUP, pNode->seqWinGroup);
15,872,665✔
3079
  }
3080
  if (TSDB_CODE_SUCCESS == code) {
15,872,828✔
3081
    code = tlvEncodeBool(pEncoder, PHY_SORT_MERGE_JOIN_CODE_GROUP_JOIN, pNode->grpJoin);
15,872,665✔
3082
  }
3083
  
3084
  return code;
15,872,665✔
3085
}
3086

3087
static int32_t msgToPhysiMergeJoinNode(STlvDecoder* pDecoder, void* pObj) {
12,977,992✔
3088
  SSortMergeJoinPhysiNode* pNode = (SSortMergeJoinPhysiNode*)pObj;
12,977,992✔
3089

3090
  int32_t code = TSDB_CODE_SUCCESS;
12,977,992✔
3091
  STlv*   pTlv = NULL;
12,977,992✔
3092
  tlvForEach(pDecoder, pTlv, code) {
190,947,103✔
3093
    switch (pTlv->type) {
177,969,111✔
3094
      case PHY_SORT_MERGE_JOIN_CODE_BASE_NODE:
12,977,487✔
3095
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
12,977,487✔
3096
        break;
12,977,992✔
3097
      case PHY_SORT_MERGE_JOIN_CODE_JOIN_TYPE:
12,977,992✔
3098
        code = tlvDecodeEnum(pTlv, &pNode->joinType, sizeof(pNode->joinType));
12,977,992✔
3099
        break;
12,977,992✔
3100
      case PHY_SORT_MERGE_JOIN_CODE_SUB_TYPE:
12,977,992✔
3101
        code = tlvDecodeEnum(pTlv, &pNode->subType, sizeof(pNode->subType));
12,977,992✔
3102
        break;
12,977,992✔
3103
      case PHY_SORT_MERGE_JOIN_CODE_WINDOW_OFFSET:
327,012✔
3104
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pWindowOffset);
327,012✔
3105
        break;
327,012✔
3106
      case PHY_SORT_MERGE_JOIN_CODE_JOIN_LIMIT:
160,631✔
3107
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pJLimit);
160,631✔
3108
        break;
160,631✔
3109
      case PHY_SORT_MERGE_JOIN_CODE_ASOF_OP:
12,977,992✔
3110
        code = tlvDecodeI32(pTlv, &pNode->asofOpType);
12,977,992✔
3111
        break;
12,977,992✔
3112
      case PHY_SORT_MERGE_JOIN_CODE_LEFT_PRIM_EXPR:
311,103✔
3113
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->leftPrimExpr);
311,103✔
3114
        break;
311,103✔
3115
      case PHY_SORT_MERGE_JOIN_CODE_RIGHT_PRIM_EXPR:
275,418✔
3116
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->rightPrimExpr);
275,418✔
3117
        break;
275,418✔
3118
      case PHY_SORT_MERGE_JOIN_CODE_LEFT_PRIM_SLOT_ID:
12,977,992✔
3119
        code = tlvDecodeI32(pTlv, &pNode->leftPrimSlotId);
12,977,992✔
3120
        break;
12,977,464✔
3121
      case PHY_SORT_MERGE_JOIN_CODE_RIGHT_PRIM_SLOT_ID:
12,977,992✔
3122
        code = tlvDecodeI32(pTlv, &pNode->rightPrimSlotId);
12,977,992✔
3123
        break;
12,977,992✔
3124
      case PHY_SORT_MERGE_JOIN_CODE_LEFT_EQ_COLS:
101,539✔
3125
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pEqLeft);
101,539✔
3126
        break;
101,539✔
3127
      case PHY_SORT_MERGE_JOIN_CODE_RIGHT_EQ_COLS:
101,539✔
3128
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pEqRight);
101,539✔
3129
        break;
101,539✔
3130
      case PHY_SORT_MERGE_JOIN_CODE_COL_ON_CONDITIONS:
3,957,513✔
3131
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pColOnCond);
3,957,513✔
3132
        break;
3,957,513✔
3133
      case PHY_SORT_MERGE_JOIN_CODE_FULL_ON_CONDITIONS:
4,020,988✔
3134
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pFullOnCond);
4,020,988✔
3135
        break;
4,020,988✔
3136
      case PHY_SORT_MERGE_JOIN_CODE_TARGETS:
12,977,487✔
3137
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTargets);
12,977,487✔
3138
        break;
12,977,992✔
3139
      case PHY_SORT_MERGE_JOIN_CODE_INPUT_ROW_NUM0:
12,977,992✔
3140
        code = tlvDecodeI64(pTlv, &pNode->inputStat[0].inputRowNum);
12,977,992✔
3141
        break;
12,977,992✔
3142
      case PHY_SORT_MERGE_JOIN_CODE_INPUT_ROW_NUM1:
12,977,992✔
3143
        code = tlvDecodeI64(pTlv, &pNode->inputStat[1].inputRowNum);
12,977,992✔
3144
        break;
12,977,992✔
3145
      case PHY_SORT_MERGE_JOIN_CODE_INPUT_ROW_SIZE0:
12,977,992✔
3146
        code = tlvDecodeI32(pTlv, &pNode->inputStat[0].inputRowSize);
12,977,992✔
3147
        break;
12,977,992✔
3148
      case PHY_SORT_MERGE_JOIN_CODE_INPUT_ROW_SIZE1:
12,977,992✔
3149
        code = tlvDecodeI32(pTlv, &pNode->inputStat[1].inputRowSize);
12,977,992✔
3150
        break;
12,977,992✔
3151
      case PHY_SORT_MERGE_JOIN_CODE_SEQ_WIN_GROUP:
12,977,992✔
3152
        code = tlvDecodeBool(pTlv, &pNode->seqWinGroup);
12,977,992✔
3153
        break;
12,977,992✔
3154
      case PHY_SORT_MERGE_JOIN_CODE_GROUP_JOIN:
12,978,474✔
3155
        code = tlvDecodeBool(pTlv, &pNode->grpJoin);
12,978,474✔
3156
        break;
12,977,992✔
3157
      default:
×
3158
        break;
×
3159
    }
3160
  }
3161

3162
  return code;
12,978,497✔
3163
}
3164

3165
enum {
3166
  PHY_HASH_JOIN_CODE_BASE_NODE = 1,
3167
  PHY_HASH_JOIN_CODE_JOIN_TYPE,
3168
  PHY_HASH_JOIN_CODE_JOIN_STYPE,
3169
  PHY_HASH_JOIN_CODE_ON_LEFT_COLUMN,
3170
  PHY_HASH_JOIN_CODE_ON_RIGHT_COLUMN,
3171
  PHY_HASH_JOIN_CODE_LEFT_PRIM_EXPR,
3172
  PHY_HASH_JOIN_CODE_RIGHT_PRIM_EXPR,
3173
  PHY_HASH_JOIN_CODE_LEFT_PRIM_SLOTID,
3174
  PHY_HASH_JOIN_CODE_RIGHT_PRIM_SLOTID,
3175
  PHY_HASH_JOIN_CODE_TIME_RANGE_TARGET,
3176
  PHY_HASH_JOIN_CODE_ON_CONDITIONS,
3177
  PHY_HASH_JOIN_CODE_TARGETS,
3178
  PHY_HASH_JOIN_CODE_INPUT_ROW_NUM0,
3179
  PHY_HASH_JOIN_CODE_INPUT_ROW_SIZE0,
3180
  PHY_HASH_JOIN_CODE_INPUT_ROW_NUM1,
3181
  PHY_HASH_JOIN_CODE_INPUT_ROW_SIZE1,
3182
  PHY_HASH_JOIN_CODE_LEFT_ON_COND,
3183
  PHY_HASH_JOIN_CODE_RIGHT_ON_COND,
3184
  PHY_HASH_JOIN_CODE_TIME_RANGE_SKEY,
3185
  PHY_HASH_JOIN_CODE_TIME_RANGE_EKEY,
3186

3187
};
3188

3189
static int32_t physiHashJoinNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
1,224,398✔
3190
  const SHashJoinPhysiNode* pNode = (const SHashJoinPhysiNode*)pObj;
1,224,398✔
3191

3192
  int32_t code = tlvEncodeObj(pEncoder, PHY_HASH_JOIN_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
1,224,398✔
3193
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3194
    code = tlvEncodeEnum(pEncoder, PHY_HASH_JOIN_CODE_JOIN_TYPE, pNode->joinType);
1,224,398✔
3195
  }
3196
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3197
    code = tlvEncodeEnum(pEncoder, PHY_HASH_JOIN_CODE_JOIN_STYPE, pNode->subType);
1,224,398✔
3198
  }
3199
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3200
    code = tlvEncodeObj(pEncoder, PHY_HASH_JOIN_CODE_ON_LEFT_COLUMN, nodeListToMsg, pNode->pOnLeft);
1,224,398✔
3201
  }
3202
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3203
    code = tlvEncodeObj(pEncoder, PHY_HASH_JOIN_CODE_ON_RIGHT_COLUMN, nodeListToMsg, pNode->pOnRight);
1,224,398✔
3204
  }  
3205
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3206
    code = tlvEncodeObj(pEncoder, PHY_HASH_JOIN_CODE_LEFT_PRIM_EXPR, nodeToMsg, pNode->leftPrimExpr);
1,224,398✔
3207
  }
3208
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3209
    code = tlvEncodeObj(pEncoder, PHY_HASH_JOIN_CODE_RIGHT_PRIM_EXPR, nodeToMsg, pNode->rightPrimExpr);
1,224,398✔
3210
  }
3211
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3212
    code = tlvEncodeI32(pEncoder, PHY_HASH_JOIN_CODE_LEFT_PRIM_SLOTID, pNode->leftPrimSlotId);
1,224,398✔
3213
  }
3214
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3215
    code = tlvEncodeI32(pEncoder, PHY_HASH_JOIN_CODE_RIGHT_PRIM_SLOTID, pNode->rightPrimSlotId);
1,224,398✔
3216
  }
3217
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3218
    code = tlvEncodeI32(pEncoder, PHY_HASH_JOIN_CODE_TIME_RANGE_TARGET, pNode->timeRangeTarget);
1,224,398✔
3219
  }
3220
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3221
    code = tlvEncodeObj(pEncoder, PHY_HASH_JOIN_CODE_ON_CONDITIONS, nodeToMsg, pNode->pFullOnCond);
1,224,398✔
3222
  }
3223
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3224
    code = tlvEncodeObj(pEncoder, PHY_HASH_JOIN_CODE_TARGETS, nodeListToMsg, pNode->pTargets);
1,224,398✔
3225
  }
3226
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3227
    code = tlvEncodeI64(pEncoder, PHY_HASH_JOIN_CODE_INPUT_ROW_NUM0, pNode->inputStat[0].inputRowNum);
1,224,398✔
3228
  }
3229
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3230
    code = tlvEncodeI64(pEncoder, PHY_HASH_JOIN_CODE_INPUT_ROW_NUM1, pNode->inputStat[1].inputRowNum);
1,224,398✔
3231
  }
3232
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3233
    code = tlvEncodeI32(pEncoder, PHY_HASH_JOIN_CODE_INPUT_ROW_SIZE0, pNode->inputStat[0].inputRowSize);
1,224,398✔
3234
  }
3235
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3236
    code = tlvEncodeI32(pEncoder, PHY_HASH_JOIN_CODE_INPUT_ROW_SIZE1, pNode->inputStat[1].inputRowSize);
1,224,398✔
3237
  }
3238
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3239
    code = tlvEncodeObj(pEncoder, PHY_HASH_JOIN_CODE_LEFT_ON_COND, nodeToMsg, pNode->pLeftOnCond);
1,224,398✔
3240
  }
3241
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3242
    code = tlvEncodeObj(pEncoder, PHY_HASH_JOIN_CODE_RIGHT_ON_COND, nodeToMsg, pNode->pRightOnCond);
1,224,398✔
3243
  }
3244
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3245
    code = tlvEncodeI64(pEncoder, PHY_HASH_JOIN_CODE_TIME_RANGE_SKEY, pNode->timeRange.skey);
1,224,398✔
3246
  }
3247
  if (TSDB_CODE_SUCCESS == code) {
1,224,398✔
3248
    code = tlvEncodeI64(pEncoder, PHY_HASH_JOIN_CODE_TIME_RANGE_EKEY, pNode->timeRange.ekey);
1,224,398✔
3249
  }
3250

3251
  return code;
1,224,398✔
3252
}
3253

3254

3255
static int32_t msgToPhysiHashJoinNode(STlvDecoder* pDecoder, void* pObj) {
1,224,119✔
3256
  SHashJoinPhysiNode* pNode = (SHashJoinPhysiNode*)pObj;
1,224,119✔
3257

3258
  int32_t code = TSDB_CODE_SUCCESS;
1,224,119✔
3259
  STlv*   pTlv = NULL;
1,224,119✔
3260
  tlvForEach(pDecoder, pTlv, code) {
19,585,904✔
3261
    switch (pTlv->type) {
18,361,785✔
3262
      case PHY_HASH_JOIN_CODE_BASE_NODE:
1,224,119✔
3263
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
1,224,119✔
3264
        break;
1,224,119✔
3265
      case PHY_HASH_JOIN_CODE_JOIN_TYPE:
1,224,119✔
3266
        code = tlvDecodeEnum(pTlv, &pNode->joinType, sizeof(pNode->joinType));
1,224,119✔
3267
        break;
1,224,119✔
3268
      case PHY_HASH_JOIN_CODE_JOIN_STYPE:
1,224,119✔
3269
        code = tlvDecodeEnum(pTlv, &pNode->subType, sizeof(pNode->subType));
1,224,119✔
3270
        break;
1,224,119✔
3271
      case PHY_HASH_JOIN_CODE_ON_LEFT_COLUMN:
1,224,119✔
3272
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pOnLeft);
1,224,119✔
3273
        break;
1,224,119✔
3274
      case PHY_HASH_JOIN_CODE_ON_RIGHT_COLUMN:
1,224,119✔
3275
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pOnRight);
1,224,119✔
3276
        break;
1,224,119✔
3277
      case PHY_HASH_JOIN_CODE_LEFT_PRIM_EXPR:
×
3278
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->leftPrimExpr);
×
3279
        break;
×
3280
      case PHY_HASH_JOIN_CODE_RIGHT_PRIM_EXPR:
×
3281
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->rightPrimExpr);
×
3282
        break;
×
3283
      case PHY_HASH_JOIN_CODE_LEFT_PRIM_SLOTID:
1,224,119✔
3284
        code = tlvDecodeI32(pTlv, &pNode->leftPrimSlotId);
1,224,119✔
3285
        break;
1,224,119✔
3286
      case PHY_HASH_JOIN_CODE_RIGHT_PRIM_SLOTID:
1,224,119✔
3287
        code = tlvDecodeI32(pTlv, &pNode->rightPrimSlotId);
1,224,119✔
3288
        break;
1,224,119✔
3289
      case PHY_HASH_JOIN_CODE_TIME_RANGE_TARGET:
1,224,119✔
3290
        code = tlvDecodeI32(pTlv, &pNode->timeRangeTarget);
1,224,119✔
3291
        break;
1,224,119✔
3292
      case PHY_HASH_JOIN_CODE_ON_CONDITIONS:
×
3293
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pFullOnCond);
×
3294
        break;
×
3295
      case PHY_HASH_JOIN_CODE_TARGETS:
1,224,119✔
3296
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTargets);
1,224,119✔
3297
        break;
1,224,119✔
3298
      case PHY_HASH_JOIN_CODE_INPUT_ROW_NUM0:
1,224,119✔
3299
        code = tlvDecodeI64(pTlv, &pNode->inputStat[0].inputRowNum);
1,224,119✔
3300
        break;
1,224,119✔
3301
      case PHY_HASH_JOIN_CODE_INPUT_ROW_NUM1:
1,224,119✔
3302
        code = tlvDecodeI64(pTlv, &pNode->inputStat[1].inputRowNum);
1,224,119✔
3303
        break;
1,224,119✔
3304
      case PHY_HASH_JOIN_CODE_INPUT_ROW_SIZE0:
1,224,119✔
3305
        code = tlvDecodeI32(pTlv, &pNode->inputStat[0].inputRowSize);
1,224,119✔
3306
        break;
1,224,119✔
3307
      case PHY_HASH_JOIN_CODE_INPUT_ROW_SIZE1:
1,224,119✔
3308
        code = tlvDecodeI32(pTlv, &pNode->inputStat[1].inputRowSize);
1,224,119✔
3309
        break;
1,224,119✔
3310
      case PHY_HASH_JOIN_CODE_LEFT_ON_COND:
×
3311
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pLeftOnCond);
×
3312
        break;
×
3313
      case PHY_HASH_JOIN_CODE_RIGHT_ON_COND:
×
3314
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pRightOnCond);
×
3315
        break;
×
3316
      case PHY_HASH_JOIN_CODE_TIME_RANGE_SKEY:
1,224,119✔
3317
        code = tlvDecodeI64(pTlv, &pNode->timeRange.skey);
1,224,119✔
3318
        break;
1,224,119✔
3319
      case PHY_HASH_JOIN_CODE_TIME_RANGE_EKEY:
1,224,119✔
3320
        code = tlvDecodeI64(pTlv, &pNode->timeRange.ekey);
1,224,119✔
3321
        break;
1,224,119✔
3322
      default:
×
3323
        break;
×
3324
    }
3325
  }
3326

3327
  return code;
1,224,119✔
3328
}
3329

3330

3331
enum {
3332
  PHY_AGG_CODE_BASE_NODE = 1,
3333
  PHY_AGG_CODE_EXPR,
3334
  PHY_AGG_CODE_GROUP_KEYS,
3335
  PHY_AGG_CODE_AGG_FUNCS,
3336
  PHY_AGG_CODE_MERGE_DATA_BLOCK,
3337
  PHY_AGG_CODE_GROUP_KEY_OPTIMIZE,
3338
  PHY_AGG_CODE_HAS_COUNT_LIKE_FUNCS,
3339
};
3340

3341
static int32_t physiAggNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
163,522,851✔
3342
  const SAggPhysiNode* pNode = (const SAggPhysiNode*)pObj;
163,522,851✔
3343

3344
  int32_t code = tlvEncodeObj(pEncoder, PHY_AGG_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
163,522,851✔
3345
  if (TSDB_CODE_SUCCESS == code) {
163,633,521✔
3346
    code = tlvEncodeObj(pEncoder, PHY_AGG_CODE_EXPR, nodeListToMsg, pNode->pExprs);
163,637,670✔
3347
  }
3348
  if (TSDB_CODE_SUCCESS == code) {
163,539,049✔
3349
    code = tlvEncodeObj(pEncoder, PHY_AGG_CODE_GROUP_KEYS, nodeListToMsg, pNode->pGroupKeys);
163,523,830✔
3350
  }
3351
  if (TSDB_CODE_SUCCESS == code) {
163,547,277✔
3352
    code = tlvEncodeObj(pEncoder, PHY_AGG_CODE_AGG_FUNCS, nodeListToMsg, pNode->pAggFuncs);
163,534,197✔
3353
  }
3354
  if (TSDB_CODE_SUCCESS == code) {
163,640,566✔
3355
    code = tlvEncodeBool(pEncoder, PHY_AGG_CODE_MERGE_DATA_BLOCK, pNode->mergeDataBlock);
163,627,623✔
3356
  }
3357
  if (TSDB_CODE_SUCCESS == code) {
163,655,906✔
3358
    code = tlvEncodeBool(pEncoder, PHY_AGG_CODE_GROUP_KEY_OPTIMIZE, pNode->groupKeyOptimized);
163,643,123✔
3359
  }
3360
  if (TSDB_CODE_SUCCESS == code) {
163,651,274✔
3361
    code = tlvEncodeBool(pEncoder, PHY_AGG_CODE_HAS_COUNT_LIKE_FUNCS, pNode->hasCountLikeFunc);
163,634,395✔
3362
  }
3363

3364
  return code;
163,640,762✔
3365
}
3366

3367
static int32_t msgToPhysiAggNode(STlvDecoder* pDecoder, void* pObj) {
127,389,478✔
3368
  SAggPhysiNode* pNode = (SAggPhysiNode*)pObj;
127,389,478✔
3369

3370
  int32_t code = TSDB_CODE_SUCCESS;
127,389,478✔
3371
  STlv*   pTlv = NULL;
127,389,478✔
3372
  tlvForEach(pDecoder, pTlv, code) {
803,066,110✔
3373
    switch (pTlv->type) {
675,674,828✔
3374
      case PHY_AGG_CODE_BASE_NODE:
127,379,682✔
3375
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
127,379,682✔
3376
        break;
127,397,956✔
3377
      case PHY_AGG_CODE_EXPR:
34,559,652✔
3378
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
34,559,652✔
3379
        break;
34,559,506✔
3380
      case PHY_AGG_CODE_GROUP_KEYS:
32,028,380✔
3381
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pGroupKeys);
32,028,380✔
3382
        break;
32,027,854✔
3383
      case PHY_AGG_CODE_AGG_FUNCS:
99,476,803✔
3384
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pAggFuncs);
99,476,803✔
3385
        break;
99,489,413✔
3386
      case PHY_AGG_CODE_MERGE_DATA_BLOCK:
127,391,329✔
3387
        code = tlvDecodeBool(pTlv, &pNode->mergeDataBlock);
127,391,329✔
3388
        break;
127,398,640✔
3389
      case PHY_AGG_CODE_GROUP_KEY_OPTIMIZE:
127,400,361✔
3390
        code = tlvDecodeBool(pTlv, &pNode->groupKeyOptimized);
127,400,361✔
3391
        break;
127,400,176✔
3392
      case PHY_AGG_CODE_HAS_COUNT_LIKE_FUNCS:
127,434,884✔
3393
        code = tlvDecodeBool(pTlv, &pNode->hasCountLikeFunc);
127,434,884✔
3394
        break;
127,400,361✔
3395
      default:
×
3396
        break;
×
3397
    }
3398
  }
3399

3400
  return code;
127,400,449✔
3401
}
3402

3403
enum {
3404
  PHY_EXCHANGE_CODE_BASE_NODE = 1,
3405
  PHY_EXCHANGE_CODE_SRC_START_GROUP_ID,
3406
  PHY_EXCHANGE_CODE_SRC_END_GROUP_ID,
3407
  PHY_EXCHANGE_CODE_CHILDREN_VGIDS,
3408
  PHY_EXCHANGE_CODE_SINGLE_CHANNEL,
3409
  PHY_EXCHANGE_CODE_SRC_ENDPOINTS,
3410
  PHY_EXCHANGE_CODE_SEQ_RECV_DATA,
3411
  PHY_EXCHANGE_CODE_DYN_TBNAME,
3412
  PHY_EXCHANGE_CODE_SINGLE_SOURCE,
3413
};
3414

3415
static int32_t physiExchangeNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
142,571,908✔
3416
  const SExchangePhysiNode* pNode = (const SExchangePhysiNode*)pObj;
142,571,908✔
3417

3418
  int32_t code = tlvEncodeObj(pEncoder, PHY_EXCHANGE_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
142,571,908✔
3419
  if (TSDB_CODE_SUCCESS == code) {
142,575,361✔
3420
    code = tlvEncodeI32(pEncoder, PHY_EXCHANGE_CODE_SRC_START_GROUP_ID, pNode->srcStartGroupId);
142,575,428✔
3421
  }
3422
  if (TSDB_CODE_SUCCESS == code) {
142,575,074✔
3423
    code = tlvEncodeI32(pEncoder, PHY_EXCHANGE_CODE_SRC_END_GROUP_ID, pNode->srcEndGroupId);
142,574,514✔
3424
  }
3425
  if (TSDB_CODE_SUCCESS == code && pNode->childrenVgIds) {
142,575,694✔
3426
    code = tlvEncodeObj(pEncoder, PHY_EXCHANGE_CODE_CHILDREN_VGIDS, SArrayToMsg, pNode->childrenVgIds);
142,575,134✔
3427
  }
3428
  if (TSDB_CODE_SUCCESS == code) {
142,575,015✔
3429
    code = tlvEncodeBool(pEncoder, PHY_EXCHANGE_CODE_SINGLE_CHANNEL, pNode->grpSingleChannel);
142,574,599✔
3430
  }
3431
  if (TSDB_CODE_SUCCESS == code) {
142,575,614✔
3432
    code = tlvEncodeObj(pEncoder, PHY_EXCHANGE_CODE_SRC_ENDPOINTS, nodeListToMsg, pNode->pSrcEndPoints);
142,575,265✔
3433
  }
3434
  if (TSDB_CODE_SUCCESS == code) {
142,575,065✔
3435
    code = tlvEncodeBool(pEncoder, PHY_EXCHANGE_CODE_SEQ_RECV_DATA, pNode->seqRecvData);
142,574,879✔
3436
  }
3437
  if (TSDB_CODE_SUCCESS == code) {
142,575,320✔
3438
    code = tlvEncodeBool(pEncoder, PHY_EXCHANGE_CODE_DYN_TBNAME, pNode->dynTbname);
142,575,134✔
3439
  }
3440
  if (TSDB_CODE_SUCCESS == code) {
142,574,160✔
3441
    code = tlvEncodeBool(pEncoder, PHY_EXCHANGE_CODE_SINGLE_SOURCE, pNode->singleSrc);
142,574,000✔
3442
  }
3443

3444
  return code;
142,575,115✔
3445
}
3446

3447
static int32_t msgToPhysiExchangeNode(STlvDecoder* pDecoder, void* pObj) {
110,468,216✔
3448
  SExchangePhysiNode* pNode = (SExchangePhysiNode*)pObj;
110,468,216✔
3449

3450
  int32_t code = TSDB_CODE_SUCCESS;
110,468,216✔
3451
  STlv*   pTlv = NULL;
110,468,216✔
3452
  tlvForEach(pDecoder, pTlv, code) {
1,104,690,856✔
3453
    switch (pTlv->type) {
994,220,988✔
3454
      case PHY_EXCHANGE_CODE_BASE_NODE:
110,468,745✔
3455
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
110,468,745✔
3456
        break;
110,468,754✔
3457
      case PHY_EXCHANGE_CODE_SRC_START_GROUP_ID:
110,469,283✔
3458
        code = tlvDecodeI32(pTlv, &pNode->srcStartGroupId);
110,469,283✔
3459
        break;
110,469,283✔
3460
      case PHY_EXCHANGE_CODE_SRC_END_GROUP_ID:
110,469,283✔
3461
        code = tlvDecodeI32(pTlv, &pNode->srcEndGroupId);
110,469,283✔
3462
        break;
110,469,283✔
3463
      case PHY_EXCHANGE_CODE_CHILDREN_VGIDS:
110,469,283✔
3464
        code = msgToSArray(pTlv, (void**)&pNode->childrenVgIds);
110,469,283✔
3465
        break;
110,468,905✔
3466
      case PHY_EXCHANGE_CODE_SINGLE_CHANNEL:
110,469,283✔
3467
        code = tlvDecodeBool(pTlv, &pNode->grpSingleChannel);
110,469,283✔
3468
        break;
110,468,216✔
3469
      case PHY_EXCHANGE_CODE_SRC_ENDPOINTS:
110,469,283✔
3470
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pSrcEndPoints);
110,469,283✔
3471
        break;
110,469,283✔
3472
      case PHY_EXCHANGE_CODE_SEQ_RECV_DATA:
110,469,283✔
3473
        code = tlvDecodeBool(pTlv, &pNode->seqRecvData);
110,469,283✔
3474
        break;
110,469,283✔
3475
      case PHY_EXCHANGE_CODE_DYN_TBNAME:
110,469,283✔
3476
        code = tlvDecodeBool(pTlv, &pNode->dynTbname);
110,469,283✔
3477
        break;
110,469,283✔
3478
      case PHY_EXCHANGE_CODE_SINGLE_SOURCE:
110,467,800✔
3479
        code = tlvDecodeBool(pTlv, &pNode->singleSrc);
110,467,800✔
3480
        break;
110,469,283✔
3481
      default:
×
3482
        break;
×
3483
    }
3484
  }
3485

3486
  return code;
110,477,287✔
3487
}
3488

3489
enum {
3490
  PHY_MERGE_CODE_BASE_NODE = 1,
3491
  PHY_MERGE_CODE_MERGE_KEYS,
3492
  PHY_MERGE_CODE_TARGETS,
3493
  PHY_MERGE_CODE_NUM_OF_CHANNELS,
3494
  PHY_MERGE_CODE_SRC_GROUP_ID,
3495
  PHY_MERGE_CODE_GROUP_SORT,
3496
  PHY_MERGE_CODE_IGNORE_GROUP_ID,
3497
  PHY_MERGE_CODE_INPUT_WITH_GROUP_ID,
3498
  PHY_MERGE_CODE_TYPE,
3499
};
3500

3501
static int32_t physiMergeNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
18,263,404✔
3502
  const SMergePhysiNode* pNode = (const SMergePhysiNode*)pObj;
18,263,404✔
3503

3504
  int32_t code = tlvEncodeObj(pEncoder, PHY_MERGE_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
18,263,404✔
3505
  if (TSDB_CODE_SUCCESS == code) {
18,263,538✔
3506
    code = tlvEncodeObj(pEncoder, PHY_MERGE_CODE_MERGE_KEYS, nodeListToMsg, pNode->pMergeKeys);
18,263,538✔
3507
  }
3508
  if (TSDB_CODE_SUCCESS == code) {
18,263,538✔
3509
    code = tlvEncodeObj(pEncoder, PHY_MERGE_CODE_TARGETS, nodeListToMsg, pNode->pTargets);
18,263,538✔
3510
  }
3511
  if (TSDB_CODE_SUCCESS == code) {
18,263,538✔
3512
    code = tlvEncodeI32(pEncoder, PHY_MERGE_CODE_NUM_OF_CHANNELS, pNode->numOfChannels);
18,263,538✔
3513
  }
3514
  if (TSDB_CODE_SUCCESS == code) {
18,263,538✔
3515
    code = tlvEncodeI32(pEncoder, PHY_MERGE_CODE_SRC_GROUP_ID, pNode->srcGroupId);
18,263,471✔
3516
  }
3517
  if (TSDB_CODE_SUCCESS == code) {
18,263,605✔
3518
    code = tlvEncodeBool(pEncoder, PHY_MERGE_CODE_GROUP_SORT, pNode->groupSort);
18,263,538✔
3519
  }
3520
  if (TSDB_CODE_SUCCESS == code) {
18,263,605✔
3521
    code = tlvEncodeBool(pEncoder, PHY_MERGE_CODE_IGNORE_GROUP_ID, pNode->ignoreGroupId);
18,263,538✔
3522
  }
3523
  if (TSDB_CODE_SUCCESS == code) {
18,263,605✔
3524
    code = tlvEncodeBool(pEncoder, PHY_MERGE_CODE_INPUT_WITH_GROUP_ID, pNode->inputWithGroupId);
18,263,471✔
3525
  }
3526
  if (TSDB_CODE_SUCCESS == code) {
18,263,672✔
3527
    code = tlvEncodeI32(pEncoder, PHY_MERGE_CODE_TYPE, pNode->type);
18,263,471✔
3528
  }
3529

3530
  return code;
18,263,538✔
3531
}
3532

3533
static int32_t msgToPhysiMergeNode(STlvDecoder* pDecoder, void* pObj) {
13,819,489✔
3534
  SMergePhysiNode* pNode = (SMergePhysiNode*)pObj;
13,819,489✔
3535

3536
  int32_t code = TSDB_CODE_SUCCESS;
13,819,489✔
3537
  STlv*   pTlv = NULL;
13,819,489✔
3538
  tlvForEach(pDecoder, pTlv, code) {
137,587,711✔
3539
    switch (pTlv->type) {
123,768,222✔
3540
      case PHY_MERGE_CODE_BASE_NODE:
13,819,489✔
3541
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
13,819,489✔
3542
        break;
13,819,489✔
3543
      case PHY_MERGE_CODE_MERGE_KEYS:
13,212,310✔
3544
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pMergeKeys);
13,212,310✔
3545
        break;
13,212,310✔
3546
      case PHY_MERGE_CODE_TARGETS:
13,819,489✔
3547
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTargets);
13,819,489✔
3548
        break;
13,819,489✔
3549
      case PHY_MERGE_CODE_NUM_OF_CHANNELS:
13,819,489✔
3550
        code = tlvDecodeI32(pTlv, &pNode->numOfChannels);
13,819,489✔
3551
        break;
13,819,489✔
3552
      case PHY_MERGE_CODE_SRC_GROUP_ID:
13,819,489✔
3553
        code = tlvDecodeI32(pTlv, &pNode->srcGroupId);
13,819,489✔
3554
        break;
13,819,489✔
3555
      case PHY_MERGE_CODE_GROUP_SORT:
13,819,489✔
3556
        code = tlvDecodeBool(pTlv, &pNode->groupSort);
13,819,489✔
3557
        break;
13,819,489✔
3558
      case PHY_MERGE_CODE_IGNORE_GROUP_ID:
13,819,489✔
3559
        code = tlvDecodeBool(pTlv, &pNode->ignoreGroupId);
13,819,489✔
3560
        break;
13,819,489✔
3561
      case PHY_MERGE_CODE_INPUT_WITH_GROUP_ID:
13,819,489✔
3562
        code = tlvDecodeBool(pTlv, &pNode->inputWithGroupId);
13,819,489✔
3563
        break;
13,819,489✔
3564
      case PHY_MERGE_CODE_TYPE:
13,819,489✔
3565
        code = tlvDecodeI32(pTlv, (int32_t*)&pNode->type);
13,819,489✔
3566
        break;
13,819,489✔
3567
      default:
×
3568
        break;
×
3569
    }
3570
  }
3571

3572
  return code;
13,819,489✔
3573
}
3574

3575
enum {
3576
  PHY_SORT_CODE_BASE_NODE = 1,
3577
  PHY_SORT_CODE_EXPR,
3578
  PHY_SORT_CODE_SORT_KEYS,
3579
  PHY_SORT_CODE_TARGETS,
3580
  PHY_SORT_CODE_CALC_GROUPID,
3581
  PHY_SORT_CODE_EXCLUDE_PK_COL
3582
};
3583

3584
static int32_t physiSortNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
53,423,389✔
3585
  const SSortPhysiNode* pNode = (const SSortPhysiNode*)pObj;
53,423,389✔
3586

3587
  int32_t code = tlvEncodeObj(pEncoder, PHY_SORT_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
53,423,389✔
3588
  if (TSDB_CODE_SUCCESS == code) {
53,446,043✔
3589
    code = tlvEncodeObj(pEncoder, PHY_SORT_CODE_EXPR, nodeListToMsg, pNode->pExprs);
53,446,165✔
3590
  }
3591
  if (TSDB_CODE_SUCCESS == code) {
53,436,806✔
3592
    code = tlvEncodeObj(pEncoder, PHY_SORT_CODE_SORT_KEYS, nodeListToMsg, pNode->pSortKeys);
53,428,571✔
3593
  }
3594
  if (TSDB_CODE_SUCCESS == code) {
53,454,949✔
3595
    code = tlvEncodeObj(pEncoder, PHY_SORT_CODE_TARGETS, nodeListToMsg, pNode->pTargets);
53,446,851✔
3596
  }
3597
  if (TSDB_CODE_SUCCESS == code) {
53,455,492✔
3598
    code = tlvEncodeBool(pEncoder, PHY_SORT_CODE_CALC_GROUPID, pNode->calcGroupId);
53,447,487✔
3599
  }
3600
  if (TSDB_CODE_SUCCESS == code) {
53,455,898✔
3601
    code = tlvEncodeBool(pEncoder, PHY_SORT_CODE_EXCLUDE_PK_COL, pNode->excludePkCol);
53,447,893✔
3602
  }
3603

3604
  return code;
53,448,078✔
3605
}
3606

3607
static int32_t msgToPhysiSortNode(STlvDecoder* pDecoder, void* pObj) {
32,793,393✔
3608
  SSortPhysiNode* pNode = (SSortPhysiNode*)pObj;
32,793,393✔
3609

3610
  int32_t code = TSDB_CODE_SUCCESS;
32,793,393✔
3611
  STlv*   pTlv = NULL;
32,793,393✔
3612
  tlvForEach(pDecoder, pTlv, code) {
197,209,348✔
3613
    switch (pTlv->type) {
164,416,284✔
3614
      case PHY_SORT_CODE_BASE_NODE:
32,792,983✔
3615
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
32,792,983✔
3616
        break;
32,794,981✔
3617
      case PHY_SORT_CODE_EXPR:
439,678✔
3618
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
439,678✔
3619
        break;
439,678✔
3620
      case PHY_SORT_CODE_SORT_KEYS:
32,794,836✔
3621
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pSortKeys);
32,794,836✔
3622
        break;
32,793,039✔
3623
      case PHY_SORT_CODE_TARGETS:
32,795,507✔
3624
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTargets);
32,795,507✔
3625
        break;
32,795,507✔
3626
      case PHY_SORT_CODE_CALC_GROUPID:
32,795,507✔
3627
        code = tlvDecodeBool(pTlv, &pNode->calcGroupId);
32,795,507✔
3628
        break;
32,795,507✔
3629
      case PHY_SORT_CODE_EXCLUDE_PK_COL:
32,795,507✔
3630
        code = tlvDecodeBool(pTlv, &pNode->excludePkCol);
32,795,507✔
3631
      default:
32,795,507✔
3632
        break;
32,795,507✔
3633
    }
3634
  }
3635

3636
  return code;
32,797,697✔
3637
}
3638

3639
enum {
3640
  PHY_WINDOW_CODE_BASE_NODE = 1,
3641
  PHY_WINDOW_CODE_EXPR,
3642
  PHY_WINDOW_CODE_FUNCS,
3643
  PHY_WINDOW_CODE_TS_PK,
3644
  PHY_WINDOW_CODE_TS_END,
3645
  PHY_WINDOW_CODE_TRIGGER_TYPE,
3646
  PHY_WINDOW_CODE_WATERMARK,
3647
  PHY_WINDOW_CODE_DELETE_MARK,
3648
  PHY_WINDOW_CODE_IG_EXPIRED,
3649
  PHY_WINDOW_CODE_INDEF_ROWS_FUNC,
3650
  PHY_WINDOW_CODE_INPUT_TS_ORDER,
3651
  PHY_WINDOW_CODE_OUTPUT_TS_ORDER,
3652
  PHY_WINDOW_CODE_MERGE_DATA_BLOCK,
3653
};
3654

3655
static int32_t physiWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
22,441,504✔
3656
  const SWindowPhysiNode* pNode = (const SWindowPhysiNode*)pObj;
22,441,504✔
3657

3658
  int32_t code = tlvEncodeObj(pEncoder, PHY_WINDOW_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
22,441,504✔
3659
  if (TSDB_CODE_SUCCESS == code) {
22,457,741✔
3660
    code = tlvEncodeObj(pEncoder, PHY_WINDOW_CODE_EXPR, nodeListToMsg, pNode->pExprs);
22,457,671✔
3661
  }
3662
  if (TSDB_CODE_SUCCESS == code) {
22,452,668✔
3663
    code = tlvEncodeObj(pEncoder, PHY_WINDOW_CODE_FUNCS, nodeListToMsg, pNode->pFuncs);
22,452,682✔
3664
  }
3665
  if (TSDB_CODE_SUCCESS == code) {
22,457,012✔
3666
    code = tlvEncodeObj(pEncoder, PHY_WINDOW_CODE_TS_PK, nodeToMsg, pNode->pTspk);
22,457,212✔
3667
  }
3668
  if (TSDB_CODE_SUCCESS == code) {
22,458,090✔
3669
    code = tlvEncodeObj(pEncoder, PHY_WINDOW_CODE_TS_END, nodeToMsg, pNode->pTsEnd);
22,457,876✔
3670
  }
3671
  if (TSDB_CODE_SUCCESS == code) {
22,457,380✔
3672
    code = tlvEncodeI8(pEncoder, PHY_WINDOW_CODE_TRIGGER_TYPE, pNode->unusedParam1);
22,457,408✔
3673
  }
3674
  if (TSDB_CODE_SUCCESS == code) {
22,458,185✔
3675
    code = tlvEncodeI64(pEncoder, PHY_WINDOW_CODE_WATERMARK, pNode->unusedParam2);
22,458,213✔
3676
  }
3677
  if (TSDB_CODE_SUCCESS == code) {
22,457,593✔
3678
    code = tlvEncodeI64(pEncoder, PHY_WINDOW_CODE_DELETE_MARK, pNode->unusedParam3);
22,457,621✔
3679
  }
3680
  if (TSDB_CODE_SUCCESS == code) {
22,457,880✔
3681
    code = tlvEncodeI8(pEncoder, PHY_WINDOW_CODE_IG_EXPIRED, pNode->unusedParam4);
22,457,105✔
3682
  }
3683
  if (TSDB_CODE_SUCCESS == code) {
22,459,362✔
3684
    code = tlvEncodeBool(pEncoder, PHY_WINDOW_CODE_MERGE_DATA_BLOCK, pNode->mergeDataBlock);
22,458,654✔
3685
  }
3686
  if (TSDB_CODE_SUCCESS == code) {
22,458,163✔
3687
    code = tlvEncodeI8(pEncoder, PHY_WINDOW_CODE_INDEF_ROWS_FUNC, pNode->indefRowsFunc);
22,457,455✔
3688
  }
3689

3690
  return code;
22,455,661✔
3691
}
3692

3693
static int32_t msgToPhysiWindowNode(STlvDecoder* pDecoder, void* pObj) {
8,493,449✔
3694
  SWindowPhysiNode* pNode = (SWindowPhysiNode*)pObj;
8,493,449✔
3695

3696
  int32_t code = TSDB_CODE_SUCCESS;
8,493,449✔
3697
  STlv*   pTlv = NULL;
8,493,449✔
3698
  tlvForEach(pDecoder, pTlv, code) {
86,345,049✔
3699
    switch (pTlv->type) {
77,850,018✔
3700
      case PHY_WINDOW_CODE_BASE_NODE:
8,493,518✔
3701
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
8,493,518✔
3702
        break;
8,494,927✔
3703
      case PHY_WINDOW_CODE_EXPR:
912,626✔
3704
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
912,626✔
3705
        break;
912,626✔
3706
      case PHY_WINDOW_CODE_FUNCS:
8,418,226✔
3707
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pFuncs);
8,418,226✔
3708
        break;
8,418,226✔
3709
      case PHY_WINDOW_CODE_TS_PK:
8,494,927✔
3710
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTspk);
8,494,927✔
3711
        break;
8,494,927✔
3712
      case PHY_WINDOW_CODE_TS_END:
560,937✔
3713
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTsEnd);
560,937✔
3714
        break;
560,937✔
3715
      case PHY_WINDOW_CODE_TRIGGER_TYPE:
8,494,927✔
3716
        code = tlvDecodeI8(pTlv, &pNode->unusedParam1);
8,494,927✔
3717
        break;
8,494,927✔
3718
      case PHY_WINDOW_CODE_WATERMARK:
8,494,927✔
3719
        code = tlvDecodeI64(pTlv, &pNode->unusedParam2);
8,494,927✔
3720
        break;
8,494,927✔
3721
      case PHY_WINDOW_CODE_DELETE_MARK:
8,494,927✔
3722
        code = tlvDecodeI64(pTlv, &pNode->unusedParam3);
8,494,927✔
3723
        break;
8,494,927✔
3724
      case PHY_WINDOW_CODE_IG_EXPIRED:
8,494,927✔
3725
        code = tlvDecodeI8(pTlv, &pNode->unusedParam4);
8,494,927✔
3726
        break;
8,494,927✔
3727
      case PHY_WINDOW_CODE_MERGE_DATA_BLOCK:
8,494,927✔
3728
        code = tlvDecodeBool(pTlv, &pNode->mergeDataBlock);
8,494,927✔
3729
        break;
8,494,927✔
3730
      case PHY_WINDOW_CODE_INDEF_ROWS_FUNC:
8,495,149✔
3731
        code = tlvDecodeI8(pTlv, &pNode->indefRowsFunc);
8,495,149✔
3732
        break;
8,494,927✔
3733
      default:
×
3734
        break;
×
3735
    }
3736
  }
3737

3738
  return code;
8,497,335✔
3739
}
3740

3741
enum { PHY_INTERVAL_CODE_WINDOW = 1, PHY_INTERVAL_CODE_INLINE_ATTRS, PHY_INTERVAL_CODE_TIME_RANGE };
3742

3743
static int32_t physiIntervalNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
13,335,176✔
3744
  const SIntervalPhysiNode* pNode = (const SIntervalPhysiNode*)pObj;
13,335,176✔
3745

3746
  int32_t code = tlvEncodeValueI64(pEncoder, pNode->interval);
13,335,176✔
3747
  if (TSDB_CODE_SUCCESS == code) {
13,342,108✔
3748
    code = tlvEncodeValueI64(pEncoder, pNode->offset);
13,342,250✔
3749
  }
3750
  if (TSDB_CODE_SUCCESS == code) {
13,341,850✔
3751
    code = tlvEncodeValueI64(pEncoder, pNode->sliding);
13,342,055✔
3752
  }
3753
  if (TSDB_CODE_SUCCESS == code) {
13,342,707✔
3754
    code = tlvEncodeValueI8(pEncoder, pNode->intervalUnit);
13,342,749✔
3755
  }
3756
  if (TSDB_CODE_SUCCESS == code) {
13,343,813✔
3757
    code = tlvEncodeValueI8(pEncoder, pNode->slidingUnit);
13,342,203✔
3758
  }
3759

3760
  return code;
13,342,832✔
3761
}
3762

3763
static int32_t physiIntervalNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
13,329,741✔
3764
  const SIntervalPhysiNode* pNode = (const SIntervalPhysiNode*)pObj;
13,329,741✔
3765

3766
  int32_t code = tlvEncodeObj(pEncoder, PHY_INTERVAL_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window);
13,329,741✔
3767
  if (TSDB_CODE_SUCCESS == code) {
13,343,846✔
3768
    code = tlvEncodeObj(pEncoder, PHY_INTERVAL_CODE_INLINE_ATTRS, physiIntervalNodeInlineToMsg, pNode);
13,343,930✔
3769
  }
3770
  if (TSDB_CODE_SUCCESS == code) {
13,342,520✔
3771
    code = tlvEncodeObj(pEncoder, PHY_INTERVAL_CODE_TIME_RANGE, timeWindowToMsg, &pNode->timeRange);
13,342,671✔
3772
  }
3773

3774
  return code;
13,338,918✔
3775
}
3776

3777
static int32_t msgToPhysiIntervalNodeInline(STlvDecoder* pDecoder, void* pObj) {
5,455,211✔
3778
  SIntervalPhysiNode* pNode = (SIntervalPhysiNode*)pObj;
5,455,211✔
3779

3780
  int32_t code = tlvDecodeValueI64(pDecoder, &pNode->interval);
5,455,211✔
3781
  if (TSDB_CODE_SUCCESS == code) {
5,455,740✔
3782
    code = tlvDecodeValueI64(pDecoder, &pNode->offset);
5,455,740✔
3783
  }
3784
  if (TSDB_CODE_SUCCESS == code) {
5,455,740✔
3785
    code = tlvDecodeValueI64(pDecoder, &pNode->sliding);
5,455,740✔
3786
  }
3787
  if (TSDB_CODE_SUCCESS == code) {
5,455,740✔
3788
    code = tlvDecodeValueI8(pDecoder, &pNode->intervalUnit);
5,455,740✔
3789
  }
3790
  if (TSDB_CODE_SUCCESS == code) {
5,455,740✔
3791
    code = tlvDecodeValueI8(pDecoder, &pNode->slidingUnit);
5,455,740✔
3792
  }
3793

3794
  return code;
5,455,740✔
3795
}
3796

3797
static int32_t msgToPhysiIntervalNode(STlvDecoder* pDecoder, void* pObj) {
5,454,816✔
3798
  SIntervalPhysiNode* pNode = (SIntervalPhysiNode*)pObj;
5,454,816✔
3799

3800
  int32_t code = TSDB_CODE_SUCCESS;
5,454,816✔
3801
  STlv*   pTlv = NULL;
5,454,816✔
3802
  tlvForEach(pDecoder, pTlv, code) {
21,822,036✔
3803
    switch (pTlv->type) {
16,367,074✔
3804
      case PHY_INTERVAL_CODE_WINDOW:
5,454,405✔
3805
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window);
5,454,405✔
3806
        break;
5,455,211✔
3807
      case PHY_INTERVAL_CODE_INLINE_ATTRS:
5,455,740✔
3808
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiIntervalNodeInline, pNode);
5,455,740✔
3809
        break;
5,455,740✔
3810
      case PHY_INTERVAL_CODE_TIME_RANGE:
5,455,594✔
3811
        code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, &pNode->timeRange);
5,455,594✔
3812
      default:
5,455,740✔
3813
        break;
5,455,740✔
3814
    }
3815
  }
3816

3817
  return code;
5,455,977✔
3818
}
3819

3820
enum {
3821
  PHY_FILL_CODE_BASE_NODE = 1,
3822
  PHY_FILL_CODE_MODE,
3823
  PHY_FILL_CODE_FILL_EXPRS,
3824
  PHY_FILL_CODE_NOT_FILL_EXPRS,
3825
  PHY_FILL_CODE_WSTART,
3826
  PHY_FILL_CODE_VALUES,
3827
  PHY_FILL_CODE_TIME_RANGE,
3828
  PHY_FILL_CODE_INPUT_TS_ORDER,
3829
  PHY_FILL_CODE_FILL_NULL_EXPRS,
3830
  PHY_FILL_CODE_TIME_RANGE_EXPR,
3831
  PHY_FILL_CODE_SURROUNDING_TIME,
3832
};
3833

3834
static int32_t physiFillNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
513,405✔
3835
  const SFillPhysiNode* pNode = (const SFillPhysiNode*)pObj;
513,405✔
3836

3837
  int32_t code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
513,405✔
3838
  if (TSDB_CODE_SUCCESS == code) {
514,626✔
3839
    code = tlvEncodeEnum(pEncoder, PHY_FILL_CODE_MODE, pNode->mode);
514,626✔
3840
  }
3841
  if (TSDB_CODE_SUCCESS == code) {
514,626✔
3842
    code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_FILL_EXPRS, nodeListToMsg, pNode->pFillExprs);
514,626✔
3843
  }
3844
  if (TSDB_CODE_SUCCESS == code) {
514,626✔
3845
    code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_NOT_FILL_EXPRS, nodeListToMsg, pNode->pNotFillExprs);
514,626✔
3846
  }
3847
  if (TSDB_CODE_SUCCESS == code) {
514,626✔
3848
    code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_WSTART, nodeToMsg, pNode->pWStartTs);
514,626✔
3849
  }
3850
  if (TSDB_CODE_SUCCESS == code) {
514,626✔
3851
    code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_VALUES, nodeToMsg, pNode->pValues);
514,626✔
3852
  }
3853
  if (TSDB_CODE_SUCCESS == code) {
514,626✔
3854
    code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_TIME_RANGE, timeWindowToMsg, &pNode->timeRange);
514,626✔
3855
  }
3856
  if (TSDB_CODE_SUCCESS == code) {
514,626✔
3857
    code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_FILL_NULL_EXPRS, nodeListToMsg, pNode->pFillNullExprs);
514,626✔
3858
  }
3859
  if (TSDB_CODE_SUCCESS == code) {
514,626✔
3860
    code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_TIME_RANGE_EXPR, nodeToMsg, pNode->pTimeRange);
514,626✔
3861
  }
3862
  if (TSDB_CODE_SUCCESS == code) {
514,626✔
3863
    code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_SURROUNDING_TIME, nodeToMsg,
514,626✔
3864
                        pNode->pSurroundingTime);
514,626✔
3865
  }
3866
  return code;
514,626✔
3867
}
3868

3869
static int32_t msgToPhysiFillNode(STlvDecoder* pDecoder, void* pObj) {
509,283✔
3870
  SFillPhysiNode* pNode = (SFillPhysiNode*)pObj;
509,283✔
3871

3872
  int32_t code = TSDB_CODE_SUCCESS;
509,283✔
3873
  STlv*   pTlv = NULL;
509,283✔
3874
  tlvForEach(pDecoder, pTlv, code) {
3,598,996✔
3875
    switch (pTlv->type) {
3,089,713✔
3876
      case PHY_FILL_CODE_BASE_NODE:
509,283✔
3877
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
509,283✔
3878
        break;
509,283✔
3879
      case PHY_FILL_CODE_MODE:
509,283✔
3880
        code = tlvDecodeEnum(pTlv, &pNode->mode, sizeof(pNode->mode));
509,283✔
3881
        break;
509,283✔
3882
      case PHY_FILL_CODE_FILL_EXPRS:
508,515✔
3883
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pFillExprs);
508,515✔
3884
        break;
508,515✔
3885
      case PHY_FILL_CODE_NOT_FILL_EXPRS:
435,225✔
3886
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pNotFillExprs);
435,225✔
3887
        break;
435,225✔
3888
      case PHY_FILL_CODE_WSTART:
509,283✔
3889
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pWStartTs);
509,283✔
3890
        break;
509,283✔
3891
      case PHY_FILL_CODE_VALUES:
84,544✔
3892
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pValues);
84,544✔
3893
        break;
84,544✔
3894
      case PHY_FILL_CODE_TIME_RANGE:
509,283✔
3895
        code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, (void**)&pNode->timeRange);
509,283✔
3896
        break;
509,283✔
3897
      case PHY_FILL_CODE_FILL_NULL_EXPRS:
18,537✔
3898
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pFillNullExprs);
18,537✔
3899
        break;
18,537✔
3900
      case PHY_FILL_CODE_TIME_RANGE_EXPR:
×
3901
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTimeRange);
×
3902
        break;
×
3903
      case PHY_FILL_CODE_SURROUNDING_TIME:
5,760✔
3904
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pSurroundingTime);
5,760✔
3905
        break;
5,760✔
3906
      default:
×
3907
        break;
×
3908
    }
3909
  }
3910

3911
  return code;
509,283✔
3912
}
3913

3914
enum { PHY_SESSION_CODE_WINDOW = 1, PHY_SESSION_CODE_GAP };
3915

3916
static int32_t physiSessionWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,403,511✔
3917
  const SSessionWinodwPhysiNode* pNode = (const SSessionWinodwPhysiNode*)pObj;
2,403,511✔
3918

3919
  int32_t code = tlvEncodeObj(pEncoder, PHY_SESSION_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window);
2,403,511✔
3920
  if (TSDB_CODE_SUCCESS == code) {
2,403,918✔
3921
    code = tlvEncodeI64(pEncoder, PHY_SESSION_CODE_GAP, pNode->gap);
2,403,918✔
3922
  }
3923

3924
  return code;
2,403,918✔
3925
}
3926

3927
static int32_t msgToPhysiSessionWindowNode(STlvDecoder* pDecoder, void* pObj) {
560,937✔
3928
  SSessionWinodwPhysiNode* pNode = (SSessionWinodwPhysiNode*)pObj;
560,937✔
3929

3930
  int32_t code = TSDB_CODE_SUCCESS;
560,937✔
3931
  STlv*   pTlv = NULL;
560,937✔
3932
  tlvForEach(pDecoder, pTlv, code) {
1,682,811✔
3933
    switch (pTlv->type) {
1,121,874✔
3934
      case PHY_SESSION_CODE_WINDOW:
560,937✔
3935
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window);
560,937✔
3936
        break;
560,937✔
3937
      case PHY_SESSION_CODE_GAP:
560,937✔
3938
        code = tlvDecodeI64(pTlv, &pNode->gap);
560,937✔
3939
        break;
560,937✔
3940
      default:
×
3941
        break;
×
3942
    }
3943
  }
3944

3945
  return code;
560,937✔
3946
}
3947

3948
enum { PHY_EXT_CODE_WINDOW = 1,
3949
       PHY_EXT_CODE_SKEY,
3950
       PHY_EXT_CODE_EKEY,
3951
       PHY_EXT_CODE_TIME_RANGE_EXPR,
3952
       PHY_EXT_CODE_IS_SINGLE_TABLE,
3953
       PHY_EXT_CODE_INPUT_HAS_ORDER,
3954
       PHY_EXT_CODE_ORG_TABLE_UID,
3955
       PHY_EXT_CODE_ORG_TABLE_VGID };
3956

3957
static int32_t physiExternalWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
947,585✔
3958
  const SExternalWindowPhysiNode* pNode = (const SExternalWindowPhysiNode*)pObj;
947,585✔
3959
  int32_t code = tlvEncodeObj(pEncoder, PHY_EXT_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window);
947,585✔
3960
  if (TSDB_CODE_SUCCESS == code) {
947,585✔
3961
    code = tlvEncodeI64(pEncoder, PHY_EXT_CODE_SKEY, pNode->timeRange.skey);
947,585✔
3962
  }
3963
  if (TSDB_CODE_SUCCESS == code) {
947,585✔
3964
    code = tlvEncodeI64(pEncoder, PHY_EXT_CODE_EKEY, pNode->timeRange.ekey);
947,585✔
3965
  }
3966
  if (TSDB_CODE_SUCCESS == code) {
947,585✔
3967
    code = tlvEncodeObj(pEncoder, PHY_EXT_CODE_TIME_RANGE_EXPR, nodeToMsg, pNode->pTimeRange);
947,585✔
3968
  }
3969
  if (TSDB_CODE_SUCCESS == code) {
947,585✔
3970
    code = tlvEncodeBool(pEncoder, PHY_EXT_CODE_IS_SINGLE_TABLE, pNode->isSingleTable);
947,585✔
3971
  }
3972
  if (TSDB_CODE_SUCCESS == code) {
947,585✔
3973
    code = tlvEncodeBool(pEncoder, PHY_EXT_CODE_INPUT_HAS_ORDER, pNode->inputHasOrder);
947,585✔
3974
  }
3975
  if (TSDB_CODE_SUCCESS == code) {
947,585✔
3976
    code = tlvEncodeI64(pEncoder, PHY_EXT_CODE_ORG_TABLE_UID, pNode->orgTableUid);
947,585✔
3977
  }
3978
  if (TSDB_CODE_SUCCESS == code) {
947,585✔
3979
    code = tlvEncodeI32(pEncoder, PHY_EXT_CODE_ORG_TABLE_VGID, pNode->orgTableVgId);
947,585✔
3980
  }
3981

3982
  return code;
947,585✔
3983
}
3984

3985
static int32_t msgToPhysiExternalWindowNode(STlvDecoder* pDecoder, void* pObj) {
937,134✔
3986
  SExternalWindowPhysiNode* pNode = (SExternalWindowPhysiNode*)pObj;
937,134✔
3987

3988
  int32_t code = TSDB_CODE_SUCCESS;
937,134✔
3989
  STlv*   pTlv = NULL;
937,134✔
3990
  tlvForEach(pDecoder, pTlv, code) {
7,497,072✔
3991
    switch (pTlv->type) {
6,559,938✔
3992
      case PHY_EXT_CODE_WINDOW:
937,134✔
3993
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window);
937,134✔
3994
        break;
937,134✔
3995
      case PHY_EXT_CODE_SKEY:
937,134✔
3996
        code = tlvDecodeI64(pTlv, &pNode->timeRange.skey);
937,134✔
3997
        break;
937,134✔
3998
      case PHY_EXT_CODE_EKEY:
937,134✔
3999
        code = tlvDecodeI64(pTlv, &pNode->timeRange.ekey);
937,134✔
4000
        break;
937,134✔
4001
      case PHY_EXT_CODE_TIME_RANGE_EXPR:
×
4002
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTimeRange);
×
4003
        break;
×
4004
      case PHY_EXT_CODE_IS_SINGLE_TABLE:
937,134✔
4005
        code = tlvDecodeBool(pTlv, &pNode->isSingleTable);
937,134✔
4006
        break;
937,134✔
4007
      case PHY_EXT_CODE_INPUT_HAS_ORDER:
937,134✔
4008
        code = tlvDecodeBool(pTlv, &pNode->inputHasOrder);
937,134✔
4009
        break;
937,134✔
4010
      case PHY_EXT_CODE_ORG_TABLE_UID:
937,134✔
4011
        code = tlvDecodeI64(pTlv, &pNode->orgTableUid);
937,134✔
4012
        break;
937,134✔
4013
      case PHY_EXT_CODE_ORG_TABLE_VGID:
937,134✔
4014
        code = tlvDecodeI32(pTlv, &pNode->orgTableVgId);
937,134✔
4015
        break;
937,134✔
4016
      default:
×
4017
        break;
×
4018
    }
4019
  }
4020
  return code;
937,134✔
4021
}
4022

4023
enum { PHY_STATE_CODE_WINDOW = 1, PHY_STATE_CODE_KEY, PHY_STATE_CODE_TRUE_FOR_DURATION, PHY_STATE_CODE_EXTEND_OPTION, PHY_STATE_CODE_TRUE_FOR_TYPE, PHY_STATE_CODE_TRUE_FOR_COUNT };
4024

4025
static int32_t physiStateWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,370,160✔
4026
  const SStateWindowPhysiNode* pNode = (const SStateWindowPhysiNode*)pObj;
2,370,160✔
4027

4028
  int32_t code = tlvEncodeObj(pEncoder, PHY_STATE_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window);
2,370,160✔
4029
  if (TSDB_CODE_SUCCESS == code) {
2,370,160✔
4030
    code = tlvEncodeObj(pEncoder, PHY_STATE_CODE_KEY, nodeToMsg, pNode->pStateKey);
2,370,160✔
4031
  }
4032
  if (TSDB_CODE_SUCCESS == code) {
2,370,160✔
4033
    code = tlvEncodeI32(pEncoder, PHY_STATE_CODE_TRUE_FOR_TYPE, pNode->trueForType);
2,370,160✔
4034
  }
4035
  if (TSDB_CODE_SUCCESS == code) {
2,370,160✔
4036
    code = tlvEncodeI32(pEncoder, PHY_STATE_CODE_TRUE_FOR_COUNT, pNode->trueForCount);
2,370,160✔
4037
  }
4038
  if (TSDB_CODE_SUCCESS == code) {
2,370,160✔
4039
    code = tlvEncodeI64(pEncoder, PHY_STATE_CODE_TRUE_FOR_DURATION, pNode->trueForDuration);
2,370,160✔
4040
  }
4041
  if (TSDB_CODE_SUCCESS == code) {
2,370,160✔
4042
    code = tlvEncodeI32(pEncoder, PHY_STATE_CODE_EXTEND_OPTION, pNode->extendOption);
2,370,160✔
4043
  }
4044

4045
  return code;
2,370,160✔
4046
}
4047

4048
static int32_t msgToPhysiStateWindowNode(STlvDecoder* pDecoder, void* pObj) {
977,597✔
4049
  SStateWindowPhysiNode* pNode = (SStateWindowPhysiNode*)pObj;
977,597✔
4050

4051
  int32_t code = TSDB_CODE_SUCCESS;
977,597✔
4052
  STlv*   pTlv = NULL;
977,597✔
4053
  tlvForEach(pDecoder, pTlv, code) {
6,843,179✔
4054
    switch (pTlv->type) {
5,865,582✔
4055
      case PHY_STATE_CODE_WINDOW:
977,597✔
4056
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window);
977,597✔
4057
        break;
977,597✔
4058
      case PHY_STATE_CODE_KEY:
977,597✔
4059
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pStateKey);
977,597✔
4060
        break;
977,597✔
4061
      case PHY_STATE_CODE_TRUE_FOR_TYPE:
977,597✔
4062
        code = tlvDecodeI32(pTlv, (int32_t*)&pNode->trueForType);
977,597✔
4063
        break;
977,597✔
4064
      case PHY_STATE_CODE_TRUE_FOR_COUNT:
977,597✔
4065
        code = tlvDecodeI32(pTlv, &pNode->trueForCount);
977,597✔
4066
        break;
977,597✔
4067
      case PHY_STATE_CODE_TRUE_FOR_DURATION:
977,597✔
4068
        code = tlvDecodeI64(pTlv, &pNode->trueForDuration);
977,597✔
4069
        break;
977,597✔
4070
      case PHY_STATE_CODE_EXTEND_OPTION:
977,597✔
4071
        code = tlvDecodeI32(pTlv, (int32_t*)&pNode->extendOption);
977,597✔
4072
      default:
977,597✔
4073
        break;
977,597✔
4074
    }
4075
  }
4076

4077
  return code;
977,597✔
4078
}
4079

4080
enum { PHY_EVENT_CODE_WINDOW = 1, PHY_EVENT_CODE_START_COND, PHY_EVENT_CODE_END_COND, PHY_EVENT_CODE_TRUE_FOR_DURATION, PHY_EVENT_CODE_TRUE_FOR_TYPE, PHY_EVENT_CODE_TRUE_FOR_COUNT };
4081

4082
static int32_t physiEventWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
1,765,120✔
4083
  const SEventWinodwPhysiNode* pNode = (const SEventWinodwPhysiNode*)pObj;
1,765,120✔
4084

4085
  int32_t code = tlvEncodeObj(pEncoder, PHY_EVENT_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window);
1,765,120✔
4086
  if (TSDB_CODE_SUCCESS == code) {
1,764,805✔
4087
    code = tlvEncodeObj(pEncoder, PHY_EVENT_CODE_START_COND, nodeToMsg, pNode->pStartCond);
1,764,805✔
4088
  }
4089
  if (TSDB_CODE_SUCCESS == code) {
1,765,213✔
4090
    code = tlvEncodeObj(pEncoder, PHY_EVENT_CODE_END_COND, nodeToMsg, pNode->pEndCond);
1,765,213✔
4091
  }
4092
  if (TSDB_CODE_SUCCESS == code) {
1,765,213✔
4093
    code = tlvEncodeI32(pEncoder, PHY_EVENT_CODE_TRUE_FOR_TYPE, pNode->trueForType);
1,765,213✔
4094
  }
4095
  if (TSDB_CODE_SUCCESS == code) {
1,765,213✔
4096
    code = tlvEncodeI32(pEncoder, PHY_EVENT_CODE_TRUE_FOR_COUNT, pNode->trueForCount);
1,765,213✔
4097
  }
4098
  if (TSDB_CODE_SUCCESS == code) {
1,765,213✔
4099
    code = tlvEncodeI64(pEncoder, PHY_EVENT_CODE_TRUE_FOR_DURATION, pNode->trueForDuration);
1,765,213✔
4100
  }
4101

4102
  return code;
1,765,213✔
4103
}
4104

4105
static int32_t msgToPhysiEventWindowNode(STlvDecoder* pDecoder, void* pObj) {
312,591✔
4106
  SEventWinodwPhysiNode* pNode = (SEventWinodwPhysiNode*)pObj;
312,591✔
4107

4108
  int32_t code = TSDB_CODE_SUCCESS;
312,591✔
4109
  STlv*   pTlv = NULL;
312,591✔
4110
  tlvForEach(pDecoder, pTlv, code) {
2,188,137✔
4111
    switch (pTlv->type) {
1,875,546✔
4112
      case PHY_EVENT_CODE_WINDOW:
312,591✔
4113
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window);
312,591✔
4114
        break;
312,591✔
4115
      case PHY_EVENT_CODE_START_COND:
312,591✔
4116
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pStartCond);
312,591✔
4117
        break;
312,591✔
4118
      case PHY_EVENT_CODE_END_COND:
312,591✔
4119
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pEndCond);
312,591✔
4120
        break;
312,591✔
4121
      case PHY_EVENT_CODE_TRUE_FOR_TYPE:
312,591✔
4122
        code = tlvDecodeI32(pTlv, (int32_t *)&pNode->trueForType);
312,591✔
4123
        break;
312,591✔
4124
      case PHY_EVENT_CODE_TRUE_FOR_COUNT:
312,591✔
4125
        code = tlvDecodeI32(pTlv, &pNode->trueForCount);
312,591✔
4126
        break;
312,591✔
4127
      case PHY_EVENT_CODE_TRUE_FOR_DURATION:
312,591✔
4128
        code = tlvDecodeI64(pTlv, &pNode->trueForDuration);
312,591✔
4129
        break;
312,591✔
4130
      default:
×
4131
        break;
×
4132
    }
4133
  }
4134

4135
  return code;
312,591✔
4136
}
4137

4138
enum { PHY_COUNT_CODE_WINDOW = 1, PHY_COUNT_CODE_WINDOW_COUNT, PHY_COUNT_CODE_WINDOW_SLIDING };
4139

4140
static int32_t physiCountWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
1,627,185✔
4141
  const SCountWindowPhysiNode* pNode = (const SCountWindowPhysiNode*)pObj;
1,627,185✔
4142

4143
  int32_t code = tlvEncodeObj(pEncoder, PHY_COUNT_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window);
1,627,185✔
4144
  if (TSDB_CODE_SUCCESS == code) {
1,627,185✔
4145
    code = tlvEncodeI64(pEncoder, PHY_COUNT_CODE_WINDOW_COUNT, pNode->windowCount);
1,627,185✔
4146
  }
4147
  if (TSDB_CODE_SUCCESS == code) {
1,627,185✔
4148
    code = tlvEncodeI64(pEncoder, PHY_COUNT_CODE_WINDOW_SLIDING, pNode->windowSliding);
1,627,185✔
4149
  }
4150

4151
  return code;
1,627,185✔
4152
}
4153

4154
static int32_t msgToPhysiCountWindowNode(STlvDecoder* pDecoder, void* pObj) {
250,928✔
4155
  SCountWindowPhysiNode* pNode = (SCountWindowPhysiNode*)pObj;
250,928✔
4156

4157
  int32_t code = TSDB_CODE_SUCCESS;
250,928✔
4158
  STlv*   pTlv = NULL;
250,928✔
4159
  tlvForEach(pDecoder, pTlv, code) {
1,003,712✔
4160
    switch (pTlv->type) {
752,784✔
4161
      case PHY_COUNT_CODE_WINDOW:
250,928✔
4162
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window);
250,928✔
4163
        break;
250,928✔
4164
      case PHY_COUNT_CODE_WINDOW_COUNT:
250,928✔
4165
        code = tlvDecodeI64(pTlv, &pNode->windowCount);
250,928✔
4166
        break;
250,928✔
4167
      case PHY_COUNT_CODE_WINDOW_SLIDING:
250,928✔
4168
        code = tlvDecodeI64(pTlv, &pNode->windowSliding);
250,928✔
4169
        break;
250,928✔
4170
      default:
×
4171
        break;
×
4172
    }
4173
  }
4174

4175
  return code;
250,928✔
4176
}
4177

4178
enum { PHY_ANOMALY_CODE_WINDOW = 1, PHY_ANOMALY_CODE_KEY, PHY_ANOMALY_CODE_WINDOW_OPTION };
4179

4180
static int32_t physiAnomalyWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
×
4181
  const SAnomalyWindowPhysiNode* pNode = (const SAnomalyWindowPhysiNode*)pObj;
×
4182

4183
  int32_t code = tlvEncodeObj(pEncoder, PHY_ANOMALY_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window);
×
4184
  if (TSDB_CODE_SUCCESS == code) {
×
4185
    code = tlvEncodeObj(pEncoder, PHY_ANOMALY_CODE_KEY, nodeListToMsg, pNode->pAnomalyKeys);
×
4186
  }
4187
  if (TSDB_CODE_SUCCESS == code) {
×
4188
    code = tlvEncodeCStr(pEncoder, PHY_ANOMALY_CODE_WINDOW_OPTION, pNode->anomalyOpt);
×
4189
  }
4190

4191
  return code;
×
4192
}
4193

4194
static int32_t msgToPhysiAnomalyWindowNode(STlvDecoder* pDecoder, void* pObj) {
×
4195
  SAnomalyWindowPhysiNode* pNode = (SAnomalyWindowPhysiNode*)pObj;
×
4196

4197
  int32_t code = TSDB_CODE_SUCCESS;
×
4198
  STlv*   pTlv = NULL;
×
4199
  tlvForEach(pDecoder, pTlv, code) {
×
4200
    switch (pTlv->type) {
×
4201
      case PHY_ANOMALY_CODE_WINDOW:
×
4202
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window);
×
4203
        break;
×
4204
      case PHY_ANOMALY_CODE_KEY:
×
4205
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pAnomalyKeys);
×
4206
        break;
×
4207
      case PHY_ANOMALY_CODE_WINDOW_OPTION:
×
4208
        code = tlvDecodeCStr(pTlv, pNode->anomalyOpt, sizeof(pNode->anomalyOpt));
×
4209
        break;
×
4210
      default:
×
4211
        break;
×
4212
    }
4213
  }
4214

4215
  return code;
×
4216
}
4217

4218
enum {
4219
  PHY_PARTITION_CODE_BASE_NODE = 1,
4220
  PHY_PARTITION_CODE_EXPR,
4221
  PHY_PARTITION_CODE_KEYS,
4222
  PHY_PARTITION_CODE_TARGETS,
4223
  PHY_PARTITION_CODE_HAS_OUTPUT_TS_ORDER,
4224
  PHY_PARTITION_CODE_TS_SLOTID
4225
};
4226

4227
static int32_t physiPartitionNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
10,566,801✔
4228
  const SPartitionPhysiNode* pNode = (const SPartitionPhysiNode*)pObj;
10,566,801✔
4229

4230
  int32_t code = tlvEncodeObj(pEncoder, PHY_PARTITION_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
10,566,801✔
4231
  if (TSDB_CODE_SUCCESS == code) {
10,573,729✔
4232
    code = tlvEncodeObj(pEncoder, PHY_PARTITION_CODE_EXPR, nodeListToMsg, pNode->pExprs);
10,573,703✔
4233
  }
4234
  if (TSDB_CODE_SUCCESS == code) {
10,572,331✔
4235
    code = tlvEncodeObj(pEncoder, PHY_PARTITION_CODE_KEYS, nodeListToMsg, pNode->pPartitionKeys);
10,568,260✔
4236
  }
4237
  if (TSDB_CODE_SUCCESS == code) {
10,578,594✔
4238
    code = tlvEncodeObj(pEncoder, PHY_PARTITION_CODE_TARGETS, nodeListToMsg, pNode->pTargets);
10,574,523✔
4239
  }
4240
  if (TSDB_CODE_SUCCESS == code) {
10,578,455✔
4241
    code = tlvEncodeBool(pEncoder, PHY_PARTITION_CODE_HAS_OUTPUT_TS_ORDER, pNode->needBlockOutputTsOrder);
10,574,451✔
4242
  }
4243
  if (TSDB_CODE_SUCCESS == code) {
10,579,020✔
4244
    code = tlvEncodeI32(pEncoder, PHY_PARTITION_CODE_TS_SLOTID, pNode->tsSlotId);
10,575,016✔
4245
  }
4246

4247
  return code;
10,574,649✔
4248
}
4249

4250
static int32_t msgToPhysiPartitionNode(STlvDecoder* pDecoder, void* pObj) {
2,980,067✔
4251
  SPartitionPhysiNode* pNode = (SPartitionPhysiNode*)pObj;
2,980,067✔
4252

4253
  int32_t code = TSDB_CODE_SUCCESS;
2,980,067✔
4254
  STlv*   pTlv = NULL;
2,980,067✔
4255
  tlvForEach(pDecoder, pTlv, code) {
17,968,073✔
4256
    switch (pTlv->type) {
14,988,400✔
4257
      case PHY_PARTITION_CODE_BASE_NODE:
2,980,097✔
4258
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
2,980,097✔
4259
        break;
2,981,020✔
4260
      case PHY_PARTITION_CODE_EXPR:
83,300✔
4261
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
83,300✔
4262
        break;
83,300✔
4263
      case PHY_PARTITION_CODE_KEYS:
2,981,020✔
4264
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pPartitionKeys);
2,981,020✔
4265
        break;
2,981,020✔
4266
      case PHY_PARTITION_CODE_TARGETS:
2,981,020✔
4267
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTargets);
2,981,020✔
4268
        break;
2,981,020✔
4269
      case PHY_PARTITION_CODE_HAS_OUTPUT_TS_ORDER:
2,981,020✔
4270
        code = tlvDecodeBool(pTlv, &pNode->needBlockOutputTsOrder);
2,981,020✔
4271
        break;
2,981,020✔
4272
      case PHY_PARTITION_CODE_TS_SLOTID:
2,981,943✔
4273
        code = tlvDecodeI32(pTlv, &pNode->tsSlotId);
2,981,943✔
4274
        break;
2,980,626✔
4275
      default:
×
4276
        break;
×
4277
    }
4278
  }
4279

4280
  return code;
2,979,673✔
4281
}
4282

4283
enum { PHY_INDEF_ROWS_FUNC_CODE_BASE_NODE = 1, PHY_INDEF_ROWS_FUNC_CODE_EXPRS, PHY_INDEF_ROWS_FUNC_CODE_FUNCS };
4284

4285
static int32_t physiIndefRowsFuncNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
3,151,025✔
4286
  const SIndefRowsFuncPhysiNode* pNode = (const SIndefRowsFuncPhysiNode*)pObj;
3,151,025✔
4287

4288
  int32_t code = tlvEncodeObj(pEncoder, PHY_INDEF_ROWS_FUNC_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
3,151,025✔
4289
  if (TSDB_CODE_SUCCESS == code) {
3,151,403✔
4290
    code = tlvEncodeObj(pEncoder, PHY_INDEF_ROWS_FUNC_CODE_EXPRS, nodeListToMsg, pNode->pExprs);
3,151,403✔
4291
  }
4292
  if (TSDB_CODE_SUCCESS == code) {
3,151,403✔
4293
    code = tlvEncodeObj(pEncoder, PHY_INDEF_ROWS_FUNC_CODE_FUNCS, nodeListToMsg, pNode->pFuncs);
3,151,403✔
4294
  }
4295

4296
  return code;
3,151,403✔
4297
}
4298

4299
static int32_t msgToPhysiIndefRowsFuncNode(STlvDecoder* pDecoder, void* pObj) {
3,123,662✔
4300
  SIndefRowsFuncPhysiNode* pNode = (SIndefRowsFuncPhysiNode*)pObj;
3,123,662✔
4301

4302
  int32_t code = TSDB_CODE_SUCCESS;
3,123,662✔
4303
  STlv*   pTlv = NULL;
3,123,662✔
4304
  tlvForEach(pDecoder, pTlv, code) {
9,393,816✔
4305
    switch (pTlv->type) {
6,270,532✔
4306
      case PHY_INDEF_ROWS_FUNC_CODE_BASE_NODE:
3,123,132✔
4307
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
3,123,132✔
4308
        break;
3,123,662✔
4309
      case PHY_INDEF_ROWS_FUNC_CODE_EXPRS:
23,208✔
4310
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
23,208✔
4311
        break;
23,208✔
4312
      case PHY_INDEF_ROWS_FUNC_CODE_FUNCS:
3,124,192✔
4313
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pFuncs);
3,124,192✔
4314
        break;
3,123,284✔
4315
      default:
×
4316
        break;
×
4317
    }
4318
  }
4319

4320
  return code;
3,123,132✔
4321
}
4322

4323
enum {
4324
  PHY_INERP_FUNC_CODE_BASE_NODE = 1,
4325
  PHY_INERP_FUNC_CODE_EXPR,
4326
  PHY_INERP_FUNC_CODE_FUNCS,
4327
  PHY_INERP_FUNC_CODE_TIME_RANGE,
4328
  PHY_INERP_FUNC_CODE_INTERVAL,
4329
  PHY_INERP_FUNC_CODE_INTERVAL_UNIT,
4330
  PHY_INERP_FUNC_CODE_FILL_MODE,
4331
  PHY_INERP_FUNC_CODE_FILL_VALUES,
4332
  PHY_INERP_FUNC_CODE_TIME_SERIES,
4333
  PHY_INTERP_FUNC_CODE_SURROUNDING_TIME,
4334
  PHY_INERP_FUNC_CODE_TIME_RANGE_EXPR,
4335
};
4336

4337
static int32_t physiInterpFuncNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
3,451,522✔
4338
  const SInterpFuncPhysiNode* pNode = (const SInterpFuncPhysiNode*)pObj;
3,451,522✔
4339

4340
  int32_t code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
3,451,522✔
4341
  if (TSDB_CODE_SUCCESS == code) {
3,451,522✔
4342
    code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_EXPR, nodeListToMsg, pNode->pExprs);
3,451,522✔
4343
  }
4344
  if (TSDB_CODE_SUCCESS == code) {
3,451,522✔
4345
    code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_FUNCS, nodeListToMsg, pNode->pFuncs);
3,451,522✔
4346
  }
4347
  if (TSDB_CODE_SUCCESS == code) {
3,451,522✔
4348
    code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_TIME_RANGE, timeWindowToMsg, &pNode->timeRange);
3,451,522✔
4349
  }
4350
  if (TSDB_CODE_SUCCESS == code) {
3,451,522✔
4351
    code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_TIME_RANGE_EXPR, nodeToMsg, pNode->pTimeRange);
3,451,522✔
4352
  }
4353
  if (TSDB_CODE_SUCCESS == code) {
3,451,522✔
4354
    code = tlvEncodeI64(pEncoder, PHY_INERP_FUNC_CODE_INTERVAL, pNode->interval);
3,451,522✔
4355
  }
4356
  if (TSDB_CODE_SUCCESS == code) {
3,451,522✔
4357
    code = tlvEncodeI8(pEncoder, PHY_INERP_FUNC_CODE_INTERVAL_UNIT, pNode->intervalUnit);
3,451,522✔
4358
  }
4359
  if (TSDB_CODE_SUCCESS == code) {
3,451,522✔
4360
    code = tlvEncodeEnum(pEncoder, PHY_INERP_FUNC_CODE_FILL_MODE, pNode->fillMode);
3,451,522✔
4361
  }
4362
  if (TSDB_CODE_SUCCESS == code) {
3,451,522✔
4363
    code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_FILL_VALUES, nodeToMsg, pNode->pFillValues);
3,451,522✔
4364
  }
4365
  if (TSDB_CODE_SUCCESS == code) {
3,451,522✔
4366
    code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_TIME_SERIES, nodeToMsg, pNode->pTimeSeries);
3,451,522✔
4367
  }
4368
  if (TSDB_CODE_SUCCESS == code) {
3,451,522✔
4369
    code = tlvEncodeI64(pEncoder, PHY_INTERP_FUNC_CODE_SURROUNDING_TIME, pNode->surroundingTime);
3,451,522✔
4370
  }
4371

4372
  return code;
3,451,522✔
4373
}
4374

4375
static int32_t msgToPhysiInterpFuncNode(STlvDecoder* pDecoder, void* pObj) {
3,443,288✔
4376
  SInterpFuncPhysiNode* pNode = (SInterpFuncPhysiNode*)pObj;
3,443,288✔
4377

4378
  int32_t code = TSDB_CODE_SUCCESS;
3,443,288✔
4379
  STlv*   pTlv = NULL;
3,443,288✔
4380
  tlvForEach(pDecoder, pTlv, code) {
32,729,920✔
4381
    switch (pTlv->type) {
29,286,632✔
4382
      case PHY_INERP_FUNC_CODE_BASE_NODE:
3,443,288✔
4383
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
3,443,288✔
4384
        break;
3,443,288✔
4385
      case PHY_INERP_FUNC_CODE_EXPR:
86,617✔
4386
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
86,617✔
4387
        break;
86,617✔
4388
      case PHY_INERP_FUNC_CODE_FUNCS:
3,443,288✔
4389
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pFuncs);
3,443,288✔
4390
        break;
3,443,288✔
4391
      case PHY_INERP_FUNC_CODE_TIME_RANGE:
3,443,288✔
4392
        code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, &pNode->timeRange);
3,443,288✔
4393
        break;
3,443,288✔
4394
      case PHY_INERP_FUNC_CODE_TIME_RANGE_EXPR:
×
4395
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTimeRange);
×
4396
        break;
×
4397
      case PHY_INERP_FUNC_CODE_INTERVAL:
3,443,288✔
4398
        code = tlvDecodeI64(pTlv, &pNode->interval);
3,443,288✔
4399
        break;
3,443,288✔
4400
      case PHY_INERP_FUNC_CODE_INTERVAL_UNIT:
3,443,288✔
4401
        code = tlvDecodeI8(pTlv, &pNode->intervalUnit);
3,443,288✔
4402
        break;
3,443,288✔
4403
      case PHY_INERP_FUNC_CODE_FILL_MODE:
3,443,288✔
4404
        code = tlvDecodeEnum(pTlv, &pNode->fillMode, sizeof(pNode->fillMode));
3,443,288✔
4405
        break;
3,443,288✔
4406
      case PHY_INERP_FUNC_CODE_FILL_VALUES:
1,653,711✔
4407
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pFillValues);
1,653,711✔
4408
        break;
1,653,711✔
4409
      case PHY_INERP_FUNC_CODE_TIME_SERIES:
3,443,288✔
4410
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTimeSeries);
3,443,288✔
4411
        break;
3,443,288✔
4412
      case PHY_INTERP_FUNC_CODE_SURROUNDING_TIME:
3,443,288✔
4413
        code = tlvDecodeI64(pTlv, &pNode->surroundingTime);
3,443,288✔
4414
        break;
3,443,288✔
4415
      default:
×
4416
        break;
×
4417
    }
4418
  }
4419

4420
  return code;
3,443,288✔
4421
}
4422

4423
enum {
4424
  PHY_FORECAST_FUNC_CODE_BASE_NODE = 1,
4425
  PHY_FORECAST_FUNC_CODE_EXPR,
4426
  PHY_FORECAST_FUNC_CODE_FUNCS,
4427
};
4428

4429
static int32_t physiForecastFuncNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
×
4430
  const SForecastFuncPhysiNode* pNode = (const SForecastFuncPhysiNode*)pObj;
×
4431

4432
  int32_t code = tlvEncodeObj(pEncoder, PHY_FORECAST_FUNC_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
×
4433
  if (TSDB_CODE_SUCCESS == code) {
×
4434
    code = tlvEncodeObj(pEncoder, PHY_FORECAST_FUNC_CODE_EXPR, nodeListToMsg, pNode->pExprs);
×
4435
  }
4436
  if (TSDB_CODE_SUCCESS == code) {
×
4437
    code = tlvEncodeObj(pEncoder, PHY_FORECAST_FUNC_CODE_FUNCS, nodeListToMsg, pNode->pFuncs);
×
4438
  }
4439

4440
  return code;
×
4441
}
4442

4443
static int32_t msgToPhysiForecastFuncNode(STlvDecoder* pDecoder, void* pObj) {
×
4444
  SForecastFuncPhysiNode* pNode = (SForecastFuncPhysiNode*)pObj;
×
4445

4446
  int32_t code = TSDB_CODE_SUCCESS;
×
4447
  STlv*   pTlv = NULL;
×
4448
  tlvForEach(pDecoder, pTlv, code) {
×
4449
    switch (pTlv->type) {
×
4450
      case PHY_FORECAST_FUNC_CODE_BASE_NODE:
×
4451
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
×
4452
        break;
×
4453
      case PHY_FORECAST_FUNC_CODE_EXPR:
×
4454
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
×
4455
        break;
×
4456
      case PHY_FORECAST_FUNC_CODE_FUNCS:
×
4457
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pFuncs);
×
4458
        break;
×
4459
      default:
×
4460
        break;
×
4461
    }
4462
  }
4463

4464
  return code;
×
4465
}
4466

4467
enum { PHY_DATA_SINK_CODE_INPUT_DESC = 1 };
4468

4469
static int32_t physicDataSinkNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
510,846,341✔
4470
  const SDataSinkNode* pNode = (const SDataSinkNode*)pObj;
510,846,341✔
4471
  return tlvEncodeObj(pEncoder, PHY_DATA_SINK_CODE_INPUT_DESC, nodeToMsg, pNode->pInputDataBlockDesc);
510,846,341✔
4472
}
4473

4474
static int32_t msgToPhysicDataSinkNode(STlvDecoder* pDecoder, void* pObj) {
358,886,726✔
4475
  SDataSinkNode* pNode = (SDataSinkNode*)pObj;
358,886,726✔
4476

4477
  int32_t code = TSDB_CODE_SUCCESS;
358,886,726✔
4478
  STlv*   pTlv = NULL;
358,886,726✔
4479
  tlvForEach(pDecoder, pTlv, code) {
717,837,511✔
4480
    switch (pTlv->type) {
358,929,322✔
4481
      case PHY_DATA_SINK_CODE_INPUT_DESC:
358,930,817✔
4482
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pInputDataBlockDesc);
358,930,817✔
4483
        break;
358,934,507✔
4484
      default:
×
4485
        break;
×
4486
    }
4487
  }
4488

4489
  return code;
358,954,512✔
4490
}
4491

4492
enum { PHY_DISPATCH_CODE_SINK = 1,
4493
       PHY_DISPATCH_DYNAMIC_SCHEMA};
4494

4495
static int32_t physiDispatchNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
508,767,008✔
4496
  const SDataDispatcherNode* pNode = (const SDataDispatcherNode*)pObj;
508,767,008✔
4497
  int32_t                    code = tlvEncodeObj(pEncoder, PHY_DISPATCH_CODE_SINK, physicDataSinkNodeToMsg, &pNode->sink);
508,767,008✔
4498
  if (TSDB_CODE_SUCCESS == code) {
509,310,958✔
4499
    code = tlvEncodeBool(pEncoder, PHY_DISPATCH_DYNAMIC_SCHEMA, pNode->dynamicSchema);
509,316,012✔
4500
  }
4501
  return code;
509,364,860✔
4502
}
4503

4504
static int32_t msgToPhysiDispatchNode(STlvDecoder* pDecoder, void* pObj) {
356,804,700✔
4505
  SDataDispatcherNode* pNode = (SDataDispatcherNode*)pObj;
356,804,700✔
4506

4507
  int32_t code = TSDB_CODE_SUCCESS;
356,804,700✔
4508
  STlv*   pTlv = NULL;
356,804,700✔
4509
  tlvForEach(pDecoder, pTlv, code) {
1,070,517,494✔
4510
    switch (pTlv->type) {
713,691,987✔
4511
      case PHY_DISPATCH_CODE_SINK:
356,819,008✔
4512
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysicDataSinkNode, &pNode->sink);
356,819,008✔
4513
        break;
356,847,756✔
4514
      case PHY_DISPATCH_DYNAMIC_SCHEMA:
356,873,895✔
4515
        code = tlvDecodeBool(pTlv, &pNode->dynamicSchema);
356,873,895✔
4516
        break;
356,847,670✔
4517
      default:
×
4518
        break;
×
4519
    }
4520
  }
4521

4522
  return code;
356,863,206✔
4523
}
4524

4525
enum {
4526
  PHY_QUERY_INSERT_CODE_SINK = 1,
4527
  PHY_QUERY_INSERT_CODE_COLS,
4528
  PHY_QUERY_INSERT_CODE_TABLE_ID,
4529
  PHY_QUERY_INSERT_CODE_STABLE_ID,
4530
  PHY_QUERY_INSERT_CODE_TABLE_TYPE,
4531
  PHY_QUERY_INSERT_CODE_TABLE_NAME,
4532
  PHY_QUERY_INSERT_CODE_VG_ID,
4533
  PHY_QUERY_INSERT_CODE_EP_SET,
4534
  PHY_QUERY_INSERT_CODE_EXPLAIN
4535
};
4536

4537
static int32_t physiQueryInsertNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
286,779✔
4538
  const SQueryInserterNode* pNode = (const SQueryInserterNode*)pObj;
286,779✔
4539

4540
  int32_t code = tlvEncodeObj(pEncoder, PHY_QUERY_INSERT_CODE_SINK, physicDataSinkNodeToMsg, &pNode->sink);
286,779✔
4541
  if (TSDB_CODE_SUCCESS == code) {
286,779✔
4542
    code = tlvEncodeObj(pEncoder, PHY_QUERY_INSERT_CODE_COLS, nodeListToMsg, pNode->pCols);
286,779✔
4543
  }
4544
  if (TSDB_CODE_SUCCESS == code) {
286,779✔
4545
    code = tlvEncodeU64(pEncoder, PHY_QUERY_INSERT_CODE_TABLE_ID, pNode->tableId);
286,779✔
4546
  }
4547
  if (TSDB_CODE_SUCCESS == code) {
286,779✔
4548
    code = tlvEncodeU64(pEncoder, PHY_QUERY_INSERT_CODE_STABLE_ID, pNode->stableId);
286,779✔
4549
  }
4550
  if (TSDB_CODE_SUCCESS == code) {
286,779✔
4551
    code = tlvEncodeI8(pEncoder, PHY_QUERY_INSERT_CODE_TABLE_TYPE, pNode->tableType);
286,779✔
4552
  }
4553
  if (TSDB_CODE_SUCCESS == code) {
286,779✔
4554
    code = tlvEncodeCStr(pEncoder, PHY_QUERY_INSERT_CODE_TABLE_NAME, pNode->tableName);
286,779✔
4555
  }
4556
  if (TSDB_CODE_SUCCESS == code) {
286,779✔
4557
    code = tlvEncodeI32(pEncoder, PHY_QUERY_INSERT_CODE_VG_ID, pNode->vgId);
286,779✔
4558
  }
4559
  if (TSDB_CODE_SUCCESS == code) {
286,779✔
4560
    code = tlvEncodeObj(pEncoder, PHY_QUERY_INSERT_CODE_EP_SET, epSetToMsg, &pNode->epSet);
286,779✔
4561
  }
4562
  if (TSDB_CODE_SUCCESS == code) {
286,779✔
4563
    code = tlvEncodeBool(pEncoder, PHY_QUERY_INSERT_CODE_EXPLAIN, pNode->explain);
286,779✔
4564
  }
4565

4566
  return code;
286,779✔
4567
}
4568

4569
static int32_t msgToPhysiQueryInsertNode(STlvDecoder* pDecoder, void* pObj) {
286,373✔
4570
  SQueryInserterNode* pNode = (SQueryInserterNode*)pObj;
286,373✔
4571

4572
  int32_t code = TSDB_CODE_SUCCESS;
286,373✔
4573
  STlv*   pTlv = NULL;
286,373✔
4574
  tlvForEach(pDecoder, pTlv, code) {
2,863,730✔
4575
    switch (pTlv->type) {
2,577,357✔
4576
      case PHY_QUERY_INSERT_CODE_SINK:
286,373✔
4577
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysicDataSinkNode, &pNode->sink);
286,373✔
4578
        break;
286,373✔
4579
      case PHY_QUERY_INSERT_CODE_COLS:
286,373✔
4580
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pCols);
286,373✔
4581
        break;
286,373✔
4582
      case PHY_QUERY_INSERT_CODE_TABLE_ID:
286,373✔
4583
        code = tlvDecodeU64(pTlv, &pNode->tableId);
286,373✔
4584
        break;
286,373✔
4585
      case PHY_QUERY_INSERT_CODE_STABLE_ID:
286,373✔
4586
        code = tlvDecodeU64(pTlv, &pNode->stableId);
286,373✔
4587
        break;
286,373✔
4588
      case PHY_QUERY_INSERT_CODE_TABLE_TYPE:
286,373✔
4589
        code = tlvDecodeI8(pTlv, &pNode->tableType);
286,373✔
4590
        break;
286,373✔
4591
      case PHY_QUERY_INSERT_CODE_TABLE_NAME:
286,373✔
4592
        code = tlvDecodeCStr(pTlv, pNode->tableName, sizeof(pNode->tableName));
286,373✔
4593
        break;
286,373✔
4594
      case PHY_QUERY_INSERT_CODE_VG_ID:
286,373✔
4595
        code = tlvDecodeI32(pTlv, &pNode->vgId);
286,373✔
4596
        break;
286,373✔
4597
      case PHY_QUERY_INSERT_CODE_EP_SET:
286,373✔
4598
        code = tlvDecodeObjFromTlv(pTlv, msgToEpSet, &pNode->epSet);
286,373✔
4599
        break;
286,373✔
4600
      case PHY_QUERY_INSERT_CODE_EXPLAIN:
286,373✔
4601
        code = tlvDecodeBool(pTlv, &pNode->explain);
286,373✔
4602
        break;
286,373✔
4603
      default:
×
4604
        break;
×
4605
    }
4606
  }
4607

4608
  return code;
286,373✔
4609
}
4610

4611
enum {
4612
  PHY_DELETER_CODE_SINK = 1,
4613
  PHY_DELETER_CODE_TABLE_ID,
4614
  PHY_DELETER_CODE_TABLE_TYPE,
4615
  PHY_DELETER_CODE_TABLE_FNAME,
4616
  PHY_DELETER_CODE_TS_COL_NAME,
4617
  PHY_DELETER_CODE_DELETE_TIME_RANGE,
4618
  PHY_DELETER_CODE_AFFECTED_ROWS,
4619
  PHY_DELETER_CODE_START_TS,
4620
  PHY_DELETER_CODE_END_TS
4621
};
4622

4623
static int32_t physiDeleteNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
1,803,701✔
4624
  const SDataDeleterNode* pNode = (const SDataDeleterNode*)pObj;
1,803,701✔
4625

4626
  int32_t code = tlvEncodeObj(pEncoder, PHY_DELETER_CODE_SINK, physicDataSinkNodeToMsg, &pNode->sink);
1,803,701✔
4627
  if (TSDB_CODE_SUCCESS == code) {
1,803,701✔
4628
    code = tlvEncodeU64(pEncoder, PHY_DELETER_CODE_TABLE_ID, pNode->tableId);
1,803,701✔
4629
  }
4630
  if (TSDB_CODE_SUCCESS == code) {
1,803,701✔
4631
    code = tlvEncodeI8(pEncoder, PHY_DELETER_CODE_TABLE_TYPE, pNode->tableType);
1,803,701✔
4632
  }
4633
  if (TSDB_CODE_SUCCESS == code) {
1,803,701✔
4634
    code = tlvEncodeCStr(pEncoder, PHY_DELETER_CODE_TABLE_FNAME, pNode->tableFName);
1,803,701✔
4635
  }
4636
  if (TSDB_CODE_SUCCESS == code) {
1,803,701✔
4637
    code = tlvEncodeCStr(pEncoder, PHY_DELETER_CODE_TS_COL_NAME, pNode->tsColName);
1,803,701✔
4638
  }
4639
  if (TSDB_CODE_SUCCESS == code) {
1,803,701✔
4640
    code = tlvEncodeObj(pEncoder, PHY_DELETER_CODE_DELETE_TIME_RANGE, timeWindowToMsg, &pNode->deleteTimeRange);
1,803,701✔
4641
  }
4642
  if (TSDB_CODE_SUCCESS == code) {
1,803,701✔
4643
    code = tlvEncodeObj(pEncoder, PHY_DELETER_CODE_AFFECTED_ROWS, nodeToMsg, pNode->pAffectedRows);
1,803,701✔
4644
  }
4645
  if (TSDB_CODE_SUCCESS == code) {
1,803,701✔
4646
    code = tlvEncodeObj(pEncoder, PHY_DELETER_CODE_START_TS, nodeToMsg, pNode->pStartTs);
1,803,701✔
4647
  }
4648
  if (TSDB_CODE_SUCCESS == code) {
1,803,701✔
4649
    code = tlvEncodeObj(pEncoder, PHY_DELETER_CODE_END_TS, nodeToMsg, pNode->pEndTs);
1,803,701✔
4650
  }
4651

4652
  return code;
1,803,701✔
4653
}
4654

4655
static int32_t msgToPhysiDeleteNode(STlvDecoder* pDecoder, void* pObj) {
1,799,574✔
4656
  SDataDeleterNode* pNode = (SDataDeleterNode*)pObj;
1,799,574✔
4657

4658
  int32_t code = TSDB_CODE_SUCCESS;
1,799,574✔
4659
  STlv*   pTlv = NULL;
1,799,574✔
4660
  tlvForEach(pDecoder, pTlv, code) {
17,995,740✔
4661
    switch (pTlv->type) {
16,196,166✔
4662
      case PHY_DELETER_CODE_SINK:
1,799,574✔
4663
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysicDataSinkNode, &pNode->sink);
1,799,574✔
4664
        break;
1,799,574✔
4665
      case PHY_DELETER_CODE_TABLE_ID:
1,799,574✔
4666
        code = tlvDecodeU64(pTlv, &pNode->tableId);
1,799,574✔
4667
        break;
1,799,574✔
4668
      case PHY_DELETER_CODE_TABLE_TYPE:
1,799,574✔
4669
        code = tlvDecodeI8(pTlv, &pNode->tableType);
1,799,574✔
4670
        break;
1,799,574✔
4671
      case PHY_DELETER_CODE_TABLE_FNAME:
1,799,574✔
4672
        code = tlvDecodeCStr(pTlv, pNode->tableFName, sizeof(pNode->tableFName));
1,799,574✔
4673
        break;
1,799,574✔
4674
      case PHY_DELETER_CODE_TS_COL_NAME:
1,799,574✔
4675
        code = tlvDecodeCStr(pTlv, pNode->tsColName, sizeof(pNode->tsColName));
1,799,574✔
4676
        break;
1,799,574✔
4677
      case PHY_DELETER_CODE_DELETE_TIME_RANGE:
1,799,574✔
4678
        code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, &pNode->deleteTimeRange);
1,799,574✔
4679
        break;
1,799,574✔
4680
      case PHY_DELETER_CODE_AFFECTED_ROWS:
1,799,574✔
4681
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pAffectedRows);
1,799,574✔
4682
        break;
1,799,574✔
4683
      case PHY_DELETER_CODE_START_TS:
1,799,574✔
4684
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pStartTs);
1,799,574✔
4685
        break;
1,799,574✔
4686
      case PHY_DELETER_CODE_END_TS:
1,799,574✔
4687
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pEndTs);
1,799,574✔
4688
        break;
1,799,574✔
4689
      default:
×
4690
        break;
×
4691
    }
4692
  }
4693

4694
  return code;
1,799,574✔
4695
}
4696

4697
enum {
4698
  PHY_GROUP_CACHE_CODE_BASE_NODE = 1,
4699
  PHY_GROUP_CACHE_CODE_GROUP_COLS_MAY_BE_NULL,
4700
  PHY_GROUP_CACHE_CODE_GROUP_BY_UID,
4701
  PHY_GROUP_CACHE_CODE_GLOBAL_GROUP,
4702
  PHY_GROUP_CACHE_CODE_BATCH_FETCH,
4703
  PHY_GROUP_CACHE_CODE_GROUP_COLUMNS
4704
};
4705

4706
static int32_t physiGroupCacheNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
1,223,602✔
4707
  const SGroupCachePhysiNode* pNode = (const SGroupCachePhysiNode*)pObj;
1,223,602✔
4708

4709
  int32_t code = tlvEncodeObj(pEncoder, PHY_GROUP_CACHE_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
1,223,602✔
4710
  if (TSDB_CODE_SUCCESS == code) {
1,223,602✔
4711
    code = tlvEncodeObj(pEncoder, PHY_GROUP_CACHE_CODE_GROUP_COLUMNS, nodeListToMsg, pNode->pGroupCols);
1,223,602✔
4712
  }
4713
  if (TSDB_CODE_SUCCESS == code) {
1,223,602✔
4714
    code = tlvEncodeBool(pEncoder, PHY_GROUP_CACHE_CODE_GROUP_COLS_MAY_BE_NULL, pNode->grpColsMayBeNull);
1,223,602✔
4715
  }
4716
  if (TSDB_CODE_SUCCESS == code) {
1,223,602✔
4717
    code = tlvEncodeBool(pEncoder, PHY_GROUP_CACHE_CODE_GROUP_BY_UID, pNode->grpByUid);
1,223,602✔
4718
  }
4719
  if (TSDB_CODE_SUCCESS == code) {
1,223,602✔
4720
    code = tlvEncodeBool(pEncoder, PHY_GROUP_CACHE_CODE_GLOBAL_GROUP, pNode->globalGrp);
1,223,602✔
4721
  }
4722
  if (TSDB_CODE_SUCCESS == code) {
1,223,602✔
4723
    code = tlvEncodeBool(pEncoder, PHY_GROUP_CACHE_CODE_BATCH_FETCH, pNode->batchFetch);
1,223,602✔
4724
  }
4725

4726
  return code;
1,223,602✔
4727
}
4728

4729
static int32_t msgToPhysiGroupCacheNode(STlvDecoder* pDecoder, void* pObj) {
1,223,323✔
4730
  SGroupCachePhysiNode* pNode = (SGroupCachePhysiNode*)pObj;
1,223,323✔
4731

4732
  int32_t code = TSDB_CODE_SUCCESS;
1,223,323✔
4733
  STlv*   pTlv = NULL;
1,223,323✔
4734
  tlvForEach(pDecoder, pTlv, code) {
7,339,938✔
4735
    switch (pTlv->type) {
6,116,615✔
4736
      case PHY_GROUP_CACHE_CODE_BASE_NODE:
1,223,323✔
4737
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
1,223,323✔
4738
        break;
1,223,323✔
4739
      case PHY_GROUP_CACHE_CODE_GROUP_COLUMNS:
×
4740
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pGroupCols);
×
4741
        break;
×
4742
      case PHY_GROUP_CACHE_CODE_GROUP_COLS_MAY_BE_NULL:
1,223,323✔
4743
        code = tlvDecodeBool(pTlv, &pNode->grpColsMayBeNull);
1,223,323✔
4744
        break;    
1,223,323✔
4745
      case PHY_GROUP_CACHE_CODE_GROUP_BY_UID:
1,223,323✔
4746
        code = tlvDecodeBool(pTlv, &pNode->grpByUid);
1,223,323✔
4747
        break;    
1,223,323✔
4748
      case PHY_GROUP_CACHE_CODE_GLOBAL_GROUP:
1,223,323✔
4749
        code = tlvDecodeBool(pTlv, &pNode->globalGrp);
1,223,323✔
4750
        break;    
1,223,323✔
4751
      case PHY_GROUP_CACHE_CODE_BATCH_FETCH:
1,223,323✔
4752
        code = tlvDecodeBool(pTlv, &pNode->batchFetch);
1,223,323✔
4753
        break;    
1,223,323✔
4754
      default:
×
4755
        break;
×
4756
    }
4757
  }
4758

4759
  return code;
1,223,323✔
4760
}
4761

4762

4763
enum {
4764
  PHY_DYN_QUERY_CTRL_CODE_BASE_NODE = 1,
4765
  PHY_DYN_QUERY_CTRL_CODE_QUERY_TYPE,
4766
  PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_BATCH_FETCH,
4767
  PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_VG_SLOT0,
4768
  PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_VG_SLOT1,
4769
  PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_UID_SLOT0,
4770
  PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_UID_SLOT1,
4771
  PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_SRC_SCAN0,
4772
  PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_SRC_SCAN1,
4773
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_SCAN_ALL_COLS,
4774
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_SUID,
4775
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_DBNAME,
4776
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_STBNAME,
4777
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_ACCOUNT_ID,
4778
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_EP_SET,
4779
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_SCAN_COLS,
4780
  PHY_DYN_QUERY_CTRL_CODE_DYN_TBNAME,
4781
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_UID,
4782
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_IS_SUPER_TABLE,
4783
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_RVERSION,
4784
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_ORG_VG_IDS,
4785
  PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_WSTART_SLOTID,
4786
  PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_WEND_SLOTID,
4787
  PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_WDURATION_SLOTID,
4788
  PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_TARGETS,
4789
  PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_IS_VSTB,
4790
  PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_STATE_EXTEND_OPTION,
4791
  PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_IS_SPARSE_WINDOW,
4792
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_BATCH_PROCESS_CHILD,
4793
  PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_HAS_PARTITION,
4794
};
4795

4796
static int32_t physiDynQueryCtrlNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
5,262,429✔
4797
  const SDynQueryCtrlPhysiNode* pNode = (const SDynQueryCtrlPhysiNode*)pObj;
5,262,429✔
4798

4799
  int32_t code = tlvEncodeObj(pEncoder, PHY_DYN_QUERY_CTRL_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
5,262,429✔
4800
  if (TSDB_CODE_SUCCESS == code) {
5,262,429✔
4801
    code = tlvEncodeEnum(pEncoder, PHY_DYN_QUERY_CTRL_CODE_QUERY_TYPE, pNode->qType);
5,262,429✔
4802
  }
4803
  if (TSDB_CODE_SUCCESS == code) {
5,262,429✔
4804
    switch (pNode->qType) {
5,262,429✔
4805
      case DYN_QTYPE_STB_HASH: {
1,223,602✔
4806
        code = tlvEncodeBool(pEncoder, PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_BATCH_FETCH, pNode->stbJoin.batchFetch);
1,223,602✔
4807
        if (TSDB_CODE_SUCCESS == code) {
1,223,602✔
4808
          code = tlvEncodeEnum(pEncoder, PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_VG_SLOT0, pNode->stbJoin.vgSlot[0]);
1,223,602✔
4809
        }
4810
        if (TSDB_CODE_SUCCESS == code) {
1,223,602✔
4811
          code = tlvEncodeEnum(pEncoder, PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_VG_SLOT1, pNode->stbJoin.vgSlot[1]);
1,223,602✔
4812
        }
4813
        if (TSDB_CODE_SUCCESS == code) {
1,223,602✔
4814
          code = tlvEncodeEnum(pEncoder, PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_UID_SLOT0, pNode->stbJoin.uidSlot[0]);
1,223,602✔
4815
        }
4816
        if (TSDB_CODE_SUCCESS == code) {
1,223,602✔
4817
          code = tlvEncodeEnum(pEncoder, PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_UID_SLOT1, pNode->stbJoin.uidSlot[1]);
1,223,602✔
4818
        }
4819
        if (TSDB_CODE_SUCCESS == code) {
1,223,602✔
4820
          code = tlvEncodeBool(pEncoder, PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_SRC_SCAN0, pNode->stbJoin.srcScan[0]);
1,223,602✔
4821
        }
4822
        if (TSDB_CODE_SUCCESS == code) {
1,223,602✔
4823
          code = tlvEncodeBool(pEncoder, PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_SRC_SCAN1, pNode->stbJoin.srcScan[1]);
1,223,602✔
4824
        }
4825
        break;
1,223,602✔
4826
      }
4827
      case DYN_QTYPE_VTB_WINDOW: {
524,189✔
4828
        code = tlvEncodeI32(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_WSTART_SLOTID, pNode->vtbWindow.wstartSlotId);
524,189✔
4829
        if (TSDB_CODE_SUCCESS == code) {
524,189✔
4830
          code = tlvEncodeI32(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_WEND_SLOTID, pNode->vtbWindow.wendSlotId);
524,189✔
4831
        }
4832
        if (TSDB_CODE_SUCCESS == code) {
524,189✔
4833
          code = tlvEncodeI32(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_WDURATION_SLOTID, pNode->vtbWindow.wdurationSlotId);
524,189✔
4834
        }
4835
        if (TSDB_CODE_SUCCESS == code) {
524,189✔
4836
          code = tlvEncodeObj(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_TARGETS, nodeListToMsg, pNode->vtbWindow.pTargets);
524,189✔
4837
        }
4838
        if (TSDB_CODE_SUCCESS == code) {
524,189✔
4839
          code = tlvEncodeBool(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_IS_VSTB, pNode->vtbWindow.isVstb);
524,189✔
4840
        }
4841
        if (TSDB_CODE_SUCCESS == code) {
524,189✔
4842
          code = tlvEncodeI32(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_STATE_EXTEND_OPTION, pNode->vtbWindow.extendOption);
524,189✔
4843
        }
4844
        // do not break
4845
      }
4846
      case DYN_QTYPE_VTB_TS_SCAN:
4847
      case DYN_QTYPE_VTB_INTERVAL:
4848
      case DYN_QTYPE_VTB_AGG:
4849
      case DYN_QTYPE_VTB_SCAN: {
4850
        code = tlvEncodeBool(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_SCAN_ALL_COLS, pNode->vtbScan.scanAllCols);
4,038,827✔
4851
        if (TSDB_CODE_SUCCESS == code) {
4,038,827✔
4852
          code = tlvEncodeU64(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_SUID, pNode->vtbScan.suid);
4,038,827✔
4853
        }
4854
        if (TSDB_CODE_SUCCESS == code) {
4,038,827✔
4855
          code = tlvEncodeCStr(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_DBNAME, pNode->vtbScan.dbName);
4,038,827✔
4856
        }
4857
        if (TSDB_CODE_SUCCESS == code) {
4,038,827✔
4858
          code = tlvEncodeCStr(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_STBNAME, pNode->vtbScan.tbName);
4,038,827✔
4859
        }
4860
        if (TSDB_CODE_SUCCESS == code) {
4,038,827✔
4861
          code = tlvEncodeI32(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_ACCOUNT_ID, pNode->vtbScan.accountId);
4,038,827✔
4862
        }
4863
        if (TSDB_CODE_SUCCESS == code) {
4,038,827✔
4864
          code = tlvEncodeObj(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_EP_SET, epSetToMsg, &pNode->vtbScan.mgmtEpSet);
4,038,827✔
4865
        }
4866
        if (TSDB_CODE_SUCCESS == code) {
4,038,827✔
4867
          code = tlvEncodeObj(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_SCAN_COLS, nodeListToMsg, pNode->vtbScan.pScanCols);
4,038,827✔
4868
        }
4869
        if (TSDB_CODE_SUCCESS == code) {
4,038,827✔
4870
          code = tlvEncodeU64(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_UID, pNode->vtbScan.uid);
4,038,827✔
4871
        }
4872
        if (TSDB_CODE_SUCCESS == code) {
4,038,827✔
4873
          code = tlvEncodeBool(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_IS_SUPER_TABLE, pNode->vtbScan.isSuperTable);
4,038,827✔
4874
        }
4875
        if (TSDB_CODE_SUCCESS == code) {
4,038,827✔
4876
          code = tlvEncodeI32(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_RVERSION, pNode->vtbScan.rversion);
4,038,827✔
4877
        }
4878
        if (TSDB_CODE_SUCCESS == code) {
4,038,827✔
4879
          code = tlvEncodeObj(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_ORG_VG_IDS, nodeListToMsg, pNode->vtbScan.pOrgVgIds);
4,038,827✔
4880
        }
4881
        if (TSDB_CODE_SUCCESS == code) {
4,038,827✔
4882
          code = tlvEncodeBool(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_BATCH_PROCESS_CHILD, pNode->vtbScan.batchProcessChild);
4,038,827✔
4883
        }
4884
        if (TSDB_CODE_SUCCESS == code) {
4,038,827✔
4885
          code = tlvEncodeBool(pEncoder, PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_HAS_PARTITION, pNode->vtbScan.hasPartition);
4,038,827✔
4886
        }
4887
        break;
4,038,827✔
4888
      }
4889
      default:
×
4890
        return TSDB_CODE_INVALID_PARA;
×
4891
    }
4892
  }
4893
  if (TSDB_CODE_SUCCESS == code) {
5,262,429✔
4894
    code = tlvEncodeBool(pEncoder, PHY_DYN_QUERY_CTRL_CODE_DYN_TBNAME, pNode->dynTbname);
5,262,429✔
4895
  }
4896
  return code;
5,262,429✔
4897
}
4898

4899
static int32_t msgToPhysiDynQueryCtrlNode(STlvDecoder* pDecoder, void* pObj) {
3,389,349✔
4900
  SDynQueryCtrlPhysiNode* pNode = (SDynQueryCtrlPhysiNode*)pObj;
3,389,349✔
4901

4902
  int32_t code = TSDB_CODE_SUCCESS;
3,389,349✔
4903
  STlv*   pTlv = NULL;
3,389,349✔
4904
  tlvForEach(pDecoder, pTlv, code) {
53,085,600✔
4905
    switch (pTlv->type) {
49,696,251✔
4906
      case PHY_DYN_QUERY_CTRL_CODE_BASE_NODE:
3,389,349✔
4907
        code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
3,389,349✔
4908
        break;
3,389,349✔
4909
      case PHY_DYN_QUERY_CTRL_CODE_QUERY_TYPE:
3,389,349✔
4910
        code = tlvDecodeEnum(pTlv, &pNode->qType, sizeof(pNode->qType));
3,389,349✔
4911
        break;
3,389,349✔
4912
      case PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_BATCH_FETCH:
1,223,323✔
4913
        code = tlvDecodeBool(pTlv, &pNode->stbJoin.batchFetch);
1,223,323✔
4914
        break;
1,223,323✔
4915
      case PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_VG_SLOT0:
1,223,323✔
4916
        code = tlvDecodeEnum(pTlv, &pNode->stbJoin.vgSlot[0], sizeof(pNode->stbJoin.vgSlot[0]));
1,223,323✔
4917
        break;
1,223,323✔
4918
      case PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_VG_SLOT1:
1,223,323✔
4919
        code = tlvDecodeEnum(pTlv, &pNode->stbJoin.vgSlot[1], sizeof(pNode->stbJoin.vgSlot[1]));
1,223,323✔
4920
        break;
1,223,323✔
4921
      case PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_UID_SLOT0:
1,223,323✔
4922
        code = tlvDecodeEnum(pTlv, &pNode->stbJoin.uidSlot[0], sizeof(pNode->stbJoin.uidSlot[0]));
1,223,323✔
4923
        break;
1,223,323✔
4924
      case PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_UID_SLOT1:
1,223,323✔
4925
        code = tlvDecodeEnum(pTlv, &pNode->stbJoin.uidSlot[1], sizeof(pNode->stbJoin.uidSlot[1]));
1,223,323✔
4926
        break;      
1,223,323✔
4927
      case PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_SRC_SCAN0:
1,223,323✔
4928
        code = tlvDecodeBool(pTlv, &pNode->stbJoin.srcScan[0]);
1,223,323✔
4929
        break;
1,223,323✔
4930
      case PHY_DYN_QUERY_CTRL_CODE_STB_JOIN_SRC_SCAN1:
1,223,323✔
4931
        code = tlvDecodeBool(pTlv, &pNode->stbJoin.srcScan[1]);
1,223,323✔
4932
        break;
1,223,323✔
4933
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_SCAN_ALL_COLS:
2,166,026✔
4934
        code = tlvDecodeBool(pTlv, &pNode->vtbScan.scanAllCols);
2,166,026✔
4935
        break;
2,166,026✔
4936
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_SUID:
2,166,026✔
4937
        code = tlvDecodeU64(pTlv, &pNode->vtbScan.suid);
2,166,026✔
4938
        break;
2,166,026✔
4939
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_DBNAME:
2,166,026✔
4940
        code = tlvDecodeCStr(pTlv, pNode->vtbScan.dbName, sizeof(pNode->vtbScan.dbName));
2,166,026✔
4941
        break;
2,166,026✔
4942
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_STBNAME:
2,166,026✔
4943
        code = tlvDecodeCStr(pTlv, pNode->vtbScan.tbName, sizeof(pNode->vtbScan.tbName));
2,166,026✔
4944
        break;
2,166,026✔
4945
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_ACCOUNT_ID:
2,166,026✔
4946
        code = tlvDecodeI32(pTlv, &pNode->vtbScan.accountId);
2,166,026✔
4947
        break;
2,166,026✔
4948
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_EP_SET:
2,166,026✔
4949
        code = tlvDecodeObjFromTlv(pTlv, msgToEpSet, &pNode->vtbScan.mgmtEpSet);
2,166,026✔
4950
        break;
2,166,026✔
4951
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_SCAN_COLS:
2,166,026✔
4952
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->vtbScan.pScanCols);
2,166,026✔
4953
        break;
2,166,026✔
4954
      case PHY_DYN_QUERY_CTRL_CODE_DYN_TBNAME:
3,389,349✔
4955
        code = tlvDecodeBool(pTlv, &pNode->dynTbname);
3,389,349✔
4956
        break;
3,389,349✔
4957
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_UID:
2,166,026✔
4958
        code = tlvDecodeU64(pTlv, &pNode->vtbScan.uid);
2,166,026✔
4959
        break;
2,166,026✔
4960
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_IS_SUPER_TABLE:
2,166,026✔
4961
        code = tlvDecodeBool(pTlv, &pNode->vtbScan.isSuperTable);
2,166,026✔
4962
        break;
2,166,026✔
4963
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_RVERSION:
2,166,026✔
4964
        code = tlvDecodeI32(pTlv, &pNode->vtbScan.rversion);
2,166,026✔
4965
        break;
2,166,026✔
4966
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_ORG_VG_IDS:
1,864,553✔
4967
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->vtbScan.pOrgVgIds);
1,864,553✔
4968
        break;
1,864,553✔
4969
      case PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_WSTART_SLOTID:
518,013✔
4970
        code = tlvDecodeI32(pTlv, &pNode->vtbWindow.wstartSlotId);
518,013✔
4971
        break;
518,013✔
4972
      case PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_WEND_SLOTID:
518,013✔
4973
        code = tlvDecodeI32(pTlv, &pNode->vtbWindow.wendSlotId);
518,013✔
4974
        break;
518,013✔
4975
      case PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_WDURATION_SLOTID:
518,013✔
4976
        code = tlvDecodeI32(pTlv, &pNode->vtbWindow.wdurationSlotId);
518,013✔
4977
        break;
518,013✔
4978
      case PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_TARGETS:
518,013✔
4979
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->vtbWindow.pTargets);
518,013✔
4980
        break;
518,013✔
4981
      case PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_IS_VSTB:
518,013✔
4982
        code = tlvDecodeBool(pTlv, &pNode->vtbWindow.isVstb);
518,013✔
4983
        break;
518,013✔
4984
      case PHY_DYN_QUERY_CTRL_CODE_VTB_WINDOW_STATE_EXTEND_OPTION:
518,013✔
4985
        code = tlvDecodeI32(pTlv, (int32_t*)&pNode->vtbWindow.extendOption);
518,013✔
4986
        break;
518,013✔
4987
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_BATCH_PROCESS_CHILD:
2,166,026✔
4988
        code = tlvDecodeBool(pTlv, &pNode->vtbScan.batchProcessChild);
2,166,026✔
4989
        break;
2,166,026✔
4990
      case PHY_DYN_QUERY_CTRL_CODE_VTB_SCAN_HAS_PARTITION:
2,166,026✔
4991
        code = tlvDecodeBool(pTlv, &pNode->vtbScan.hasPartition);
2,166,026✔
4992
        break;
2,166,026✔
4993
      default:
×
4994
        break;
×
4995
    }
4996
  }
4997

4998
  return code;
3,389,349✔
4999
}
5000

5001

5002

5003
enum { SUBPLAN_ID_CODE_QUERY_ID = 1, SUBPLAN_ID_CODE_GROUP_ID, SUBPLAN_ID_CODE_SUBPLAN_ID };
5004

5005
static int32_t subplanIdInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
511,185,761✔
5006
  const SSubplanId* pNode = (const SSubplanId*)pObj;
511,185,761✔
5007

5008
  int32_t code = tlvEncodeValueU64(pEncoder, pNode->queryId);
511,185,761✔
5009
  if (TSDB_CODE_SUCCESS == code) {
510,259,587✔
5010
    code = tlvEncodeValueI32(pEncoder, pNode->groupId);
510,313,511✔
5011
  }
5012
  if (TSDB_CODE_SUCCESS == code) {
510,921,901✔
5013
    code = tlvEncodeValueI32(pEncoder, pNode->subplanId);
510,876,099✔
5014
  }
5015

5016
  return code;
511,055,309✔
5017
}
5018

5019
static int32_t subplanIdToMsg(const void* pObj, STlvEncoder* pEncoder) {
×
5020
  const SSubplanId* pNode = (const SSubplanId*)pObj;
×
5021

5022
  int32_t code = tlvEncodeU64(pEncoder, SUBPLAN_ID_CODE_QUERY_ID, pNode->queryId);
×
5023
  if (TSDB_CODE_SUCCESS == code) {
×
5024
    code = tlvEncodeI32(pEncoder, SUBPLAN_ID_CODE_GROUP_ID, pNode->groupId);
×
5025
  }
5026
  if (TSDB_CODE_SUCCESS == code) {
×
5027
    code = tlvEncodeI32(pEncoder, SUBPLAN_ID_CODE_SUBPLAN_ID, pNode->subplanId);
×
5028
  }
5029

5030
  return code;
×
5031
}
5032

5033
static int32_t msgToSubplanIdInline(STlvDecoder* pDecoder, void* pObj) {
358,902,476✔
5034
  SSubplanId* pNode = (SSubplanId*)pObj;
358,902,476✔
5035

5036
  int32_t code = tlvDecodeValueU64(pDecoder, &pNode->queryId);
358,902,476✔
5037
  if (TSDB_CODE_SUCCESS == code) {
358,815,572✔
5038
    code = tlvDecodeValueI32(pDecoder, &pNode->groupId);
358,819,638✔
5039
  }
5040
  if (TSDB_CODE_SUCCESS == code) {
358,910,556✔
5041
    code = tlvDecodeValueI32(pDecoder, &pNode->subplanId);
358,910,556✔
5042
  }
5043

5044
  return code;
358,919,265✔
5045
}
5046

5047
static int32_t msgToSubplanId(STlvDecoder* pDecoder, void* pObj) {
×
5048
  SSubplanId* pNode = (SSubplanId*)pObj;
×
5049

5050
  int32_t code = TSDB_CODE_SUCCESS;
×
5051
  STlv*   pTlv = NULL;
×
5052
  tlvForEach(pDecoder, pTlv, code) {
×
5053
    switch (pTlv->type) {
×
5054
      case SUBPLAN_ID_CODE_QUERY_ID:
×
5055
        code = tlvDecodeU64(pTlv, &pNode->queryId);
×
5056
        break;
×
5057
      case SUBPLAN_ID_CODE_GROUP_ID:
×
5058
        code = tlvDecodeI32(pTlv, &pNode->groupId);
×
5059
        break;
×
5060
      case SUBPLAN_ID_CODE_SUBPLAN_ID:
×
5061
        code = tlvDecodeI32(pTlv, &pNode->subplanId);
×
5062
        break;
×
5063
      default:
×
5064
        break;
×
5065
    }
5066
  }
5067

5068
  return code;
×
5069
}
5070

5071
enum {
5072
  SUBPLAN_CODE_INLINE_ATTRS = 1,
5073
  SUBPLAN_CODE_ROOT_NODE,
5074
  SUBPLAN_CODE_DATA_SINK,
5075
  SUBPLAN_CODE_TAG_COND,
5076
  SUBPLAN_CODE_TAG_INDEX_COND
5077
};
5078

5079
static int32_t subplanInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
511,195,820✔
5080
  const SSubplan* pNode = (const SSubplan*)pObj;
511,195,820✔
5081

5082
  int32_t code = subplanIdInlineToMsg(&pNode->id, pEncoder);
511,195,820✔
5083
  if (TSDB_CODE_SUCCESS == code) {
511,048,082✔
5084
    code = tlvEncodeValueEnum(pEncoder, pNode->subplanType);
511,055,632✔
5085
  }
5086
  if (TSDB_CODE_SUCCESS == code) {
511,229,613✔
5087
    code = tlvEncodeValueI32(pEncoder, pNode->msgType);
511,203,278✔
5088
  }
5089
  if (TSDB_CODE_SUCCESS == code) {
511,145,113✔
5090
    code = tlvEncodeValueI32(pEncoder, pNode->level);
511,126,466✔
5091
  }
5092
  if (TSDB_CODE_SUCCESS == code) {
511,288,135✔
5093
    code = tlvEncodeValueCStr(pEncoder, pNode->dbFName);
511,270,602✔
5094
  }
5095
  if (TSDB_CODE_SUCCESS == code) {
511,219,736✔
5096
    code = tlvEncodeValueCStr(pEncoder, pNode->user);
511,206,166✔
5097
  }
5098
  if (TSDB_CODE_SUCCESS == code) {
511,320,836✔
5099
    code = queryNodeAddrInlineToMsg(&pNode->execNode, pEncoder);
511,280,606✔
5100
  }
5101
  if (TSDB_CODE_SUCCESS == code) {
511,053,730✔
5102
    code = tlvEncodeValueBool(pEncoder, pNode->showRewrite);
511,013,738✔
5103
  }
5104
  if (TSDB_CODE_SUCCESS == code) {
511,344,763✔
5105
    code = tlvEncodeValueI32(pEncoder, pNode->rowsThreshold);
511,312,921✔
5106
  }
5107
  if (TSDB_CODE_SUCCESS == code) {
511,236,993✔
5108
    code = tlvEncodeValueBool(pEncoder, pNode->dynamicRowThreshold);
511,206,654✔
5109
  }
5110
  if (TSDB_CODE_SUCCESS == code) {
511,242,711✔
5111
    code = tlvEncodeValueBool(pEncoder, pNode->isView);
511,173,914✔
5112
  }
5113
  if (TSDB_CODE_SUCCESS == code) {
511,306,737✔
5114
    code = tlvEncodeValueBool(pEncoder, pNode->isAudit);
511,247,704✔
5115
  }
5116
  if (TSDB_CODE_SUCCESS == code) {
511,399,920✔
5117
    code = tlvEncodeValueBool(pEncoder, pNode->processOneBlock);
511,349,479✔
5118
  }
5119
  if (TSDB_CODE_SUCCESS == code) {
511,309,265✔
5120
    code = tlvEncodeValueBool(pEncoder, pNode->dynTbname);
511,269,149✔
5121
  }
5122
  return code;
511,357,474✔
5123
}
5124

5125
static int32_t subplanToMsg(const void* pObj, STlvEncoder* pEncoder) {
511,196,517✔
5126
  const SSubplan* pNode = (const SSubplan*)pObj;
511,196,517✔
5127

5128
  int32_t code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_INLINE_ATTRS, subplanInlineToMsg, pNode);
511,196,517✔
5129
  if (TSDB_CODE_SUCCESS == code) {
511,050,768✔
5130
    code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_ROOT_NODE, nodeToMsg, pNode->pNode);
511,063,752✔
5131
  }
5132
  if (TSDB_CODE_SUCCESS == code) {
511,280,182✔
5133
    code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_DATA_SINK, nodeToMsg, pNode->pDataSink);
511,285,959✔
5134
  }
5135
  if (TSDB_CODE_SUCCESS == code) {
511,437,504✔
5136
    code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_TAG_COND, nodeToMsg, pNode->pTagCond);
511,443,887✔
5137
  }
5138
  if (TSDB_CODE_SUCCESS == code) {
511,173,442✔
5139
    code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_TAG_INDEX_COND, nodeToMsg, pNode->pTagIndexCond);
511,178,657✔
5140
  }
5141

5142
  return code;
510,863,284✔
5143
}
5144

5145
static int32_t msgToSubplanInline(STlvDecoder* pDecoder, void* pObj) {
358,901,710✔
5146
  SSubplan* pNode = (SSubplan*)pObj;
358,901,710✔
5147

5148
  int32_t code = msgToSubplanIdInline(pDecoder, &pNode->id);
358,901,710✔
5149
  if (TSDB_CODE_SUCCESS == code) {
358,918,735✔
5150
    code = tlvDecodeValueEnum(pDecoder, &pNode->subplanType, sizeof(pNode->subplanType));
358,887,255✔
5151
  }
5152
  if (TSDB_CODE_SUCCESS == code) {
358,783,752✔
5153
    code = tlvDecodeValueI32(pDecoder, &pNode->msgType);
358,783,752✔
5154
  }
5155
  if (TSDB_CODE_SUCCESS == code) {
358,897,672✔
5156
    code = tlvDecodeValueI32(pDecoder, &pNode->level);
358,897,672✔
5157
  }
5158
  if (TSDB_CODE_SUCCESS == code) {
358,902,088✔
5159
    code = tlvDecodeValueCStr(pDecoder, pNode->dbFName);
358,902,088✔
5160
  }
5161
  if (TSDB_CODE_SUCCESS == code) {
358,900,201✔
5162
    code = tlvDecodeValueCStr(pDecoder, pNode->user);
358,900,201✔
5163
  }
5164
  if (TSDB_CODE_SUCCESS == code) {
358,934,830✔
5165
    code = msgToQueryNodeAddrInline(pDecoder, &pNode->execNode);
358,934,830✔
5166
  }
5167
  if (TSDB_CODE_SUCCESS == code) {
358,914,243✔
5168
    code = tlvDecodeValueBool(pDecoder, &pNode->showRewrite);
358,914,243✔
5169
  }
5170
  if (TSDB_CODE_SUCCESS == code) {
358,904,546✔
5171
    code = tlvDecodeValueI32(pDecoder, &pNode->rowsThreshold);
358,904,546✔
5172
  }
5173
  if (TSDB_CODE_SUCCESS == code) {
358,926,804✔
5174
    code = tlvDecodeValueBool(pDecoder, &pNode->dynamicRowThreshold);
358,926,804✔
5175
  }
5176
  if (TSDB_CODE_SUCCESS == code) {
358,919,890✔
5177
    code = tlvDecodeValueBool(pDecoder, &pNode->isView);
358,919,890✔
5178
  }
5179
  if (TSDB_CODE_SUCCESS == code) {
358,926,666✔
5180
    code = tlvDecodeValueBool(pDecoder, &pNode->isAudit);
358,926,666✔
5181
  }
5182
  if (TSDB_CODE_SUCCESS == code) {
358,923,120✔
5183
    code = tlvDecodeValueBool(pDecoder, &pNode->processOneBlock);
358,923,120✔
5184
  }
5185
  if (TSDB_CODE_SUCCESS == code) {
358,926,889✔
5186
    code = tlvDecodeValueBool(pDecoder, &pNode->dynTbname);
358,926,889✔
5187
  }
5188
  return code;
358,923,267✔
5189
}
5190

5191
static int32_t msgToSubplan(STlvDecoder* pDecoder, void* pObj) {
358,894,721✔
5192
  SSubplan* pNode = (SSubplan*)pObj;
358,894,721✔
5193

5194
  int32_t code = TSDB_CODE_SUCCESS;
358,894,721✔
5195
  STlv*   pTlv = NULL;
358,894,721✔
5196
  tlvForEach(pDecoder, pTlv, code) {
1,454,604,570✔
5197
    switch (pTlv->type) {
1,095,758,884✔
5198
      case SUBPLAN_CODE_INLINE_ATTRS:
358,883,903✔
5199
        code = tlvDecodeObjFromTlv(pTlv, msgToSubplanInline, pNode);
358,883,903✔
5200
        break;
358,888,493✔
5201
      case SUBPLAN_CODE_ROOT_NODE:
358,930,688✔
5202
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pNode);
358,930,688✔
5203
        break;
358,910,586✔
5204
      case SUBPLAN_CODE_DATA_SINK:
358,925,994✔
5205
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pDataSink);
358,925,994✔
5206
        break;
358,925,002✔
5207
      case SUBPLAN_CODE_TAG_COND:
14,417,970✔
5208
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTagCond);
14,417,970✔
5209
        break;
14,415,339✔
5210
      case SUBPLAN_CODE_TAG_INDEX_COND:
4,595,054✔
5211
        code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTagIndexCond);
4,595,054✔
5212
        break;
4,550,950✔
5213
      default:
×
5214
        break;
×
5215
    }
5216
  }
5217

5218
  return code;
358,954,208✔
5219
}
5220

5221
enum { QUERY_PLAN_CODE_INLINE_ATTRS = 1, QUERY_PLAN_CODE_SUBPLANS };
5222

5223
static int32_t queryPlanInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,352✔
5224
  const SQueryPlan* pNode = (const SQueryPlan*)pObj;
2,352✔
5225

5226
  int32_t code = tlvEncodeValueU64(pEncoder, pNode->queryId);
2,352✔
5227
  if (TSDB_CODE_SUCCESS == code) {
2,352✔
5228
    code = tlvEncodeValueI32(pEncoder, pNode->numOfSubplans);
2,352✔
5229
  }
5230

5231
  return code;
2,352✔
5232
}
5233

5234
static int32_t queryPlanToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,352✔
5235
  const SQueryPlan* pNode = (const SQueryPlan*)pObj;
2,352✔
5236

5237
  int32_t code = tlvEncodeObj(pEncoder, QUERY_PLAN_CODE_INLINE_ATTRS, queryPlanInlineToMsg, pNode);
2,352✔
5238
  if (TSDB_CODE_SUCCESS == code) {
2,352✔
5239
    code = tlvEncodeObj(pEncoder, QUERY_PLAN_CODE_SUBPLANS, nodeListToMsg, pNode->pSubplans);
2,352✔
5240
  }
5241

5242
  return code;
2,352✔
5243
}
5244

5245
static int32_t msgToQueryPlanInline(STlvDecoder* pDecoder, void* pObj) {
1,176✔
5246
  SQueryPlan* pNode = (SQueryPlan*)pObj;
1,176✔
5247

5248
  int32_t code = tlvDecodeValueU64(pDecoder, &pNode->queryId);
1,176✔
5249
  if (TSDB_CODE_SUCCESS == code) {
1,176✔
5250
    code = tlvDecodeValueI32(pDecoder, &pNode->numOfSubplans);
1,176✔
5251
  }
5252

5253
  return code;
1,176✔
5254
}
5255

5256
static int32_t msgToQueryPlan(STlvDecoder* pDecoder, void* pObj) {
1,176✔
5257
  SQueryPlan* pNode = (SQueryPlan*)pObj;
1,176✔
5258

5259
  int32_t code = TSDB_CODE_SUCCESS;
1,176✔
5260
  STlv*   pTlv = NULL;
1,176✔
5261
  tlvForEach(pDecoder, pTlv, code) {
3,528✔
5262
    switch (pTlv->type) {
2,352✔
5263
      case QUERY_PLAN_CODE_INLINE_ATTRS:
1,176✔
5264
        code = tlvDecodeObjFromTlv(pTlv, msgToQueryPlanInline, pNode);
1,176✔
5265
        break;
1,176✔
5266
      case QUERY_PLAN_CODE_SUBPLANS:
1,176✔
5267
        code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pSubplans);
1,176✔
5268
        break;
1,176✔
5269
      default:
×
5270
        break;
×
5271
    }
5272
  }
5273

5274
  return code;
1,176✔
5275
}
5276

5277
static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,147,483,647✔
5278
  // nodesWarn("specificNodeToMsg node = %s, before tlv count = %d", nodesNodeName(nodeType(pObj)), pEncoder->tlvCount);
5279
  int32_t code = TSDB_CODE_SUCCESS;
2,147,483,647✔
5280
  switch (nodeType(pObj)) {
2,147,483,647✔
5281
    case QUERY_NODE_COLUMN:
2,147,483,647✔
5282
      code = columnNodeToMsg(pObj, pEncoder);
2,147,483,647✔
5283
      break;
2,147,483,647✔
5284
    case QUERY_NODE_VALUE:
470,488,096✔
5285
      code = valueNodeToMsg(pObj, pEncoder);
470,488,096✔
5286
      break;
470,386,898✔
5287
    case QUERY_NODE_OPERATOR:
321,287,968✔
5288
      code = operatorNodeToMsg(pObj, pEncoder);
321,287,968✔
5289
      break;
321,288,305✔
5290
    case QUERY_NODE_LOGIC_CONDITION:
48,481,324✔
5291
      code = logicConditionNodeToMsg(pObj, pEncoder);
48,481,324✔
5292
      break;
48,495,757✔
5293
    case QUERY_NODE_FUNCTION:
698,286,973✔
5294
      code = functionNodeToMsg(pObj, pEncoder);
698,286,973✔
5295
      break;
698,309,821✔
5296
    case QUERY_NODE_ORDER_BY_EXPR:
92,562,109✔
5297
      code = orderByExprNodeToMsg(pObj, pEncoder);
92,562,109✔
5298
      break;
92,569,314✔
5299
    case QUERY_NODE_LIMIT:
41,238,741✔
5300
      code = limitNodeToMsg(pObj, pEncoder);
41,238,741✔
5301
      break;
41,255,304✔
5302
    case QUERY_NODE_NODE_LIST:
11,096,421✔
5303
      code = nodeListNodeToMsg(pObj, pEncoder);
11,096,421✔
5304
      break;
11,101,192✔
5305
    case QUERY_NODE_TARGET:
2,147,483,647✔
5306
      code = targetNodeToMsg(pObj, pEncoder);
2,147,483,647✔
5307
      break;
2,147,483,647✔
5308
    case QUERY_NODE_TIME_RANGE:
×
5309
      code = timeRangeNodeToMsg(pObj, pEncoder);
×
5310
      break;
×
5311
    case QUERY_NODE_DATABLOCK_DESC:
1,588,367,254✔
5312
      code = dataBlockDescNodeToMsg(pObj, pEncoder);
1,588,367,254✔
5313
      break;
1,589,524,026✔
5314
    case QUERY_NODE_SLOT_DESC:
2,147,483,647✔
5315
      code = slotDescNodeToMsg(pObj, pEncoder);
2,147,483,647✔
5316
      break;
2,147,483,647✔
5317
    case QUERY_NODE_DOWNSTREAM_SOURCE:
241,847,351✔
5318
      code = downstreamSourceNodeToMsg(pObj, pEncoder);
241,847,351✔
5319
      break;
241,846,361✔
5320
    case QUERY_NODE_LEFT_VALUE:
7,409,467✔
5321
      break;
7,409,467✔
5322
    case QUERY_NODE_WHEN_THEN:
7,160,446✔
5323
      code = whenThenNodeToMsg(pObj, pEncoder);
7,160,446✔
5324
      break;
7,160,446✔
5325
    case QUERY_NODE_CASE_WHEN:
6,977,851✔
5326
      code = caseWhenNodeToMsg(pObj, pEncoder);
6,977,851✔
5327
      break;
6,978,368✔
5328
    case QUERY_NODE_WINDOW_OFFSET:
325,560✔
5329
      code = windowOffsetNodeToMsg(pObj, pEncoder);
325,560✔
5330
      break;
325,560✔
5331
    case QUERY_NODE_REMOTE_VALUE:
60,192,526✔
5332
      code = remoteValueNodeToMsg(pObj, pEncoder);
60,192,526✔
5333
      break;
60,192,087✔
5334
    case QUERY_NODE_REMOTE_VALUE_LIST:
18,289,614✔
5335
      code = remoteValueListNodeToMsg(pObj, pEncoder);
18,289,614✔
5336
      break;
18,291,830✔
5337
    case QUERY_NODE_REMOTE_ROW:
23,250,529✔
5338
      code = remoteRowNodeToMsg(pObj, pEncoder);
23,250,529✔
5339
      break;
23,250,442✔
5340
    case QUERY_NODE_REMOTE_ZERO_ROWS:
1,310,178✔
5341
      code = remoteZeroRowsNodeToMsg(pObj, pEncoder);
1,310,178✔
5342
      break;
1,309,028✔
5343
    case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
14,299,152✔
5344
      code = physiTagScanNodeToMsg(pObj, pEncoder);
14,299,152✔
5345
      break;
14,288,321✔
5346
    case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN:
5,469✔
5347
      code = physiScanNodeToMsg(pObj, pEncoder);
5,469✔
5348
      break;
5,469✔
5349
    case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN:
1,237,141✔
5350
    case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN:
5351
      code = physiLastRowScanNodeToMsg(pObj, pEncoder);
1,237,141✔
5352
      break;
1,237,391✔
5353
    case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
376,501,540✔
5354
    case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN:
5355
    case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
5356
      code = physiTableScanNodeToMsg(pObj, pEncoder);
376,501,540✔
5357
      break;
375,636,070✔
5358
    case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
31,275,310✔
5359
      code = physiSysTableScanNodeToMsg(pObj, pEncoder);
31,275,310✔
5360
      break;
31,277,450✔
5361
    case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
208,694,566✔
5362
      code = physiProjectNodeToMsg(pObj, pEncoder);
208,694,566✔
5363
      break;
208,774,146✔
5364
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN:
15,872,665✔
5365
      code = physiMergeJoinNodeToMsg(pObj, pEncoder);
15,872,665✔
5366
      break;
15,872,665✔
5367
    case QUERY_NODE_PHYSICAL_PLAN_HASH_JOIN:
1,224,398✔
5368
      code = physiHashJoinNodeToMsg(pObj, pEncoder);
1,224,398✔
5369
      break;
1,224,398✔
5370
    case QUERY_NODE_PHYSICAL_PLAN_HASH_AGG:
163,546,706✔
5371
      code = physiAggNodeToMsg(pObj, pEncoder);
163,546,706✔
5372
      break;
163,607,499✔
5373
    case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:
142,573,067✔
5374
      code = physiExchangeNodeToMsg(pObj, pEncoder);
142,573,067✔
5375
      break;
142,573,204✔
5376
    case QUERY_NODE_PHYSICAL_PLAN_MERGE:
18,263,404✔
5377
      code = physiMergeNodeToMsg(pObj, pEncoder);
18,263,404✔
5378
      break;
18,263,471✔
5379
    case QUERY_NODE_PHYSICAL_PLAN_SORT:
53,429,499✔
5380
    case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT:
5381
      code = physiSortNodeToMsg(pObj, pEncoder);
53,429,499✔
5382
      break;
53,438,807✔
5383
    case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
13,332,019✔
5384
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL:
5385
      code = physiIntervalNodeToMsg(pObj, pEncoder);
13,332,019✔
5386
      break;
13,332,002✔
5387
    case QUERY_NODE_PHYSICAL_PLAN_FILL:
513,405✔
5388
      code = physiFillNodeToMsg(pObj, pEncoder);
513,405✔
5389
      break;
514,626✔
5390
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION:
2,403,918✔
5391
      code = physiSessionWindowNodeToMsg(pObj, pEncoder);
2,403,918✔
5392
      break;
2,403,511✔
5393
    case QUERY_NODE_PHYSICAL_PLAN_EXTERNAL_WINDOW:
947,585✔
5394
    case QUERY_NODE_PHYSICAL_PLAN_HASH_EXTERNAL:
5395
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_EXTERNAL:
5396
      code = physiExternalWindowNodeToMsg(pObj, pEncoder);
947,585✔
5397
      break;
947,585✔
5398
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE:
2,369,324✔
5399
      code = physiStateWindowNodeToMsg(pObj, pEncoder);
2,369,324✔
5400
      break;
2,370,160✔
5401
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_EVENT:
1,765,120✔
5402
      code = physiEventWindowNodeToMsg(pObj, pEncoder);
1,765,120✔
5403
      break;
1,764,805✔
5404
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT:
1,627,185✔
5405
      code = physiCountWindowNodeToMsg(pObj, pEncoder);
1,627,185✔
5406
      break;
1,627,185✔
5407
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_ANOMALY:
×
5408
      code = physiAnomalyWindowNodeToMsg(pObj, pEncoder);
×
5409
      break;
×
5410
    case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
10,564,154✔
5411
      code = physiPartitionNodeToMsg(pObj, pEncoder);
10,564,154✔
5412
      break;
10,570,500✔
5413
    case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC:
3,147,018✔
5414
      code = physiIndefRowsFuncNodeToMsg(pObj, pEncoder);
3,147,018✔
5415
      break;
3,151,403✔
5416
    case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC:
3,451,522✔
5417
      code = physiInterpFuncNodeToMsg(pObj, pEncoder);
3,451,522✔
5418
      break;
3,451,522✔
5419
    case QUERY_NODE_PHYSICAL_PLAN_ANALYSIS_FUNC:
×
5420
    case QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC:
5421
      code = physiForecastFuncNodeToMsg(pObj, pEncoder);
×
5422
      break;
×
5423
    case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
508,823,808✔
5424
      code = physiDispatchNodeToMsg(pObj, pEncoder);
508,823,808✔
5425
      break;
508,969,053✔
5426
    case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT:
286,779✔
5427
      code = physiQueryInsertNodeToMsg(pObj, pEncoder);
286,779✔
5428
      break;
286,779✔
5429
    case QUERY_NODE_PHYSICAL_PLAN_DELETE:
1,803,701✔
5430
      code = physiDeleteNodeToMsg(pObj, pEncoder);
1,803,701✔
5431
      break;
1,803,701✔
5432
    case QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE:
1,223,602✔
5433
      code = physiGroupCacheNodeToMsg(pObj, pEncoder);
1,223,602✔
5434
      break;
1,223,602✔
5435
    case QUERY_NODE_PHYSICAL_PLAN_DYN_QUERY_CTRL:
5,262,429✔
5436
      code = physiDynQueryCtrlNodeToMsg(pObj, pEncoder);
5,262,429✔
5437
      break;
5,262,429✔
5438
    case QUERY_NODE_PHYSICAL_PLAN_VIRTUAL_TABLE_SCAN:
4,264,891✔
5439
      code = physiVirtualTableScanNodeToMsg(pObj, pEncoder);
4,264,891✔
5440
      break;
4,264,891✔
5441
    case QUERY_NODE_PHYSICAL_SUBPLAN:
511,278,698✔
5442
      code = subplanToMsg(pObj, pEncoder);
511,278,698✔
5443
      break;
510,941,678✔
5444
    case QUERY_NODE_PHYSICAL_PLAN:
2,570✔
5445
      code = queryPlanToMsg(pObj, pEncoder);
2,570✔
5446
      break;
2,352✔
5447
    default:
×
5448
      break;
×
5449
  }
5450
  if (TSDB_CODE_SUCCESS != code) {
2,147,483,647✔
5451
    nodesError("specificNodeToMsg error node = %s", nodesNodeName(nodeType(pObj)));
×
5452
  }
5453
  // nodesWarn("specificNodeToMsg node = %s, after tlv count = %d", nodesNodeName(nodeType(pObj)), pEncoder->tlvCount);
5454
  return code;
2,147,483,647✔
5455
}
5456

5457
static int32_t msgToSpecificNode(STlvDecoder* pDecoder, void* pObj) {
2,147,483,647✔
5458
  int32_t code = TSDB_CODE_SUCCESS;
2,147,483,647✔
5459
  switch (nodeType(pObj)) {
2,147,483,647✔
5460
    case QUERY_NODE_COLUMN:
2,147,483,647✔
5461
      code = msgToColumnNode(pDecoder, pObj);
2,147,483,647✔
5462
      break;
2,147,483,647✔
5463
    case QUERY_NODE_VALUE:
390,533,903✔
5464
      code = msgToValueNode(pDecoder, pObj);
390,533,903✔
5465
      break;
390,505,705✔
5466
    case QUERY_NODE_OPERATOR:
262,048,749✔
5467
      code = msgToOperatorNode(pDecoder, pObj);
262,048,749✔
5468
      break;
262,036,015✔
5469
    case QUERY_NODE_LOGIC_CONDITION:
44,505,117✔
5470
      code = msgToLogicConditionNode(pDecoder, pObj);
44,505,117✔
5471
      break;
44,504,061✔
5472
    case QUERY_NODE_FUNCTION:
575,670,972✔
5473
      code = msgToFunctionNode(pDecoder, pObj);
575,670,972✔
5474
      break;
575,650,753✔
5475
    case QUERY_NODE_ORDER_BY_EXPR:
60,725,911✔
5476
      code = msgToOrderByExprNode(pDecoder, pObj);
60,725,911✔
5477
      break;
60,727,290✔
5478
    case QUERY_NODE_LIMIT:
34,884,612✔
5479
      code = msgToLimitNode(pDecoder, pObj);
34,884,612✔
5480
      break;
34,884,830✔
5481
    case QUERY_NODE_NODE_LIST:
7,570,224✔
5482
      code = msgToNodeListNode(pDecoder, pObj);
7,570,224✔
5483
      break;
7,570,224✔
5484
    case QUERY_NODE_TARGET:
2,147,483,647✔
5485
      code = msgToTargetNode(pDecoder, pObj);
2,147,483,647✔
5486
      break;
2,147,483,647✔
5487
    case QUERY_NODE_TIME_RANGE:
×
5488
      code = msgToTimeRangeNode(pDecoder, pObj);
×
5489
      break;
×
5490
    case QUERY_NODE_DATABLOCK_DESC:
1,127,438,033✔
5491
      code = msgToDataBlockDescNode(pDecoder, pObj);
1,127,438,033✔
5492
      break;
1,127,436,458✔
5493
    case QUERY_NODE_SLOT_DESC:
2,147,483,647✔
5494
      code = msgToSlotDescNode(pDecoder, pObj);
2,147,483,647✔
5495
      break;
2,147,483,647✔
5496
    case QUERY_NODE_DOWNSTREAM_SOURCE:
179,582,280✔
5497
      code = msgToDownstreamSourceNode(pDecoder, pObj);
179,582,280✔
5498
    case QUERY_NODE_LEFT_VALUE:
186,976,960✔
5499
      break;
186,976,960✔
5500
    case QUERY_NODE_WHEN_THEN:
1,621,401✔
5501
      code = msgToWhenThenNode(pDecoder, pObj);
1,621,401✔
5502
      break;
1,621,401✔
5503
    case QUERY_NODE_CASE_WHEN:
1,440,469✔
5504
      code = msgToCaseWhenNode(pDecoder, pObj);
1,440,469✔
5505
      break;
1,440,469✔
5506
    case QUERY_NODE_WINDOW_OFFSET:
327,012✔
5507
      code = msgToWindowOffsetNode(pDecoder, pObj);
327,012✔
5508
      break;
327,012✔
5509
    case QUERY_NODE_REMOTE_VALUE:
4,867,410✔
5510
      code = msgToRemoteValueNode(pDecoder, pObj);
4,867,410✔
5511
      break;
4,867,410✔
5512
    case QUERY_NODE_REMOTE_VALUE_LIST:
11,964,692✔
5513
      code = msgToRemoteValueListNode(pDecoder, pObj);
11,964,692✔
5514
      break;
11,964,692✔
5515
    case QUERY_NODE_REMOTE_ROW:
21,728,295✔
5516
      code = msgToRemoteRowNode(pDecoder, pObj);
21,728,295✔
5517
      break;
21,728,295✔
5518
    case QUERY_NODE_REMOTE_ZERO_ROWS:
380,395✔
5519
      code = msgToRemoteZeroRowsNode(pDecoder, pObj);
380,395✔
5520
      break;
380,395✔
5521
    case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
7,983,207✔
5522
      code = msgToPhysiTagScanNode(pDecoder, pObj);
7,983,207✔
5523
      break;
7,984,115✔
5524
    case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN:
5,470✔
5525
      code = msgToPhysiScanNode(pDecoder, pObj);
5,470✔
5526
      break;
5,470✔
5527
    case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN:
1,232,936✔
5528
    case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN:
5529
      code = msgToPhysiLastRowScanNode(pDecoder, pObj);
1,232,936✔
5530
      break;
1,232,936✔
5531
    case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
271,170,147✔
5532
    case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN:
5533
    case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
5534
      code = msgToPhysiTableScanNode(pDecoder, pObj);
271,170,147✔
5535
      break;
271,148,992✔
5536
    case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
16,222,738✔
5537
      code = msgToPhysiSysTableScanNode(pDecoder, pObj);
16,222,738✔
5538
      break;
16,223,432✔
5539
    case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
146,171,714✔
5540
      code = msgToPhysiProjectNode(pDecoder, pObj);
146,171,714✔
5541
      break;
146,180,308✔
5542
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN:
12,977,992✔
5543
      code = msgToPhysiMergeJoinNode(pDecoder, pObj);
12,977,992✔
5544
      break;
12,977,992✔
5545
    case QUERY_NODE_PHYSICAL_PLAN_HASH_JOIN:
1,224,119✔
5546
      code = msgToPhysiHashJoinNode(pDecoder, pObj);
1,224,119✔
5547
      break;
1,224,119✔
5548
    case QUERY_NODE_PHYSICAL_PLAN_HASH_AGG:
127,390,906✔
5549
      code = msgToPhysiAggNode(pDecoder, pObj);
127,390,906✔
5550
      break;
127,396,165✔
5551
    case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:
110,468,754✔
5552
      code = msgToPhysiExchangeNode(pDecoder, pObj);
110,468,754✔
5553
      break;
110,468,745✔
5554
    case QUERY_NODE_PHYSICAL_PLAN_MERGE:
13,819,489✔
5555
      code = msgToPhysiMergeNode(pDecoder, pObj);
13,819,489✔
5556
      break;
13,819,489✔
5557
    case QUERY_NODE_PHYSICAL_PLAN_SORT:
32,793,931✔
5558
    case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT:
5559
      code = msgToPhysiSortNode(pDecoder, pObj);
32,793,931✔
5560
      break;
32,794,065✔
5561
    case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
5,454,816✔
5562
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL:
5563
      code = msgToPhysiIntervalNode(pDecoder, pObj);
5,454,816✔
5564
      break;
5,455,211✔
5565
    case QUERY_NODE_PHYSICAL_PLAN_FILL:
509,283✔
5566
      code = msgToPhysiFillNode(pDecoder, pObj);
509,283✔
5567
      break;
509,283✔
5568
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION:
560,937✔
5569
      code = msgToPhysiSessionWindowNode(pDecoder, pObj);
560,937✔
5570
      break;
560,937✔
5571
    case QUERY_NODE_PHYSICAL_PLAN_EXTERNAL_WINDOW:
937,134✔
5572
    case QUERY_NODE_PHYSICAL_PLAN_HASH_EXTERNAL:
5573
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_EXTERNAL:
5574
      code = msgToPhysiExternalWindowNode(pDecoder, pObj);
937,134✔
5575
      break;
937,134✔
5576
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE:
977,597✔
5577
      code = msgToPhysiStateWindowNode(pDecoder, pObj);
977,597✔
5578
      break;
977,597✔
5579
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_EVENT:
312,591✔
5580
      code = msgToPhysiEventWindowNode(pDecoder, pObj);
312,591✔
5581
      break;
312,591✔
5582
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT:
250,928✔
5583
      code = msgToPhysiCountWindowNode(pDecoder, pObj);
250,928✔
5584
      break;
250,928✔
5585
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_ANOMALY:
×
5586
      code = msgToPhysiAnomalyWindowNode(pDecoder, pObj);
×
5587
      break;
×
5588
    case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
2,980,072✔
5589
      code = msgToPhysiPartitionNode(pDecoder, pObj);
2,980,072✔
5590
      break;
2,980,626✔
5591
    case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC:
3,122,754✔
5592
      code = msgToPhysiIndefRowsFuncNode(pDecoder, pObj);
3,122,754✔
5593
      break;
3,123,284✔
5594
    case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC:
3,443,288✔
5595
      code = msgToPhysiInterpFuncNode(pDecoder, pObj);
3,443,288✔
5596
      break;
3,443,288✔
5597
    case QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC:
×
5598
    case QUERY_NODE_PHYSICAL_PLAN_ANALYSIS_FUNC:
5599
      code = msgToPhysiForecastFuncNode(pDecoder, pObj);
×
5600
      break;
×
5601
    case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
356,811,118✔
5602
      code = msgToPhysiDispatchNode(pDecoder, pObj);
356,811,118✔
5603
      break;
356,822,869✔
5604
    case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT:
286,373✔
5605
      code = msgToPhysiQueryInsertNode(pDecoder, pObj);
286,373✔
5606
      break;
286,373✔
5607
    case QUERY_NODE_PHYSICAL_PLAN_DELETE:
1,799,574✔
5608
      code = msgToPhysiDeleteNode(pDecoder, pObj);
1,799,574✔
5609
      break;
1,799,574✔
5610
    case QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE:
1,223,323✔
5611
      code = msgToPhysiGroupCacheNode(pDecoder, pObj);
1,223,323✔
5612
      break;
1,223,323✔
5613
    case QUERY_NODE_PHYSICAL_PLAN_DYN_QUERY_CTRL:
3,389,349✔
5614
      code = msgToPhysiDynQueryCtrlNode(pDecoder, pObj);
3,389,349✔
5615
      break;
3,389,349✔
5616
    case QUERY_NODE_PHYSICAL_PLAN_VIRTUAL_TABLE_SCAN:
3,874,185✔
5617
      code = msgToPhysiVirtualTableScanNode(pDecoder, pObj);
3,874,185✔
5618
      break;
3,874,185✔
5619
    case QUERY_NODE_PHYSICAL_SUBPLAN:
358,899,907✔
5620
      code = msgToSubplan(pDecoder, pObj);
358,899,907✔
5621
      break;
358,917,432✔
5622
    case QUERY_NODE_PHYSICAL_PLAN:
1,176✔
5623
      code = msgToQueryPlan(pDecoder, pObj);
1,176✔
5624
      break;
1,176✔
5625
    default:
×
5626
      break;
×
5627
  }
5628
  if (TSDB_CODE_SUCCESS != code) {
2,147,483,647✔
5629
    nodesError("msgToSpecificNode error node = %s", nodesNodeName(nodeType(pObj)));
×
5630
  }
5631
  return code;
2,147,483,647✔
5632
}
5633

5634
static int32_t nodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,147,483,647✔
5635
  return tlvEncodeObj(pEncoder, nodeType(pObj), specificNodeToMsg, pObj);
2,147,483,647✔
5636
}
5637

5638
static int32_t msgToNode(STlvDecoder* pDecoder, void** pObj) {
2,147,483,647✔
5639
  return tlvDecodeDynObj(pDecoder, (FMakeObject)nodesMakeNode, msgToSpecificNode, pObj);
2,147,483,647✔
5640
}
5641

5642
static int32_t msgToNodeFromTlv(STlv* pTlv, void** pObj) {
2,147,483,647✔
5643
  STlvDecoder decoder = {.bufSize = pTlv->len, .offset = 0, .pBuf = pTlv->value};
2,147,483,647✔
5644
  return msgToNode(&decoder, pObj);
2,147,483,647✔
5645
}
5646

5647
static int32_t nodeListToMsg(const void* pObj, STlvEncoder* pEncoder) {
2,147,483,647✔
5648
  const SNodeList* pList = (const SNodeList*)pObj;
2,147,483,647✔
5649

5650
  SNode* pNode = NULL;
2,147,483,647✔
5651
  FOREACH(pNode, pList) {
2,147,483,647✔
5652
    int32_t code = nodeToMsg(pNode, pEncoder);
2,147,483,647✔
5653
    if (TSDB_CODE_SUCCESS != code) {
2,147,483,647✔
5654
      return code;
×
5655
    }
5656
  }
5657

5658
  return TSDB_CODE_SUCCESS;
2,147,483,647✔
5659
}
5660
enum {
5661
  SARRAY_CODE_CAPACITY = 1,
5662
  SARRAY_CODE_ELEMSIZE,
5663
  SARRAY_CODE_SIZE,
5664
  SARRAY_CODE_PDATA
5665
};
5666

5667
static int32_t SArrayToMsg(const void* pObj, STlvEncoder* pEncoder) {
142,572,804✔
5668
  const SArray* pArray = (const SArray*)pObj;
142,572,804✔
5669
  int32_t code = TSDB_CODE_SUCCESS;
142,572,804✔
5670
  if (TSDB_CODE_SUCCESS == code) {
142,572,804✔
5671
    code = tlvEncodeI32(pEncoder, SARRAY_CODE_CAPACITY, pArray->capacity);
142,574,292✔
5672
  }
5673
  if (TSDB_CODE_SUCCESS == code) {
142,574,397✔
5674
    code = tlvEncodeI32(pEncoder, SARRAY_CODE_ELEMSIZE, pArray->elemSize);
142,574,888✔
5675
  }
5676
  if (TSDB_CODE_SUCCESS == code) {
142,572,322✔
5677
    code = tlvEncodeI32(pEncoder, SARRAY_CODE_SIZE, pArray->size);
142,572,947✔
5678
  }
5679
  if (TSDB_CODE_SUCCESS == code && pArray->capacity * pArray->elemSize > 0 && pArray->pData != NULL) {
142,574,282✔
5680
    code = tlvEncodeBinary(pEncoder, SARRAY_CODE_PDATA, pArray->pData, pArray->capacity * pArray->elemSize);
142,573,910✔
5681
  }
5682
  return code;
142,574,455✔
5683
}
5684

5685

5686
static int32_t msgToNodeList(STlvDecoder* pDecoder, void** pObj) {
2,147,483,647✔
5687
  SNodeList* pList = NULL;
2,147,483,647✔
5688
  int32_t code = TSDB_CODE_SUCCESS;
2,147,483,647✔
5689
  code = nodesMakeList(&pList);
2,147,483,647✔
5690

5691
  while (TSDB_CODE_SUCCESS == code && !tlvDecodeEnd(pDecoder)) {
2,147,483,647✔
5692
    SNode* pNode = NULL;
2,147,483,647✔
5693
    code = msgToNode(pDecoder, (void**)&pNode);
2,147,483,647✔
5694
    if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
5695
      code = nodesListAppend(pList, pNode);
2,147,483,647✔
5696
    }
5697
  }
5698
  if (TSDB_CODE_SUCCESS == code) {
2,147,483,647✔
5699
    *pObj = pList;
2,147,483,647✔
5700
  } else {
5701
    nodesDestroyList(pList);
×
5702
  }
5703
  return code;
2,147,483,647✔
5704
}
5705

5706
static int32_t msgToSArray(STlv* pTlv, void** pObj){
110,467,711✔
5707
  SArray* pArray = NULL;
110,467,711✔
5708
  uint32_t capacity = 0;
110,467,711✔
5709
  uint32_t elemSize = 0;
110,468,216✔
5710
  uint32_t actualSize;
110,467,081✔
5711
  int32_t decodeFieldNum = 0;;
110,468,240✔
5712
  int32_t code = TSDB_CODE_SUCCESS;
110,468,240✔
5713
  STlvDecoder decoder = {.bufSize = pTlv->len, .offset = 0, .pBuf = pTlv->value};
110,468,240✔
5714
  STlv*   pTlvTemp = NULL;
110,468,216✔
5715
  STlv*   pDataTlv = NULL;
110,468,216✔
5716

5717
  tlvForEach(&decoder, pTlvTemp, code) {
552,341,741✔
5718
    switch (pTlvTemp->type) {
441,876,603✔
5719
      case SARRAY_CODE_CAPACITY:
110,468,229✔
5720
        code = tlvDecodeI32(pTlvTemp, &capacity);
110,468,229✔
5721
        break;
110,468,216✔
5722
      case SARRAY_CODE_ELEMSIZE:
110,469,283✔
5723
        code = tlvDecodeI32(pTlvTemp, &elemSize);
110,469,283✔
5724
        break;
110,469,283✔
5725
      case SARRAY_CODE_SIZE:
110,470,337✔
5726
        code = tlvDecodeI32(pTlvTemp, &actualSize);
110,470,337✔
5727
        break;
110,469,283✔
5728
      case SARRAY_CODE_PDATA:
110,469,283✔
5729
        if (decodeFieldNum < 3) {
110,469,283✔
5730
          pDataTlv = pTlvTemp;
×
5731
          break;
×
5732
        }
5733
        pArray = taosArrayInit(capacity, elemSize);
110,469,283✔
5734
        if (NULL == pArray) {
110,467,308✔
5735
          return terrno;
×
5736
        }
5737
        pArray->size = actualSize;
110,467,308✔
5738
        if (TSDB_CODE_SUCCESS != code || pTlvTemp == NULL) {
110,468,216✔
5739
          taosArrayDestroy(pArray);
×
5740
          return TSDB_CODE_OUT_OF_MEMORY;
×
5741
        }
5742
        code = tlvDecodeBinary(pTlvTemp, pArray->pData);
110,469,283✔
5743
        break;
110,466,743✔
5744
      default:
×
5745
        break;
×
5746
    }
5747
    decodeFieldNum++;
441,873,525✔
5748
  }
5749

5750
  if (pDataTlv != NULL) {
110,469,036✔
5751
    pArray = taosArrayInit(capacity, elemSize);
×
5752
    if (NULL == pArray) {
×
5753
      return terrno;
×
5754
    }
5755
    pArray->size = actualSize;
×
5756
    if (TSDB_CODE_SUCCESS != code || pTlvTemp == NULL) {
×
5757
      taosArrayDestroy(pArray);
×
5758
      return TSDB_CODE_OUT_OF_MEMORY;
×
5759
    }
5760
    code = tlvDecodeBinary(pDataTlv, pArray->pData);
×
5761
  }
5762
  *pObj = pArray;
110,469,036✔
5763
  return code;
110,468,216✔
5764
}
5765

5766

5767
static int32_t msgToNodeListFromTlv(STlv* pTlv, void** pObj) {
2,147,483,647✔
5768
  STlvDecoder decoder = {.bufSize = pTlv->len, .offset = 0, .pBuf = pTlv->value};
2,147,483,647✔
5769
  return msgToNodeList(&decoder, pObj);
2,147,483,647✔
5770
}
5771

5772
int32_t nodesNodeToMsg(const SNode* pNode, char** pMsg, int32_t* pLen) {
511,280,781✔
5773
  if (NULL == pNode || NULL == pMsg || NULL == pLen) {
511,280,781✔
5774
    terrno = TSDB_CODE_FAILED;
43,870✔
5775
    return TSDB_CODE_FAILED;
×
5776
  }
5777

5778
  STlvEncoder encoder;
386,134,550✔
5779
  int32_t     code = initTlvEncoder(&encoder);
511,398,029✔
5780
  if (TSDB_CODE_SUCCESS == code) {
510,631,892✔
5781
    code = nodeToMsg(pNode, &encoder);
510,669,719✔
5782
  }
5783
  if (TSDB_CODE_SUCCESS == code) {
511,271,358✔
5784
    endTlvEncode(&encoder, pMsg, pLen);
511,334,148✔
5785
  }
5786
  clearTlvEncoder(&encoder);
510,511,480✔
5787

5788
  terrno = code;
510,887,401✔
5789
  return code;
511,029,513✔
5790
}
5791

5792
int32_t nodesMsgToNode(const char* pMsg, int32_t len, SNode** pNode) {
358,971,617✔
5793
  if (NULL == pMsg || NULL == pNode) {
358,971,617✔
5794
    return TSDB_CODE_SUCCESS;
×
5795
  }
5796

5797
  STlvDecoder decoder = {.bufSize = len, .offset = 0, .pBuf = pMsg};
358,985,468✔
5798
  int32_t     code = msgToNode(&decoder, (void**)pNode);
358,986,150✔
5799
  if (TSDB_CODE_SUCCESS != code) {
358,954,463✔
5800
    nodesDestroyNode(*pNode);
×
5801
    *pNode = NULL;
×
5802
  }
5803

5804
  terrno = code;
358,954,463✔
5805
  return code;
358,942,040✔
5806
}
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