From 2354cd9ec0ee9b20cac1a58e7ba1b0288837f5bc Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 28 Mar 2022 22:21:51 +0800 Subject: [PATCH] update fst range --- source/libs/index/src/index_fst.c | 5 +++-- source/libs/index/test/fstTest.cc | 15 +++++++-------- source/libs/index/test/fstUT.cc | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source/libs/index/src/index_fst.c b/source/libs/index/src/index_fst.c index 3edf5fa406..1a556950ba 100644 --- a/source/libs/index/src/index_fst.c +++ b/source/libs/index/src/index_fst.c @@ -720,6 +720,7 @@ bool fstNodeFindInput(FstNode* node, uint8_t b, uint64_t* res) { uint64_t out = fstStateFindInput(st, node, b, &null); if (null == false) { *res = out; + } else { s = false; } } @@ -1238,8 +1239,8 @@ bool streamWithStateSeekMin(StreamWithState* sws, FstBoundWithData* min) { for (uint32_t i = 0; i < len; i++) { uint8_t b = data[i]; uint64_t res = 0; - bool null = fstNodeFindInput(node, b, &res); - if (null == false) { + bool find = fstNodeFindInput(node, b, &res); + if (find == true) { FstTransition trn; fstNodeGetTransitionAt(node, res, &trn); void* preState = autState; diff --git a/source/libs/index/test/fstTest.cc b/source/libs/index/test/fstTest.cc index a38a7c9701..f13fdf7214 100644 --- a/source/libs/index/test/fstTest.cc +++ b/source/libs/index/test/fstTest.cc @@ -101,15 +101,16 @@ class FstReadMemory { } return true; } - bool SearchRange(AutomationCtx* ctx, const std::string& low, const std::string& high, std::vector& result) { + bool SearchRange(AutomationCtx* ctx, const std::string& low, RangeType lowType, const std::string& high, + RangeType highType, std::vector& result) { FstStreamBuilder* sb = fstSearch(_fst, ctx); FstSlice l = fstSliceCreate((uint8_t*)low.c_str(), low.size()); FstSlice h = fstSliceCreate((uint8_t*)high.c_str(), high.size()); // range [low, high); - fstStreamBuilderSetRange(sb, &l, GE); - fstStreamBuilderSetRange(sb, &h, LT); + fstStreamBuilderSetRange(sb, &l, lowType); + fstStreamBuilderSetRange(sb, &h, highType); fstSliceDestroy(&l); fstSliceDestroy(&h); @@ -406,11 +407,9 @@ void checkFstCheckIteratorRange1() { { // prefix search std::vector result; - - AutomationCtx* ctx = automCtxCreate((void*)"he", AUTOMATION_ALWAYS); - + AutomationCtx* ctx = automCtxCreate((void*)"he", AUTOMATION_ALWAYS); // [b, e) - m->SearchRange(ctx, "b", "e", result); + m->SearchRange(ctx, "b", GE, "e", LT, result); assert(result.size() == 3); taosMemoryFree(ctx); } @@ -445,7 +444,7 @@ void checkFstCheckIteratorRange2() { AutomationCtx* ctx = automCtxCreate((void*)"he", AUTOMATION_ALWAYS); // [b, e) - m->SearchRange(ctx, "b", "ed", result); + m->SearchRange(ctx, "b", GE, "ed", LT, result); assert(result.size() == 4); taosMemoryFree(ctx); } diff --git a/source/libs/index/test/fstUT.cc b/source/libs/index/test/fstUT.cc index 1bdc7fc9c9..e7efbaf21f 100644 --- a/source/libs/index/test/fstUT.cc +++ b/source/libs/index/test/fstUT.cc @@ -13,9 +13,9 @@ #include "index_fst_util.h" #include "index_tfile.h" #include "tglobal.h" +#include "tlog.h" #include "tskiplist.h" #include "tutil.h" -#include "tlog.h" static std::string dir = "/tmp/index";