diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /searchlib/src/tests/queryeval/weak_and/weak_and_test_expensive.cpp |
Publish
Diffstat (limited to 'searchlib/src/tests/queryeval/weak_and/weak_and_test_expensive.cpp')
-rw-r--r-- | searchlib/src/tests/queryeval/weak_and/weak_and_test_expensive.cpp | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/searchlib/src/tests/queryeval/weak_and/weak_and_test_expensive.cpp b/searchlib/src/tests/queryeval/weak_and/weak_and_test_expensive.cpp new file mode 100644 index 00000000000..8f60b6dd8c7 --- /dev/null +++ b/searchlib/src/tests/queryeval/weak_and/weak_and_test_expensive.cpp @@ -0,0 +1,102 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/fastos/fastos.h> +#include "wand_bench_setup.hpp" + +using namespace rise; + +namespace { + +template <typename WeakAndType, typename RiseType> +void checkWandHits(WandFactory &vespa, WandFactory &rise, uint32_t step, uint32_t filter) { + WandSetup vespaSetup(vespa, 500, 5000000); + WandSetup riseSetup(rise, 500, 5000000); + SearchIterator::UP s1 = vespaSetup.create(); + s1->initFullRange(); + SearchIterator::UP s2 = riseSetup.create(); + s2->initFullRange(); + ASSERT_TRUE(dynamic_cast<WeakAndType*>(s1.get()) != 0); + ASSERT_TRUE(dynamic_cast<WeakAndType*>(s2.get()) == 0); + ASSERT_TRUE(dynamic_cast<RiseType*>(s2.get()) != 0); + ASSERT_TRUE(dynamic_cast<RiseType*>(s1.get()) == 0); + s1->seek(1); + s2->seek(1); + while (!s1->isAtEnd() && + !s2->isAtEnd()) + { + ASSERT_EQUAL(s1->getDocId(), s2->getDocId()); + if ((filter == 0) || ((s1->getDocId() % filter) != 0)) { + s1->unpack(s1->getDocId()); + s2->unpack(s2->getDocId()); + } + s1->seek(s1->getDocId() + step); + s2->seek(s2->getDocId() + step); + } + ASSERT_TRUE(s1->isAtEnd()); + ASSERT_TRUE(s2->isAtEnd()); +} + +} // namespace <unnamed> + +TEST("require that mod search works") { + Stats stats; + SearchIterator::UP search(new ModSearch(stats, 3, 8, 3, NULL)); + SimpleResult hits; + hits.search(*search); + EXPECT_EQUAL(SimpleResult().addHit(3).addHit(6), hits); +} + +//---- WeakAndSearch ------------------------------------------------------------------------------ + +TEST_FF("require that (array) WAND and RISE WAND gives the same hits", + VespaArrayWandFactory(500), TermFrequencyRiseWandFactory(500)) +{ + checkWandHits<WeakAndSearch, TermFrequencyRiseWand>(f1, f2, 1, 0); +} + +TEST_FF("require that (heap) WAND and RISE WAND gives the same hits", + VespaHeapWandFactory(500), TermFrequencyRiseWandFactory(500)) +{ + checkWandHits<WeakAndSearch, TermFrequencyRiseWand>(f1, f2, 1, 0); +} + +TEST_FF("require that (array) WAND and RISE WAND gives the same hits with filtering and skipping", + VespaArrayWandFactory(500), TermFrequencyRiseWandFactory(500)) +{ + checkWandHits<WeakAndSearch, TermFrequencyRiseWand>(f1, f2, 123, 5); +} + +TEST_FF("require that (heap) WAND and RISE WAND gives the same hits with filtering and skipping", + VespaHeapWandFactory(500), TermFrequencyRiseWandFactory(500)) +{ + checkWandHits<WeakAndSearch, TermFrequencyRiseWand>(f1, f2, 123, 5); +} + + +//---- ParallelWeakAndSearch ---------------------------------------------------------------------- + +TEST_FF("require that (array) PWAND and RISE WAND gives the same hits", + VespaParallelArrayWandFactory(500), DotProductRiseWandFactory(500)) +{ + checkWandHits<ParallelWeakAndSearch, DotProductRiseWand>(f1, f2, 1, 0); +} + +TEST_FF("require that (heap) PWAND and RISE WAND gives the same hits", + VespaParallelHeapWandFactory(500), DotProductRiseWandFactory(500)) +{ + checkWandHits<ParallelWeakAndSearch, DotProductRiseWand>(f1, f2, 1, 0); +} + +TEST_FF("require that (array) PWAND and RISE WAND gives the same hits with filtering and skipping", + VespaParallelArrayWandFactory(500), DotProductRiseWandFactory(500)) +{ + checkWandHits<ParallelWeakAndSearch, DotProductRiseWand>(f1, f2, 123, 5); +} + +TEST_FF("require that (heap) PWAND and RISE WAND gives the same hits with filtering and skipping", + VespaParallelHeapWandFactory(500), DotProductRiseWandFactory(500)) +{ + checkWandHits<ParallelWeakAndSearch, DotProductRiseWand>(f1, f2, 123, 5); +} + + +TEST_MAIN() { TEST_RUN_ALL(); } |