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

taosdata / TDengine / #4986

15 Mar 2026 08:32AM UTC coverage: 37.305% (-31.3%) from 68.601%
#4986

push

travis-ci

tomchon
test: keep docs and unit test

125478 of 336361 relevant lines covered (37.3%)

1134847.06 hits per line

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

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

16
#ifndef _TD_COMMON_DATA_FORMAT_H_
17
#define _TD_COMMON_DATA_FORMAT_H_
18

19
#include "os.h"
20
#include "talgo.h"
21
#include "tarray.h"
22
#include "tbuffer.h"
23
#include "tencode.h"
24
#include "tsimplehash.h"
25
#include "ttypes.h"
26
#include "tutil.h"
27

28
#ifdef __cplusplus
29
extern "C" {
30
#endif
31

32
typedef struct SSchema     SSchema;
33
typedef struct SSchema2    SSchema2;
34
typedef struct SSchemaExt  SSchemaExt;
35
typedef struct SSchemaRsma SSchemaRsma;
36
typedef struct STColumn    STColumn;
37
typedef struct STSchema    STSchema;
38
typedef struct SRSchema    SRSchema;
39
typedef struct SValue      SValue;
40
typedef struct SColVal     SColVal;
41
typedef struct SRow        SRow;
42
typedef struct SRowIter    SRowIter;
43
typedef struct STagVal     STagVal;
44
typedef struct STag        STag;
45
typedef struct SColData    SColData;
46
typedef struct SBlobSet    SBlobSet;
47

48
typedef struct SRowKey           SRowKey;
49
typedef struct SValueColumn      SValueColumn;
50
typedef struct SRowBuildScanInfo SRowBuildScanInfo;
51

52
#define ROW_BUILD_NONE   ((uint8_t)0x1)
53
#define ROW_BUILD_UPDATE ((uint8_t)0x2)
54
#define ROW_BUILD_MERGE  ((uint8_t)0x4)
55

56
typedef struct SBlobValOffset SBlobValOffset;
57
struct SColumnDataAgg;
58
typedef struct SColumnDataAgg *SColumnDataAggPtr;
59

60
#define HAS_NONE  ((uint8_t)0x1)
61
#define HAS_NULL  ((uint8_t)0x2)
62
#define HAS_VALUE ((uint8_t)0x4)
63
#define HAS_BLOB  ((uint8_t)0x8)
64

65
// bitmap ================================
66
const static uint8_t BIT1_MAP[8] = {0b11111110, 0b11111101, 0b11111011, 0b11110111,
67
                                    0b11101111, 0b11011111, 0b10111111, 0b01111111};
68

69
const static uint8_t BIT2_MAP[4] = {0b11111100, 0b11110011, 0b11001111, 0b00111111};
70

71
#define ONE               ((uint8_t)1)
72
#define THREE             ((uint8_t)3)
73
#define DIV_8(i)          ((i) >> 3)
74
#define MOD_8(i)          ((i)&7)
75
#define DIV_4(i)          ((i) >> 2)
76
#define MOD_4(i)          ((i)&3)
77
#define MOD_4_TIME_2(i)   (MOD_4(i) << 1)
78
#define BIT1_SIZE(n)      (DIV_8((n)-1) + 1)
79
#define BIT2_SIZE(n)      (DIV_4((n)-1) + 1)
80
#define SET_BIT1(p, i, v) ((p)[DIV_8(i)] = (p)[DIV_8(i)] & BIT1_MAP[MOD_8(i)] | ((v) << MOD_8(i)))
81
#define SET_BIT1_EX(p, i, v) \
82
  do {                       \
83
    if (MOD_8(i) == 0) {     \
84
      (p)[DIV_8(i)] = 0;     \
85
    }                        \
86
    SET_BIT1(p, i, v);       \
87
  } while (0)
88
#define GET_BIT1(p, i)    (((p)[DIV_8(i)] >> MOD_8(i)) & ONE)
89
#define SET_BIT2(p, i, v) ((p)[DIV_4(i)] = (p)[DIV_4(i)] & BIT2_MAP[MOD_4(i)] | ((v) << MOD_4_TIME_2(i)))
90
#define SET_BIT2_EX(p, i, v) \
91
  do {                       \
92
    if (MOD_4(i) == 0) {     \
93
      (p)[DIV_4(i)] = 0;     \
94
    }                        \
95
    SET_BIT2(p, i, v);       \
96
  } while (0)
97
#define GET_BIT2(p, i) (((p)[DIV_4(i)] >> MOD_4_TIME_2(i)) & THREE)
98

99
// SColVal ================================
100
#define CV_FLAG_VALUE ((int8_t)0x0)
101
#define CV_FLAG_NONE  ((int8_t)0x1)
102
#define CV_FLAG_NULL  ((int8_t)0x2)
103

104
#define COL_VAL_NONE(CID, TYPE) ((SColVal){.cid = (CID), .flag = CV_FLAG_NONE, .value = {.type = (TYPE)}})
105
#define COL_VAL_NULL(CID, TYPE) ((SColVal){.cid = (CID), .flag = CV_FLAG_NULL, .value = {.type = (TYPE)}})
106
#define COL_VAL_VALUE(CID, V)   ((SColVal){.cid = (CID), .flag = CV_FLAG_VALUE, .value = (V)})
107

108
#define COL_VAL_IS_NONE(CV)  ((CV)->flag == CV_FLAG_NONE)
109
#define COL_VAL_IS_NULL(CV)  ((CV)->flag == CV_FLAG_NULL)
110
#define COL_VAL_IS_VALUE(CV) ((CV)->flag == CV_FLAG_VALUE)
111

112
// Strategies of merging rows with
113
// same pk in single insert batch.
114
typedef enum {
115
  PREFER_NON_NULL = 0,  // choose latest non-null value for each column
116
  KEEP_CONSISTENCY = 1  // choose latest row
117
} ERowMergeStrategy;
118
#define BSE_SEQUECE_SIZE sizeof(uint64_t)
119

120
enum { TSDB_DATA_BLOB_VALUE = 0x1, TSDB_DATA_BLOB_EMPTY_VALUE = 0x2, TSDB_DATA_BLOB_NULL_VALUE = 0x4 };
121

122
#define tRowGetKey(_pRow, _pKey)                       \
123
  do {                                                 \
124
    (_pKey)->ts = taosGetInt64Aligned(&((_pRow)->ts)); \
125
    (_pKey)->numOfPKs = 0;                             \
126
    if ((_pRow)->numOfPKs > 0) {                       \
127
      tRowGetPrimaryKey((_pRow), (_pKey));             \
128
    }                                                  \
129
  } while (0)
130

131
// SValueColumn ================================
132
typedef struct {
133
  int8_t  cmprAlg;  // filled by caller
134
  int8_t  type;
135
  int32_t dataOriginalSize;
136
  int32_t dataCompressedSize;
137
  int32_t offsetOriginalSize;
138
  int32_t offsetCompressedSize;
139
} SValueColumnCompressInfo;
140

141
int32_t tValueColumnInit(SValueColumn *valCol);
142
void    tValueColumnDestroy(SValueColumn *valCol);
143
void    tValueColumnClear(SValueColumn *valCol);
144
int32_t tValueColumnAppend(SValueColumn *valCol, const SValue *value);
145
int32_t tValueColumnUpdate(SValueColumn *valCol, int32_t idx, const SValue *value);
146
int32_t tValueColumnGet(SValueColumn *valCol, int32_t idx, SValue *value);
147
int32_t tValueColumnCompress(SValueColumn *valCol, SValueColumnCompressInfo *info, SBuffer *output, SBuffer *assist);
148
int32_t tValueColumnDecompress(void *input, const SValueColumnCompressInfo *compressInfo, SValueColumn *valCol,
149
                               SBuffer *buffer);
150
int32_t tValueColumnCompressInfoEncode(const SValueColumnCompressInfo *compressInfo, SBuffer *buffer);
151
int32_t tValueColumnCompressInfoDecode(SBufferReader *reader, SValueColumnCompressInfo *compressInfo);
152
int32_t tValueCompare(const SValue *tv1, const SValue *tv2);
153

154
// SRow ================================
155
int32_t tRowBuild(SArray *aColVal, const STSchema *pTSchema, SRow **ppRow, SRowBuildScanInfo *pScanInfo);
156
int32_t tRowBuildWithBlob(SArray *aColVal, const STSchema *pTSchema, SRow **ppRow, SBlobSet *pBlobSet,
157
                          SRowBuildScanInfo *sinfo);
158
int32_t tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal);
159

