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

fix ci coredump

上级 a12f04b2
...@@ -131,16 +131,17 @@ int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest); ...@@ -131,16 +131,17 @@ int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest);
#define tBlockDataLastRow(PBLOCKDATA) tsdbRowFromBlockData(PBLOCKDATA, (PBLOCKDATA)->nRow - 1) #define tBlockDataLastRow(PBLOCKDATA) tsdbRowFromBlockData(PBLOCKDATA, (PBLOCKDATA)->nRow - 1)
#define tBlockDataFirstKey(PBLOCKDATA) TSDBROW_KEY(&tBlockDataFirstRow(PBLOCKDATA)) #define tBlockDataFirstKey(PBLOCKDATA) TSDBROW_KEY(&tBlockDataFirstRow(PBLOCKDATA))
#define tBlockDataLastKey(PBLOCKDATA) TSDBROW_KEY(&tBlockDataLastRow(PBLOCKDATA)) #define tBlockDataLastKey(PBLOCKDATA) TSDBROW_KEY(&tBlockDataLastRow(PBLOCKDATA))
int32_t tBlockDataInit(SBlockData *pBlockData); int32_t tBlockDataInit(SBlockData *pBlockData);
void tBlockDataReset(SBlockData *pBlockData); void tBlockDataReset(SBlockData *pBlockData);
int32_t tBlockDataSetSchema(SBlockData *pBlockData, STSchema *pTSchema); int32_t tBlockDataSetSchema(SBlockData *pBlockData, STSchema *pTSchema);
void tBlockDataClearData(SBlockData *pBlockData); void tBlockDataClearData(SBlockData *pBlockData);
void tBlockDataClear(SBlockData *pBlockData); void tBlockDataClear(SBlockData *pBlockData);
int32_t tBlockDataAddColData(SBlockData *pBlockData, int32_t iColData, SColData **ppColData); int32_t tBlockDataAddColData(SBlockData *pBlockData, int32_t iColData, SColData **ppColData);
int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema); int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema);
int32_t tBlockDataMerge(SBlockData *pBlockData1, SBlockData *pBlockData2, SBlockData *pBlockData); int32_t tBlockDataMerge(SBlockData *pBlockData1, SBlockData *pBlockData2, SBlockData *pBlockData);
int32_t tBlockDataCopy(SBlockData *pBlockDataSrc, SBlockData *pBlockDataDest); int32_t tBlockDataCopy(SBlockData *pBlockDataSrc, SBlockData *pBlockDataDest);
void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColData); SColData *tBlockDataGetColDataByIdx(SBlockData *pBlockData, int32_t idx);
void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColData);
// SDelIdx // SDelIdx
int32_t tPutDelIdx(uint8_t *p, void *ph); int32_t tPutDelIdx(uint8_t *p, void *ph);
int32_t tGetDelIdx(uint8_t *p, void *ph); int32_t tGetDelIdx(uint8_t *p, void *ph);
...@@ -419,8 +420,8 @@ struct SBlockData { ...@@ -419,8 +420,8 @@ struct SBlockData {
int32_t nRow; int32_t nRow;
int64_t *aVersion; int64_t *aVersion;
TSKEY *aTSKEY; TSKEY *aTSKEY;
SArray *aColDataP; // SArray<SColData *> SArray *aIdx; // SArray<int32_t>
SArray *aColData; // SArray<SColData> SArray *aColData; // SArray<SColData>
}; };
// ================== TSDB global config // ================== TSDB global config
......
...@@ -756,11 +756,11 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn ...@@ -756,11 +756,11 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
i += 1; i += 1;
} }
while (i < numOfCols && colIndex < taosArrayGetSize(pBlockData->aColDataP)) { while (i < numOfCols && colIndex < taosArrayGetSize(pBlockData->aIdx)) {
rowIndex = 0; rowIndex = 0;
pColData = taosArrayGet(pResBlock->pDataBlock, i); pColData = taosArrayGet(pResBlock->pDataBlock, i);
SColData* pData = (SColData*)taosArrayGetP(pBlockData->aColDataP, colIndex); SColData* pData = tBlockDataGetColDataByIdx(pBlockData, colIndex);
if (pData->cid == pColData->info.colId) { if (pData->cid == pColData->info.colId) {
for (int32_t j = pDumpInfo->rowIndex; j < endIndex && j >= 0; j += step) { for (int32_t j = pDumpInfo->rowIndex; j < endIndex && j >= 0; j += step) {
......
...@@ -902,7 +902,7 @@ static int32_t tsdbReadSubColData(SDataFReader *pReader, SBlockIdx *pBlockIdx, S ...@@ -902,7 +902,7 @@ static int32_t tsdbReadSubColData(SDataFReader *pReader, SBlockIdx *pBlockIdx, S
ASSERT(pBlockCol->flag && pBlockCol->flag != HAS_NONE); ASSERT(pBlockCol->flag && pBlockCol->flag != HAS_NONE);
code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aColDataP), &pColData); code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aIdx), &pColData);
if (code) goto _err; if (code) goto _err;
tColDataInit(pColData, pBlockCol->cid, pBlockCol->type, pBlockCol->smaOn); tColDataInit(pColData, pBlockCol->cid, pBlockCol->type, pBlockCol->smaOn);
...@@ -1762,8 +1762,8 @@ static int32_t tsdbWriteBlockSma(TdFilePtr pFD, SBlockData *pBlockData, SSubBloc ...@@ -1762,8 +1762,8 @@ static int32_t tsdbWriteBlockSma(TdFilePtr pFD, SBlockData *pBlockData, SSubBloc
// prepare // prepare
pSubBlock->nSma = 0; pSubBlock->nSma = 0;
for (int32_t iColData = 0; iColData < taosArrayGetSize(pBlockData->aColDataP); iColData++) { for (int32_t iColData = 0; iColData < taosArrayGetSize(pBlockData->aIdx); iColData++) {
pColData = (SColData *)taosArrayGetP(pBlockData->aColDataP, iColData); pColData = tBlockDataGetColDataByIdx(pBlockData, iColData);
if (IS_VAR_DATA_TYPE(pColData->type) || (!pColData->smaOn)) continue; if (IS_VAR_DATA_TYPE(pColData->type) || (!pColData->smaOn)) continue;
...@@ -1775,8 +1775,8 @@ static int32_t tsdbWriteBlockSma(TdFilePtr pFD, SBlockData *pBlockData, SSubBloc ...@@ -1775,8 +1775,8 @@ static int32_t tsdbWriteBlockSma(TdFilePtr pFD, SBlockData *pBlockData, SSubBloc
code = tRealloc(ppBuf, sizeof(SColumnDataAgg) * pSubBlock->nSma + sizeof(TSCKSUM)); code = tRealloc(ppBuf, sizeof(SColumnDataAgg) * pSubBlock->nSma + sizeof(TSCKSUM));
if (code) goto _err; if (code) goto _err;
n = 0; n = 0;
for (int32_t iColData = 0; iColData < taosArrayGetSize(pBlockData->aColDataP); iColData++) { for (int32_t iColData = 0; iColData < taosArrayGetSize(pBlockData->aIdx); iColData++) {
pColData = (SColData *)taosArrayGetP(pBlockData->aColDataP, iColData); pColData = tBlockDataGetColDataByIdx(pBlockData, iColData);
if (IS_VAR_DATA_TYPE(pColData->type) || (!pColData->smaOn)) continue; if (IS_VAR_DATA_TYPE(pColData->type) || (!pColData->smaOn)) continue;
...@@ -1834,14 +1834,14 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, uint8_ ...@@ -1834,14 +1834,14 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, uint8_
if (code) goto _err; if (code) goto _err;
// COLUMNS // COLUMNS
aBlockCol = taosArrayInit(taosArrayGetSize(pBlockData->aColDataP), sizeof(SBlockCol)); aBlockCol = taosArrayInit(taosArrayGetSize(pBlockData->aIdx), sizeof(SBlockCol));
if (aBlockCol == NULL) { if (aBlockCol == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
goto _err; goto _err;
} }
int32_t offset = 0; int32_t offset = 0;
for (int32_t iCol = 0; iCol < taosArrayGetSize(pBlockData->aColDataP); iCol++) { for (int32_t iCol = 0; iCol < taosArrayGetSize(pBlockData->aIdx); iCol++) {
SColData *pColData = (SColData *)taosArrayGetP(pBlockData->aColDataP, iCol); SColData *pColData = tBlockDataGetColDataByIdx(pBlockData, iCol);
ASSERT(pColData->flag); ASSERT(pColData->flag);
......
...@@ -544,8 +544,8 @@ SColVal *tRowIterNext(SRowIter *pIter) { ...@@ -544,8 +544,8 @@ SColVal *tRowIterNext(SRowIter *pIter) {
return &pIter->colVal; return &pIter->colVal;
} }
} else { } else {
if (pIter->i < taosArrayGetSize(pIter->pRow->pBlockData->aColDataP)) { if (pIter->i < taosArrayGetSize(pIter->pRow->pBlockData->aIdx)) {
SColData *pColData = (SColData *)taosArrayGetP(pIter->pRow->pBlockData->aColDataP, pIter->i); SColData *pColData = tBlockDataGetColDataByIdx(pIter->pRow->pBlockData, pIter->i);
tColDataGetValue(pColData, pIter->pRow->iRow, &pIter->colVal); tColDataGetValue(pColData, pIter->pRow->iRow, &pIter->colVal);
pIter->i++; pIter->i++;
...@@ -892,9 +892,9 @@ _exit: ...@@ -892,9 +892,9 @@ _exit:
return code; return code;
} }
static FORCE_INLINE int32_t tColDataPCmprFn(const void *p1, const void *p2) { static FORCE_INLINE int32_t tColDataCmprFn(const void *p1, const void *p2) {
SColData *pColData1 = *(SColData **)p1; SColData *pColData1 = (SColData *)p1;
SColData *pColData2 = *(SColData **)p2; SColData *pColData2 = (SColData *)p2;
if (pColData1->cid < pColData2->cid) { if (pColData1->cid < pColData2->cid) {
return -1; return -1;
...@@ -912,14 +912,14 @@ int32_t tBlockDataInit(SBlockData *pBlockData) { ...@@ -912,14 +912,14 @@ int32_t tBlockDataInit(SBlockData *pBlockData) {
pBlockData->nRow = 0; pBlockData->nRow = 0;
pBlockData->aVersion = NULL; pBlockData->aVersion = NULL;
pBlockData->aTSKEY = NULL; pBlockData->aTSKEY = NULL;
pBlockData->aColDataP = taosArrayInit(0, sizeof(SColData *)); pBlockData->aIdx = taosArrayInit(0, sizeof(int32_t));
if (pBlockData->aColDataP == NULL) { if (pBlockData->aIdx == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit; goto _exit;
} }
pBlockData->aColData = taosArrayInit(0, sizeof(SColData)); pBlockData->aColData = taosArrayInit(0, sizeof(SColData));
if (pBlockData->aColData == NULL) { if (pBlockData->aColData == NULL) {
taosArrayDestroy(pBlockData->aColDataP); taosArrayDestroy(pBlockData->aIdx);
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit; goto _exit;
} }
...@@ -930,13 +930,13 @@ _exit: ...@@ -930,13 +930,13 @@ _exit:
void tBlockDataReset(SBlockData *pBlockData) { void tBlockDataReset(SBlockData *pBlockData) {
pBlockData->nRow = 0; pBlockData->nRow = 0;
taosArrayClear(pBlockData->aColDataP); taosArrayClear(pBlockData->aIdx);
} }
void tBlockDataClear(SBlockData *pBlockData) { void tBlockDataClear(SBlockData *pBlockData) {
tFree((uint8_t *)pBlockData->aVersion); tFree((uint8_t *)pBlockData->aVersion);
tFree((uint8_t *)pBlockData->aTSKEY); tFree((uint8_t *)pBlockData->aTSKEY);
taosArrayDestroy(pBlockData->aColDataP); taosArrayDestroy(pBlockData->aIdx);
taosArrayDestroyEx(pBlockData->aColData, tColDataClear); taosArrayDestroyEx(pBlockData->aColData, tColDataClear);
} }
...@@ -961,8 +961,8 @@ _exit: ...@@ -961,8 +961,8 @@ _exit:
void tBlockDataClearData(SBlockData *pBlockData) { void tBlockDataClearData(SBlockData *pBlockData) {
pBlockData->nRow = 0; pBlockData->nRow = 0;
for (int32_t iColData = 0; iColData < taosArrayGetSize(pBlockData->aColDataP); iColData++) { for (int32_t iColData = 0; iColData < taosArrayGetSize(pBlockData->aIdx); iColData++) {
SColData *pColData = (SColData *)taosArrayGetP(pBlockData->aColDataP, iColData); SColData *pColData = tBlockDataGetColDataByIdx(pBlockData, iColData);
tColDataReset(pColData); tColDataReset(pColData);
} }
} }
...@@ -970,7 +970,7 @@ void tBlockDataClearData(SBlockData *pBlockData) { ...@@ -970,7 +970,7 @@ void tBlockDataClearData(SBlockData *pBlockData) {
int32_t tBlockDataAddColData(SBlockData *pBlockData, int32_t iColData, SColData **ppColData) { int32_t tBlockDataAddColData(SBlockData *pBlockData, int32_t iColData, SColData **ppColData) {
int32_t code = 0; int32_t code = 0;
SColData *pColData = NULL; SColData *pColData = NULL;
int32_t idx = taosArrayGetSize(pBlockData->aColDataP); int32_t idx = taosArrayGetSize(pBlockData->aIdx);
if (idx >= taosArrayGetSize(pBlockData->aColData)) { if (idx >= taosArrayGetSize(pBlockData->aColData)) {
if (taosArrayPush(pBlockData->aColData, &((SColData){0})) == NULL) { if (taosArrayPush(pBlockData->aColData, &((SColData){0})) == NULL) {
...@@ -980,7 +980,7 @@ int32_t tBlockDataAddColData(SBlockData *pBlockData, int32_t iColData, SColData ...@@ -980,7 +980,7 @@ int32_t tBlockDataAddColData(SBlockData *pBlockData, int32_t iColData, SColData
} }
pColData = (SColData *)taosArrayGet(pBlockData->aColData, idx); pColData = (SColData *)taosArrayGet(pBlockData->aColData, idx);
if (taosArrayInsert(pBlockData->aColDataP, iColData, &pColData) == NULL) { if (taosArrayInsert(pBlockData->aIdx, iColData, &idx) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
goto _err; goto _err;
} }
...@@ -1006,7 +1006,7 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS ...@@ -1006,7 +1006,7 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS
// OTHER // OTHER
int32_t iColData = 0; int32_t iColData = 0;
int32_t nColData = taosArrayGetSize(pBlockData->aColDataP); int32_t nColData = taosArrayGetSize(pBlockData->aIdx);
SRowIter iter = {0}; SRowIter iter = {0};
SRowIter *pIter = &iter; SRowIter *pIter = &iter;
SColData *pColData; SColData *pColData;
...@@ -1015,7 +1015,7 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS ...@@ -1015,7 +1015,7 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS
ASSERT(nColData > 0); ASSERT(nColData > 0);
tRowIterInit(pIter, pRow, pTSchema); tRowIterInit(pIter, pRow, pTSchema);
pColData = (SColData *)taosArrayGetP(pBlockData->aColDataP, iColData); pColData = tBlockDataGetColDataByIdx(pBlockData, iColData);
pColVal = tRowIterNext(pIter); pColVal = tRowIterNext(pIter);
while (pColData) { while (pColData) {
...@@ -1025,12 +1025,12 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS ...@@ -1025,12 +1025,12 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS
if (code) goto _err; if (code) goto _err;
pColVal = tRowIterNext(pIter); pColVal = tRowIterNext(pIter);
pColData = ((++iColData) < nColData) ? (SColData *)taosArrayGetP(pBlockData->aColDataP, iColData) : NULL; pColData = ((++iColData) < nColData) ? tBlockDataGetColDataByIdx(pBlockData, iColData) : NULL;
} else if (pColData->cid < pColVal->cid) { } else if (pColData->cid < pColVal->cid) {
code = tColDataAppendValue(pColData, &COL_VAL_NONE(pColData->cid, pColData->type)); code = tColDataAppendValue(pColData, &COL_VAL_NONE(pColData->cid, pColData->type));
if (code) goto _err; if (code) goto _err;
pColData = ((++iColData) < nColData) ? (SColData *)taosArrayGetP(pBlockData->aColDataP, iColData) : NULL; pColData = ((++iColData) < nColData) ? tBlockDataGetColDataByIdx(pBlockData, iColData) : NULL;
} else { } else {
pColVal = tRowIterNext(pIter); pColVal = tRowIterNext(pIter);
} }
...@@ -1038,7 +1038,7 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS ...@@ -1038,7 +1038,7 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS
code = tColDataAppendValue(pColData, &COL_VAL_NONE(pColData->cid, pColData->type)); code = tColDataAppendValue(pColData, &COL_VAL_NONE(pColData->cid, pColData->type));
if (code) goto _err; if (code) goto _err;
pColData = ((++iColData) < nColData) ? (SColData *)taosArrayGetP(pBlockData->aColDataP, iColData) : NULL; pColData = ((++iColData) < nColData) ? tBlockDataGetColDataByIdx(pBlockData, iColData) : NULL;
} }
} }
...@@ -1054,33 +1054,33 @@ int32_t tBlockDataMerge(SBlockData *pBlockData1, SBlockData *pBlockData2, SBlock ...@@ -1054,33 +1054,33 @@ int32_t tBlockDataMerge(SBlockData *pBlockData1, SBlockData *pBlockData2, SBlock
// set target // set target
int32_t iColData1 = 0; int32_t iColData1 = 0;
int32_t nColData1 = taosArrayGetSize(pBlockData1->aColDataP); int32_t nColData1 = taosArrayGetSize(pBlockData1->aIdx);
int32_t iColData2 = 0; int32_t iColData2 = 0;
int32_t nColData2 = taosArrayGetSize(pBlockData2->aColDataP); int32_t nColData2 = taosArrayGetSize(pBlockData2->aIdx);
SColData *pColData1; SColData *pColData1;
SColData *pColData2; SColData *pColData2;
SColData *pColData; SColData *pColData;
tBlockDataReset(pBlockData); tBlockDataReset(pBlockData);
while (iColData1 < nColData1 && iColData2 < nColData2) { while (iColData1 < nColData1 && iColData2 < nColData2) {
pColData1 = (SColData *)taosArrayGetP(pBlockData1->aColDataP, iColData1); pColData1 = tBlockDataGetColDataByIdx(pBlockData1, iColData1);
pColData2 = (SColData *)taosArrayGetP(pBlockData2->aColDataP, iColData2); pColData2 = tBlockDataGetColDataByIdx(pBlockData2, iColData2);
if (pColData1->cid == pColData2->cid) { if (pColData1->cid == pColData2->cid) {
code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aColDataP), &pColData); code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aIdx), &pColData);
if (code) goto _exit; if (code) goto _exit;
tColDataInit(pColData, pColData2->cid, pColData2->type, pColData2->smaOn); tColDataInit(pColData, pColData2->cid, pColData2->type, pColData2->smaOn);
iColData1++; iColData1++;
iColData2++; iColData2++;
} else if (pColData1->cid < pColData2->cid) { } else if (pColData1->cid < pColData2->cid) {
code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aColDataP), &pColData); code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aIdx), &pColData);
if (code) goto _exit; if (code) goto _exit;
tColDataInit(pColData, pColData1->cid, pColData1->type, pColData1->smaOn); tColDataInit(pColData, pColData1->cid, pColData1->type, pColData1->smaOn);
iColData1++; iColData1++;
} else { } else {
code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aColDataP), &pColData); code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aIdx), &pColData);
if (code) goto _exit; if (code) goto _exit;
tColDataInit(pColData, pColData2->cid, pColData2->type, pColData2->smaOn); tColDataInit(pColData, pColData2->cid, pColData2->type, pColData2->smaOn);
...@@ -1089,7 +1089,7 @@ int32_t tBlockDataMerge(SBlockData *pBlockData1, SBlockData *pBlockData2, SBlock ...@@ -1089,7 +1089,7 @@ int32_t tBlockDataMerge(SBlockData *pBlockData1, SBlockData *pBlockData2, SBlock
} }
while (iColData1 < nColData1) { while (iColData1 < nColData1) {
code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aColDataP), &pColData); code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aIdx), &pColData);
if (code) goto _exit; if (code) goto _exit;
tColDataInit(pColData, pColData1->cid, pColData1->type, pColData1->smaOn); tColDataInit(pColData, pColData1->cid, pColData1->type, pColData1->smaOn);
...@@ -1097,7 +1097,7 @@ int32_t tBlockDataMerge(SBlockData *pBlockData1, SBlockData *pBlockData2, SBlock ...@@ -1097,7 +1097,7 @@ int32_t tBlockDataMerge(SBlockData *pBlockData1, SBlockData *pBlockData2, SBlock
} }
while (iColData2 < nColData2) { while (iColData2 < nColData2) {
code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aColDataP), &pColData); code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aIdx), &pColData);
if (code) goto _exit; if (code) goto _exit;
tColDataInit(pColData, pColData2->cid, pColData2->type, pColData2->smaOn); tColDataInit(pColData, pColData2->cid, pColData2->type, pColData2->smaOn);
...@@ -1168,8 +1168,8 @@ int32_t tBlockDataCopy(SBlockData *pBlockDataSrc, SBlockData *pBlockDataDest) { ...@@ -1168,8 +1168,8 @@ int32_t tBlockDataCopy(SBlockData *pBlockDataSrc, SBlockData *pBlockDataDest) {
memcpy(pBlockDataDest->aTSKEY, pBlockDataSrc->aTSKEY, sizeof(TSKEY) * pBlockDataSrc->nRow); memcpy(pBlockDataDest->aTSKEY, pBlockDataSrc->aTSKEY, sizeof(TSKEY) * pBlockDataSrc->nRow);
// other // other
for (size_t iColData = 0; iColData < taosArrayGetSize(pBlockDataSrc->aColDataP); iColData++) { for (size_t iColData = 0; iColData < taosArrayGetSize(pBlockDataSrc->aIdx); iColData++) {
pColDataSrc = (SColData *)taosArrayGetP(pBlockDataSrc->aColDataP, iColData); pColDataSrc = tBlockDataGetColDataByIdx(pBlockDataSrc, iColData);
code = tBlockDataAddColData(pBlockDataDest, iColData, &pColDataDest); code = tBlockDataAddColData(pBlockDataDest, iColData, &pColDataDest);
if (code) goto _exit; if (code) goto _exit;
...@@ -1181,17 +1181,36 @@ _exit: ...@@ -1181,17 +1181,36 @@ _exit:
return code; return code;
} }
SColData *tBlockDataGetColDataByIdx(SBlockData *pBlockData, int32_t idx) {
ASSERT(idx >= 0 && idx < taosArrayGetSize(pBlockData->aIdx));
return (SColData *)taosArrayGet(pBlockData->aColData, *(int32_t *)taosArrayGet(pBlockData->aIdx, idx));
}
void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColData) { void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColData) {
ASSERT(cid != PRIMARYKEY_TIMESTAMP_COL_ID); ASSERT(cid != PRIMARYKEY_TIMESTAMP_COL_ID);
int32_t lidx = 0;
int32_t ridx = taosArrayGetSize(pBlockData->aIdx) - 1;
int32_t midx;
SColData *pColData = &(SColData){.cid = cid}; while (lidx <= ridx) {
SColData *pColData;
int32_t c;
void *p = taosArraySearch(pBlockData->aColDataP, &pColData, tColDataPCmprFn, TD_EQ); midx = (lidx + midx) / 2;
if (p == NULL) {
*ppColData = NULL; pColData = tBlockDataGetColDataByIdx(pBlockData, midx);
} else { c = tColDataCmprFn(pColData, &(SColData){.cid = cid});
*ppColData = *(SColData **)p; if (c == 0) {
*ppColData = pColData;
return;
} else if (c < 0) {
lidx = midx + 1;
} else {
ridx = midx - 1;
}
} }
*ppColData = NULL;
} }
// ALGORITHM ============================== // ALGORITHM ==============================
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册