From f523a96c2dab8c2113f34e6eb8033e4461a39e82 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 10 Feb 2023 13:38:21 +0800 Subject: [PATCH] fix compact problem --- include/libs/cache/cache.h | 27 ----------------------- source/dnode/vnode/src/tsdb/tsdbCompact.c | 2 +- source/dnode/vnode/src/tsdb/tsdbUtil.c | 20 ++++++++--------- source/libs/CMakeLists.txt | 1 - source/libs/cache/CMakeLists.txt | 7 ------ source/libs/cache/inc/cacheDef.h | 27 ----------------------- source/libs/cache/src/cache.c | 14 ------------ source/libs/cache/test/cacheTests.cpp | 0 8 files changed, 10 insertions(+), 88 deletions(-) delete mode 100644 include/libs/cache/cache.h delete mode 100644 source/libs/cache/CMakeLists.txt delete mode 100644 source/libs/cache/inc/cacheDef.h delete mode 100644 source/libs/cache/src/cache.c delete mode 100644 source/libs/cache/test/cacheTests.cpp diff --git a/include/libs/cache/cache.h b/include/libs/cache/cache.h deleted file mode 100644 index 6a2587ee96..0000000000 --- a/include/libs/cache/cache.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_CACHE_H_ -#define _TD_CACHE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_CACHE_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbCompact.c b/source/dnode/vnode/src/tsdb/tsdbCompact.c index 75023f3ef2..7258f2973a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCompact.c +++ b/source/dnode/vnode/src/tsdb/tsdbCompact.c @@ -314,7 +314,7 @@ static bool tsdbCompactTableIsDropped(STsdbCompactor *pCompactor) { SMetaInfo info; if (pCompactor->pIter->rowInfo.uid == pCompactor->tbid.uid) return false; - if (metaGetInfo(pCompactor->pTsdb->pVnode->pMeta, pCompactor->tbid.uid, &info, NULL)) { + if (metaGetInfo(pCompactor->pTsdb->pVnode->pMeta, pCompactor->pIter->rowInfo.uid, &info, NULL)) { return true; } return false; diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index 391891da28..24dcae91d9 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -1057,14 +1057,13 @@ _exit: return code; } - int32_t tsdbBuildDeleteSkylineImpl(SArray *aSkyline, int32_t sidx, int32_t eidx, SArray *pSkyline) { int32_t code = 0; SDelData *pDelData; int32_t midx; taosArrayClear(pSkyline); - if (sidx == eidx) { + if (sidx == eidx) { TSDBKEY *pItem1 = taosArrayGet(aSkyline, sidx * 2); TSDBKEY *pItem2 = taosArrayGet(aSkyline, sidx * 2 + 1); taosArrayPush(pSkyline, &pItem1); @@ -1097,14 +1096,13 @@ int32_t tsdbBuildDeleteSkylineImpl(SArray *aSkyline, int32_t sidx, int32_t eidx, return code; } - int32_t tsdbBuildDeleteSkyline(SArray *aDelData, int32_t sidx, int32_t eidx, SArray *aSkyline) { SDelData *pDelData; - int32_t code = 0; - int32_t dataNum = eidx - sidx + 1; - SArray *aTmpSkyline = taosArrayInit(dataNum * 2, sizeof(TSDBKEY)); - SArray *pSkyline = taosArrayInit(dataNum * 2, POINTER_BYTES); - + int32_t code = 0; + int32_t dataNum = eidx - sidx + 1; + SArray *aTmpSkyline = taosArrayInit(dataNum * 2, sizeof(TSDBKEY)); + SArray *pSkyline = taosArrayInit(dataNum * 2, POINTER_BYTES); + for (int32_t i = sidx; i <= eidx; ++i) { pDelData = (SDelData *)taosArrayGet(aDelData, i); taosArrayPush(aTmpSkyline, &(TSDBKEY){.ts = pDelData->sKey, .version = pDelData->version}); @@ -1116,8 +1114,8 @@ int32_t tsdbBuildDeleteSkyline(SArray *aDelData, int32_t sidx, int32_t eidx, SAr int32_t skylineNum = taosArrayGetSize(pSkyline); for (int32_t i = 0; i < skylineNum; ++i) { - TSDBKEY *p = taosArrayGetP(pSkyline, i); - taosArrayPush(aSkyline, p); + TSDBKEY *p = taosArrayGetP(pSkyline, i); + taosArrayPush(aSkyline, p); } _clear: @@ -1394,7 +1392,7 @@ int32_t tBlockDataTryUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, int64_t ui } int32_t tBlockDataUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema, int64_t uid) { - if (pBlockData->aTSKEY[pBlockData->nRow - 1] == TSDBROW_TS(pRow)) { + if (pBlockData->nRow > 0 && pBlockData->aTSKEY[pBlockData->nRow - 1] == TSDBROW_TS(pRow)) { return tBlockDataUpdateRow(pBlockData, pRow, pTSchema); } else { return tBlockDataAppendRow(pBlockData, pRow, pTSchema, uid); diff --git a/source/libs/CMakeLists.txt b/source/libs/CMakeLists.txt index 72459f4d35..e18be94ace 100644 --- a/source/libs/CMakeLists.txt +++ b/source/libs/CMakeLists.txt @@ -1,5 +1,4 @@ add_subdirectory(tdb) -add_subdirectory(cache) add_subdirectory(transport) add_subdirectory(wal) add_subdirectory(monitor) diff --git a/source/libs/cache/CMakeLists.txt b/source/libs/cache/CMakeLists.txt deleted file mode 100644 index dc631e5bfd..0000000000 --- a/source/libs/cache/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -aux_source_directory(src CACHE_SRC) -add_library(cache STATIC ${CACHE_SRC}) -target_include_directories( - cache - PUBLIC "${TD_SOURCE_DIR}/include/libs/cache" - PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" -) \ No newline at end of file diff --git a/source/libs/cache/inc/cacheDef.h b/source/libs/cache/inc/cacheDef.h deleted file mode 100644 index 2e0dbfcdb6..0000000000 --- a/source/libs/cache/inc/cacheDef.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_CACHE_DEF_H_ -#define _TD_CACHE_DEF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_CACHE_DEF_H_*/ \ No newline at end of file diff --git a/source/libs/cache/src/cache.c b/source/libs/cache/src/cache.c deleted file mode 100644 index 6dea4a4e57..0000000000 --- a/source/libs/cache/src/cache.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ \ No newline at end of file diff --git a/source/libs/cache/test/cacheTests.cpp b/source/libs/cache/test/cacheTests.cpp deleted file mode 100644 index e69de29bb2..0000000000 -- GitLab