提交 08bf69e1 编写于 作者: H Hongze Cheng

more code fix

上级 663c13b5
...@@ -220,7 +220,7 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) { ...@@ -220,7 +220,7 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
pColVal = (iColVal < nColVal) ? (SColVal *)taosArrayGet(aColVal, iColVal) : NULL; pColVal = (iColVal < nColVal) ? (SColVal *)taosArrayGet(aColVal, iColVal) : NULL;
iTColumn = 1; iTColumn = 1;
pTColumn = pTSchema->columns + iTColumn; pTColumn = pTSchema->columns + iTColumn;
if (flag & 0xf0) { // KV if (flag >> 4) { // KV
SKVIdx *pIdx = (SKVIdx *)pRow->data; SKVIdx *pIdx = (SKVIdx *)pRow->data;
int32_t iIdx = 0; int32_t iIdx = 0;
int32_t nv = 0; int32_t nv = 0;
...@@ -385,7 +385,7 @@ void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) { ...@@ -385,7 +385,7 @@ void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) {
return; return;
} }
if (pRow->flag & 0xf0) { // KV Row if (pRow->flag >> 4) { // KV Row
SKVIdx *pIdx = (SKVIdx *)pRow->data; SKVIdx *pIdx = (SKVIdx *)pRow->data;
uint8_t *pv = NULL; uint8_t *pv = NULL;
if (pRow->flag & KV_FLG_LIT) { if (pRow->flag & KV_FLG_LIT) {
...@@ -441,60 +441,74 @@ void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) { ...@@ -441,60 +441,74 @@ void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) {
*pColVal = COL_VAL_NONE(pTColumn->colId, pTColumn->type); *pColVal = COL_VAL_NONE(pTColumn->colId, pTColumn->type);
} else { // Tuple Row } else { // Tuple Row
uint8_t *pf = NULL; if (pRow->flag == HAS_VALUE) {
uint8_t *pv = NULL; pColVal->cid = pTColumn->colId;
uint8_t bv = ROW_BIT_VALUE; pColVal->type = pTColumn->type;
pColVal->flag = CV_FLAG_VALUE;
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
uint8_t *pData = pRow->data + pTSchema->flen + *(int32_t *)(pRow->data + pTColumn->offset);
pData += tGetU32v(pData, &pColVal->value.nData);
if (pColVal->value.nData) {
pColVal->value.pData = pData;
} else {
pColVal->value.pData = NULL;
}
} else {
memcpy(&pColVal->value.val, pRow->data + pTColumn->offset, TYPE_BYTES[pTColumn->type]);
}
} else {
uint8_t *pf;
uint8_t *pv;
uint8_t bv = ROW_BIT_VALUE;
switch (pRow->flag) { switch (pRow->flag) {
case HAS_VALUE: case (HAS_NULL | HAS_NONE):
pf = pRow->data; bv = GET_BIT1(pRow->data, iCol - 1);
pv = pf + pTSchema->flen; break;
break; case (HAS_VALUE | HAS_NONE):
case (HAS_NULL | HAS_NONE): bv = GET_BIT1(pRow->data, iCol - 1);
bv = GET_BIT1(pRow->data, iCol - 1); if (bv) bv++;
break; pf = pRow->data + BIT1_SIZE(pTSchema->numOfCols - 1);
case (HAS_VALUE | HAS_NONE): pv = pf + pTSchema->flen;
bv = GET_BIT1(pRow->data, iCol - 1); break;
if (bv) bv++; case (HAS_VALUE | HAS_NULL):
pf = pRow->data + BIT1_SIZE(pTSchema->numOfCols - 1); bv = GET_BIT1(pRow->data, iCol - 1);
pv = pf + pTSchema->flen; bv++;
break; pf = pRow->data + BIT1_SIZE(pTSchema->numOfCols - 1);
case (HAS_VALUE | HAS_NULL): pv = pf + pTSchema->flen;
bv = GET_BIT1(pRow->data, iCol - 1); break;
bv++; case (HAS_VALUE | HAS_NULL | HAS_NONE):
pf = pRow->data + BIT1_SIZE(pTSchema->numOfCols - 1); bv = GET_BIT2(pRow->data, iCol - 1);
pv = pf + pTSchema->flen; pf = pRow->data + BIT2_SIZE(pTSchema->numOfCols - 1);
break; pv = pf + pTSchema->flen;
case (HAS_VALUE | HAS_NULL | HAS_NONE): break;
bv = GET_BIT2(pRow->data, iCol - 1); default:
pf = pRow->data + BIT2_SIZE(pTSchema->numOfCols - 1); ASSERT(0);
pv = pf + pTSchema->flen; break;
break; }
default:
break;
}
if (bv == ROW_BIT_NONE) { if (bv == ROW_BIT_NONE) {
*pColVal = COL_VAL_NONE(pTColumn->colId, pTColumn->type); *pColVal = COL_VAL_NONE(pTColumn->colId, pTColumn->type);
return; return;
} else if (bv == ROW_BIT_NULL) { } else if (bv == ROW_BIT_NULL) {
*pColVal = COL_VAL_NULL(pTColumn->colId, pTColumn->type); *pColVal = COL_VAL_NULL(pTColumn->colId, pTColumn->type);
return; return;
} }
pColVal->cid = pTColumn->colId; pColVal->cid = pTColumn->colId;
pColVal->type = pTColumn->type; pColVal->type = pTColumn->type;
pColVal->flag = CV_FLAG_VALUE; pColVal->flag = CV_FLAG_VALUE;
if (IS_VAR_DATA_TYPE(pTColumn->type)) { if (IS_VAR_DATA_TYPE(pTColumn->type)) {
uint8_t *pData = pv + *(int32_t *)(pf + pTColumn->offset); uint8_t *pData = pv + *(int32_t *)(pf + pTColumn->offset);
pData += tGetU32v(pData, &pColVal->value.nData); pData += tGetU32v(pData, &pColVal->value.nData);
if (pColVal->value.nData) { if (pColVal->value.nData) {
pColVal->value.pData = pData; pColVal->value.pData = pData;
} else {
pColVal->value.pData = NULL;
}
} else { } else {
pColVal->value.pData = NULL; memcpy(&pColVal->value.val, pf + pTColumn->offset, TYPE_BYTES[pTColumn->type]);
} }
} else {
memcpy(&pColVal->value.val, pv + pTColumn->offset, pTColumn->bytes);
} }
} }
} }
...@@ -512,7 +526,7 @@ static int32_t tRowPCmprFn(const void *p1, const void *p2) { ...@@ -512,7 +526,7 @@ static int32_t tRowPCmprFn(const void *p1, const void *p2) {
return 0; return 0;
} }
static void tRowPDestroy(SRow **ppRow) { tFree((uint8_t *)*ppRow); } static void tRowPDestroy(SRow **ppRow) { tRowDestroy(*ppRow); }
static int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int32_t iStart, int32_t iEnd, int8_t flag) { static int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int32_t iStart, int32_t iEnd, int8_t flag) {
int32_t code = 0; int32_t code = 0;
...@@ -623,10 +637,9 @@ struct SRowIter { ...@@ -623,10 +637,9 @@ struct SRowIter {
uint8_t *pb; uint8_t *pb;
uint8_t *pf; uint8_t *pf;
}; };
uint8_t *pv;
}; };
uint8_t *pv;
SColVal cv; SColVal cv;
}; };
int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter) { int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter) {
...@@ -646,15 +659,15 @@ int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter) { ...@@ -646,15 +659,15 @@ int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter) {
if (pRow->flag == HAS_NONE || pRow->flag == HAS_NULL) goto _exit; if (pRow->flag == HAS_NONE || pRow->flag == HAS_NULL) goto _exit;
if (pRow->flag & 0xf0) { if (pRow->flag >> 4) {
pIter->iCol = 0; pIter->iCol = 0;
pIter->pIdx = (SKVIdx *)pRow->data; pIter->pIdx = (SKVIdx *)pRow->data;
if (pRow->flag & KV_FLG_LIT) { if (pRow->flag & KV_FLG_LIT) {
pIter->pv = pIter->pIdx->idx + pIter->pIdx->nCol; pIter->pv = pIter->pIdx->idx + pIter->pIdx->nCol;
} else if (pRow->flag & KV_FLG_MID) { } else if (pRow->flag & KV_FLG_MID) {
pIter->pv = pIter->pIdx->idx + (pIter->pIdx->nCol << 1); pIter->pv = pIter->pIdx->idx + (pIter->pIdx->nCol << 1); // * sizeof(uint16_t)
} else { } else {
pIter->pv = pIter->pIdx->idx + (pIter->pIdx->nCol << 2); pIter->pv = pIter->pIdx->idx + (pIter->pIdx->nCol << 2); // * sizeof(uint32_t)
} }
} else { } else {
switch (pRow->flag) { switch (pRow->flag) {
...@@ -726,7 +739,7 @@ SColVal *tRowIterNext(SRowIter *pIter) { ...@@ -726,7 +739,7 @@ SColVal *tRowIterNext(SRowIter *pIter) {
goto _exit; goto _exit;
} }
if (pIter->pRow->flag & 0xf0) { // KV if (pIter->pRow->flag >> 4) { // KV
if (pIter->iCol < pIter->pIdx->nCol) { if (pIter->iCol < pIter->pIdx->nCol) {
uint8_t *pData; uint8_t *pData;
...@@ -816,7 +829,7 @@ SColVal *tRowIterNext(SRowIter *pIter) { ...@@ -816,7 +829,7 @@ SColVal *tRowIterNext(SRowIter *pIter) {
pIter->cv.value.pData = NULL; pIter->cv.value.pData = NULL;
} }
} else { } else {
memcpy(&pIter->cv.value.val, pIter->pv + pTColumn->offset, pTColumn->bytes); memcpy(&pIter->cv.value.val, pIter->pf + pTColumn->offset, TYPE_BYTES[pTColumn->type]);
} }
goto _exit; goto _exit;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册