diff --git a/include/common/trow.h b/include/common/trow.h
index 8332c10ed2..92713e8e63 100644
--- a/include/common/trow.h
+++ b/include/common/trow.h
@@ -289,7 +289,7 @@ int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValT
*/
static FORCE_INLINE void tdSRowInit(SRowBuilder *pBuilder, int16_t sver) {
- pBuilder->rowType = TD_ROW_TP; // default STpRow
+ pBuilder->rowType = pBuilder->rowType;
pBuilder->sver = sver;
}
int32_t tdSRowSetInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBoundCols, int32_t flen);
@@ -331,7 +331,7 @@ void tdSTSRowIterReset(STSRowIter *pIter, STSRow *pRow);
bool tdSTSRowIterFetch(STSRowIter *pIter, col_id_t colId, col_type_t colType, SCellVal *pVal);
bool tdSTSRowIterNext(STSRowIter *pIter, SCellVal *pVal);
-int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow);
+int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t rowType);
bool tdSTSRowGetVal(STSRowIter *pIter, col_id_t colId, col_type_t colType, SCellVal *pVal);
void tdSRowPrint(STSRow *row, STSchema *pSchema, const char *tag);
diff --git a/source/common/src/trow.c b/source/common/src/trow.c
index b91562be7a..cf6d4752d9 100644
--- a/source/common/src/trow.c
+++ b/source/common/src/trow.c
@@ -231,7 +231,7 @@ bool tdSTSRowIterGetKvVal(STSRowIter *pIter, col_id_t colId, col_id_t *nIdx, SCe
return true;
}
-#ifdef BUILD_NO_CALL
+// #ifdef BUILD_NO_CALL
const uint8_t tdVTypeByte[2][3] = {{
// 2 bits
TD_VTYPE_NORM_BYTE_II,
@@ -439,13 +439,14 @@ bool tdSTSRowIterNext(STSRowIter *pIter, SCellVal *pVal) {
return true;
}
-int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow) {
+int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t rowType) {
STColumn *pTColumn;
SColVal *pColVal;
int32_t nColVal = taosArrayGetSize(pArray);
int32_t varDataLen = 0;
int32_t maxVarDataLen = 0;
int32_t iColVal = 0;
+ int32_t nBound = 0;
void *varBuf = NULL;
bool isAlloc = false;
@@ -458,6 +459,9 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow) {
} else {
pColVal = NULL;
}
+ if (pColVal && !COL_VAL_IS_NONE(pColVal)) {
+ ++nBound;
+ }
if (iColumn == 0) {
ASSERT(pColVal && pColVal->cid == pTColumn->colId);
@@ -512,10 +516,11 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow) {
}
}
- SRowBuilder rb = {0};
+ SRowBuilder rb = {.rowType = rowType};
tdSRowInit(&rb, pTSchema->version);
- tdSRowSetInfo(&rb, pTSchema->numOfCols, pTSchema->numOfCols, pTSchema->flen);
+ tdSRowSetInfo(&rb, pTSchema->numOfCols, nBound, pTSchema->flen);
tdSRowResetBuf(&rb, *ppRow);
+ int32_t iBound = 0;
iColVal = 0;
for (int32_t iColumn = 0; iColumn < pTSchema->numOfCols; ++iColumn) {
@@ -529,21 +534,28 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow) {
valType = TD_VTYPE_NONE;
} else if (COL_VAL_IS_NULL(pColVal)) {
valType = TD_VTYPE_NULL;
+ ++iBound;
} else if (IS_VAR_DATA_TYPE(pTColumn->type)) {
varDataSetLen(varBuf, pColVal->value.nData);
if (pColVal->value.nData != 0) {
memcpy(varDataVal(varBuf), pColVal->value.pData, pColVal->value.nData);
}
val = varBuf;
+ ++iBound;
} else {
val = (const void *)&pColVal->value.val;
+ ++iBound;
}
} else {
// pColVal = NULL;
valType = TD_VTYPE_NONE;
}
- tdAppendColValToRow(&rb, pTColumn->colId, pTColumn->type, valType, val, true, pTColumn->offset, iColVal);
+ if (TD_IS_TP_ROW(rb.pBuf)) {
+ tdAppendColValToRow(&rb, pTColumn->colId, pTColumn->type, valType, val, true, pTColumn->offset, iColVal);
+ } else {
+ tdAppendColValToRow(&rb, pTColumn->colId, pTColumn->type, valType, val, true, rb.offset, iBound);
+ }
++iColVal;
}
@@ -761,11 +773,11 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp
int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val, bool isCopyVarData,
int8_t colType, int16_t colIdx, int32_t offset, col_id_t colId) {
- if ((offset < (int32_t)sizeof(SKvRowIdx)) || (colIdx < 1)) {
+ if (colIdx < 1) {
terrno = TSDB_CODE_INVALID_PARA;
+ ASSERTS(0, "colIdx is %" PRIi64, colIdx);
return terrno;
}
- offset -= sizeof(SKvRowIdx);
--colIdx;
#ifdef TD_SUPPORT_BITMAP
@@ -779,6 +791,7 @@ int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const vo
SKvRowIdx *pColIdx = (SKvRowIdx *)POINTER_SHIFT(TD_ROW_COL_IDX(row), offset);
pColIdx->colId = colId;
pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN
+ pBuilder->offset += sizeof(SKvRowIdx);
if (valType == TD_VTYPE_NORM) {
char *ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row));
if (IS_VAR_DATA_TYPE(colType)) {
@@ -904,6 +917,7 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
TD_ROW_SET_LEN(pBuilder->pBuf, len);
TD_ROW_SET_SVER(pBuilder->pBuf, pBuilder->sver);
TD_ROW_SET_NCOLS(pBuilder->pBuf, pBuilder->nBoundCols);
+ pBuilder->offset = 0;
break;
default:
terrno = TSDB_CODE_INVALID_PARA;
@@ -1056,7 +1070,7 @@ int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TDRowValT valType, int
void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColVal) {
STColumn *pTColumn = &pTSchema->columns[iCol];
SCellVal cv = {0};
- SValue value = {0};
+ // SValue value = {0};
ASSERT((pTColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) || (iCol > 0));
@@ -1084,5 +1098,4 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV
memcpy(&pColVal->value.val, cv.val, tDataTypes[pTColumn->type].bytes);
}
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/source/common/test/dataformatTest.cpp b/source/common/test/dataformatTest.cpp
index b1083e4590..81407c7ef0 100644
--- a/source/common/test/dataformatTest.cpp
+++ b/source/common/test/dataformatTest.cpp
@@ -13,7 +13,6 @@
* along with this program. If not, see .
*/
-#if 0
#include
#include
@@ -59,7 +58,6 @@ STSchema *genSTSchema(int16_t nCols) {
case 1: {
pSchema[i].type = TSDB_DATA_TYPE_INT;
pSchema[i].bytes = TYPE_BYTES[pSchema[i].type];
- ;
} break;
case 2: {
pSchema[i].type = TSDB_DATA_TYPE_BIGINT;
@@ -123,7 +121,8 @@ STSchema *genSTSchema(int16_t nCols) {
return pResult;
}
-// ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(10), c6 nchar(10), c7 tinyint, c8 smallint, c9 bool
+// ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(10), c6 nchar(10), c7 tinyint, c8 smallint,
+// c9 bool c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned
static int32_t genTestData(const char **data, int16_t nCols, SArray **pArray) {
if (!(*pArray)) {
*pArray = taosArrayInit(nCols, sizeof(SColVal));
@@ -142,59 +141,76 @@ static int32_t genTestData(const char **data, int16_t nCols, SArray **pArray) {
taosArrayPush(*pArray, &colVal);
continue;
}
-
switch (i) {
case 0:
- sscanf(data[i], "%" PRIi64, &colVal.value.ts);
+ colVal.type = TSDB_DATA_TYPE_TIMESTAMP;
+ sscanf(data[i], "%" PRIi64, &colVal.value.val);
break;
case 1:
- sscanf(data[i], "%" PRIi32, &colVal.value.i32);
+ colVal.type = TSDB_DATA_TYPE_INT;
+ sscanf(data[i], "%" PRIi32, (int32_t *)&colVal.value.val);
break;
case 2:
- sscanf(data[i], "%" PRIi64, &colVal.value.i64);
+ colVal.type = TSDB_DATA_TYPE_BIGINT;
+ sscanf(data[i], "%" PRIi64, &colVal.value.val);
break;
case 3:
- sscanf(data[i], "%f", &colVal.value.f);
+ colVal.type = TSDB_DATA_TYPE_FLOAT;
+ sscanf(data[i], "%f", (float *)&colVal.value.val);
break;
case 4:
- sscanf(data[i], "%lf", &colVal.value.d);
+ colVal.type = TSDB_DATA_TYPE_DOUBLE;
+ sscanf(data[i], "%lf", (double *)&colVal.value.val);
break;
case 5: {
+ colVal.type = TSDB_DATA_TYPE_BINARY;
int16_t dataLen = strlen(data[i]) + 1;
colVal.value.nData = dataLen < 10 ? dataLen : 10;
colVal.value.pData = (uint8_t *)data[i];
} break;
case 6: {
+ colVal.type = TSDB_DATA_TYPE_NCHAR;
int16_t dataLen = strlen(data[i]) + 1;
colVal.value.nData = dataLen < 40 ? dataLen : 40;
colVal.value.pData = (uint8_t *)data[i]; // just for test, not real nchar
} break;
- case 7:
- case 9: {
+ case 7: {
+ colVal.type = TSDB_DATA_TYPE_TINYINT;
int32_t d8;
sscanf(data[i], "%" PRId32, &d8);
- colVal.value.i8 = (int8_t)d8;
- } break;
+ colVal.value.val = (int8_t)d8;
+ }
case 8: {
+ colVal.type = TSDB_DATA_TYPE_SMALLINT;
int32_t d16;
sscanf(data[i], "%" PRId32, &d16);
- colVal.value.i16 = (int16_t)d16;
+ colVal.value.val = (int16_t)d16;
+ } break;
+ case 9: {
+ colVal.type = TSDB_DATA_TYPE_BOOL;
+ int32_t d8;
+ sscanf(data[i], "%" PRId32, &d8);
+ colVal.value.val = (int8_t)d8;
} break;
case 10: {
+ colVal.type = TSDB_DATA_TYPE_UTINYINT;
uint32_t u8;
sscanf(data[i], "%" PRId32, &u8);
- colVal.value.u8 = (uint8_t)u8;
+ colVal.value.val = (uint8_t)u8;
} break;
case 11: {
+ colVal.type = TSDB_DATA_TYPE_USMALLINT;
uint32_t u16;
sscanf(data[i], "%" PRId32, &u16);
- colVal.value.u16 = (uint16_t)u16;
+ colVal.value.val = (uint16_t)u16;
} break;
case 12: {
- sscanf(data[i], "%" PRIu32, &colVal.value.u32);
+ colVal.type = TSDB_DATA_TYPE_UINT;
+ sscanf(data[i], "%" PRIu32, (uint32_t *)&colVal.value.val);
} break;
case 13: {
- sscanf(data[i], "%" PRIu64, &colVal.value.u64);
+ colVal.type = TSDB_DATA_TYPE_UBIGINT;
+ sscanf(data[i], "%" PRIu64, (uint64_t *)&colVal.value.val);
} break;
default:
ASSERT(0);
@@ -215,25 +231,25 @@ int32_t debugPrintSColVal(SColVal *cv, int8_t type) {
}
switch (type) {
case TSDB_DATA_TYPE_BOOL:
- printf("%s ", cv->value.i8 == 0 ? "false" : "true");
+ printf("%s ", cv->value.val == 0 ? "false" : "true");
break;
case TSDB_DATA_TYPE_TINYINT:
- printf("%" PRIi8 " ", cv->value.i8);
+ printf("%" PRIi8 " ", *(int8_t *)&cv->value.val);
break;
case TSDB_DATA_TYPE_SMALLINT:
- printf("%" PRIi16 " ", cv->value.i16);
+ printf("%" PRIi16 " ", *(int16_t *)&cv->value.val);
break;
case TSDB_DATA_TYPE_INT:
- printf("%" PRIi32 " ", cv->value.i32);
+ printf("%" PRIi32 " ", *(int32_t *)&cv->value.val);
break;
case TSDB_DATA_TYPE_BIGINT:
- printf("%" PRIi64 " ", cv->value.i64);
+ printf("%" PRIi64 " ", cv->value.val);
break;
case TSDB_DATA_TYPE_FLOAT:
- printf("%f ", cv->value.f);
+ printf("%f ", *(float *)&cv->value.val);
break;
case TSDB_DATA_TYPE_DOUBLE:
- printf("%lf ", cv->value.d);
+ printf("%lf ", *(double *)&cv->value.val);
break;
case TSDB_DATA_TYPE_VARCHAR:
case TSDB_DATA_TYPE_GEOMETRY: {
@@ -242,7 +258,7 @@ int32_t debugPrintSColVal(SColVal *cv, int8_t type) {
printf("%s ", tv);
} break;
case TSDB_DATA_TYPE_TIMESTAMP:
- printf("%" PRIi64 " ", cv->value.i64);
+ printf("%" PRIi64 " ", cv->value.val);
break;
case TSDB_DATA_TYPE_NCHAR: {
char tv[15] = {0};
@@ -250,16 +266,16 @@ int32_t debugPrintSColVal(SColVal *cv, int8_t type) {
printf("%s ", tv);
} break;
case TSDB_DATA_TYPE_UTINYINT:
- printf("%" PRIu8 " ", cv->value.u8);
+ printf("%" PRIu8 " ", *(uint8_t *)&cv->value.val);
break;
case TSDB_DATA_TYPE_USMALLINT:
- printf("%" PRIu16 " ", cv->value.u16);
+ printf("%" PRIu16 " ", *(uint16_t *)&cv->value.val);
break;
case TSDB_DATA_TYPE_UINT:
- printf("%" PRIu32 " ", cv->value.u32);
+ printf("%" PRIu32 " ", *(uint32_t *)&cv->value.val);
break;
case TSDB_DATA_TYPE_UBIGINT:
- printf("%" PRIu64 " ", cv->value.u64);
+ printf("%" PRIu64 " ", *(uint64_t *)&cv->value.val);
break;
case TSDB_DATA_TYPE_JSON:
printf("JSON ");
@@ -286,11 +302,11 @@ int32_t debugPrintSColVal(SColVal *cv, int8_t type) {
return 0;
}
-void debugPrintTSRow(STSRow2 *row, STSchema *pTSchema, const char *tags, int32_t ln) {
- // printf("%s:%d %s:v%d:%d ", tags, ln, (row->flags & 0xf0) ? "KV" : "TP", row->sver, row->nData);
+void debugPrintTSRow(STSRow *row, STSchema *pTSchema, const char *tags, int32_t ln) {
+ printf("%s:%d %s:v%d:len-%u ", tags, ln, (row->type) ? "KV" : "TP", row->sver, row->len);
for (int16_t i = 0; i < pTSchema->numOfCols; ++i) {
SColVal cv = {0};
- tTSRowGet(row, pTSchema, i, &cv);
+ tTSRowGetVal(row, pTSchema, i, &cv);
debugPrintSColVal(&cv, pTSchema->columns[i].type);
}
printf("\n");
@@ -315,36 +331,36 @@ static int32_t checkSColVal(const char *rawVal, SColVal *cv, int8_t type) {
case TSDB_DATA_TYPE_TINYINT: {
int32_t d8;
sscanf(rawVal, "%" PRId32, &d8);
- EXPECT_EQ(cv->value.i8, (int8_t)d8);
+ EXPECT_EQ((int8_t)cv->value.val, (int8_t)d8);
} break;
case TSDB_DATA_TYPE_SMALLINT: {
int32_t d16;
sscanf(rawVal, "%" PRId32, &d16);
- EXPECT_EQ(cv->value.i16, (int16_t)d16);
+ EXPECT_EQ((int16_t)cv->value.val, (int16_t)d16);
} break;
case TSDB_DATA_TYPE_INT: {
- sscanf(rawVal, "%" PRId32, &rawSVal.i32);
- EXPECT_EQ(cv->value.i32, rawSVal.i32);
+ sscanf(rawVal, "%" PRId32, (int32_t *)&rawSVal.val);
+ EXPECT_EQ((int32_t)cv->value.val, (int32_t)rawSVal.val);
} break;
case TSDB_DATA_TYPE_BIGINT: {
- sscanf(rawVal, "%" PRIi64, &rawSVal.i64);
- EXPECT_EQ(cv->value.i64, rawSVal.i64);
+ sscanf(rawVal, "%" PRIi64, &rawSVal.val);
+ EXPECT_EQ(cv->value.val, rawSVal.val);
} break;
case TSDB_DATA_TYPE_FLOAT: {
- sscanf(rawVal, "%f", &rawSVal.f);
- EXPECT_FLOAT_EQ(cv->value.f, rawSVal.f);
+ sscanf(rawVal, "%f", (float *)&rawSVal.val);
+ EXPECT_FLOAT_EQ((float)cv->value.val, (float)rawSVal.val);
} break;
case TSDB_DATA_TYPE_DOUBLE: {
- sscanf(rawVal, "%lf", &rawSVal.d);
- EXPECT_DOUBLE_EQ(cv->value.d, rawSVal.d);
+ sscanf(rawVal, "%lf", (double *)&rawSVal.val);
+ EXPECT_DOUBLE_EQ((double)cv->value.val, (double)rawSVal.val);
} break;
case TSDB_DATA_TYPE_VARCHAR:
case TSDB_DATA_TYPE_GEOMETRY: {
EXPECT_STRCASEEQ(rawVal, (const char *)cv->value.pData);
} break;
case TSDB_DATA_TYPE_TIMESTAMP: {
- sscanf(rawVal, "%" PRIi64, &rawSVal.ts);
- EXPECT_DOUBLE_EQ(cv->value.ts, rawSVal.ts);
+ sscanf(rawVal, "%" PRIi64, &rawSVal.val);
+ EXPECT_DOUBLE_EQ(cv->value.val, rawSVal.val);
} break;
case TSDB_DATA_TYPE_NCHAR: {
EXPECT_STRCASEEQ(rawVal, (const char *)cv->value.pData); // informal nchar comparsion
@@ -352,20 +368,20 @@ static int32_t checkSColVal(const char *rawVal, SColVal *cv, int8_t type) {
case TSDB_DATA_TYPE_UTINYINT: {
uint32_t u8;
sscanf(rawVal, "%" PRIu32, &u8);
- EXPECT_EQ(cv->value.u8, (uint8_t)u8);
+ EXPECT_EQ((uint8_t)cv->value.val, (uint8_t)u8);
} break;
case TSDB_DATA_TYPE_USMALLINT: {
uint32_t u16;
sscanf(rawVal, "%" PRIu32, &u16);
- EXPECT_EQ(cv->value.u16, (uint16_t)u16);
+ EXPECT_EQ((uint16_t)cv->value.val, (uint16_t)u16);
} break;
case TSDB_DATA_TYPE_UINT: {
- sscanf(rawVal, "%" PRIu32, &rawSVal.u32);
- EXPECT_EQ(cv->value.u32, rawSVal.u32);
+ sscanf(rawVal, "%" PRIu32, (uint32_t *)&rawSVal.val);
+ EXPECT_EQ((uint32_t)cv->value.val, (uint32_t)rawSVal.val);
} break;
case TSDB_DATA_TYPE_UBIGINT: {
- sscanf(rawVal, "%" PRIu64, &rawSVal.u64);
- EXPECT_EQ(cv->value.u64, rawSVal.u64);
+ sscanf(rawVal, "%" PRIu64, (uint64_t *)&rawSVal.val);
+ EXPECT_EQ((uint64_t)cv->value.val, (uint64_t)rawSVal.val);
} break;
case TSDB_DATA_TYPE_JSON:
printf("JSON ");
@@ -395,36 +411,63 @@ static int32_t checkSColVal(const char *rawVal, SColVal *cv, int8_t type) {
return 0;
}
-static void checkTSRow(const char **data, STSRow2 *row, STSchema *pTSchema) {
+static void checkTSRow(const char **data, STSRow *row, STSchema *pTSchema) {
for (int16_t i = 0; i < pTSchema->numOfCols; ++i) {
SColVal cv = {0};
- tTSRowGet(row, pTSchema, i, &cv);
+ tTSRowGetVal(row, pTSchema, i, &cv);
checkSColVal(data[i], &cv, pTSchema->columns[i].type);
}
+
+ STSRowIter rowIter = {.pSchema = pTSchema};
+ tdSTSRowIterReset(&rowIter, row);
+ for (int32_t i = 0; i < pTSchema->numOfCols; ++i) {
+ STColumn *pCol = pTSchema->columns + i;
+ SColVal colVal = {0};
+ SCellVal cv = {0};
+ if (!tdSTSRowIterFetch(&rowIter, pCol->colId, pCol->type, &cv)) {
+ break;
+ }
+ if (tdValTypeIsNone(cv.valType)) {
+ colVal = COL_VAL_NONE(pCol->colId, pCol->type);
+ } else if (tdValTypeIsNull(cv.valType)) {
+ colVal = COL_VAL_NULL(pCol->colId, pCol->type);
+ } else {
+ colVal.cid = pCol->colId;
+ colVal.type = pCol->type;
+ colVal.flag = CV_FLAG_VALUE;
+
+ if (IS_VAR_DATA_TYPE(pCol->type)) {
+ colVal.value.nData = varDataLen(cv.val);
+ colVal.value.pData = (uint8_t *)varDataVal(cv.val);
+ } else {
+ memcpy(&colVal.value.val, cv.val, tDataTypes[pCol->type].bytes);
+ }
+ }
+ checkSColVal(data[i], &colVal, pCol->type);
+ }
}
TEST(testCase, AllNormTest) {
- int16_t nCols = 14;
- STSRowBuilder rb = {0};
- STSRow2 *row = nullptr;
- SArray *pArray = taosArrayInit(nCols, sizeof(SColVal));
+ int16_t nCols = 14;
+ STSRow *row = nullptr;
+ SArray *pArray = taosArrayInit(nCols, sizeof(SColVal));
EXPECT_NE(pArray, nullptr);
STSchema *pTSchema = genSTSchema(nCols);
EXPECT_NE(pTSchema, nullptr);
- // ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(10), c6 nchar(10), c7 tinyint, c8 smallint,
- // c9 bool
- char *data[14] = {"1653694220000", "no", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "no", "no", "no", "no", "no"};
+ // ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(10), c6 nchar(10), c7 tinyint, c8 smallint,
+ // c9 bool c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned
+ char *data[14] = {
+ "1653694220000", "10", "20", "10.1", "10.1", "binary10", "nchar10", "10", "10", "10", "10", "20", "30", "40"};
- genTestData((const char **)&data, nCols, &pArray);
+ // genTestData((const char **)&data, nCols, &pArray);
- tTSRowNew(&rb, pArray, pTSchema, &row);
+ // tdSTSRowNew(pArray, pTSchema, &row, TD_ROW_TP);
+ // debugPrintTSRow(row, pTSchema, __func__, __LINE__);
+ // tdSRowPrint(row, pTSchema, __func__);
+ // checkTSRow((const char **)&data, row, pTSchema);
- debugPrintTSRow(row, pTSchema, __func__, __LINE__);
- checkTSRow((const char **)&data, row, pTSchema);
-
- tsRowBuilderClear(&rb);
taosArrayDestroy(pArray);
taosMemoryFree(pTSchema);
}
@@ -433,7 +476,7 @@ TEST(testCase, AllNormTest) {
TEST(testCase, NoneTest) {
const static int nCols = 14;
const static int nRows = 20;
- STSRow2 *row = nullptr;
+ STSRow *row = nullptr;
SArray *pArray = taosArrayInit(nCols, sizeof(SColVal));
EXPECT_NE(pArray, nullptr);
@@ -442,42 +485,49 @@ TEST(testCase, NoneTest) {
// ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(10), c6 nchar(10), c7 tinyint, c8 smallint,
// c9 bool c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned
- const char *data[nRows][nCols] = {
- {"1653694220000", "no", "20", "10.1", "10.1", "binary10", "no", "10", "10", "nu", "10", "20", "30", "40"},
- {"1653694220001", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no"},
- {"1653694220002", "10", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no"},
- {"1653694220003", "10", "10", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no"},
- {"1653694220004", "no", "20", "no", "no", "no", "nchar10", "no", "no", "no", "no", "no", "no", "no"},
- {"1653694220005", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu"},
- {"1653694220006", "no", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu"},
- {"1653694220007", "no", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "no", "no", "no", "no", "no"},
- {"1653694220008", "no", "nu", "nu", "nu", "binary10", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "no"},
- {"1653694220009", "no", "nu", "nu", "nu", "binary10", "nu", "nu", "10", "no", "nu", "nu", "nu", "100"},
- {"1653694220010", "-1", "-1", "-1", "-1", "binary10", "nu", "-1", "0", "0", "0", "0", "0", "0"},
- {"1653694220011", "-2147483648", "nu", "nu", "nu", "biy10", "nu", "nu", "32767", "no", "nu", "nu", "nu", "100"},
- {"1653694220012", "2147483647", "nu", "nu", "nu", "ary10", "nu", "nu", "-32768", "no", "nu", "nu", "nu", "100"},
- {"1653694220013", "no", "-9223372036854775818", "nu", "nu", "b1", "nu", "nu", "10", "no", "nu", "nu", "nu", "nu"},
- {"1653694220014", "no", "nu", "nu", "nu", "b0", "nu", "nu", "10", "no", "nu", "nu", "nu", "9223372036854775808"},
- {"1653694220015", "no", "nu", "nu", "nu", "binary30", "char4", "nu", "10", "no", "nu", "nu", "nu",
- "18446744073709551615"},
- {"1653694220016", "2147483647", "nu", "nu", "nu", "bin50", "nu", "nu", "10", "no", "nu", "nu", "nu", "100"},
- {"1653694220017", "2147483646", "0", "0", "0", "binary10", "0", "0", "0", "0", "255", "0", "0", "0"},
- {"1653694220018", "no", "-9223372036854775808", "nu", "nu", "binary10", "nu", "nu", "10", "no", "nu", "nu",
- "4294967295", "100"},
- {"1653694220019", "no", "9223372036854775807", "nu", "nu", "bin10", "nu", "nu", "10", "no", "254", "nu", "nu",
- "no"}};
+ // const int8_t rowType[nRows] = {TD_ROW_TP, TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_KV,
+ // TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_TP, TD_ROW_KV, TD_ROW_KV,
+ // TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_TP};
+ const int8_t rowType[nRows] = {TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_KV,
+ TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_TP, TD_ROW_KV, TD_ROW_KV,
+ TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_KV, TD_ROW_TP};
+const char *data[nRows][nCols] = {
+ // {"1653694220000", "no", "20", "10.1", "10.1", "binary10", "no", "10", "10", "nu", "10", "20", "30", "40"},
+ // {"1653694220001", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no"},
+ // {"1653694220002", "10", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no"},
+ // {"1653694220003", "10", "10", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no"},
+ {"1653694220004", "no", "20", "no", "no", "no", "nchar10", "no", "no", "no", "no", "no", "no", "no"},
+ {"1653694220005", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu"},
+ {"1653694220006", "no", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "nu"},
+ {"1653694220007", "no", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "no", "no", "no", "no", "no"},
+ {"1653694220008", "no", "nu", "nu", "nu", "binary10", "nu", "nu", "nu", "nu", "nu", "nu", "nu", "no"},
+ {"1653694220009", "no", "nu", "nu", "nu", "binary10", "nu", "nu", "10", "no", "nu", "nu", "nu", "100"},
+ {"1653694220010", "-1", "-1", "-1", "-1", "binary10", "nu", "-1", "0", "0", "0", "0", "0", "0"},
+ {"1653694220011", "-2147483648", "nu", "nu", "nu", "biy10", "nu", "nu", "32767", "no", "nu", "nu", "nu", "100"},
+ {"1653694220012", "2147483647", "nu", "nu", "nu", "ary10", "nu", "nu", "-32768", "no", "nu", "nu", "nu", "100"},
+ {"1653694220013", "no", "-9223372036854775818", "nu", "nu", "b1", "nu", "nu", "10", "no", "nu", "nu", "nu", "nu"},
+ {"1653694220014", "no", "nu", "nu", "nu", "b0", "nu", "nu", "10", "no", "nu", "nu", "nu", "9223372036854775808"},
+ {"1653694220015", "no", "nu", "nu", "nu", "binary30", "char4", "nu", "10", "no", "nu", "nu", "nu",
+ "18446744073709551615"},
+ {"1653694220016", "2147483647", "nu", "nu", "nu", "bin50", "nu", "nu", "10", "no", "nu", "nu", "nu", "100"},
+ {"1653694220017", "2147483646", "0", "0", "0", "binary10", "0", "0", "0", "0", "255", "0", "0", "0"},
+ {"1653694220018", "no", "-9223372036854775808", "nu", "nu", "binary10", "nu", "nu", "10", "no", "nu", "nu",
+ "4294967295", "100"},
+ {"1653694220019", "no", "9223372036854775807", "nu", "nu", "bin10", "nu", "nu", "10", "no", "254", "nu", "nu",
+ "no"}};
- for (int r = 0; r < nRows; ++r) {
- genTestData((const char **)&data[r], nCols, &pArray);
- tTSRowNew(NULL, pArray, pTSchema, &row);
- debugPrintTSRow(row, pTSchema, __func__, __LINE__); // debug print
- checkTSRow((const char **)&data[r], row, pTSchema); // check
- tTSRowFree(row);
- taosArrayClear(pArray);
+for (int r = 0; r < nRows; ++r) {
+ printf("%s:%d index:%d\n", __func__, __LINE__, r);
+ genTestData((const char **)&data[r], nCols, &pArray);
+ tdSTSRowNew(pArray, pTSchema, &row, rowType[r]);
+ debugPrintTSRow(row, pTSchema, __func__, __LINE__); // debug print
+ tdSRowPrint(row, pTSchema, __func__);
+ checkTSRow((const char **)&data[r], row, pTSchema); // check
+ taosMemoryFreeClear(row);
+ taosArrayClear(pArray);
}
taosArrayDestroy(pArray);
taosMemoryFree(pTSchema);
}
-#endif
#endif
\ No newline at end of file