From 716c0045f8aa32ddff8e8fd8cb7d6d8c9726010a Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 1 Dec 2021 17:29:59 +0800 Subject: [PATCH] refactor builder struct --- source/libs/index/inc/index_fst_util.h | 4 ++-- source/libs/index/src/index_fst.c | 8 ++++---- source/libs/index/src/index_fst_util.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/libs/index/inc/index_fst_util.h b/source/libs/index/inc/index_fst_util.h index a3cef493eb..d87e5bd57e 100644 --- a/source/libs/index/inc/index_fst_util.h +++ b/source/libs/index/inc/index_fst_util.h @@ -82,8 +82,8 @@ typedef struct FstSlice { FstSlice fstSliceCreate(uint8_t *data, uint64_t len); FstSlice fstSliceCopy(FstSlice *s, int32_t start, int32_t end); FstSlice fstSliceDeepCopy(FstSlice *s, int32_t start, int32_t end); -bool fstSliceEmpty(FstSlice *s); -int fstSliceCompare(FstSlice *s1, FstSlice *s2); +bool fstSliceIsEmpty(FstSlice *s); +int fstSliceCompare(FstSlice *s1, FstSlice *s2); void fstSliceDestroy(FstSlice *s); uint8_t *fstSliceData(FstSlice *s, int32_t *sz); diff --git a/source/libs/index/src/index_fst.c b/source/libs/index/src/index_fst.c index dd43890209..ca1c7910ed 100644 --- a/source/libs/index/src/index_fst.c +++ b/source/libs/index/src/index_fst.c @@ -92,7 +92,7 @@ void fstUnFinishedNodesTopLastFreeze(FstUnFinishedNodes *nodes, CompiledAddr add } void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes *nodes, FstSlice bs, Output out) { FstSlice *s = &bs; - if (fstSliceEmpty(s)) { + if (fstSliceIsEmpty(s)) { return; } size_t sz = taosArrayGetSize(nodes->stack) - 1; @@ -801,7 +801,7 @@ bool fstBuilderInsert(FstBuilder *b, FstSlice bs, Output in) { void fstBuilderInsertOutput(FstBuilder *b, FstSlice bs, Output in) { FstSlice *s = &bs; - if (fstSliceEmpty(s)) { + if (fstSliceIsEmpty(s)) { b->len = 1; fstUnFinishedNodesSetRootOutput(b->unfinished, in); return; @@ -831,7 +831,7 @@ void fstBuilderInsertOutput(FstBuilder *b, FstSlice bs, Output in) { OrderType fstBuilderCheckLastKey(FstBuilder *b, FstSlice bs, bool ckDup) { FstSlice *input = &bs; - if (fstSliceEmpty(&b->last)) { + if (fstSliceIsEmpty(&b->last)) { // deep copy or not b->last = fstSliceCopy(&bs, input->start, input->end); } else { @@ -1115,7 +1115,7 @@ bool fstBoundWithDataIsEmpty(FstBoundWithData *bound) { if (bound->type == Unbounded) { return true; } else { - return fstSliceEmpty(&bound->data); + return fstSliceIsEmpty(&bound->data); } } diff --git a/source/libs/index/src/index_fst_util.c b/source/libs/index/src/index_fst_util.c index 92949d1ff2..1c7a1a9e9d 100644 --- a/source/libs/index/src/index_fst_util.c +++ b/source/libs/index/src/index_fst_util.c @@ -122,7 +122,7 @@ FstSlice fstSliceDeepCopy(FstSlice *s, int32_t start, int32_t end) { assert(tlen <= alen); uint8_t *buf = malloc(sizeof(uint8_t) * tlen); - memcpy(buf, data, tlen); + memcpy(buf, data + start, tlen); FstString *str = malloc(sizeof(FstString)); str->data = buf; @@ -135,7 +135,7 @@ FstSlice fstSliceDeepCopy(FstSlice *s, int32_t start, int32_t end) { ans.end = tlen - 1; return ans; } -bool fstSliceEmpty(FstSlice *s) { +bool fstSliceIsEmpty(FstSlice *s) { return s->str == NULL || s->start < 0 || s->end < 0; }