160
typedef struct {
161
  uint64_t offset;
162
  uint32_t len;
163
  uint32_t dataOffset;
164
  int8_t   nextRow;
165
  int8_t   type;
166
} SBlobValue;
167

168
typedef struct {
169
  uint64_t seq;
170
  uint32_t seqOffsetInRow;
171
  void    *data;
172
  int32_t  len;
173
  int8_t   type;
174
} SBlobItem;
175
int32_t tBlobSetCreate(int64_t cap, int8_t type, SBlobSet **ppBlobSet);
176
int32_t tBlobSetPush(SBlobSet *pBlobSet, SBlobItem *pBlobItem, uint64_t *seq, int8_t nextRow);
177
int32_t tBlobSetUpdate(SBlobSet *pBlobSet, uint64_t seq, SBlobItem *pBlobItem);
178
int32_t tBlobSetGet(SBlobSet *pBlobSet, uint64_t seq, SBlobItem *pItem);
179
void    tBlobSetDestroy(SBlobSet *pBlowRow);
180
int32_t tBlobSetSize(SBlobSet *pBlobSet);
181
void    tBlobSetSwap(SBlobSet *p1, SBlobSet *p2);
182
// int32_t tBlobRowEnd(SBlobSet *pBlobSet);
183
//  int32_t tBlobSetRebuild(SBlobSet *pBlobSet, int32_t srow, int32_t nrow, SBlobSet **pNew);
184

