Merge pull request #11072 from taosdata/feature/index_query

update fst range
This commit is contained in:
Yihao Deng 2022-03-29 09:26:03 +08:00 committed by GitHub
commit 4d67df79c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 11 deletions

View File

@ -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;

View File

@ -101,15 +101,16 @@ class FstReadMemory {
}
return true;
}
bool SearchRange(AutomationCtx* ctx, const std::string& low, const std::string& high, std::vector<uint64_t>& result) {
bool SearchRange(AutomationCtx* ctx, const std::string& low, RangeType lowType, const std::string& high,
RangeType highType, std::vector<uint64_t>& 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<uint64_t> 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);
}

View File

@ -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";