diff --git a/include/common/trow.h b/include/common/trow.h index e77fce022506e243ad4f1531618015364a62a6f4..ec8b38df467563854792ea8b83abe86bacdb4124 100644 --- a/include/common/trow.h +++ b/include/common/trow.h @@ -98,7 +98,7 @@ typedef struct { #pragma pack(push, 1) typedef struct { - col_id_t cid; + col_id_t colId; uint32_t offset; } SKvRowIdx; #pragma pack(pop) @@ -485,7 +485,7 @@ static FORCE_INLINE int32_t tdAppendColValToTpRow(STSRow *row, void *pBitmap, TD // 1. No need to set flen part for Null/None, just use bitmap. When upsert for the same primary TS key, the bitmap should // be updated simultaneously if Norm val overwrite Null/None cols. // 2. When consume STSRow in memory by taos client/tq, the output of Null/None cols should both be Null. - if (tdValIsNorm(valType)) { + if (tdValIsNorm(valType, val, colType)) { //TODO: The layout of new data types imported since 3.0 like blob/medium blob is the same with binary/nchar. if (IS_VAR_DATA_TYPE(colType)) { // ts key stored in STSRow.ts @@ -502,7 +502,7 @@ static FORCE_INLINE int32_t tdAppendColValToTpRow(STSRow *row, void *pBitmap, TD // NULL/None value else { //TODO: Null value for new data types imported since 3.0 need to be defined. - void *nullVal = getNullValue(colType); + const void *nullVal = getNullValue(colType); if (IS_VAR_DATA_TYPE(colType)) { // ts key stored in STSRow.ts *(VarDataOffsetT *)POINTER_SHIFT(row->data, offset) = TD_ROW_LEN(row); @@ -540,7 +540,7 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(STSRow *row, void *pBitmap, T #endif // No need to store None/Null values. - if (tdValIsNorm(valType)) { + if (tdValIsNorm(valType, val, colType)) { // ts key stored in STSRow.ts SKvRowIdx *pColIdx = (SKvRowIdx *)POINTER_SHIFT(row->data, offset); char * ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); @@ -548,7 +548,7 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(STSRow *row, void *pBitmap, T pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN if (IS_VAR_DATA_TYPE(colType)) { - if (isCopyValData) { + if (isCopyVarData) { memcpy(ptr, val, varDataTLen(val)); } TD_ROW_LEN(row) += varDataTLen(val); @@ -564,10 +564,10 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(STSRow *row, void *pBitmap, T char * ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); pColIdx->colId = colId; pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN - void *nullVal = getNullValue(colType); + const void *nullVal = getNullValue(colType); if (IS_VAR_DATA_TYPE(colType)) { - if (isCopyValData) { + if (isCopyVarData) { memcpy(ptr, nullVal, varDataTLen(nullVal)); } TD_ROW_LEN(row) += varDataTLen(nullVal); @@ -626,9 +626,9 @@ static FORCE_INLINE int32_t tdAppendColValToRow(SRowBuilder *pBuilder, int16_t c // const void *val, int8_t valType, int32_t tOffset, int16_t // colIdx); if (TD_IS_TP_ROW(pRow)) { - tdAppendColValToTpRow(pRow, pBitmap, val, true, colType, valType, colIdx, offset); + tdAppendColValToTpRow(pRow, pBitmap, valType, val, true, colType, colIdx, offset); } else { - tdAppendColValToKvRow(pRow, pBitmap, val, true, colType, valType, colIdx, offset, colId); + tdAppendColValToKvRow(pRow, pBitmap, valType, val, true, colType, colIdx, offset, colId); } return TSDB_CODE_SUCCESS; } @@ -819,13 +819,13 @@ static FORCE_INLINE bool tdGetKvRowValOfColEx(STSRowIter *pIter, col_id_t colId, SKvRowIdx *pKvIdx = NULL; bool colFound = false; while (*nIdx < pRow->ncols) { - pKvIdx = POINTER_SHIFT(pRow->data, *nIdx * sizeof(SKvRowIdx)); - if (pKvIdx->cid == colId) { + pKvIdx = (SKvRowIdx *)POINTER_SHIFT(pRow->data, *nIdx * sizeof(SKvRowIdx)); + if (pKvIdx->colId == colId) { ++(*nIdx); pVal->val = POINTER_SHIFT(pRow, pKvIdx->offset); colFound = true; break; - } else if (pKvIdx->cid > colId) { + } else if (pKvIdx->colId > colId) { pVal->valType = TD_VTYPE_NONE; return true; } else { diff --git a/source/common/src/trow.c b/source/common/src/trow.c index 07415054fca1387c40394663145d973c1310f032..b0c14a315900fd85019d071fc8982d21127efa04 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -22,9 +22,8 @@ const uint8_t tdVTypeByte[3] = { }; static void dataColSetNEleNull(SDataCol *pCol, int nEle); -static void tdMergeTwoDat 6z, z, - zaCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2, int limit2, - int tRows, bool forceSetNull); +static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2, + int limit2, int tRows, bool forceSetNull); static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index) { if (IS_VAR_DATA_TYPE(pCol->type)) { @@ -560,14 +559,14 @@ static int32_t tdAppendTpRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols return TSDB_CODE_SUCCESS; } // internal -static void tdAppendKvRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols) { +static int32_t tdAppendKvRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols) { ASSERT(pCols->numOfRows == 0 || dataColsKeyLast(pCols) < TD_ROW_TSKEY(pRow)); int rcol = 0; int dcol = 1; int tRowCols = TD_ROW_NCOLS(pRow) - 1; // the primary TS key not included in kvRowColIdx part int tSchemaCols = schemaNCols(pSchema) - 1; - void *pBitmap = tdGetBitmapAddrKv(pRow, nRowCols); + void *pBitmap = tdGetBitmapAddrKv(pRow, TD_ROW_NCOLS(pRow)); SDataCol *pDataCol = &(pCols->cols[0]); if (pDataCol->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { @@ -615,17 +614,17 @@ static void tdAppendKvRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *p * @param pCols * @param forceSetNull */ -void tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols, bool forceSetNull) { +int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols, bool forceSetNull) { if (TD_IS_TP_ROW(pRow)) { - tdAppendTpRowToDataCol(pRow, pSchema, pCols); + return tdAppendTpRowToDataCol(pRow, pSchema, pCols); } else if (TD_IS_KV_ROW(pRow)) { - tdAppendKvRowToDataCol(pRow, pSchema, pCols); + return tdAppendKvRowToDataCol(pRow, pSchema, pCols); } else { ASSERT(0); } + return TSDB_CODE_SUCCESS; } - #if 0 int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge, int *pOffset, bool forceSetNull) {