185
int32_t tRowGetBlobSeq(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal, uint64_t *seq);
186
void    tRowDestroy(SRow *pRow);
187
int32_t tRowSort(SArray *aRowP);
188
int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, ERowMergeStrategy strategy);
189
int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag);
190
void    tRowGetPrimaryKey(SRow *pRow, SRowKey *key);
191
int32_t tRowKeyCompare(const SRowKey *key1, const SRowKey *key2);
192
void    tRowKeyAssign(SRowKey *pDst, SRowKey *pSrc);
193
int32_t tRowSortWithBlob(SArray *aRowP, STSchema *pTSchema, SBlobSet *pBlobSet);
194
int32_t tRowMergeWithBlob(SArray *pRow, STSchema *pTSchema, SBlobSet *pBlobSet, int8_t flag);
195

196
// SRowIter ================================
197
int32_t  tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter);
198
void     tRowIterClose(SRowIter **ppIter);
199
SColVal *tRowIterNext(SRowIter *pIter);
200

201
// STag ================================
202
int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag);
203
void    tTagFree(STag *pTag);
204
bool    tTagIsJson(const void *pTag);
205
bool    tTagIsJsonNull(void *tagVal);
206
bool    tTagGet(const STag *pTag, STagVal *pTagVal);
207
char   *tTagValToData(const STagVal *pTagVal, bool isJson);
208
int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag);
209
int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag);
210
int32_t tTagToValArray(const STag *pTag, SArray **ppArray);
211
void    destroyTagVal(void *pTag);
212
void    debugPrintSTag(STag *pTag, const char *tag, int32_t ln);  // TODO: remove
213
int32_t parseJsontoTagData(const char *json, SArray *pTagVals, STag **ppTag, void *pMsgBuf, void *charsetCxt);
214
void    destroyColVal(void *p);
215

216
// SColData ================================
217
typedef struct {
218
  uint32_t cmprAlg;  // filled by caller
219
  int8_t   columnFlag;
220
  int8_t   flag;
221
  int8_t   dataType;
222
  int16_t  columnId;
223
  int32_t  numOfData;
224
  int32_t  bitmapOriginalSize;
225
  int32_t  bitmapCompressedSize;
226
  int32_t  offsetOriginalSize;
227
  int32_t  offsetCompressedSize;
228
  int32_t  dataOriginalSize;
229
  int32_t  dataCompressedSize;
230
} SColDataCompressInfo;
231

232
typedef void *(*xMallocFn)(void *, int32_t);
233
typedef int32_t (*checkWKBGeometryFn)(const unsigned char *geoWKB, size_t nGeom);
234
typedef int32_t (*initGeosFn)();
235

236
void    tColDataDestroy(void *ph);
237
void    tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t cflag);
238
void    tColDataClear(SColData *pColData);
239
void    tColDataDeepClear(SColData *pColData);
240
int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal);
241
int32_t tColDataUpdateValue(SColData *pColData, SColVal *pColVal, bool forward);
242
int32_t tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal);
243
uint8_t tColDataGetBitValue(const SColData *pColData, int32_t iVal);
244
int32_t tColDataCopy(SColData *pColDataFrom, SColData *pColData, xMallocFn xMalloc, void *arg);
245
void    tColDataArrGetRowKey(SColData *aColData, int32_t nColData, int32_t iRow, SRowKey *key);
246

