From 91a5e17b9b76f85b62f274c45e8a190dcc688f0c Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 23 May 2023 11:45:33 +0800 Subject: [PATCH] more code --- include/util/tarray2.h | 2 ++ source/dnode/vnode/src/tsdb/dev/tsdbCommit.c | 13 ++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/util/tarray2.h b/include/util/tarray2.h index 7c253d36eb..589dfb12ee 100644 --- a/include/util/tarray2.h +++ b/include/util/tarray2.h @@ -45,6 +45,8 @@ typedef void (*TArray2Cb)(void *); #define TARRAY2_SIZE(a) ((a)->size) #define TARRAY2_ELEM(a, i) ((a)->data[i]) #define TARRAY2_ELEM_PTR(a, i) (&((a)->data[i])) +#define TARRAY2_FIRST(a) ((a)->data[0]) +#define TARRAY2_LAST(a) ((a)->data[(a)->size - 1]) static FORCE_INLINE int32_t tarray2_make_room( // void *arg, // array diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c b/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c index 88474fdcac..37158acf78 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c @@ -124,17 +124,12 @@ static int32_t open_committer_writer(SCommitter *pCommitter) { return open_writer_with_new_stt(pCommitter); } - SRBTreeNode *node = NULL; // tRBTreeMax(&lvl0->sttTree); - if (node == NULL) { + ASSERT(TARRAY2_SIZE(&lvl0->farr) > 0); + STFileObj *fobj = TARRAY2_LAST(&lvl0->farr); + if (fobj->f.stt.nseg >= pCommitter->sttTrigger) { return open_writer_with_new_stt(pCommitter); } else { - // STFileObj *fobj = TCONTAINER_OF(node, STFileObj, rbtn); - // if (fobj->f.stt.nseg >= pCommitter->sttTrigger) { - // return open_writer_with_new_stt(pCommitter); - // } else { - // return open_writer_with_exist_stt(pCommitter, &fobj->f); - // } - return 0; + return open_writer_with_exist_stt(pCommitter, &fobj->f); } } -- GitLab