diff --git a/coding/coding.pro b/coding/coding.pro index f159e3fb3a..adf2dd5515 100644 --- a/coding/coding.pro +++ b/coding/coding.pro @@ -89,12 +89,6 @@ HEADERS += \ streams_common.hpp \ streams_sink.hpp \ succinct_mapper.hpp \ - succinct_trie.hpp \ - succinct_trie_builder.hpp \ - succinct_trie_reader.hpp \ - trie.hpp \ - trie_builder.hpp \ - trie_reader.hpp \ uri.hpp \ url_encode.hpp \ value_opt_string.hpp \ diff --git a/coding/coding_tests/coding_tests.pro b/coding/coding_tests/coding_tests.pro index f782173851..adb3676b54 100644 --- a/coding/coding_tests/coding_tests.pro +++ b/coding/coding_tests/coding_tests.pro @@ -39,8 +39,6 @@ SOURCES += ../../testing/testingmain.cpp \ simple_dense_coding_test.cpp \ sha2_test.cpp \ succinct_mapper_test.cpp \ - succinct_trie_test.cpp \ - trie_test.cpp \ uri_test.cpp \ url_encode_test.cpp \ value_opt_string_test.cpp \ diff --git a/indexer/indexer.pro b/indexer/indexer.pro index ac32398306..e0a6ee2958 100644 --- a/indexer/indexer.pro +++ b/indexer/indexer.pro @@ -51,6 +51,7 @@ SOURCES += \ types_mapping.cpp \ types_skipper.cpp \ + HEADERS += \ categories_holder.hpp \ cell_coverer.hpp \ @@ -103,8 +104,14 @@ HEADERS += \ search_trie.hpp \ string_file.hpp \ string_file_values.hpp \ + succinct_trie.hpp \ + succinct_trie_builder.hpp \ + succinct_trie_reader.hpp \ tesselator_decl.hpp \ tree_structure.hpp \ + trie.hpp \ + trie_builder.hpp \ + trie_reader.hpp \ types_mapping.hpp \ types_skipper.hpp \ unique_index.hpp \ diff --git a/indexer/indexer_tests/indexer_tests.pro b/indexer/indexer_tests/indexer_tests.pro index ae4ee56e2d..d6c87aaca1 100644 --- a/indexer/indexer_tests/indexer_tests.pro +++ b/indexer/indexer_tests/indexer_tests.pro @@ -37,6 +37,8 @@ SOURCES += \ scales_test.cpp \ search_string_utils_test.cpp \ sort_and_merge_intervals_test.cpp \ + succinct_trie_test.cpp \ test_polylines.cpp \ test_type.cpp \ + trie_test.cpp \ visibility_test.cpp \ diff --git a/coding/coding_tests/succinct_trie_test.cpp b/indexer/indexer_tests/succinct_trie_test.cpp similarity index 97% rename from coding/coding_tests/succinct_trie_test.cpp rename to indexer/indexer_tests/succinct_trie_test.cpp index 4eeae0f9cf..5381cd4b00 100644 --- a/coding/coding_tests/succinct_trie_test.cpp +++ b/indexer/indexer_tests/succinct_trie_test.cpp @@ -1,15 +1,14 @@ #include "testing/testing.hpp" -#include "coding/succinct_trie_builder.hpp" -#include "coding/succinct_trie_reader.hpp" -#include "coding/trie_builder.hpp" -#include "coding/trie.hpp" #include "coding/reader.hpp" #include "coding/writer.hpp" -#include "coding/trie_reader.hpp" - #include "indexer/search_trie.hpp" +#include "indexer/succinct_trie_builder.hpp" +#include "indexer/succinct_trie_reader.hpp" +#include "indexer/trie.hpp" +#include "indexer/trie_builder.hpp" +#include "indexer/trie_reader.hpp" #include "base/string_utils.hpp" diff --git a/coding/coding_tests/trie_test.cpp b/indexer/indexer_tests/trie_test.cpp similarity index 97% rename from coding/coding_tests/trie_test.cpp rename to indexer/indexer_tests/trie_test.cpp index 890e6bdaff..4b5a91bfee 100644 --- a/coding/coding_tests/trie_test.cpp +++ b/indexer/indexer_tests/trie_test.cpp @@ -1,9 +1,11 @@ #include "testing/testing.hpp" + +#include "indexer/trie.hpp" +#include "indexer/trie_builder.hpp" +#include "indexer/trie_reader.hpp" + #include "coding/byte_stream.hpp" #include "coding/reader.hpp" -#include "coding/trie.hpp" -#include "coding/trie_builder.hpp" -#include "coding/trie_reader.hpp" #include "coding/write_to_sink.hpp" #include "base/logging.hpp" @@ -134,11 +136,6 @@ public: template void Deserialize(TSource & src, uint32_t valueCount, TSerializer const & /* serializer */) { - if (valueCount == 0) - { - Deserialize(src, TSerializer()); - return; - } m_values.resize(valueCount); for (size_t i = 0; i < valueCount; ++i) m_values[i] = ReadPrimitiveFromSource(src); diff --git a/indexer/search_index_builder.cpp b/indexer/search_index_builder.cpp index d5fac2a000..b0260ed512 100644 --- a/indexer/search_index_builder.cpp +++ b/indexer/search_index_builder.cpp @@ -11,6 +11,7 @@ #include "indexer/search_trie.hpp" #include "indexer/string_file.hpp" #include "indexer/string_file_values.hpp" +#include "indexer/trie_builder.hpp" #include "indexer/types_skipper.hpp" #include "search/search_common.hpp" // for MAX_TOKENS constant @@ -21,7 +22,6 @@ #include "coding/file_name_utils.hpp" #include "coding/reader_writer_ops.hpp" -#include "coding/trie_builder.hpp" #include "coding/writer.hpp" #include "base/assert.hpp" diff --git a/indexer/search_trie.hpp b/indexer/search_trie.hpp index 0ce0d8904f..c715ab306b 100644 --- a/indexer/search_trie.hpp +++ b/indexer/search_trie.hpp @@ -2,11 +2,10 @@ #include "indexer/geometry_serialization.hpp" #include "indexer/string_file_values.hpp" +#include "indexer/trie.hpp" +#include "indexer/trie_reader.hpp" #include "coding/reader.hpp" -#include "coding/trie.hpp" -#include "coding/trie_reader.hpp" - namespace search { diff --git a/indexer/string_file_values.hpp b/indexer/string_file_values.hpp index 12c9fe763a..1d41186e62 100644 --- a/indexer/string_file_values.hpp +++ b/indexer/string_file_values.hpp @@ -203,6 +203,15 @@ public: m_cbv.reset(); } + template + void Deserialize(TSource & src, SingleValueSerializer const & /* serializer */) + { + if (src.Size() > 0) + m_cbv = coding::CompressedBitVectorBuilder::DeserializeFromSource(src); + else + m_cbv.reset(); + } + template void ForEach(TF && f) const { diff --git a/coding/succinct_trie_builder.hpp b/indexer/succinct_trie_builder.hpp similarity index 100% rename from coding/succinct_trie_builder.hpp rename to indexer/succinct_trie_builder.hpp diff --git a/coding/succinct_trie_reader.hpp b/indexer/succinct_trie_reader.hpp similarity index 99% rename from coding/succinct_trie_reader.hpp rename to indexer/succinct_trie_reader.hpp index cc61d6b0f2..969302bb2d 100644 --- a/coding/succinct_trie_reader.hpp +++ b/indexer/succinct_trie_reader.hpp @@ -1,8 +1,9 @@ #pragma once +#include "indexer/trie.hpp" + #include "coding/bit_streams.hpp" #include "coding/huffman.hpp" #include "coding/reader.hpp" -#include "coding/trie.hpp" #include "coding/varint.hpp" #include "base/assert.hpp" diff --git a/coding/trie.hpp b/indexer/trie.hpp similarity index 100% rename from coding/trie.hpp rename to indexer/trie.hpp diff --git a/coding/trie_builder.hpp b/indexer/trie_builder.hpp similarity index 97% rename from coding/trie_builder.hpp rename to indexer/trie_builder.hpp index 714c8f02f6..6ba69c2430 100644 --- a/coding/trie_builder.hpp +++ b/indexer/trie_builder.hpp @@ -50,7 +50,14 @@ void WriteNode(TSink & sink, TSerializer const & serializer, TrieChar baseChar, if (begChild == endChild && !isRoot) { // Leaf node. +#ifdef DEBUG + auto posBefore = sink.Pos(); +#endif valueList.Serialize(sink, serializer); +#ifdef DEBUG + if (valueCount == 0) + ASSERT_EQUAL(sink.Pos(), posBefore, ("Empty valueList must produce an empty serialization.")); +#endif return; } uint32_t const childCount = endChild - begChild; diff --git a/coding/trie_reader.hpp b/indexer/trie_reader.hpp similarity index 97% rename from coding/trie_reader.hpp rename to indexer/trie_reader.hpp index 2b4c651762..0afc853180 100644 --- a/coding/trie_reader.hpp +++ b/indexer/trie_reader.hpp @@ -1,5 +1,6 @@ #pragma once -#include "coding/trie.hpp" +#include "indexer/trie.hpp" + #include "coding/reader.hpp" #include "coding/varint.hpp" @@ -20,8 +21,7 @@ public: LeafIterator0(TReader const & reader, TSerializer const & serializer) { ReaderSource src(reader); - if (src.Size() > 0) - m_valueList.Deserialize(src, 0 /* valueCount */, serializer); + m_valueList.Deserialize(src, serializer); ASSERT_EQUAL(src.Size(), 0, ()); } diff --git a/search/search_trie.cpp b/search/search_trie.cpp deleted file mode 100644 index 623f914f4c..0000000000 --- a/search/search_trie.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "search/search_trie.hpp" -#include "search" -#include "coding/writer.hpp" - -void Build(FeaturesVector const & featuresVector, Writer & writer); diff --git a/tizen/RunUnitTests/.project b/tizen/RunUnitTests/.project index 34a0dd8edf..2cb162d4be 100644 --- a/tizen/RunUnitTests/.project +++ b/tizen/RunUnitTests/.project @@ -521,7 +521,7 @@ PARENT-2-ECLIPSE_HOME/GitHub/omim/coding/coding_tests/sha2_test.cpp - src/Tests/coding/trie_test.cpp + src/Tests/indexer/trie_test.cpp 1 PARENT-2-ECLIPSE_HOME/GitHub/omim/coding/coding_tests/trie_test.cpp