support STSRow
This commit is contained in:
parent
7a2e667ac0
commit
e1c9534cff
|
@ -98,7 +98,7 @@ typedef struct {
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
col_id_t cid;
|
col_id_t colId;
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
} SKvRowIdx;
|
} SKvRowIdx;
|
||||||
#pragma pack(pop)
|
#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
|
// 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.
|
// 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.
|
// 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.
|
//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)) {
|
if (IS_VAR_DATA_TYPE(colType)) {
|
||||||
// ts key stored in STSRow.ts
|
// ts key stored in STSRow.ts
|
||||||
|
@ -502,7 +502,7 @@ static FORCE_INLINE int32_t tdAppendColValToTpRow(STSRow *row, void *pBitmap, TD
|
||||||
// NULL/None value
|
// NULL/None value
|
||||||
else {
|
else {
|
||||||
//TODO: Null value for new data types imported since 3.0 need to be defined.
|
//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)) {
|
if (IS_VAR_DATA_TYPE(colType)) {
|
||||||
// ts key stored in STSRow.ts
|
// ts key stored in STSRow.ts
|
||||||
*(VarDataOffsetT *)POINTER_SHIFT(row->data, offset) = TD_ROW_LEN(row);
|
*(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
|
#endif
|
||||||
|
|
||||||
// No need to store None/Null values.
|
// No need to store None/Null values.
|
||||||
if (tdValIsNorm(valType)) {
|
if (tdValIsNorm(valType, val, colType)) {
|
||||||
// ts key stored in STSRow.ts
|
// ts key stored in STSRow.ts
|
||||||
SKvRowIdx *pColIdx = (SKvRowIdx *)POINTER_SHIFT(row->data, offset);
|
SKvRowIdx *pColIdx = (SKvRowIdx *)POINTER_SHIFT(row->data, offset);
|
||||||
char * ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row));
|
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
|
pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(colType)) {
|
if (IS_VAR_DATA_TYPE(colType)) {
|
||||||
if (isCopyValData) {
|
if (isCopyVarData) {
|
||||||
memcpy(ptr, val, varDataTLen(val));
|
memcpy(ptr, val, varDataTLen(val));
|
||||||
}
|
}
|
||||||
TD_ROW_LEN(row) += 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));
|
char * ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row));
|
||||||
pColIdx->colId = colId;
|
pColIdx->colId = colId;
|
||||||
pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN
|
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 (IS_VAR_DATA_TYPE(colType)) {
|
||||||
if (isCopyValData) {
|
if (isCopyVarData) {
|
||||||
memcpy(ptr, nullVal, varDataTLen(nullVal));
|
memcpy(ptr, nullVal, varDataTLen(nullVal));
|
||||||
}
|
}
|
||||||
TD_ROW_LEN(row) += 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
|
// const void *val, int8_t valType, int32_t tOffset, int16_t
|
||||||
// colIdx);
|
// colIdx);
|
||||||
if (TD_IS_TP_ROW(pRow)) {
|
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 {
|
} 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;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -819,13 +819,13 @@ static FORCE_INLINE bool tdGetKvRowValOfColEx(STSRowIter *pIter, col_id_t colId,
|
||||||
SKvRowIdx *pKvIdx = NULL;
|
SKvRowIdx *pKvIdx = NULL;
|
||||||
bool colFound = false;
|
bool colFound = false;
|
||||||
while (*nIdx < pRow->ncols) {
|
while (*nIdx < pRow->ncols) {
|
||||||
pKvIdx = POINTER_SHIFT(pRow->data, *nIdx * sizeof(SKvRowIdx));
|
pKvIdx = (SKvRowIdx *)POINTER_SHIFT(pRow->data, *nIdx * sizeof(SKvRowIdx));
|
||||||
if (pKvIdx->cid == colId) {
|
if (pKvIdx->colId == colId) {
|
||||||
++(*nIdx);
|
++(*nIdx);
|
||||||
pVal->val = POINTER_SHIFT(pRow, pKvIdx->offset);
|
pVal->val = POINTER_SHIFT(pRow, pKvIdx->offset);
|
||||||
colFound = true;
|
colFound = true;
|
||||||
break;
|
break;
|
||||||
} else if (pKvIdx->cid > colId) {
|
} else if (pKvIdx->colId > colId) {
|
||||||
pVal->valType = TD_VTYPE_NONE;
|
pVal->valType = TD_VTYPE_NONE;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -22,9 +22,8 @@ const uint8_t tdVTypeByte[3] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void dataColSetNEleNull(SDataCol *pCol, int nEle);
|
static void dataColSetNEleNull(SDataCol *pCol, int nEle);
|
||||||
static void tdMergeTwoDat 6z, z,
|
static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2,
|
||||||
zaCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2, int limit2,
|
int limit2, int tRows, bool forceSetNull);
|
||||||
int tRows, bool forceSetNull);
|
|
||||||
|
|
||||||
static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index) {
|
static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index) {
|
||||||
if (IS_VAR_DATA_TYPE(pCol->type)) {
|
if (IS_VAR_DATA_TYPE(pCol->type)) {
|
||||||
|
@ -560,14 +559,14 @@ static int32_t tdAppendTpRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
// internal
|
// 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));
|
ASSERT(pCols->numOfRows == 0 || dataColsKeyLast(pCols) < TD_ROW_TSKEY(pRow));
|
||||||
|
|
||||||
int rcol = 0;
|
int rcol = 0;
|
||||||
int dcol = 1;
|
int dcol = 1;
|
||||||
int tRowCols = TD_ROW_NCOLS(pRow) - 1; // the primary TS key not included in kvRowColIdx part
|
int tRowCols = TD_ROW_NCOLS(pRow) - 1; // the primary TS key not included in kvRowColIdx part
|
||||||
int tSchemaCols = schemaNCols(pSchema) - 1;
|
int tSchemaCols = schemaNCols(pSchema) - 1;
|
||||||
void *pBitmap = tdGetBitmapAddrKv(pRow, nRowCols);
|
void *pBitmap = tdGetBitmapAddrKv(pRow, TD_ROW_NCOLS(pRow));
|
||||||
|
|
||||||
SDataCol *pDataCol = &(pCols->cols[0]);
|
SDataCol *pDataCol = &(pCols->cols[0]);
|
||||||
if (pDataCol->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
if (pDataCol->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
|
@ -615,17 +614,17 @@ static void tdAppendKvRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *p
|
||||||
* @param pCols
|
* @param pCols
|
||||||
* @param forceSetNull
|
* @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)) {
|
if (TD_IS_TP_ROW(pRow)) {
|
||||||
tdAppendTpRowToDataCol(pRow, pSchema, pCols);
|
return tdAppendTpRowToDataCol(pRow, pSchema, pCols);
|
||||||
} else if (TD_IS_KV_ROW(pRow)) {
|
} else if (TD_IS_KV_ROW(pRow)) {
|
||||||
tdAppendKvRowToDataCol(pRow, pSchema, pCols);
|
return tdAppendKvRowToDataCol(pRow, pSchema, pCols);
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge, int *pOffset, bool forceSetNull) {
|
int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge, int *pOffset, bool forceSetNull) {
|
||||||
|
|
Loading…
Reference in New Issue