fix insert error

This commit is contained in:
yihaoDeng 2021-12-06 21:58:33 +08:00
parent db2bf567c2
commit d266c6f29f
2 changed files with 10 additions and 8 deletions

View File

@ -273,16 +273,16 @@ void fstStateCompileForAnyTrans(FstCountingWriter *w, CompiledAddr addr, FstBuil
if (FST_BUILDER_NODE_IS_FINAL(node)) { if (FST_BUILDER_NODE_IS_FINAL(node)) {
fstCountingWriterPackUintIn(w, node->finalOutput, oSize); fstCountingWriterPackUintIn(w, node->finalOutput, oSize);
} }
for (size_t i = 0; i < sz; i++) { for (int32_t i = sz - 1; i >= 0; i--) {
FstTransition *t = taosArrayGet(node->trans, i); FstTransition *t = taosArrayGet(node->trans, i);
fstCountingWriterPackUintIn(w, t->out, oSize); fstCountingWriterPackUintIn(w, t->out, oSize);
} }
} }
for (size_t i = 0; i < sz; i++) { for (int32_t i = sz - 1; i >= 0; i--) {
FstTransition *t = taosArrayGet(node->trans, i); FstTransition *t = taosArrayGet(node->trans, i);
fstPackDeltaIn(w, addr, t->addr, tSize); fstPackDeltaIn(w, addr, t->addr, tSize);
} }
for (size_t i = 0; i < sz; i++) { for (int32_t i = sz - 1; i >= 0; i--) {
FstTransition *t = taosArrayGet(node->trans, i); FstTransition *t = taosArrayGet(node->trans, i);
fstCountingWriterWrite(w, (char *)&t->inp, 1); fstCountingWriterWrite(w, (char *)&t->inp, 1);
//fstPackDeltaIn(w, addr, t->addr, tSize); //fstPackDeltaIn(w, addr, t->addr, tSize);

View File

@ -63,7 +63,7 @@
//} //}
int main(int argc, char** argv) { int main(int argc, char** argv) {
FstBuilder *b = fstBuilderCreate(NULL, 1); FstBuilder *b = fstBuilderCreate(NULL, 0);
{ {
std::string str("abc"); std::string str("abc");
FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size()); FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size());
@ -74,11 +74,13 @@ int main(int argc, char** argv) {
//std::string str1("bcd"); //std::string str1("bcd");
//FstSlice key1 = fstSliceCreate((uint8_t *)str1.c_str(), str1.size()); //FstSlice key1 = fstSliceCreate((uint8_t *)str1.c_str(), str1.size());
//Output val2 = 10; //Output val2 = 10;
//
{ {
//std::string str("bcd"); std::string str("adc");
//FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size()); FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size());
//Output val = 1; Output val = 2;
//fstBuilderInsert(b, key, val); fstBuilderInsert(b, key, val);
} }
//fstBuilderInsert(b, key1, val2); //fstBuilderInsert(b, key1, val2);
fstBuilderFinish(b); fstBuilderFinish(b);