From d266c6f29f30d8b1ad815cb38b62bdfe879fddd9 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 6 Dec 2021 21:58:33 +0800 Subject: [PATCH] fix insert error --- source/libs/index/src/index_fst.c | 6 +++--- source/libs/index/test/indexTests.cpp | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/libs/index/src/index_fst.c b/source/libs/index/src/index_fst.c index 88fc0bd322..c986f7da01 100644 --- a/source/libs/index/src/index_fst.c +++ b/source/libs/index/src/index_fst.c @@ -273,16 +273,16 @@ void fstStateCompileForAnyTrans(FstCountingWriter *w, CompiledAddr addr, FstBuil if (FST_BUILDER_NODE_IS_FINAL(node)) { 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); 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); 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); fstCountingWriterWrite(w, (char *)&t->inp, 1); //fstPackDeltaIn(w, addr, t->addr, tSize); diff --git a/source/libs/index/test/indexTests.cpp b/source/libs/index/test/indexTests.cpp index 37aa194d6e..63e14a6949 100644 --- a/source/libs/index/test/indexTests.cpp +++ b/source/libs/index/test/indexTests.cpp @@ -63,7 +63,7 @@ //} int main(int argc, char** argv) { - FstBuilder *b = fstBuilderCreate(NULL, 1); + FstBuilder *b = fstBuilderCreate(NULL, 0); { std::string str("abc"); FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size()); @@ -74,11 +74,13 @@ int main(int argc, char** argv) { //std::string str1("bcd"); //FstSlice key1 = fstSliceCreate((uint8_t *)str1.c_str(), str1.size()); //Output val2 = 10; + // + { - //std::string str("bcd"); - //FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size()); - //Output val = 1; - //fstBuilderInsert(b, key, val); + std::string str("adc"); + FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size()); + Output val = 2; + fstBuilderInsert(b, key, val); } //fstBuilderInsert(b, key1, val2); fstBuilderFinish(b);