247
extern void (*tColDataCalcSMA[])(SColData *pColData, SColumnDataAggPtr pAggs);
248

249
int32_t tColDataCompress(SColData *colData, SColDataCompressInfo *info, SBuffer *output, SBuffer *assist);
250
int32_t tColDataDecompress(void *input, SColDataCompressInfo *info, SColData *colData, SBuffer *assist);
251

252
// for stmt bind
253
int32_t tColDataAddValueByBind(SColData *pColData, TAOS_MULTI_BIND *pBind, int32_t buffMaxLen, initGeosFn igeos,
254
                               checkWKBGeometryFn cgeos);
255
int32_t tColDataSortMerge(SArray **arr);
256
int32_t tColDataSortMergeWithBlob(SArray **arr, SBlobSet *pBlob);
257

258
// for raw block
259
int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t bytes, int32_t nRows, char *lengthOrbitmap,
260
                                    char *data);
261

262
int32_t tColDataAddValueByDataBlockWithBlob(SColData *pColData, int8_t type, int32_t bytes, int32_t nRows,
263
                                            char *lengthOrbitmap, char *data, void *pBlobSet);
264
// for encode/decode
265
int32_t tEncodeColData(uint8_t version, SEncoder *pEncoder, SColData *pColData);
266
int32_t tDecodeColData(uint8_t version, SDecoder *pDecoder, SColData *pColData, bool jump);
267
int32_t tEncodeRow(SEncoder *pEncoder, SRow *pRow);
268
int32_t tDecodeRow(SDecoder *pDecoder, SRow **ppRow);
269

270
int32_t tEncodeBlobSet(SEncoder *pEncoder, SBlobSet *pRow);
271
int32_t tDecodeBlobSet(SDecoder *pDecoder, SBlobSet **pBlobSet);
272

273
// STRUCT ================================
274
struct STColumn {
275
  col_id_t colId;
276
  int8_t   type;
277
  int8_t   flags;
278
  int32_t  bytes;
279
  int32_t  offset;
280
};
281

282
struct STSchema {
283
  int32_t  numOfCols;
284
  int32_t  version;
285
  int32_t  flen;
286
  int32_t  tlen;
287
  STColumn columns[];
288
};
289

290
struct SRSchema {
291
  char       tbName[TSDB_TABLE_NAME_LEN];
292
  int8_t     tbType;
293
  int32_t    rowSize;
294
  int32_t    maxBufRows;
295
  tb_uid_t   tbUid;
296
  int64_t    interval[2];
297
  func_id_t *funcIds;
298
  STSchema  *tSchema;
299
  void      *extSchema;  // SExtSchema, for decimal type
300
};
301

302
static FORCE_INLINE void tFreeSRSchema(SRSchema **rSchema) {
303
  if (rSchema && *rSchema) {
×
304
    taosMemoryFreeClear((*rSchema)->funcIds);
×
305
    taosMemoryFreeClear((*rSchema)->tSchema);
×
306
    taosMemoryFreeClear((*rSchema)->extSchema);
×
307
    taosMemoryFreeClear(*rSchema);
×
308
  }
309
}
×
310

311
/*
312
 * 1. Tuple format:
313
 *      SRow + [(type, offset) * numOfPKs +] [bit map +] fix-length data + [var-length data]
314
 *
315
 * 2. K-V format:
316
 *      SRow + [(type, offset) * numOfPKs +] offset array + ([-]cid [+ data]) * numColsNotNone
317
 */
318
struct SRow {
319
  uint8_t  flag;
320
  uint8_t  numOfPKs;
321
  uint16_t sver;
322
  uint32_t len;
323
  TSKEY    ts;
324
  uint8_t  data[];
325
};
326

327
struct SBlobSet {
328
  int8_t    type;
329
  int8_t    rowType;
330
  SHashObj *pSeqToffset;
331
  int64_t   seq;
332
  int64_t   len;
333
  int32_t   cap;
334
  uint8_t   compress;
335
  SArray   *pSeqTable;
336

337
  SArray  *pSet;
338
  uint8_t *data;
339
};
340

341
typedef struct {
342
  int8_t   type;
343
  uint32_t offset;
344
} SPrimaryKeyIndex;
345

346
#define DATUM_MAX_SIZE 16
347

348
struct SValue {
349
  union {
350
    int64_t  val;
351
    uint8_t *pData;
352
  };
353
  uint32_t nData;
354
  int8_t   type;
355
};
356

