From 366b07fb969848a21d88db4fee1fa685ecde9f79 Mon Sep 17 00:00:00 2001 From: hzcheng Date: Sat, 18 Apr 2020 14:03:06 +0800 Subject: [PATCH] TD-100 --- src/common/src/dataformat.c | 37 ++------------------------- src/tsdb/src/tsdbMain.c | 2 +- src/tsdb/src/tsdbRWHelper.c | 51 ++++++++++++++++++------------------- 3 files changed, 28 insertions(+), 62 deletions(-) diff --git a/src/common/src/dataformat.c b/src/common/src/dataformat.c index 15dec2c71c..fb20892452 100644 --- a/src/common/src/dataformat.c +++ b/src/common/src/dataformat.c @@ -415,39 +415,6 @@ int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) { int iter1 = 0; int iter2 = 0; tdMergeTwoDataCols(target,pTarget, &iter1, source, &iter2, pTarget->numOfPoints + rowsToMerge); - // while (true) { - // if (iter1 >= pTarget->numOfPoints && iter2 >= source->numOfPoints) break; - - // TSKEY key1 = (iter1 >= pTarget->numOfPoints) ? INT64_MAX : ((TSKEY *)(pTarget->cols[0].pData))[iter1]; - // TSKEY key2 = (iter2 >= rowsToMerge) ? INT64_MAX : ((TSKEY *)(source->cols[0].pData))[iter2]; - - // if (key1 < key2) { // Copy from pTarget - // for (int i = 0; i < pTarget->numOfCols; i++) { - // ASSERT(target->cols[i].type == pTarget->cols[i].type); - // memcpy((void *)((char *)(target->cols[i].pData) + TYPE_BYTES[target->cols[i].type] * target->numOfPoints), - // (void *)((char *)(pTarget->cols[i].pData) + TYPE_BYTES[pTarget->cols[i].type] * iter1), - // TYPE_BYTES[target->cols[i].type]); - // target->cols[i].len += TYPE_BYTES[target->cols[i].type]; - // } - - // target->numOfPoints++; - // iter1++; - // } else if (key1 > key2) { // Copy from source - // for (int i = 0; i < source->numOfCols; i++) { - // ASSERT(target->cols[i].type == pTarget->cols[i].type); - // memcpy((void *)((char *)(target->cols[i].pData) + TYPE_BYTES[target->cols[i].type] * target->numOfPoints), - // (void *)((char *)(source->cols[i].pData) + TYPE_BYTES[source->cols[i].type] * iter2), - // TYPE_BYTES[target->cols[i].type]); - // target->cols[i].len += TYPE_BYTES[target->cols[i].type]; - // } - - // target->numOfPoints++; - // iter2++; - // } else { - // // TODO - // ASSERT(false); - // } - // } tdFreeDataCols(pTarget); return 0; @@ -476,7 +443,7 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, SDataCol } target->numOfPoints++; - *iter1++; + (*iter1)++; } else if (key1 > key2) { for (int i = 0; i < src2->numOfCols; i++) { ASSERT(target->cols[i].type == src2->cols[i].type); @@ -487,7 +454,7 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, SDataCol } target->numOfPoints++; - *iter2++; + (*iter2)++; } else { ASSERT(false); } diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 9816dbf135..d09c2bba7c 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -957,7 +957,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters int nLoop = 0; while (true) { int rowsRead = tsdbReadRowsFromCache(pIter, maxKey, maxRowsToRead, pDataCols); - ASSERT(rowsRead >= 0); + assert(rowsRead >= 0); if (pDataCols->numOfPoints == 0) break; nLoop++; diff --git a/src/tsdb/src/tsdbRWHelper.c b/src/tsdb/src/tsdbRWHelper.c index 8bb32cf179..b3280e341c 100644 --- a/src/tsdb/src/tsdbRWHelper.c +++ b/src/tsdb/src/tsdbRWHelper.c @@ -20,7 +20,7 @@ // Local function definitions static int tsdbCheckHelperCfg(SHelperCfg *pCfg); static int tsdbInitHelperFile(SRWHelper *pHelper); -static void tsdbClearHelperFile(SHelperFile *pHFile); +// static void tsdbClearHelperFile(SHelperFile *pHFile); static bool tsdbShouldCreateNewLast(SRWHelper *pHelper); static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDataCols, int rowsToWrite, SCompBlock *pCompBlock, bool isLast, bool isSuperBlock); @@ -615,31 +615,30 @@ static int tsdbCheckHelperCfg(SHelperCfg *pCfg) { return 0; } - -static void tsdbClearHelperFile(SHelperFile *pHFile) { - pHFile->fid = -1; - if (pHFile->headF.fd > 0) { - close(pHFile->headF.fd); - pHFile->headF.fd = -1; - } - if (pHFile->dataF.fd > 0) { - close(pHFile->dataF.fd); - pHFile->dataF.fd = -1; - } - if (pHFile->lastF.fd > 0) { - close(pHFile->lastF.fd); - pHFile->lastF.fd = -1; - } - if (pHFile->nHeadF.fd > 0) { - close(pHFile->nHeadF.fd); - pHFile->nHeadF.fd = -1; - } - if (pHFile->nLastF.fd > 0) { - close(pHFile->nLastF.fd); - pHFile->nLastF.fd = -1; - } - -} +// static void tsdbClearHelperFile(SHelperFile *pHFile) { +// pHFile->fid = -1; +// if (pHFile->headF.fd > 0) { +// close(pHFile->headF.fd); +// pHFile->headF.fd = -1; +// } +// if (pHFile->dataF.fd > 0) { +// close(pHFile->dataF.fd); +// pHFile->dataF.fd = -1; +// } +// if (pHFile->lastF.fd > 0) { +// close(pHFile->lastF.fd); +// pHFile->lastF.fd = -1; +// } +// if (pHFile->nHeadF.fd > 0) { +// close(pHFile->nHeadF.fd); +// pHFile->nHeadF.fd = -1; +// } +// if (pHFile->nLastF.fd > 0) { +// close(pHFile->nLastF.fd); +// pHFile->nLastF.fd = -1; +// } + +// } static bool tsdbShouldCreateNewLast(SRWHelper *pHelper) { ASSERT(pHelper->files.lastF.fd > 0); -- GitLab