From 67e40f882c0a021e92ca586aa8075e28c4101e69 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 6 Dec 2021 22:34:56 +0800 Subject: [PATCH] refactor builder struct --- source/libs/index/src/index_fst.c | 2 ++ source/libs/index/test/indexTests.cpp | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/source/libs/index/src/index_fst.c b/source/libs/index/src/index_fst.c index c986f7da01..76dbe24b2a 100644 --- a/source/libs/index/src/index_fst.c +++ b/source/libs/index/src/index_fst.c @@ -16,6 +16,7 @@ #include "index_fst.h" #include "tcoding.h" #include "tchecksum.h" +#include "indexInt.h" static void fstPackDeltaIn(FstCountingWriter *wrt, CompiledAddr nodeAddr, CompiledAddr transAddr, uint8_t nBytes) { @@ -806,6 +807,7 @@ bool fstBuilderInsert(FstBuilder *b, FstSlice bs, Output in) { fstBuilderInsertOutput(b, bs, in); return true; } + indexInfo("key must be ordered"); return false; } diff --git a/source/libs/index/test/indexTests.cpp b/source/libs/index/test/indexTests.cpp index 63e14a6949..5164209922 100644 --- a/source/libs/index/test/indexTests.cpp +++ b/source/libs/index/test/indexTests.cpp @@ -65,7 +65,7 @@ int main(int argc, char** argv) { FstBuilder *b = fstBuilderCreate(NULL, 0); { - std::string str("abc"); + std::string str("aaa"); FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size()); Output val = 1; fstBuilderInsert(b, key, val); @@ -77,10 +77,15 @@ int main(int argc, char** argv) { // { - std::string str("adc"); - FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size()); - Output val = 2; - fstBuilderInsert(b, key, val); + + for (size_t i = 1; i < 26; i++) { + std::string str("aaa"); + str[2] = 'a' + i ; + FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size()); + Output val = 2; + fstBuilderInsert(b, key, val); + } + } //fstBuilderInsert(b, key1, val2); fstBuilderFinish(b);