From 33bd962894a88b30d918b27f51f37147add94ffb Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 28 Mar 2022 16:40:33 +0800 Subject: [PATCH] fst query --- source/libs/index/test/fstTest.cc | 39 +++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/source/libs/index/test/fstTest.cc b/source/libs/index/test/fstTest.cc index 7a8ee975c4..e7e5070d14 100644 --- a/source/libs/index/test/fstTest.cc +++ b/source/libs/index/test/fstTest.cc @@ -97,6 +97,7 @@ class FstReadMemory { std::string key(ch, sz); printf("key: %s, val: %" PRIu64 "\n", key.c_str(), (uint64_t)(rt->out.out)); swsResultDestroy(rt); + result.push_back(rt->out.out); } for (size_t i = 0; i < result.size(); i++) { } @@ -280,6 +281,11 @@ void checkFstCheckIteratorPrefix() { fw->Put("Hello world", 1); fw->Put("Hello worle", 2); fw->Put("hello worlf", 4); + fw->Put("ja", 4); + fw->Put("jb", 4); + fw->Put("jc", 4); + fw->Put("jddddddddd", 4); + fw->Put("jefffffff", 4); delete fw; FstReadMemory* m = new FstReadMemory(1024 * 64); @@ -288,19 +294,32 @@ void checkFstCheckIteratorPrefix() { delete m; return; } + { + // prefix search + std::vector result; - // prefix search - std::vector result; - - AutomationCtx* ctx = automCtxCreate((void*)"he", AUTOMATION_PREFIX); - m->Search(ctx, result); - std::cout << "size: " << result.size() << std::endl; - // assert(result.size() == count); - for (int i = 0; i < result.size(); i++) { - // assert(result[i] == i); // check result + AutomationCtx* ctx = automCtxCreate((void*)"he", AUTOMATION_PREFIX); + m->Search(ctx, result); + assert(result.size() == 1); + taosMemoryFree(ctx); } + { + // prefix search + std::vector result; - taosMemoryFree(ctx); + AutomationCtx* ctx = automCtxCreate((void*)"Hello", AUTOMATION_PREFIX); + m->Search(ctx, result); + assert(result.size() == 2); + taosMemoryFree(ctx); + } + { + std::vector result; + + AutomationCtx* ctx = automCtxCreate((void*)"jddd", AUTOMATION_PREFIX); + m->Search(ctx, result); + assert(result.size() == 1); + taosMemoryFree(ctx); + } delete m; }