more work

This commit is contained in:
Hongze Cheng 2022-07-07 09:02:07 +00:00
parent 4edcd7011e
commit 77f6c41d31
1 changed files with 21 additions and 4 deletions

View File

@ -308,9 +308,11 @@ struct STsdbSnapWriter {
STsdb* pTsdb; STsdb* pTsdb;
int64_t sver; int64_t sver;
int64_t ever; int64_t ever;
// config // config
int32_t minutes; int32_t minutes;
int8_t precision; int8_t precision;
// for data file // for data file
int32_t fid; int32_t fid;
SDataFReader* pDataFReader; SDataFReader* pDataFReader;
@ -321,10 +323,14 @@ struct STsdbSnapWriter {
int32_t iBlock; int32_t iBlock;
SBlockData blockData; SBlockData blockData;
int32_t iRow; int32_t iRow;
SDataFWriter* pDataFWriter; SDataFWriter* pDataFWriter;
SArray* aBlockIdxN; SArray* aBlockIdxN;
SBlockIdx blockIdx;
SMapData mBlockN; SMapData mBlockN;
SBlock block;
SBlockData nBlockData; SBlockData nBlockData;
// for del file // for del file
SDelFReader* pDelFReader; SDelFReader* pDelFReader;
SDelFWriter* pDelFWriter; SDelFWriter* pDelFWriter;
@ -408,9 +414,11 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->fs->nState, fid); SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->fs->nState, fid);
// reader // reader
if (pSet) { if (pSet) {
// open
code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet); code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet);
if (code) goto _err; if (code) goto _err;
// SBlockIdx
code = tsdbReadBlockIdx(pWriter->pDataFReader, pWriter->aBlockIdx, NULL); code = tsdbReadBlockIdx(pWriter->pDataFReader, pWriter->aBlockIdx, NULL);
if (code) goto _err; if (code) goto _err;
} else { } else {
@ -438,16 +446,14 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
TSKEY maxKey = 0; // TODO TSKEY maxKey = 0; // TODO
while (true) { while (true) {
if (pWriter->pBlockIdx == NULL) { if (pWriter->pBlockIdx) {
// TODO
} else {
int32_t c = tTABLEIDCmprFn(&id, pWriter->pBlockIdx); int32_t c = tTABLEIDCmprFn(&id, pWriter->pBlockIdx);
if (c == 0) { if (c == 0) {
} else if (c < 0) { } else if (c < 0) {
// keep merge // keep merge
} else { } else {
code = tsdbSnapWriteTableDataEnd(pWriter); // code = tsdbSnapWriteTableDataEnd(pWriter);
if (code) goto _err; if (code) goto _err;
pWriter->iBlockIdx++; pWriter->iBlockIdx++;
@ -462,6 +468,17 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
if (code) goto _err; if (code) goto _err;
} }
} }
} else {
int32_t c = tTABLEIDCmprFn(&id, &pWriter->blockIdx);
if (c == 0) {
// merge commit the block data
} else if (c > 0) {
// code = tsdbSnapWriteTableDataEnd(pWriter);
if (code) goto _err;
} else {
ASSERT(0);
}
} }
} }