From 699c9572f583a9f32eb3943cb313f444d9c93d65 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Sun, 10 Jul 2022 06:01:30 +0000 Subject: [PATCH] more --- include/util/tRealloc.h | 7 +- source/dnode/vnode/src/meta/metaTable.c | 1 - source/dnode/vnode/src/tsdb/tsdbSnapshot.c | 89 ++++++++++++---------- 3 files changed, 53 insertions(+), 44 deletions(-) diff --git a/include/util/tRealloc.h b/include/util/tRealloc.h index 8d40f6cc5d..f3593d5818 100644 --- a/include/util/tRealloc.h +++ b/include/util/tRealloc.h @@ -25,10 +25,11 @@ extern "C" { static FORCE_INLINE int32_t tRealloc(uint8_t **ppBuf, int64_t size) { int32_t code = 0; int64_t bsize = 0; - uint8_t *pBuf; + uint8_t *pBuf = NULL; if (*ppBuf) { - bsize = *(int64_t *)((*ppBuf) - sizeof(int64_t)); + pBuf = (*ppBuf) - sizeof(int64_t); + bsize = *(int64_t *)pBuf; } if (bsize >= size) goto _exit; @@ -38,7 +39,7 @@ static FORCE_INLINE int32_t tRealloc(uint8_t **ppBuf, int64_t size) { bsize *= 2; } - pBuf = (uint8_t *)taosMemoryRealloc(*ppBuf ? (*ppBuf) - sizeof(int64_t) : *ppBuf, bsize + sizeof(int64_t)); + pBuf = (uint8_t *)taosMemoryRealloc(pBuf, bsize + sizeof(int64_t)); if (pBuf == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 72c39634f5..daf7ccb26a 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -17,7 +17,6 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema); static int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema); -static int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME); static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME); static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME); static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME); diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 54087a7871..2a5c7d949d 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -394,6 +394,12 @@ _err: return code; } +static int32_t tsdbSnapWriteTableData(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { + int32_t code = 0; + // TODO + return code; +} + static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { int32_t code = 0; STsdb* pTsdb = pWriter->pTsdb; @@ -440,47 +446,50 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3 taosArrayClear(pWriter->aBlockIdxN); } - // process - TABLEID id = {0}; // TODO - TSKEY minKey = 0; // TODO - TSKEY maxKey = 0; // TODO - - while (true) { - if (pWriter->pBlockIdx) { - int32_t c = tTABLEIDCmprFn(&id, pWriter->pBlockIdx); - - if (c == 0) { - } else if (c < 0) { - // keep merge - } else { - // code = tsdbSnapWriteTableDataEnd(pWriter); - if (code) goto _err; - - pWriter->iBlockIdx++; - if (pWriter->iBlockIdx < taosArrayGetSize(pWriter->aBlockIdx)) { - pWriter->pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlockIdx); - } else { - pWriter->pBlockIdx = NULL; - } - - if (pWriter->pBlockIdx) { - code = tsdbReadBlock(pWriter->pDataFReader, pWriter->pBlockIdx, &pWriter->mBlock, NULL); - if (code) goto _err; - } - } - } else { - int32_t c = tTABLEIDCmprFn(&id, &pWriter->blockIdx); + code = tsdbSnapWriteTableData(pWriter, pData, nData); + if (code) goto _err; - if (c == 0) { - // merge commit the block data - } else if (c > 0) { - // code = tsdbSnapWriteTableDataEnd(pWriter); - if (code) goto _err; - } else { - ASSERT(0); - } - } - } + // // process + // TABLEID id = {0}; // TODO + // TSKEY minKey = 0; // TODO + // TSKEY maxKey = 0; // TODO + + // while (true) { + // if (pWriter->pBlockIdx) { + // int32_t c = tTABLEIDCmprFn(&id, pWriter->pBlockIdx); + + // if (c == 0) { + // } else if (c < 0) { + // // keep merge + // } else { + // // code = tsdbSnapWriteTableDataEnd(pWriter); + // if (code) goto _err; + + // pWriter->iBlockIdx++; + // if (pWriter->iBlockIdx < taosArrayGetSize(pWriter->aBlockIdx)) { + // pWriter->pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlockIdx); + // } else { + // pWriter->pBlockIdx = NULL; + // } + + // if (pWriter->pBlockIdx) { + // code = tsdbReadBlock(pWriter->pDataFReader, pWriter->pBlockIdx, &pWriter->mBlock, NULL); + // 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); + // } + // } + // } return code; -- GitLab