diff options
Diffstat (limited to 'searchlib/src/tests/attribute/searchcontext/searchcontext.cpp')
-rw-r--r-- | searchlib/src/tests/attribute/searchcontext/searchcontext.cpp | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp b/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp index 138e406c988..32da1743343 100644 --- a/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp +++ b/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp @@ -61,7 +61,8 @@ using fef::TermFieldMatchDataPosition; class DocSet : public std::set<uint32_t> { public: - DocSet() : std::set<uint32_t>() {} + DocSet(); + ~DocSet(); DocSet(const uint32_t *b, const uint32_t *e) : std::set<uint32_t>(b, e) {} DocSet & put(const uint32_t &v) { insert(v); @@ -69,6 +70,9 @@ public: } }; +DocSet::DocSet() : std::set<uint32_t>() {} +DocSet::~DocSet() {} + template <typename V, typename T> class PostingList { @@ -78,7 +82,8 @@ private: DocSet _hits; public: - PostingList(V & vec, T value) : _vec(&vec), _value(value), _hits() {} + PostingList(V & vec, T value); + ~PostingList(); const V & getAttribute() const { return *_vec; } V & getAttribute() { return *_vec; } const T & getValue() const { return _value; } @@ -87,6 +92,12 @@ public: uint32_t getHitCount() const { return _hits.size(); } }; +template <typename V, typename T> +PostingList<V, T>::PostingList(V & vec, T value) : _vec(&vec), _value(value), _hits() {} + +template <typename V, typename T> +PostingList<V, T>::~PostingList() {} + class DocRange { public: @@ -608,20 +619,8 @@ void SearchContextTest::testSearch(const ConfigMap & cfgs) { template<typename T, typename A> class Verifier : public search::test::SearchIteratorVerifier { public: - Verifier(T key, const vespalib::string & keyAsString, const vespalib::string & name, const Config & cfg) : - _attribute(AttributeFactory::createAttribute(name + "-initrange", cfg)), - _sc() - { - SearchContextTest::addDocs(*_attribute, getDocIdLimit()); - for (uint32_t doc : getExpectedDocIds()) { - EXPECT_TRUE(nullptr != dynamic_cast<A *>(_attribute.get())); - EXPECT_TRUE(dynamic_cast<A *>(_attribute.get())->update(doc, key)); - } - _attribute->commit(true); - _sc = SearchContextTest::getSearch(*_attribute, keyAsString); - ASSERT_TRUE(_sc->valid()); - _sc->fetchPostings(true); - } + Verifier(T key, const vespalib::string & keyAsString, const vespalib::string & name, const Config & cfg); + ~Verifier(); SearchIterator::UP create(bool strict) const override { return _sc->createIterator(&_dummy, strict); } @@ -632,6 +631,25 @@ private: }; template<typename T, typename A> +Verifier<T, A>::Verifier(T key, const vespalib::string & keyAsString, const vespalib::string & name, const Config & cfg) + :_attribute(AttributeFactory::createAttribute(name + "-initrange", cfg)), + _sc() +{ + SearchContextTest::addDocs(*_attribute, getDocIdLimit()); + for (uint32_t doc : getExpectedDocIds()) { + EXPECT_TRUE(nullptr != dynamic_cast<A *>(_attribute.get())); + EXPECT_TRUE(dynamic_cast<A *>(_attribute.get())->update(doc, key)); + } + _attribute->commit(true); + _sc = SearchContextTest::getSearch(*_attribute, keyAsString); + ASSERT_TRUE(_sc->valid()); + _sc->fetchPostings(true); +} + +template<typename T, typename A> +Verifier<T, A>::~Verifier() {} + +template<typename T, typename A> void SearchContextTest::testSearchIterator(T key, const vespalib::string &keyAsString, const ConfigMap &cfgs) { for (const auto & cfg : cfgs) { |