diff --git a/include/util/tRealloc.h b/include/util/tRealloc.h index 8d40f6cc5df71f183a8c8c4c4fcbe2ff12a1bf0f..f3593d5818cd626c7268ec1b721bd961fba3a845 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 72c39634f52aeffe627bf6c9701b0a880130b54d..daf7ccb26ae1091e386dd038aec713f857cb39aa 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 54087a787128d2672e9d6d8f29976ffececf3348..2a5c7d949d426d3cc76ebbe99eb6714e10756c16 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;