From bbd39ad17baa58613f9046b849b9402ea40e5a7b Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Tue, 15 Feb 2022 16:05:22 +0100 Subject: Propagate memory allocator to growable bitvector in SingleBoolAttribute. --- searchlib/src/tests/aggregator/perdocexpr.cpp | 2 +- searchlib/src/tests/attribute/attribute_test.cpp | 8 +++++++- .../src/tests/attribute/searchcontext/searchcontext_test.cpp | 2 +- searchlib/src/tests/queryeval/queryeval.cpp | 2 +- .../src/vespa/searchlib/attribute/createsinglefastsearch.cpp | 2 +- searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp | 2 +- searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp | 7 ++++--- searchlib/src/vespa/searchlib/attribute/singleboolattribute.h | 3 ++- 8 files changed, 18 insertions(+), 10 deletions(-) (limited to 'searchlib/src') diff --git a/searchlib/src/tests/aggregator/perdocexpr.cpp b/searchlib/src/tests/aggregator/perdocexpr.cpp index e0071e28428..291114ffa90 100644 --- a/searchlib/src/tests/aggregator/perdocexpr.cpp +++ b/searchlib/src/tests/aggregator/perdocexpr.cpp @@ -1605,7 +1605,7 @@ AttributeGuard createInt8Attribute() { } AttributeGuard createBoolAttribute() { - SingleBoolAttribute *selectAttr1(new SingleBoolAttribute("selectAttr1", search::GrowStrategy())); + SingleBoolAttribute *selectAttr1(new SingleBoolAttribute("selectAttr1", search::GrowStrategy(), false)); DocId docId(0); selectAttr1->addDoc(docId); selectAttr1->setBit(docId, true); diff --git a/searchlib/src/tests/attribute/attribute_test.cpp b/searchlib/src/tests/attribute/attribute_test.cpp index d7d0bfd4012..73dd7d2f776 100644 --- a/searchlib/src/tests/attribute/attribute_test.cpp +++ b/searchlib/src/tests/attribute/attribute_test.cpp @@ -2292,10 +2292,13 @@ AttributeTest::test_paged_attribute(const vespalib::string& name, const vespalib lid_mapping_size = 17000; sv_maxlid = 1500; } + if (cfg.basicType() == search::attribute::BasicType::Type::BOOL) { + lid_mapping_size = rounded_size * 8 + 100; + } LOG(info, "test_paged_attribute '%s'", name.c_str()); auto av = createAttribute(name, cfg); auto v = std::dynamic_pointer_cast(av); - ASSERT_TRUE(v); + ASSERT_TRUE(v || (!cfg.collectionType().isMultiValue() && !cfg.fastSearch())); auto size1 = stat_size(swapfile); // Grow mapping from lid to value or multivalue index addClearedDocs(av, lid_mapping_size); @@ -2355,6 +2358,9 @@ AttributeTest::test_paged_attributes() cfg4.setPaged(true); cfg4.setFastSearch(true); EXPECT_EQUAL(7, test_paged_attribute("fs-int-mv-paged", basedir + "/3.fs-int-mv-paged/swapfile", cfg4)); + search::attribute::Config cfg5(BasicType::BOOL, CollectionType::SINGLE); + cfg5.setPaged(true); + EXPECT_EQUAL(1, test_paged_attribute("std-bool-sv-paged", basedir + "/4.std-bool-sv-paged/swapfile", cfg5)); vespalib::alloc::MmapFileAllocatorFactory::instance().setup(""); vespalib::rmdir(basedir, true); } diff --git a/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp b/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp index de54386e4af..29f7b5c0276 100644 --- a/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp +++ b/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp @@ -1830,7 +1830,7 @@ private: public: BoolAttributeFixture(const SimpleResult& true_docs, uint32_t num_docs) - : _attr("bool_attr", search::GrowStrategy()) + : _attr("bool_attr", search::GrowStrategy(), false) { _attr.addDocs(num_docs); for (uint32_t i = 0; i < true_docs.getHitCount(); ++i) { diff --git a/searchlib/src/tests/queryeval/queryeval.cpp b/searchlib/src/tests/queryeval/queryeval.cpp index cdfe1cfca88..cc9e90bb761 100644 --- a/searchlib/src/tests/queryeval/queryeval.cpp +++ b/searchlib/src/tests/queryeval/queryeval.cpp @@ -339,7 +339,7 @@ class DummySingleValueBitNumericAttributeBlueprint : public SimpleLeafBlueprint public: DummySingleValueBitNumericAttributeBlueprint(const SimpleResult & result) : SimpleLeafBlueprint(FieldSpecBaseList()), - _a("a", search::GrowStrategy()), + _a("a", search::GrowStrategy(), false), _sc(), _tfmd() { diff --git a/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp b/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp index 71eb88d4e52..66e6e7ccd4d 100644 --- a/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp @@ -24,7 +24,7 @@ AttributeFactory::createSingleFastSearch(stringref name, const Config & info) assert(info.fastSearch()); switch(info.basicType().type()) { case BasicType::BOOL: - return std::make_shared(name, info.getGrowStrategy()); + return std::make_shared(name, info.getGrowStrategy(), info.paged()); case BasicType::UINT2: case BasicType::UINT4: break; diff --git a/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp b/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp index 3294ecd8dd2..fe2b0c9f989 100644 --- a/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp @@ -21,7 +21,7 @@ AttributeFactory::createSingleStd(stringref name, const Config & info) assert(info.collectionType().type() == attribute::CollectionType::SINGLE); switch(info.basicType().type()) { case BasicType::BOOL: - return std::make_shared(name, info.getGrowStrategy()); + return std::make_shared(name, info.getGrowStrategy(), info.paged()); case BasicType::UINT2: return std::make_shared(name, info.getGrowStrategy()); case BasicType::UINT4: diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp index 3fe7d147c1d..474265c914b 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp @@ -17,9 +17,10 @@ namespace search { using attribute::Config; SingleBoolAttribute:: -SingleBoolAttribute(const vespalib::string &baseFileName, const GrowStrategy & grow) - : IntegerAttributeTemplate(baseFileName, Config(BasicType::BOOL, CollectionType::SINGLE).setGrowStrategy(grow), BasicType::BOOL), - _bv(0, 0, getGenerationHolder()) +SingleBoolAttribute(const vespalib::string &baseFileName, const GrowStrategy & grow, bool paged) + : IntegerAttributeTemplate(baseFileName, Config(BasicType::BOOL, CollectionType::SINGLE).setGrowStrategy(grow).setPaged(paged), BasicType::BOOL), + _init_alloc(get_initial_alloc()), + _bv(0, 0, getGenerationHolder(), get_memory_allocator() ? &_init_alloc : nullptr) { } diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h index 78c07719271..469bd54fa55 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h @@ -15,7 +15,7 @@ namespace search { class SingleBoolAttribute final : public IntegerAttributeTemplate { public: - SingleBoolAttribute(const vespalib::string & baseFileName, const search::GrowStrategy & grow); + SingleBoolAttribute(const vespalib::string & baseFileName, const search::GrowStrategy & grow, bool paged); ~SingleBoolAttribute() override; void onCommit() override; @@ -108,6 +108,7 @@ private: int8_t getFast(DocId doc) const { return _bv.testBit(doc) ? 1 : 0; } + vespalib::alloc::Alloc _init_alloc; GrowableBitVector _bv; }; -- cgit v1.2.3