fix more code
This commit is contained in:
parent
74a09e27ed
commit
2c5b5289d0
|
@ -57,7 +57,7 @@ int32_t tsdbDataFileReadBlockSma(SDataFileReader *reader);
|
||||||
int32_t tsdbDataFileReadTombBlk(SDataFileReader *reader, const TTombBlkArray **tombBlkArray);
|
int32_t tsdbDataFileReadTombBlk(SDataFileReader *reader, const TTombBlkArray **tombBlkArray);
|
||||||
int32_t tsdbDataFileReadTombBlock(SDataFileReader *reader, const STombBlk *tombBlk, STombBlock *tData);
|
int32_t tsdbDataFileReadTombBlock(SDataFileReader *reader, const STombBlk *tombBlk, STombBlock *tData);
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
int32_t tsdbDataFileReadBlockIdx(SDataFileReader *reader, const TBlockIdxArray **blockIdxArray);
|
int32_t tsdbDataFileReadBlockIdx(SDataFileReader *reader, const TBlockIdxArray **blockIdxArray);
|
||||||
int32_t tsdbDataFileReadDataBlk(SDataFileReader *reader, const SBlockIdx *blockIdx, const TDataBlkArray **dataBlkArray);
|
int32_t tsdbDataFileReadDataBlk(SDataFileReader *reader, const SBlockIdx *blockIdx, const TDataBlkArray **dataBlkArray);
|
||||||
int32_t tsdbDataFileReadDataBlock(SDataFileReader *reader, const SDataBlk *dataBlk, SBlockData *bData);
|
int32_t tsdbDataFileReadDataBlock(SDataFileReader *reader, const SDataBlk *dataBlk, SBlockData *bData);
|
||||||
|
|
|
@ -297,6 +297,7 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int32_t tsdbDataFileReadBlockIdx(SDataFileReader *reader, const TBlockIdxArray **blockIdxArray) {
|
int32_t tsdbDataFileReadBlockIdx(SDataFileReader *reader, const TBlockIdxArray **blockIdxArray) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
@ -392,6 +393,7 @@ _exit:
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t tsdbDataFileReadTombBlk(SDataFileReader *reader, const TTombBlkArray **tombBlkArray) {
|
int32_t tsdbDataFileReadTombBlk(SDataFileReader *reader, const TTombBlkArray **tombBlkArray) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
|
@ -36,10 +36,10 @@ struct STsdbIter {
|
||||||
} stt[1];
|
} stt[1];
|
||||||
struct {
|
struct {
|
||||||
SDataFileReader *reader;
|
SDataFileReader *reader;
|
||||||
const TBlockIdxArray *blockIdxArray;
|
const TBrinBlkArray *brinBlkArray;
|
||||||
int32_t blockIdxArrayIdx;
|
int32_t brinBlkArrayIdx;
|
||||||
const TDataBlkArray *dataBlkArray;
|
SBrinBlock brinBlock[1];
|
||||||
int32_t dataBlkArrayIdx;
|
int32_t brinBlockIdx;
|
||||||
SBlockData bData[1];
|
SBlockData bData[1];
|
||||||
int32_t iRow;
|
int32_t iRow;
|
||||||
} data[1];
|
} data[1];
|
||||||
|
@ -118,6 +118,7 @@ static int32_t tsdbDataIterNext(STsdbIter *iter, const TABLEID *tbid) {
|
||||||
|
|
||||||
while (!iter->ctx->noMoreData) {
|
while (!iter->ctx->noMoreData) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
// SBlockData
|
||||||
for (; iter->data->iRow < iter->data->bData->nRow; iter->data->iRow++) {
|
for (; iter->data->iRow < iter->data->bData->nRow; iter->data->iRow++) {
|
||||||
if (tbid && tbid->suid == iter->data->bData->suid && tbid->uid == iter->data->bData->uid) {
|
if (tbid && tbid->suid == iter->data->bData->suid && tbid->uid == iter->data->bData->uid) {
|
||||||
iter->data->iRow = iter->data->bData->nRow;
|
iter->data->iRow = iter->data->bData->nRow;
|
||||||
|
@ -129,51 +130,48 @@ static int32_t tsdbDataIterNext(STsdbIter *iter, const TABLEID *tbid) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iter->data->dataBlkArray == NULL || iter->data->dataBlkArrayIdx >= TARRAY2_SIZE(iter->data->dataBlkArray)) {
|
// SBrinBlock
|
||||||
|
if (iter->data->brinBlockIdx >= BRIN_BLOCK_SIZE(iter->data->brinBlock)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; iter->data->dataBlkArray && iter->data->dataBlkArrayIdx < TARRAY2_SIZE(iter->data->dataBlkArray);
|
for (; iter->data->brinBlockIdx < BRIN_BLOCK_SIZE(iter->data->brinBlock); iter->data->brinBlockIdx++) {
|
||||||
iter->data->dataBlkArrayIdx++) {
|
SBrinRecord record[1];
|
||||||
const SDataBlk *dataBlk = TARRAY2_GET_PTR(iter->data->dataBlkArray, iter->data->dataBlkArrayIdx);
|
tBrinBlockGet(iter->data->brinBlock, iter->data->brinBlockIdx, record);
|
||||||
|
|
||||||
if (tbid) {
|
if (tbid && tbid->suid == record->suid && tbid->uid == record->uid) {
|
||||||
const SBlockIdx *blockIdx = TARRAY2_GET_PTR(iter->data->blockIdxArray, iter->data->blockIdxArrayIdx - 1);
|
continue;
|
||||||
|
|
||||||
if (tbid->suid == blockIdx->suid && tbid->uid == blockIdx->uid) {
|
|
||||||
iter->data->dataBlkArrayIdx = TARRAY2_SIZE(iter->data->dataBlkArray);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbDataFileReadDataBlock(iter->data->reader, dataBlk, iter->data->bData);
|
iter->row->suid = record->suid;
|
||||||
|
iter->row->uid = record->uid;
|
||||||
|
|
||||||
|
code = tsdbDataFileReadBlockData(iter->data->reader, record, iter->data->bData);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
|
|
||||||
iter->data->iRow = 0;
|
iter->data->iRow = 0;
|
||||||
iter->data->dataBlkArrayIdx++;
|
iter->data->brinBlockIdx++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iter->data->blockIdxArrayIdx >= TARRAY2_SIZE(iter->data->blockIdxArray)) {
|
if (iter->data->brinBlkArrayIdx >= TARRAY2_SIZE(iter->data->brinBlkArray)) {
|
||||||
iter->ctx->noMoreData = true;
|
iter->ctx->noMoreData = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; iter->data->blockIdxArrayIdx < TARRAY2_SIZE(iter->data->blockIdxArray); iter->data->blockIdxArrayIdx++) {
|
for (; iter->data->brinBlkArrayIdx < TARRAY2_SIZE(iter->data->brinBlkArray); iter->data->brinBlkArrayIdx++) {
|
||||||
const SBlockIdx *blockIdx = TARRAY2_GET_PTR(iter->data->blockIdxArray, iter->data->blockIdxArrayIdx);
|
const SBrinBlk *brinBlk = TARRAY2_GET_PTR(iter->data->brinBlkArray, iter->data->brinBlkArrayIdx);
|
||||||
|
|
||||||
if (tbid && tbid->suid == blockIdx->suid && tbid->uid == blockIdx->uid) {
|
if (tbid && tbid->uid == brinBlk->minTbid.uid && tbid->uid == brinBlk->maxTbid.uid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbDataFileReadDataBlk(iter->data->reader, blockIdx, &iter->data->dataBlkArray);
|
code = tsdbDataFileReadBrinBlock(iter->data->reader, brinBlk, iter->data->brinBlock);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
|
|
||||||
iter->row->suid = blockIdx->suid;
|
iter->data->brinBlockIdx = 0;
|
||||||
iter->row->uid = blockIdx->uid;
|
iter->data->brinBlkArrayIdx++;
|
||||||
iter->data->dataBlkArrayIdx = 0;
|
|
||||||
iter->data->blockIdxArrayIdx++;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,19 +288,20 @@ static int32_t tsdbSttIterOpen(STsdbIter *iter) {
|
||||||
static int32_t tsdbDataIterOpen(STsdbIter *iter) {
|
static int32_t tsdbDataIterOpen(STsdbIter *iter) {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
|
||||||
code = tsdbDataFileReadBlockIdx(iter->data->reader, &iter->data->blockIdxArray);
|
// SBrinBlk
|
||||||
|
code = tsdbDataFileReadBrinBlk(iter->data->reader, &iter->data->brinBlkArray);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
|
|
||||||
// SBlockIdx
|
if (TARRAY2_SIZE(iter->data->brinBlkArray) == 0) {
|
||||||
if (TARRAY2_SIZE(iter->data->blockIdxArray) == 0) {
|
|
||||||
iter->ctx->noMoreData = true;
|
iter->ctx->noMoreData = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
iter->data->blockIdxArrayIdx = 0;
|
|
||||||
|
|
||||||
// SDataBlk
|
iter->data->brinBlkArrayIdx = 0;
|
||||||
iter->data->dataBlkArray = NULL;
|
|
||||||
iter->data->dataBlkArrayIdx = 0;
|
// SBrinBlock
|
||||||
|
tBrinBlockInit(iter->data->brinBlock);
|
||||||
|
iter->data->brinBlockIdx = 0;
|
||||||
|
|
||||||
// SBlockData
|
// SBlockData
|
||||||
tBlockDataCreate(iter->data->bData);
|
tBlockDataCreate(iter->data->bData);
|
||||||
|
@ -331,7 +330,7 @@ static int32_t tsdbDataTombIterOpen(STsdbIter *iter) {
|
||||||
iter->ctx->noMoreData = true;
|
iter->ctx->noMoreData = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
iter->data->blockIdxArrayIdx = 0;
|
iter->dataTomb->tombBlkArrayIdx = 0;
|
||||||
|
|
||||||
tTombBlockInit(iter->dataTomb->tData);
|
tTombBlockInit(iter->dataTomb->tData);
|
||||||
iter->dataTomb->iRow = 0;
|
iter->dataTomb->iRow = 0;
|
||||||
|
@ -340,6 +339,7 @@ static int32_t tsdbDataTombIterOpen(STsdbIter *iter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbDataIterClose(STsdbIter *iter) {
|
static int32_t tsdbDataIterClose(STsdbIter *iter) {
|
||||||
|
tBrinBlockDestroy(iter->data->brinBlock);
|
||||||
tBlockDataDestroy(iter->data->bData);
|
tBlockDataDestroy(iter->data->bData);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue