From 77f6c41d3159aab5eacec65d6fd8b90d01bc9017 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 7 Jul 2022 09:02:07 +0000 Subject: [PATCH] more work --- source/dnode/vnode/src/tsdb/tsdbSnapshot.c | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index b2f4bf10e2..54087a7871 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -308,9 +308,11 @@ struct STsdbSnapWriter { STsdb* pTsdb; int64_t sver; int64_t ever; + // config int32_t minutes; int8_t precision; + // for data file int32_t fid; SDataFReader* pDataFReader; @@ -321,10 +323,14 @@ struct STsdbSnapWriter { int32_t iBlock; SBlockData blockData; int32_t iRow; + SDataFWriter* pDataFWriter; SArray* aBlockIdxN; + SBlockIdx blockIdx; SMapData mBlockN; + SBlock block; SBlockData nBlockData; + // for del file SDelFReader* pDelFReader; SDelFWriter* pDelFWriter; @@ -408,9 +414,11 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3 SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->fs->nState, fid); // reader if (pSet) { + // open code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet); if (code) goto _err; + // SBlockIdx code = tsdbReadBlockIdx(pWriter->pDataFReader, pWriter->aBlockIdx, NULL); if (code) goto _err; } else { @@ -438,16 +446,14 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3 TSKEY maxKey = 0; // TODO while (true) { - if (pWriter->pBlockIdx == NULL) { - // TODO - } else { + if (pWriter->pBlockIdx) { int32_t c = tTABLEIDCmprFn(&id, pWriter->pBlockIdx); if (c == 0) { } else if (c < 0) { // keep merge } else { - code = tsdbSnapWriteTableDataEnd(pWriter); + // code = tsdbSnapWriteTableDataEnd(pWriter); if (code) goto _err; pWriter->iBlockIdx++; @@ -462,6 +468,17 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3 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); + } } }