357
struct SBlobValOffset {
358
  uint64_t seq;
359
  uint32_t offset;
360
  uint32_t rowNum;
361
};
362
#define VALUE_GET_DATUM(pVal, type) \
363
  (IS_VAR_DATA_TYPE(type) || type == TSDB_DATA_TYPE_DECIMAL) ? (pVal)->pData : (void *)&(pVal)->val
364

365
#define VALUE_GET_TRIVIAL_DATUM(pVal)    ((pVal)->val)
366
#define VALUE_SET_TRIVIAL_DATUM(pVal, v) (pVal)->val = v
367

368
void valueSetDatum(SValue *pVal, int8_t type, void *pDatum, uint32_t len);
369
void valueCloneDatum(SValue *pDst, const SValue *pSrc, int8_t type);
370
void valueClearDatum(SValue *pVal, int8_t type);
371

372
#define TD_MAX_PK_COLS 2
373
struct SRowKey {
374
  TSKEY   ts;
375
  uint8_t numOfPKs;
376
  SValue  pks[TD_MAX_PK_COLS];
377
};
378

379
struct SColVal {
380
  int16_t cid;
381
  int8_t  flag;
382
  SValue  value;
383
};
384

385
struct SColData {
386
  int16_t  cid;
387
  int8_t   type;
388
  int8_t   cflag;
389
  int32_t  numOfNone;   // # of none
390
  int32_t  numOfNull;   // # of null
391
  int32_t  numOfValue;  // # of vale
392
  int32_t  nVal;
393
  int8_t   flag;
394
  uint8_t *pBitMap;
395
  int32_t *aOffset;
396
  int32_t  nData;
397
  uint8_t *pData;
398
};
399

400
#pragma pack(push, 1)
401
struct STagVal {
402
  //  char colName[TSDB_COL_NAME_LEN]; // only used for tmq_get_meta
403
  union {
404
    int16_t cid;
405
    char   *pKey;
406
  };
407
  int8_t type;
408
  union {
409
    int64_t i64;
410
    struct {
411
      uint32_t nData;
412
      uint8_t *pData;
413
    };
414
  };
415
};
416

417
#define TD_TAG_JSON  ((int8_t)0x40)  // distinguish JSON string and JSON value with the highest bit
418
#define TD_TAG_LARGE ((int8_t)0x20)
419
struct STag {
420
  int8_t  flags;
421
  int16_t len;
422
  int16_t nTag;
423
  int32_t ver;
424
  int8_t  idx[];
425
};
426
#pragma pack(pop)
427

428
#if 1  //================================================================================================================================================
429
// Imported since 3.0 and use bitmap to demonstrate None/Null/Norm, while use Null/Norm below 3.0 without of bitmap.
430
#define TD_SUPPORT_BITMAP
431

432
#define STR_TO_VARSTR(x, str)                     \
433
  do {                                            \
434
    VarDataLenT __len = (VarDataLenT)strlen(str); \
435
    *(VarDataLenT *)(x) = __len;                  \
436
    (void)memcpy(varDataVal(x), (str), __len);    \
437
  } while (0);
438

439
#define STR_WITH_MAXSIZE_TO_VARSTR(x, str, _maxs)                         \
440
  do {                                                                    \
441
    char *_e = stpncpy(varDataVal(x), (str), (_maxs)-VARSTR_HEADER_SIZE); \
442
    varDataSetLen(x, (_e - (x)-VARSTR_HEADER_SIZE));                      \
443
  } while (0)
444

445
#define STR_WITH_SIZE_TO_VARSTR(x, str, _size)   \
446
  do {                                           \
447
    *(VarDataLenT *)(x) = (VarDataLenT)(_size);  \
448
    (void)memcpy(varDataVal(x), (str), (_size)); \
449
  } while (0);
450

451
// STSchema ================================
452
STSchema *tBuildTSchema(SSchema *aSchema, int32_t numOfCols, int32_t version);
453
#define tDestroyTSchema(pTSchema) \
454
  do {                            \
455
    if (pTSchema) {               \
456
      taosMemoryFree(pTSchema);   \
457
      pTSchema = NULL;            \
458
    }                             \
459
  } while (0)
460
const STColumn *tTSchemaSearchColumn(const STSchema *pTSchema, int16_t cid);
461

462
struct SValueColumn {
463
  int8_t   type;
464
  uint32_t numOfValues;
465
  SBuffer  data;
466
  SBuffer  offsets;
467
};
468

