diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-11-20 21:31:40 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-11-21 17:02:10 +0000 |
commit | c0f6dc28c836f554870a47ce385ca202ee81579a (patch) | |
tree | 5db57f3275e8bd9dff603c39fe7d5cb82a5ca527 /searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp | |
parent | ab75d86b43fb1027c0f8684e4dbeacb28632f997 (diff) |
If limit not reached after a certain amount iterators, estimate how many iterators are needed and
step iterator forward.
Diffstat (limited to 'searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp')
-rw-r--r-- | searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp b/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp index 343a5c8e38b..c701d5ac19f 100644 --- a/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp +++ b/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp @@ -233,6 +233,7 @@ private: void testRangeSearch(const AttributePtr & ptr, uint32_t numDocs, std::vector<ValueType> values); void testRangeSearch(); void testRangeSearchLimited(); + void testRangeSearchLimitedHugeDictionary(); // test case insensitive search @@ -504,7 +505,7 @@ SearchContextTest::checkResultSet(const ResultSet & rs, const DocSet & expected, ASSERT_TRUE(array != nullptr); uint32_t i = 0; for (auto iter = expected.begin(); iter != expected.end(); ++iter, ++i) { - EXPECT_TRUE(array[i].getDocId() == *iter); + EXPECT_EQUAL(array[i].getDocId(), *iter); } } } @@ -1176,6 +1177,42 @@ SearchContextTest::testRangeSearch(const AttributePtr & ptr, uint32_t numDocs, s } } +DocSet +createDocs(uint32_t from, int32_t count) { + DocSet docs; + if (count >= 0) { + for (int32_t i(0); i < count; i++) { + docs.put(from + i); + } + } else { + for (int32_t i(0); i > count; i--) { + docs.put(from + i); + } + } + return docs; +} + +void +SearchContextTest::testRangeSearchLimitedHugeDictionary() { + Config cfg(BasicType::INT32, CollectionType::SINGLE); + cfg.setFastSearch(true); + std::vector<int32_t> v; + v.reserve(2000); + for (size_t i(0); i < v.capacity(); i++) { + v.push_back(i); + } + auto ptr = AttributeBuilder("limited-int32", cfg).fill(v).get(); + auto& vec = dynamic_cast<IntegerAttribute &>(*ptr); + + performRangeSearch(vec, "[1;9;1200]", createDocs(2, 9)); + performRangeSearch(vec, "[1;1109;1200]", createDocs(2, 1109)); + performRangeSearch(vec, "[1;3009;1200]", createDocs(2, 1200)); + + performRangeSearch(vec, "[1;9;-1200]", createDocs(2, 9)); + performRangeSearch(vec, "[1;1109;-1200]", createDocs(2, 1109)); + performRangeSearch(vec, "[1;3009;-1200]", createDocs(2000, -1200)); +} + void SearchContextTest::testRangeSearchLimited() { @@ -1980,6 +2017,7 @@ SearchContextTest::Main() testSearchIterator(); testRangeSearch(); testRangeSearchLimited(); + testRangeSearchLimitedHugeDictionary(); testCaseInsensitiveSearch(); testRegexSearch(); testPrefixSearch(); |