提交 73d938b0 编写于 作者: dengyihao's avatar dengyihao

add test case

上级 1fe4cd22
......@@ -167,7 +167,10 @@ uint64_t fstUnFinishedNodesFindCommPrefixAndSetOutput(FstUnFinishedNodes *node,
break;
}
if (addPrefix != 0) {
fstBuilderNodeUnfinishedAddOutputPrefix(un, addPrefix);
if (i + 1 < ssz) {
FstBuilderNodeUnfinished *unf = taosArrayGet(node->stack, i + 1);
fstBuilderNodeUnfinishedAddOutputPrefix(unf, addPrefix);
}
}
}
return i;
......@@ -581,14 +584,13 @@ uint64_t fstStateFindInput(FstState *s, FstNode *node, uint8_t b, bool *null) {
- 1 // pack size
- node->nTrans;
uint64_t end = start + node->nTrans;
uint64_t len = end - start;
int32_t dlen = 0;
uint8_t *data = fstSliceData(slice, &dlen);
FstSlice t = fstSliceCopy(slice, start, end - 1);
int32_t len = 0;
uint8_t *data = fstSliceData(&t, &len);
for(int i = 0; i < len; i++) {
//uint8_t v = slice->data[slice->start + i];
////slice->data[slice->start + i];
uint8_t v = data[i];
if (v == b) {
return node->nTrans - i - 1; // bug
}
......@@ -1060,7 +1062,7 @@ bool fstGet(Fst *fst, FstSlice *b, Output *out) {
}
*out = tOut;
return false;
return true;
}
FstNode *fstGetRoot(Fst *fst) {
......
......@@ -83,7 +83,7 @@ int main(int argc, char** argv) {
std::string str("aaa");
str[2] = 'a' + i ;
FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size());
Output val = 2;
Output val = 0;
fstBuilderInsert(b, key, val);
}
......@@ -108,13 +108,14 @@ int main(int argc, char** argv) {
Fst *fst = fstCreate(&s);
{
std::string str("aaa");
std::string str("aax");
uint64_t out;
FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size());
bool ok = fstGet(fst, &key, &out);
if (ok == true) {
printf("val = %d\n", out);
//indexInfo("Get key-value success, %s, %d", str.c_str(), out);
} else {
//indexError("Get key-value failed, %s", str.c_str());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册