469
typedef struct {
470
  int32_t  dataType;      // filled by caller
471
  uint32_t cmprAlg;       // filled by caller
472
  int32_t  originalSize;  // filled by caller
473
  int32_t  compressedSize;
474
} SCompressInfo;
475

476
int32_t tCompressData(void          *input,       // input
477
                      SCompressInfo *info,        // compress info
478
                      void          *output,      // output
479
                      int32_t        outputSize,  // output size
480
                      SBuffer       *buffer       // assistant buffer provided by caller, can be NULL
481
);
482
int32_t tDecompressData(void                *input,       // input
483
                        const SCompressInfo *info,        // compress info
484
                        void                *output,      // output
485
                        int32_t              outputSize,  // output size
486
                        SBuffer             *buffer       // assistant buffer provided by caller, can be NULL
487
);
488
int32_t tCompressDataToBuffer(void *input, SCompressInfo *info, SBuffer *output, SBuffer *assist);
489
int32_t tDecompressDataToBuffer(void *input, SCompressInfo *info, SBuffer *output, SBuffer *assist);
490

491
typedef struct {
492
  int32_t          columnId;
493
  int32_t          type;
494
  TAOS_MULTI_BIND *bind;
495
} SBindInfo;
496
int32_t tRowBuildFromBind(SBindInfo *infos, int32_t numOfInfos, bool infoSorted, const STSchema *pTSchema,
497
                          SArray *rowArray, bool *pOrdered, bool *pDupTs);
498

499
// stmt2 binding
500
int32_t tColDataAddValueByBind2(SColData *pColData, TAOS_STMT2_BIND *pBind, int32_t buffMaxLen);
501

502
int32_t tColDataAddValueByBind2WithGeos(SColData *pColData, TAOS_STMT2_BIND *pBind, int32_t buffMaxLen,
503
                                        initGeosFn igeos, checkWKBGeometryFn cgeos);
504

505
int32_t tColDataAddValueByBind2WithBlob(SColData *pColData, TAOS_STMT2_BIND *pBind, int32_t buffMaxLen,
506
                                        SBlobSet *pBlobSet);
507

508
int32_t tColDataAddValueByBind2WithDecimal(SColData *pColData, TAOS_STMT2_BIND *pBind, int32_t buffMaxLen,
509
                                           uint8_t precision, uint8_t scale);
510

511
typedef struct {
512
  int32_t          columnId;
513
  int32_t          type;
514
  int32_t          bytes;
515
  TAOS_STMT2_BIND *bind;
516

517
} SBindInfo2;
518

519
int32_t tRowBuildFromBind2(SBindInfo2 *infos, int32_t numOfInfos, SSHashObj *parsedCols, bool infoSorted,
520
                           const STSchema *pTSchema, const SSchemaExt *pSchemaExt, SArray *rowArray, bool *pOrdered,
521
                           bool *pDupTs);
522

523
int32_t tRowBuildFromBind2WithBlob(SBindInfo2 *infos, int32_t numOfInfos, bool infoSorted, const STSchema *pTSchema,
524
                                   SArray *rowArray, bool *pOrdered, bool *pDupTs, SBlobSet *pBlobSet);
525

526
struct SRowBuildScanInfo {
527
  int32_t numOfNone;
528
  int32_t numOfNull;
529
  int32_t numOfValue;
530
  int32_t numOfPKs;
531
  int8_t  flag;
532

533
  // tuple
534
  int8_t           tupleFlag;
535
  SPrimaryKeyIndex tupleIndices[TD_MAX_PK_COLS];
536
  int32_t          tuplePKSize;      // primary key size
537
  int32_t          tupleBitmapSize;  // bitmap size
538
  int32_t          tupleFixedSize;   // fixed part size
539
  int32_t          tupleVarSize;     // var part size
540
  int32_t          tupleRowSize;
541

542
  // key-value
543
  int8_t           kvFlag;
544
  SPrimaryKeyIndex kvIndices[TD_MAX_PK_COLS];
545
  int32_t          kvMaxOffset;
546
  int32_t          kvPKSize;       // primary key size
547
  int32_t          kvIndexSize;    // offset array size
548
  int32_t          kvPayloadSize;  // payload size
549
  int32_t          kvRowSize;
550

551
  int8_t hasBlob;
552
  int8_t scanType;
553
};
554

555
int8_t schemaHasBlob(const STSchema *pSchema);
556
#endif
557

558
#ifdef __cplusplus
559
}
560
#endif
561

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

© 2026 Coveralls, Inc