summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/attribute
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-09-29 10:37:03 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-09-29 10:37:03 +0000
commit606796ed3b3bce9953e419effa9365103ca4032d (patch)
tree1d31ebcc2d2b07ed5e8370b176fc46c0d08d4101 /searchlib/src/tests/attribute
parent62928f4d8b7571c4b10fedffc56b762f57b6b2ca (diff)
Alwasy use bitvector for long posting lists.
Diffstat (limited to 'searchlib/src/tests/attribute')
-rw-r--r--searchlib/src/tests/attribute/bitvector/bitvector_test.cpp49
-rw-r--r--searchlib/src/tests/attribute/posting_store/posting_store_test.cpp16
-rw-r--r--searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp28
3 files changed, 33 insertions, 60 deletions
diff --git a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp
index d1dde5ef6ea..7cfe7eaab75 100644
--- a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp
+++ b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp
@@ -57,7 +57,6 @@ struct BitVectorTest
make(Config cfg,
const vespalib::string &pref,
bool fastSearch,
- bool enableBitVectors,
bool enableOnlyBitVector,
bool filter);
@@ -65,16 +64,10 @@ struct BitVectorTest
addDocs(const AttributePtr &v, size_t sz);
template <typename VectorType>
- void populate(VectorType &v,
- uint32_t low,
- uint32_t high,
- bool set);
+ void populate(VectorType &v, uint32_t low, uint32_t high, bool set);
template <typename VectorType>
- void populateAll(VectorType &v,
- uint32_t low,
- uint32_t high,
- bool set);
+ void populateAll(VectorType &v, uint32_t low, uint32_t high, bool set);
void
buildTermQuery(std::vector<char> & buffer,
@@ -116,7 +109,6 @@ struct BitVectorTest
void
test(BasicType bt, CollectionType ct, const vespalib::string &pref,
bool fastSearch,
- bool enableBitVectors,
bool enableOnlyBitVector,
bool filter);
@@ -130,8 +122,8 @@ template <typename VectorType>
VectorType &
BitVectorTest::as(AttributePtr &v)
{
- VectorType *res = dynamic_cast<VectorType *>(v.get());
- assert(res != NULL);
+ auto *res = dynamic_cast<VectorType *>(v.get());
+ assert(res != nullptr);
return *res;
}
@@ -249,12 +241,10 @@ BitVectorTest::AttributePtr
BitVectorTest::make(Config cfg,
const vespalib::string &pref,
bool fastSearch,
- bool enableBitVectors,
bool enableOnlyBitVector,
bool filter)
{
cfg.setFastSearch(fastSearch);
- cfg.setEnableBitVectors(enableBitVectors);
cfg.setEnableOnlyBitVector(enableOnlyBitVector);
cfg.setIsFilter(filter);
AttributePtr v = AttributeFactory::createAttribute(pref, cfg);
@@ -458,7 +448,7 @@ BitVectorTest::checkSearch(AttributePtr v,
TermFieldMatchData md;
sc->fetchPostings(search::queryeval::ExecuteInfo::TRUE);
SearchBasePtr sb = sc->createIterator(&md, true);
- checkSearch(v, std::move(sb), md,
+ checkSearch(std::move(v), std::move(sb), md,
expFirstDocId, expLastDocId, expDocFreq, weights,
checkStride);
}
@@ -470,18 +460,17 @@ BitVectorTest::test(BasicType bt,
CollectionType ct,
const vespalib::string &pref,
bool fastSearch,
- bool enableBitVectors,
bool enableOnlyBitVector,
bool filter)
{
Config cfg(bt, ct);
- AttributePtr v = make(cfg, pref, fastSearch, enableBitVectors, enableOnlyBitVector, filter);
+ AttributePtr v = make(cfg, pref, fastSearch, enableOnlyBitVector, filter);
addDocs(v, 1024);
- VectorType &tv = as<VectorType>(v);
+ auto &tv = as<VectorType>(v);
populate(tv, 2, 1023, true);
SearchContextPtr sc = getSearch<VectorType>(tv, true);
- checkSearch(v, std::move(sc), 2, 1022, 205, !enableBitVectors && !filter, true);
+ checkSearch(v, std::move(sc), 2, 1022, 205, !fastSearch && !filter, true);
sc = getSearch<VectorType>(tv, false);
checkSearch(v, std::move(sc), 2, 1022, 205, !enableOnlyBitVector && !filter, true);
const search::IDocumentWeightAttribute *dwa = v->asDocumentWeightAttribute();
@@ -504,13 +493,13 @@ BitVectorTest::test(BasicType bt,
checkSearch(v, std::move(sc), 977, 1022, 10, !enableOnlyBitVector &&!filter, true);
populate(tv, 2, 973, true);
sc = getSearch<VectorType>(tv, true);
- checkSearch(v, std::move(sc), 2, 1022, 205, !enableBitVectors && !filter, true);
+ checkSearch(v, std::move(sc), 2, 1022, 205, !fastSearch && !filter, true);
addDocs(v, 15000);
sc = getSearch<VectorType>(tv, true);
checkSearch(v, std::move(sc), 2, 1022, 205, !enableOnlyBitVector && !filter, true);
populateAll(tv, 10, 15000, true);
sc = getSearch<VectorType>(tv, true);
- checkSearch(v, std::move(sc), 2, 14999, 14992, !enableBitVectors && !filter, false);
+ checkSearch(v, std::move(sc), 2, 14999, 14992, !fastSearch && !filter, false);
}
@@ -519,14 +508,12 @@ void
BitVectorTest::test(BasicType bt, CollectionType ct, const vespalib::string &pref)
{
LOG(info, "test run, pref is %s", pref.c_str());
- test<VectorType, BufferType>(bt, ct, pref, false, false, false, false);
- test<VectorType, BufferType>(bt, ct, pref, false, false, false, true);
- test<VectorType, BufferType>(bt, ct, pref, true, false, false, false);
- test<VectorType, BufferType>(bt, ct, pref, true, false, false, true);
- test<VectorType, BufferType>(bt, ct, pref, true, true, false, false);
- test<VectorType, BufferType>(bt, ct, pref, true, true, false, true);
- test<VectorType, BufferType>(bt, ct, pref, true, true, true, false);
- test<VectorType, BufferType>(bt, ct, pref, true, true, true, true);
+ test<VectorType, BufferType>(bt, ct, pref, false, false, false);
+ test<VectorType, BufferType>(bt, ct, pref, false, false, true);
+ test<VectorType, BufferType>(bt, ct, pref, true, false, false);
+ test<VectorType, BufferType>(bt, ct, pref, true, false, true);
+ test<VectorType, BufferType>(bt, ct, pref, true, true, false);
+ test<VectorType, BufferType>(bt, ct, pref, true, true, true);
}
@@ -605,8 +592,8 @@ TEST_F("Test bitvectors with weighted set value string", BitVectorTest)
class Verifier : public search::test::SearchIteratorVerifier {
public:
- Verifier(bool inverted);
- ~Verifier();
+ explicit Verifier(bool inverted);
+ ~Verifier() override;
SearchIterator::UP create(bool strict) const override {
return BitVectorIterator::create(_bv.get(), getDocIdLimit(), _tfmd, strict, _inverted);
diff --git a/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp b/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp
index 573284ffa35..36babec6a89 100644
--- a/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp
+++ b/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp
@@ -23,28 +23,25 @@ using MyPostingStore = PostingStore<int32_t>;
namespace {
-static constexpr uint32_t lid_limit = 20000;
-static constexpr uint32_t huge_sequence_length = 800;
+constexpr uint32_t lid_limit = 20000;
+constexpr uint32_t huge_sequence_length = 800;
struct PostingStoreSetup {
- bool enable_bitvectors;
bool enable_only_bitvector;
- PostingStoreSetup(bool enable_bitvectors_in, bool enable_only_bitvector_in)
- : enable_bitvectors(enable_bitvectors_in),
- enable_only_bitvector(enable_only_bitvector_in)
+ explicit PostingStoreSetup(bool enable_only_bitvector_in)
+ : enable_only_bitvector(enable_only_bitvector_in)
{
}
};
std::ostream& operator<<(std::ostream& os, const PostingStoreSetup setup)
{
- os << (setup.enable_bitvectors ? "bv" : "nobv") << "_" << (setup.enable_only_bitvector ? "onlybv" : "mixed");
+ os << (setup.enable_only_bitvector ? "onlybv" : "mixed");
return os;
}
Config make_config(PostingStoreSetup param) {
Config cfg;
- cfg.setEnableBitVectors(param.enable_bitvectors);
cfg.setEnableOnlyBitVector(param.enable_only_bitvector);
return cfg;
}
@@ -216,7 +213,6 @@ PostingStoreTest::test_compact_btree_nodes(uint32_t sequence_length)
EXPECT_EQ(make_exp_sequence(5, 5 + sequence_length), get_sequence(ref2));
auto usage_after = store.getMemoryUsage();
if (sequence_length < huge_sequence_length ||
- !_config.getEnableBitVectors() ||
!_config.getEnableOnlyBitVector()) {
EXPECT_GT(usage_before.deadBytes(), usage_after.deadBytes());
} else {
@@ -226,7 +222,7 @@ PostingStoreTest::test_compact_btree_nodes(uint32_t sequence_length)
VESPA_GTEST_INSTANTIATE_TEST_SUITE_P(PostingStoreMultiTest,
PostingStoreTest,
- testing::Values(PostingStoreSetup(false, false), PostingStoreSetup(true, false), PostingStoreSetup(true, true)), testing::PrintToStringParamName());
+ testing::Values(PostingStoreSetup(false), PostingStoreSetup(true)), testing::PrintToStringParamName());
TEST_P(PostingStoreTest, require_that_nodes_for_multiple_small_btrees_are_compacted)
{
diff --git a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
index e866c57342e..5ce20c06ab5 100644
--- a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
+++ b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
@@ -155,8 +155,8 @@ protected:
template <typename VectorType, typename BufferType>
void testPostingList(const AttributePtr& ptr1, uint32_t numDocs, const std::vector<BufferType>& values);
void testPostingList();
- void testPostingList(bool enableBitVector, bool enable_only_bitvector);
- void testPostingList(bool enableBitVector, bool enable_only_bitvector, uint32_t numDocs, uint32_t numUniqueValues);
+ void testPostingList(bool enable_only_bitvector);
+ void testPostingList(bool enable_only_bitvector, uint32_t numDocs, uint32_t numUniqueValues);
template <typename AttributeType, typename ValueType>
void checkPostingList(AttributeType & vec, ValueType value, DocSet expected);
@@ -554,7 +554,7 @@ PostingListAttributeTest::testPostingList(const AttributePtr& ptr1, uint32_t num
{
LOG(info, "testPostingList: vector '%s'", ptr1->getName().c_str());
- auto& vec1 = static_cast<VectorType &>(*ptr1.get());
+ auto& vec1 = dynamic_cast<VectorType &>(*ptr1);
addDocs(ptr1, numDocs);
uint32_t part = numDocs / values.size();
@@ -595,20 +595,19 @@ PostingListAttributeTest::testPostingList(const AttributePtr& ptr1, uint32_t num
void
PostingListAttributeTest::testPostingList()
{
- testPostingList(false, false);
- testPostingList(true, false);
- testPostingList(true, true);
+ testPostingList(false);
+ testPostingList(true);
}
void
-PostingListAttributeTest::testPostingList(bool enableBitVector, bool enable_only_bitvector)
+PostingListAttributeTest::testPostingList(bool enable_only_bitvector)
{
- testPostingList(enableBitVector, enable_only_bitvector, 1000, 50);
- testPostingList(enableBitVector, enable_only_bitvector, 2000, 10); // This should force bitvector
+ testPostingList(enable_only_bitvector, 1000, 50);
+ testPostingList(enable_only_bitvector, 2000, 10); // This should force bitvector
}
void
-PostingListAttributeTest::testPostingList(bool enableBitVector, bool enable_only_bitvector, uint32_t numDocs, uint32_t numUniqueValues)
+PostingListAttributeTest::testPostingList(bool enable_only_bitvector, uint32_t numDocs, uint32_t numUniqueValues)
{
{ // IntegerAttribute
@@ -619,7 +618,6 @@ PostingListAttributeTest::testPostingList(bool enableBitVector, bool enable_only
{
Config cfg(Config(BasicType::INT32, CollectionType::SINGLE));
cfg.setFastSearch(true);
- cfg.setEnableBitVectors(enableBitVector);
cfg.setEnableOnlyBitVector(enable_only_bitvector);
AttributePtr ptr1 = create_attribute("sint32", cfg);
testPostingList<Int32PostingListAttribute>(ptr1, numDocs, values);
@@ -627,7 +625,6 @@ PostingListAttributeTest::testPostingList(bool enableBitVector, bool enable_only
{
Config cfg(Config(BasicType::INT32, CollectionType::ARRAY));
cfg.setFastSearch(true);
- cfg.setEnableBitVectors(enableBitVector);
cfg.setEnableOnlyBitVector(enable_only_bitvector);
AttributePtr ptr1 = create_attribute("aint32", cfg);
testPostingList<Int32ArrayPostingListAttribute>(ptr1, numDocs, values);
@@ -635,7 +632,6 @@ PostingListAttributeTest::testPostingList(bool enableBitVector, bool enable_only
{
Config cfg(Config(BasicType::INT32, CollectionType::WSET));
cfg.setFastSearch(true);
- cfg.setEnableBitVectors(enableBitVector);
cfg.setEnableOnlyBitVector(enable_only_bitvector);
AttributePtr ptr1 = create_attribute("wsint32", cfg);
testPostingList<Int32WsetPostingListAttribute>(ptr1, numDocs, values);
@@ -650,7 +646,6 @@ PostingListAttributeTest::testPostingList(bool enableBitVector, bool enable_only
{
Config cfg(Config(BasicType::FLOAT, CollectionType::SINGLE));
cfg.setFastSearch(true);
- cfg.setEnableBitVectors(enableBitVector);
cfg.setEnableOnlyBitVector(enable_only_bitvector);
AttributePtr ptr1 = create_attribute("sfloat", cfg);
testPostingList<FloatPostingListAttribute>(ptr1, numDocs, values);
@@ -658,7 +653,6 @@ PostingListAttributeTest::testPostingList(bool enableBitVector, bool enable_only
{
Config cfg(Config(BasicType::FLOAT, CollectionType::ARRAY));
cfg.setFastSearch(true);
- cfg.setEnableBitVectors(enableBitVector);
cfg.setEnableOnlyBitVector(enable_only_bitvector);
AttributePtr ptr1 = create_attribute("afloat", cfg);
testPostingList<FloatArrayPostingListAttribute>(ptr1, numDocs, values);
@@ -666,7 +660,6 @@ PostingListAttributeTest::testPostingList(bool enableBitVector, bool enable_only
{
Config cfg(Config(BasicType::FLOAT, CollectionType::WSET));
cfg.setFastSearch(true);
- cfg.setEnableBitVectors(enableBitVector);
cfg.setEnableOnlyBitVector(enable_only_bitvector);
AttributePtr ptr1 = create_attribute("wsfloat", cfg);
testPostingList<FloatWsetPostingListAttribute>(ptr1, numDocs, values);
@@ -687,7 +680,6 @@ PostingListAttributeTest::testPostingList(bool enableBitVector, bool enable_only
{
Config cfg(Config(BasicType::STRING, CollectionType::SINGLE));
cfg.setFastSearch(true);
- cfg.setEnableBitVectors(enableBitVector);
cfg.setEnableOnlyBitVector(enable_only_bitvector);
AttributePtr ptr1 = create_attribute("sstr", cfg);
testPostingList<StringPostingListAttribute>(ptr1, numDocs, charValues);
@@ -695,7 +687,6 @@ PostingListAttributeTest::testPostingList(bool enableBitVector, bool enable_only
{
Config cfg(Config(BasicType::STRING, CollectionType::ARRAY));
cfg.setFastSearch(true);
- cfg.setEnableBitVectors(enableBitVector);
cfg.setEnableOnlyBitVector(enable_only_bitvector);
AttributePtr ptr1 = create_attribute("astr", cfg);
testPostingList<StringArrayPostingListAttribute>(ptr1, numDocs, charValues);
@@ -703,7 +694,6 @@ PostingListAttributeTest::testPostingList(bool enableBitVector, bool enable_only
{
Config cfg(Config(BasicType::STRING, CollectionType::WSET));
cfg.setFastSearch(true);
- cfg.setEnableBitVectors(enableBitVector);
cfg.setEnableOnlyBitVector(enable_only_bitvector);
AttributePtr ptr1 = create_attribute("wsstr", cfg);
testPostingList<StringWsetPostingListAttribute>(ptr1, numDocs, charValues);