未验证 提交 71469389 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #10370 from taosdata/feature/revertIndexImpl

add more UT
......@@ -235,6 +235,7 @@ void fstStateCompileForOneTrans(FstCountingWriter* w, CompiledAddr addr, FstTran
FstState st = fstStateCreate(OneTrans);
fstStateSetCommInput(&st, trn->inp);
bool null = false;
uint8_t inp = fstStateCommInput(&st, &null);
if (null == true) {
......@@ -936,6 +937,7 @@ FstLastTransition* fstLastTransitionCreate(uint8_t inp, Output out) {
}
void fstLastTransitionDestroy(FstLastTransition* trn) { free(trn); }
void fstBuilderNodeUnfinishedLastCompiled(FstBuilderNodeUnfinished* unNode, CompiledAddr addr) {
FstLastTransition* trn = unNode->last;
if (trn == NULL) {
......
......@@ -16,24 +16,24 @@
#include "index_fst_automation.h"
StartWithStateValue* startWithStateValueCreate(StartWithStateKind kind, ValueType ty, void* val) {
StartWithStateValue* nsv = calloc(1, sizeof(StartWithStateValue));
if (nsv == NULL) {
StartWithStateValue* sv = calloc(1, sizeof(StartWithStateValue));
if (sv == NULL) {
return NULL;
}
nsv->kind = kind;
nsv->type = ty;
sv->kind = kind;
sv->type = ty;
if (ty == FST_INT) {
nsv->val = *(int*)val;
sv->val = *(int*)val;
} else if (ty == FST_CHAR) {
size_t len = strlen((char*)val);
nsv->ptr = (char*)calloc(1, len + 1);
memcpy(nsv->ptr, val, len);
sv->ptr = (char*)calloc(1, len + 1);
memcpy(sv->ptr, val, len);
} else if (ty == FST_ARRAY) {
// TODO,
// nsv->arr = taosArrayFromList()
}
return nsv;
return sv;
}
void startWithStateValueDestroy(void* val) {
StartWithStateValue* sv = (StartWithStateValue*)val;
......@@ -146,11 +146,9 @@ AutomationCtx* automCtxCreate(void* data, AutomationType atype) {
if (atype == AUTOMATION_ALWAYS) {
int val = 0;
sv = startWithStateValueCreate(Running, FST_INT, &val);
ctx->stdata = (void*)sv;
} else if (atype == AUTOMATION_PREFIX) {
int val = 0;
sv = startWithStateValueCreate(Running, FST_INT, &val);
ctx->stdata = (void*)sv;
} else if (atype == AUTMMATION_MATCH) {
} else {
// add more search type
......@@ -160,9 +158,8 @@ AutomationCtx* automCtxCreate(void* data, AutomationType atype) {
if (data != NULL) {
char* src = (char*)data;
size_t len = strlen(src);
dst = (char*)malloc(len * sizeof(char) + 1);
dst = (char*)calloc(1, len * sizeof(char) + 1);
memcpy(dst, src, len);
dst[len] = 0;
}
ctx->data = dst;
......
......@@ -99,6 +99,7 @@ class FstReadMemory {
fstSliceDestroy(&skey);
return ok;
}
bool GetWithTimeCostUs(const std::string& key, uint64_t* val, uint64_t* elapse) {
int64_t s = taosGetTimestampUs();
bool ok = this->Get(key, val);
......@@ -120,8 +121,6 @@ class FstReadMemory {
printf("key: %s, val: %" PRIu64 "\n", key.c_str(), (uint64_t)(rt->out.out));
swsResultDestroy(rt);
}
for (size_t i = 0; i < result.size(); i++) {
}
std::cout << std::endl;
return true;
}
......@@ -137,7 +136,7 @@ class FstReadMemory {
fstDestroy(_fst);
fstSliceDestroy(&_s);
writerCtxDestroy(_wc, false);
tfCleanup();
// tfCleanup();
}
private:
......@@ -196,6 +195,10 @@ class TFst {
}
return fr->Get(k, v);
}
bool Search(AutomationCtx* ctx, std::vector<uint64_t>& result) {
// add more
return fr->Search(ctx, result);
}
private:
FstWriter* fw;
......@@ -229,5 +232,9 @@ TEST_F(FstEnv, writeNormal) {
assert(fst->Get("a", &val) == false);
assert(fst->Get("aa", &val) == true);
assert(val == 0);
std::vector<uint64_t> rlt;
AutomationCtx* ctx = automCtxCreate((void*)"ab", AUTOMATION_ALWAYS);
assert(fst->Search(ctx, rlt) == true);
}
TEST_F(FstEnv, writeExcpet) {}
TEST_F(FstEnv, WriteMillonrRecord) {}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册