diff options
32 files changed, 165 insertions, 155 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java index 30c832a7747..66fb1fe615b 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java @@ -332,26 +332,24 @@ public class RoutingPolicies { } } if (!aliasTargets.isEmpty()) { - nameServiceForwarderIn(targetZone).createAlias( + nameServiceForwarder(applicationEndpoint).createAlias( RecordName.from(applicationEndpoint.dnsName()), aliasTargets, Priority.normal, owner); } if (!directTargets.isEmpty()) { - nameServiceForwarderIn(targetZone).createDirect( + nameServiceForwarder(applicationEndpoint).createDirect( RecordName.from(applicationEndpoint.dnsName()), directTargets, Priority.normal, owner); } }); // Remove DNS records for inactive targets inactiveTargetsByEndpoint.forEach((applicationEndpoint, targets) -> { - // Where multiple zones are permitted, they all have the same routing policy, and nameServiceForwarder. - ZoneId targetZone = applicationEndpoint.targets().iterator().next().deployment().zoneId(); targets.forEach(target -> { if (!target.deployment().equals(deployment)) return; // Do not update target not matching this deployment - nameServiceForwarderIn(targetZone).removeRecords(target.type(), - RecordName.from(applicationEndpoint.dnsName()), - target.data(), - Priority.normal, - owner); + nameServiceForwarder(applicationEndpoint).removeRecords(target.type(), + RecordName.from(applicationEndpoint.dnsName()), + target.data(), + Priority.normal, + owner); }); }); } @@ -394,13 +392,14 @@ public class RoutingPolicies { /** Update zone DNS record for given policy */ private void updateZoneDnsOf(RoutingPolicy policy, LoadBalancer loadBalancer, DeploymentId deploymentId) { + RoutingMethod routingMethod = controller.zoneRegistry().routingMethod(deploymentId.zoneId()); boolean addTokenEndpoint = controller.routing().tokenEndpointEnabled(deploymentId.applicationId()); - for (var endpoint : policy.zoneEndpointsIn(controller.system(), RoutingMethod.exclusive, addTokenEndpoint)) { + for (var endpoint : policy.zoneEndpointsIn(controller.system(), routingMethod, addTokenEndpoint)) { var name = RecordName.from(endpoint.dnsName()); var record = policy.canonicalName().isPresent() ? new Record(Record.Type.CNAME, name, RecordData.fqdn(policy.canonicalName().get().value())) : new Record(Record.Type.A, name, RecordData.from(policy.ipAddress().orElseThrow())); - nameServiceForwarderIn(policy.id().zone()).createRecord(record, Priority.normal, ownerOf(deploymentId)); + nameServiceForwarder(endpoint).createRecord(record, Priority.normal, ownerOf(deploymentId)); setPrivateDns(endpoint, loadBalancer, deploymentId); } } @@ -413,13 +412,14 @@ public class RoutingPolicies { case mtls -> false; }; if (skipBasedOnAuthMethod) return; + if (endpoint.routingMethod() != RoutingMethod.exclusive) return; // Not supported for this routing method controller.serviceRegistry().vpcEndpointService() .setPrivateDns(DomainName.of(endpoint.dnsName()), new ClusterId(deploymentId, endpoint.cluster()), loadBalancer.cloudAccount()) .ifPresent(challenge -> { try (Mutex lock = db.lockNameServiceQueue()) { - nameServiceForwarderIn(deploymentId.zoneId()).createTxt(challenge.name(), List.of(challenge.data()), Priority.high, ownerOf(deploymentId)); + controller.nameServiceForwarder().createTxt(challenge.name(), List.of(challenge.data()), Priority.high, ownerOf(deploymentId)); db.writeDnsChallenge(challenge); } }); @@ -458,8 +458,7 @@ public class RoutingPolicies { } private void removeDnsChallenge(DnsChallenge challenge) { - nameServiceForwarderIn(challenge.clusterId().deploymentId().zoneId()) - .removeRecords(Type.TXT, challenge.name(), Priority.normal, ownerOf(challenge.clusterId().deploymentId())); + controller.nameServiceForwarder().removeRecords(Type.TXT, challenge.name(), Priority.normal, ownerOf(challenge.clusterId().deploymentId())); db.deleteDnsChallenge(challenge.clusterId()); } @@ -469,17 +468,18 @@ public class RoutingPolicies { * @return the updated policies */ private RoutingPolicyList removePoliciesUnreferencedBy(LoadBalancerAllocation allocation, RoutingPolicyList instancePolicies, @SuppressWarnings("unused") Mutex lock) { + RoutingMethod routingMethod = controller.zoneRegistry().routingMethod(allocation.deployment.zoneId()); boolean addTokenEndpoint = controller.routing().tokenEndpointEnabled(allocation.deployment.applicationId()); Map<RoutingPolicyId, RoutingPolicy> newPolicies = new LinkedHashMap<>(instancePolicies.asMap()); Set<RoutingPolicyId> activeIds = allocation.asPolicyIds(); RoutingPolicyList removable = instancePolicies.deployment(allocation.deployment) .not().matching(policy -> activeIds.contains(policy.id())); for (var policy : removable) { - for (var endpoint : policy.zoneEndpointsIn(controller.system(), RoutingMethod.exclusive, addTokenEndpoint)) { - nameServiceForwarderIn(allocation.deployment.zoneId()).removeRecords(Record.Type.CNAME, - RecordName.from(endpoint.dnsName()), - Priority.normal, - ownerOf(allocation)); + for (var endpoint : policy.zoneEndpointsIn(controller.system(), routingMethod, addTokenEndpoint)) { + nameServiceForwarder(endpoint).removeRecords(Record.Type.CNAME, + RecordName.from(endpoint.dnsName()), + Priority.normal, + ownerOf(allocation)); } newPolicies.remove(policy.id()); } @@ -497,12 +497,11 @@ public class RoutingPolicies { EndpointList endpoints = controller.routing().readDeclaredEndpointsOf(id.instance()) .not().requiresRotation() .named(id.endpointId(), Endpoint.Scope.global); - NameServiceForwarder forwarder = nameServiceForwarderIn(allocation.deployment.zoneId()); // This removes all ALIAS records having this DNS name. There is no attempt to delete only the entry for the // affected zone. Instead, the correct set of records is (re)created by updateGlobalDnsOf - endpoints.forEach(endpoint -> forwarder.removeRecords(Record.Type.ALIAS, RecordName.from(endpoint.dnsName()), - Priority.normal, - ownerOf(allocation))); + endpoints.forEach(endpoint -> nameServiceForwarder(endpoint).removeRecords(Record.Type.ALIAS, RecordName.from(endpoint.dnsName()), + Priority.normal, + ownerOf(allocation))); } } @@ -520,8 +519,8 @@ public class RoutingPolicies { List<RoutingPolicy> policies = routingTable.get(id); for (var policy : policies) { if (!policy.appliesTo(allocation.deployment)) continue; - NameServiceForwarder forwarder = nameServiceForwarderIn(policy.id().zone()); for (Endpoint endpoint : endpoints) { + NameServiceForwarder forwarder = nameServiceForwarder(endpoint); if (policy.canonicalName().isPresent()) { forwarder.removeRecords(Record.Type.ALIAS, RecordName.from(endpoint.dnsName()), @@ -690,11 +689,11 @@ public class RoutingPolicies { .collect(Collectors.toUnmodifiableSet()); } - /** Returns the name updater to use for given zone */ - private NameServiceForwarder nameServiceForwarderIn(ZoneId zone) { - return switch (controller.zoneRegistry().routingMethod(zone)) { + /** Returns the name updater to use for given endpoint */ + private NameServiceForwarder nameServiceForwarder(Endpoint endpoint) { + return switch (endpoint.routingMethod()) { case exclusive -> controller.nameServiceForwarder(); - case sharedLayer4 -> new NameServiceDiscarder(controller.curator()); + case sharedLayer4 -> endpoint.generated().isPresent() ? controller.nameServiceForwarder() : new NameServiceDiscarder(controller.curator()); }; } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java index f6ed8fd7323..0a6d2a3b106 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java @@ -370,14 +370,22 @@ public class RoutingPoliciesTest { } @Test - void zone_routing_policies_without_dns_update() { + void zone_routing_policies_with_shared_routing() { var tester = new RoutingPoliciesTester(new DeploymentTester(), false); var context = tester.newDeploymentContext("tenant1", "app1", "default"); tester.provisionLoadBalancers(1, context.instanceId(), true, zone1, zone2); context.submit(applicationPackage).deferLoadBalancerProvisioningIn(Environment.prod).deploy(); assertEquals(0, tester.controllerTester().controller().curator().readNameServiceQueue().requests().size()); + // Ordinary endpoints are not created in DNS assertEquals(List.of(), tester.recordNames()); assertEquals(2, tester.policiesOf(context.instanceId()).size()); + // Generated endpoints are created in DNS + tester.controllerTester().flagSource().withBooleanFlag(Flags.RANDOMIZED_ENDPOINT_NAMES.id(), true); + addCertificateToPool("cafed00d", UnassignedCertificate.State.ready, tester); + context.submit(applicationPackage).deferLoadBalancerProvisioningIn(Environment.prod).deploy(); + assertEquals(List.of("b22ab332.cafed00d.z.vespa.oath.cloud", + "d71005bf.cafed00d.z.vespa.oath.cloud"), + tester.recordNames()); } @Test diff --git a/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp b/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp index d153481ef36..f87096aa1e3 100644 --- a/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp +++ b/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp @@ -228,9 +228,8 @@ DiskIndexTest::requireThatWeCanReadPostingList() { // field 'f1' LookupResult::UP r = _index->lookup(0, "w1"); PostingListHandle::UP h = _index->readPostingList(*r); - SearchIterator * sb = h->createIterator(r->counts, mda); + auto sb = h->createIterator(r->counts, mda); EXPECT_EQ(SimpleResult({1,3}), SimpleResult().search(*sb)); - delete sb; } } diff --git a/searchlib/src/tests/queryeval/filter_search/filter_search_test.cpp b/searchlib/src/tests/queryeval/filter_search/filter_search_test.cpp index ea4753ab847..8f2f8f2e96b 100644 --- a/searchlib/src/tests/queryeval/filter_search/filter_search_test.cpp +++ b/searchlib/src/tests/queryeval/filter_search/filter_search_test.cpp @@ -273,7 +273,9 @@ struct WeightedSetTermAdapter { WeightedSetTermAdapter(); ~WeightedSetTermAdapter(); void addChild(std::unique_ptr<Blueprint> child) { - blueprint.addTerm(std::move(child), 100); + Blueprint::HitEstimate estimate = blueprint.getState().estimate(); + blueprint.addTerm(std::move(child), 100, estimate); + blueprint.complete(estimate); } auto createFilterSearch(bool strict, Constraint constraint) const { return blueprint.createFilterSearch(strict, constraint); @@ -292,7 +294,9 @@ struct DotProductAdapter { void addChild(std::unique_ptr<Blueprint> child) { auto child_field = blueprint.getNextChildField(field); auto term = std::make_unique<LeafProxy>(child_field, std::move(child)); - blueprint.addTerm(std::move(term), 100); + Blueprint::HitEstimate estimate = blueprint.getState().estimate(); + blueprint.addTerm(std::move(term), 100, estimate); + blueprint.complete(estimate); } auto createFilterSearch(bool strict, Constraint constraint) const { return blueprint.createFilterSearch(strict, constraint); @@ -310,7 +314,9 @@ struct ParallelWeakAndAdapter { void addChild(std::unique_ptr<Blueprint> child) { auto child_field = blueprint.getNextChildField(field); auto term = std::make_unique<LeafProxy>(child_field, std::move(child)); - blueprint.addTerm(std::move(term), 100); + Blueprint::HitEstimate estimate = blueprint.getState().estimate(); + blueprint.addTerm(std::move(term), 100, estimate); + blueprint.complete(estimate); } auto createFilterSearch(bool strict, Constraint constraint) const { return blueprint.createFilterSearch(strict, constraint); diff --git a/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp b/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp index 90e16d4feff..f93aa537625 100644 --- a/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp +++ b/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp @@ -312,9 +312,11 @@ TEST("require that children get a common (yet separate) term field match data") auto top_handle = layout.allocTermField(42); FieldSpec top_spec("foo", 42, top_handle); WeightedSetTermBlueprint blueprint(top_spec); + queryeval::Blueprint::HitEstimate estimate; for (size_t i = 0; i < 5; ++i) { - blueprint.addTerm(vmd.create(blueprint.getNextChildField(top_spec)), 1); + blueprint.addTerm(vmd.create(blueprint.getNextChildField(top_spec)), 1, estimate); } + blueprint.complete(estimate); auto match_data = layout.createMatchData(); auto search = blueprint.createSearch(*match_data, true); auto top_tfmd = match_data->resolveTermField(top_handle); diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp index 532d645524b..152fcef5e8b 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp @@ -412,7 +412,6 @@ template <typename SearchType> class DirectWeightedSetBlueprint : public ComplexLeafBlueprint { private: - HitEstimate _estimate; std::vector<int32_t> _weights; std::vector<IDocumentWeightAttribute::LookupResult> _terms; const IAttributeVector &_iattr; @@ -422,7 +421,6 @@ private: public: DirectWeightedSetBlueprint(const FieldSpec &field, const IAttributeVector &iattr, const IDocumentWeightAttribute &attr, size_t size_hint) : ComplexLeafBlueprint(field), - _estimate(), _weights(), _terms(), _iattr(iattr), @@ -435,20 +433,22 @@ public: } ~DirectWeightedSetBlueprint() override; - void addTerm(const IDocumentWeightAttribute::LookupKey & key, int32_t weight) { + void addTerm(const IDocumentWeightAttribute::LookupKey & key, int32_t weight, HitEstimate & estimate) { IDocumentWeightAttribute::LookupResult result = _attr.lookup(key, _dictionary_snapshot); HitEstimate childEst(result.posting_size, (result.posting_size == 0)); if (!childEst.empty) { - if (_estimate.empty) { - _estimate = childEst; + if (estimate.empty) { + estimate = childEst; } else { - _estimate.estHits += childEst.estHits; + estimate.estHits += childEst.estHits; } - setEstimate(_estimate); _weights.push_back(weight); _terms.push_back(result); } } + void complete(HitEstimate estimate) { + setEstimate(estimate); + } SearchIterator::UP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool) const override; @@ -506,7 +506,6 @@ DirectWeightedSetBlueprint<SearchType>::createFilterSearch(bool, FilterConstrain class DirectWandBlueprint : public queryeval::ComplexLeafBlueprint { private: - HitEstimate _estimate; mutable queryeval::SharedWeakAndPriorityQueue _scores; const queryeval::wand::score_t _scoreThreshold; double _thresholdBoostFactor; @@ -520,7 +519,6 @@ public: DirectWandBlueprint(const FieldSpec &field, const IDocumentWeightAttribute &attr, uint32_t scoresToTrack, queryeval::wand::score_t scoreThreshold, double thresholdBoostFactor, size_t size_hint) : ComplexLeafBlueprint(field), - _estimate(), _scores(scoresToTrack), _scoreThreshold(scoreThreshold), _thresholdBoostFactor(thresholdBoostFactor), @@ -536,20 +534,22 @@ public: ~DirectWandBlueprint() override; - void addTerm(const IDocumentWeightAttribute::LookupKey & key, int32_t weight) { + void addTerm(const IDocumentWeightAttribute::LookupKey & key, int32_t weight, HitEstimate & estimate) { IDocumentWeightAttribute::LookupResult result = _attr.lookup(key, _dictionary_snapshot); HitEstimate childEst(result.posting_size, (result.posting_size == 0)); if (!childEst.empty) { - if (_estimate.empty) { - _estimate = childEst; + if (estimate.empty) { + estimate = childEst; } else { - _estimate.estHits += childEst.estHits; + estimate.estHits += childEst.estHits; } - setEstimate(_estimate); _weights.push_back(weight); _terms.push_back(result); } } + void complete(HitEstimate estimate) { + setEstimate(estimate); + } SearchIterator::UP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool strict) const override { assert(tfmda.size() == 1); @@ -857,9 +857,11 @@ template <typename WS> void CreateBlueprintVisitor::createDirectWeightedSet(WS *bp, MultiTerm &n) { Blueprint::UP result(bp); + Blueprint::HitEstimate estimate; for (uint32_t i(0); i < n.getNumTerms(); i++) { - bp->addTerm(LookupKey(n, i), n.weight(i).percent()); + bp->addTerm(LookupKey(n, i), n.weight(i).percent(), estimate); } + bp->complete(estimate); setResult(std::move(result)); } @@ -869,11 +871,13 @@ CreateBlueprintVisitor::createShallowWeightedSet(WS *bp, MultiTerm &n, const Fie Blueprint::UP result(bp); SearchContextParams scParams = createContextParams(); bp->reserve(n.getNumTerms()); + Blueprint::HitEstimate estimate; for (uint32_t i(0); i < n.getNumTerms(); i++) { FieldSpec childfs = bp->getNextChildField(fs); auto term = n.getAsString(i); - bp->addTerm(std::make_unique<AttributeFieldBlueprint>(childfs, _attr, extractTerm(term.first, isInteger), scParams.useBitVector(childfs.isFilter())), term.second.percent()); + bp->addTerm(std::make_unique<AttributeFieldBlueprint>(childfs, _attr, extractTerm(term.first, isInteger), scParams.useBitVector(childfs.isFilter())), term.second.percent(), estimate); } + bp->complete(estimate); setResult(std::move(result)); } diff --git a/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.cpp b/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.cpp index 4ed72c2f8c3..8a987c49544 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.cpp @@ -53,7 +53,7 @@ ZcPosOccRandRead::~ZcPosOccRandRead() } -search::queryeval::SearchIterator * +std::unique_ptr<search::queryeval::SearchIterator> ZcPosOccRandRead:: createIterator(const PostingListCounts &counts, const PostingListHandle &handle, @@ -67,7 +67,7 @@ createIterator(const PostingListCounts &counts, assert(handle._bitOffsetMem <= handle._bitOffset); if (handle._bitLength == 0) { - return new search::queryeval::EmptySearch; + return std::make_unique<search::queryeval::EmptySearch>(); } const char *cmem = static_cast<const char *>(handle._mem); @@ -80,7 +80,7 @@ createIterator(const PostingListCounts &counts, handle._bitOffsetMem) & 63; Position start(mem, bitOffset); - return create_zc_posocc_iterator(true, counts, start, handle._bitLength, _posting_params, _fieldsParams, matchData).release(); + return create_zc_posocc_iterator(true, counts, start, handle._bitLength, _posting_params, _fieldsParams, matchData); } diff --git a/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.h b/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.h index f23af15f72d..db7806beadd 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.h +++ b/searchlib/src/vespa/searchlib/diskindex/zcposoccrandread.h @@ -33,7 +33,7 @@ public: * Create iterator for single word. Semantic lifetime of counts and * handle must exceed lifetime of iterator. */ - queryeval::SearchIterator * + std::unique_ptr<queryeval::SearchIterator> createIterator(const PostingListCounts &counts, const PostingListHandle &handle, const fef::TermFieldMatchDataArray &matchData, bool usebitVector) const override; diff --git a/searchlib/src/vespa/searchlib/index/postinglistfile.cpp b/searchlib/src/vespa/searchlib/index/postinglistfile.cpp index acb1d40e353..7bb724f0fe6 100644 --- a/searchlib/src/vespa/searchlib/index/postinglistfile.cpp +++ b/searchlib/src/vespa/searchlib/index/postinglistfile.cpp @@ -3,6 +3,7 @@ #include "postinglistfile.h" #include "postinglistparams.h" #include <vespa/fastos/file.h> +#include <vespa/searchlib/queryeval/searchiterator.h> namespace search::index { @@ -94,7 +95,7 @@ PostingListFileRandReadPassThrough::~PostingListFileRandReadPassThrough() } } -search::queryeval::SearchIterator * +std::unique_ptr<search::queryeval::SearchIterator> PostingListFileRandReadPassThrough:: createIterator(const PostingListCounts &counts, const PostingListHandle &handle, diff --git a/searchlib/src/vespa/searchlib/index/postinglistfile.h b/searchlib/src/vespa/searchlib/index/postinglistfile.h index 17bfb47b812..93d0dd362f7 100644 --- a/searchlib/src/vespa/searchlib/index/postinglistfile.h +++ b/searchlib/src/vespa/searchlib/index/postinglistfile.h @@ -147,7 +147,7 @@ public: * didn't cover the whole word, probably need access to higher level * API above caches. */ - virtual search::queryeval::SearchIterator * + virtual std::unique_ptr<search::queryeval::SearchIterator> createIterator(const PostingListCounts &counts, const PostingListHandle &handle, const search::fef::TermFieldMatchDataArray &matchData, @@ -194,7 +194,7 @@ public: PostingListFileRandReadPassThrough(PostingListFileRandRead *lower, bool ownLower); ~PostingListFileRandReadPassThrough(); - search::queryeval::SearchIterator * + std::unique_ptr<search::queryeval::SearchIterator> createIterator(const PostingListCounts &counts, const PostingListHandle &handle, const search::fef::TermFieldMatchDataArray &matchData, diff --git a/searchlib/src/vespa/searchlib/index/postinglisthandle.cpp b/searchlib/src/vespa/searchlib/index/postinglisthandle.cpp index 82737531d69..c8cccd89207 100644 --- a/searchlib/src/vespa/searchlib/index/postinglisthandle.cpp +++ b/searchlib/src/vespa/searchlib/index/postinglisthandle.cpp @@ -2,10 +2,11 @@ #include "postinglisthandle.h" #include "postinglistfile.h" +#include <vespa/searchlib/queryeval/searchiterator.h> namespace search::index { -search::queryeval::SearchIterator * +std::unique_ptr<search::queryeval::SearchIterator> PostingListHandle::createIterator(const PostingListCounts &counts, const search::fef::TermFieldMatchDataArray &matchData, bool useBitVector) const diff --git a/searchlib/src/vespa/searchlib/index/postinglisthandle.h b/searchlib/src/vespa/searchlib/index/postinglisthandle.h index 9a4ec212636..1f3a72a876f 100644 --- a/searchlib/src/vespa/searchlib/index/postinglisthandle.h +++ b/searchlib/src/vespa/searchlib/index/postinglisthandle.h @@ -61,7 +61,7 @@ public: * didn't cover the whole word, probably need access to higher level * API above caches. */ - search::queryeval::SearchIterator * + std::unique_ptr<search::queryeval::SearchIterator> createIterator(const PostingListCounts &counts, const search::fef::TermFieldMatchDataArray &matchData, bool useBitVector=false) const; diff --git a/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp b/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp index a2d244250cf..bb44eaa0f3d 100644 --- a/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp @@ -76,12 +76,14 @@ template <typename WS, typename NODE> void CreateBlueprintVisitorHelper::createWeightedSet(std::unique_ptr<WS> bp, NODE &n) { bp->reserve(n.getNumTerms()); + Blueprint::HitEstimate estimate; for (size_t i = 0; i < n.getNumTerms(); ++i) { auto term = n.getAsString(i); query::SimpleStringTerm node(term.first, n.getView(), 0, term.second); // TODO Temporary FieldSpec field = bp->getNextChildField(_field); - bp->addTerm(_searchable.createBlueprint(_requestContext, field, node), term.second.percent()); + bp->addTerm(_searchable.createBlueprint(_requestContext, field, node), term.second.percent(), estimate); } + bp->complete(estimate); setResult(std::move(bp)); } void diff --git a/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.cpp index de5bdc33e3c..3e85ae4d00a 100644 --- a/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.cpp @@ -9,12 +9,10 @@ namespace search::queryeval { DotProductBlueprint::DotProductBlueprint(const FieldSpec &field) : ComplexLeafBlueprint(field), - _estimate(), _layout(), _weights(), _terms() -{ -} +{ } DotProductBlueprint::~DotProductBlueprint() = default; @@ -32,16 +30,15 @@ DotProductBlueprint::reserve(size_t num_children) { } void -DotProductBlueprint::addTerm(Blueprint::UP term, int32_t weight) +DotProductBlueprint::addTerm(Blueprint::UP term, int32_t weight, HitEstimate & estimate) { HitEstimate childEst = term->getState().estimate(); if (! childEst.empty) { - if (_estimate.empty) { - _estimate = childEst; + if (estimate.empty) { + estimate = childEst; } else { - _estimate.estHits += childEst.estHits; + estimate.estHits += childEst.estHits; } - setEstimate(_estimate); } _weights.push_back(weight); _terms.push_back(std::move(term)); diff --git a/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.h index 2975958b5af..18770691350 100644 --- a/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/dot_product_blueprint.h @@ -11,7 +11,6 @@ namespace search::queryeval { class DotProductBlueprint : public ComplexLeafBlueprint { - HitEstimate _estimate; fef::MatchDataLayout _layout; std::vector<int32_t> _weights; std::vector<Blueprint::UP> _terms; @@ -27,7 +26,10 @@ public: // used by create visitor void reserve(size_t num_children); - void addTerm(Blueprint::UP term, int32_t weight); + void addTerm(Blueprint::UP term, int32_t weight, HitEstimate & estimate); + void complete(HitEstimate estimate) { + setEstimate(estimate); + } SearchIteratorUP createLeafSearch(const search::fef::TermFieldMatchDataArray &tfmda, bool strict) const override; SearchIteratorUP createFilterSearch(bool strict, FilterConstraint constraint) const override; diff --git a/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.cpp index b4b55098eaa..e303e0b16d9 100644 --- a/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.cpp @@ -22,7 +22,6 @@ ParallelWeakAndBlueprint::ParallelWeakAndBlueprint(const FieldSpec &field, _scoreThreshold(scoreThreshold), _thresholdBoostFactor(thresholdBoostFactor), _scoresAdjustFrequency(DEFAULT_PARALLEL_WAND_SCORES_ADJUST_FREQUENCY), - _estimate(), _layout(), _weights(), _terms() @@ -40,7 +39,6 @@ ParallelWeakAndBlueprint::ParallelWeakAndBlueprint(const FieldSpec &field, _scoreThreshold(scoreThreshold), _thresholdBoostFactor(thresholdBoostFactor), _scoresAdjustFrequency(scoresAdjustFrequency), - _estimate(), _layout(), _weights(), _terms() @@ -62,20 +60,18 @@ ParallelWeakAndBlueprint::reserve(size_t num_children) { } void -ParallelWeakAndBlueprint::addTerm(Blueprint::UP term, int32_t weight) +ParallelWeakAndBlueprint::addTerm(Blueprint::UP term, int32_t weight, HitEstimate & estimate) { HitEstimate childEst = term->getState().estimate(); if (!childEst.empty) { - if (_estimate.empty) { - _estimate = childEst; + if (estimate.empty) { + estimate = childEst; } else { - _estimate.estHits += childEst.estHits; + estimate.estHits += childEst.estHits; } - setEstimate(_estimate); } _weights.push_back(weight); _terms.push_back(std::move(term)); - set_tree_size(_terms.size() + 1); } SearchIterator::UP diff --git a/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.h index a2c13f12485..cb4d44f4497 100644 --- a/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_blueprint.h @@ -26,7 +26,6 @@ private: const wand::score_t _scoreThreshold; double _thresholdBoostFactor; const uint32_t _scoresAdjustFrequency; - HitEstimate _estimate; fef::MatchDataLayout _layout; std::vector<int32_t> _weights; std::vector<Blueprint::UP> _terms; @@ -57,7 +56,11 @@ public: // Used by create visitor void reserve(size_t num_children); - void addTerm(Blueprint::UP term, int32_t weight); + void addTerm(Blueprint::UP term, int32_t weight, HitEstimate & estimate); + void complete(HitEstimate estimate) { + setEstimate(estimate); + set_tree_size(_terms.size() + 1); + } SearchIterator::UP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const override; std::unique_ptr<SearchIterator> createFilterSearch(bool strict, FilterConstraint constraint) const override; diff --git a/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_search.cpp b/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_search.cpp index 1a7e91b2d1a..8540752e320 100644 --- a/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_search.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/wand/parallel_weak_and_search.cpp @@ -79,12 +79,12 @@ public: _localScores() { } - virtual size_t get_num_terms() const override { return _terms.size(); } - virtual int32_t get_term_weight(size_t idx) const override { return _terms.weight(idx); } - virtual score_t get_max_score(size_t idx) const override { return _terms.maxScore(idx); } - virtual const MatchParams &getMatchParams() const override { return _matchParams; } + size_t get_num_terms() const override { return _terms.size(); } + int32_t get_term_weight(size_t idx) const override { return _terms.weight(idx); } + score_t get_max_score(size_t idx) const override { return _terms.maxScore(idx); } + const MatchParams &getMatchParams() const override { return _matchParams; } - virtual void doSeek(uint32_t docid) override { + void doSeek(uint32_t docid) override { updateThreshold(_matchParams.scores.getMinScore()); if (IS_STRICT) { seek_strict(docid); @@ -92,7 +92,7 @@ public: seek_unstrict(docid); } } - virtual void doUnpack(uint32_t docid) override { + void doUnpack(uint32_t docid) override { score_t score = _algo.get_full_score(_terms, _heaps, DotProductScorer()); _localScores.push_back(score); if (_localScores.size() == _matchParams.scoresAdjustFrequency) { @@ -101,14 +101,14 @@ public: } _tfmd.setRawScore(docid, score); } - virtual void visitMembers(vespalib::ObjectVisitor &visitor) const override { + void visitMembers(vespalib::ObjectVisitor &visitor) const override { _terms.visit_members(visitor); } void initRange(uint32_t begin, uint32_t end) override { ParallelWeakAndSearch::initRange(begin, end); _algo.init_range(_terms, _heaps, begin, end); } - Trinary is_strict() const override { return IS_STRICT ? Trinary::True : Trinary::False; } + Trinary is_strict() const final { return IS_STRICT ? Trinary::True : Trinary::False; } }; namespace { diff --git a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp index ee55a89dcdc..4e06f170253 100644 --- a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp @@ -62,7 +62,6 @@ WeightedSetTermMatchingElementsSearch::initRange(uint32_t begin_id, uint32_t end WeightedSetTermBlueprint::WeightedSetTermBlueprint(const FieldSpec &field) : ComplexLeafBlueprint(field), - _estimate(), _layout(), _children_field(field.getName(), field.getFieldId(), _layout.allocTermField(field.getFieldId()), field.isFilter()), _weights(), @@ -81,16 +80,15 @@ WeightedSetTermBlueprint::reserve(size_t num_children) { } void -WeightedSetTermBlueprint::addTerm(Blueprint::UP term, int32_t weight) +WeightedSetTermBlueprint::addTerm(Blueprint::UP term, int32_t weight, HitEstimate & estimate) { HitEstimate childEst = term->getState().estimate(); if (! childEst.empty) { - if (_estimate.empty) { - _estimate = childEst; + if (estimate.empty) { + estimate = childEst; } else { - _estimate.estHits += childEst.estHits; + estimate.estHits += childEst.estHits; } - setEstimate(_estimate); } _weights.push_back(weight); _terms.push_back(std::move(term)); diff --git a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.h index 3827dc8a35f..b40ab421890 100644 --- a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.h @@ -12,7 +12,6 @@ namespace search::queryeval { class WeightedSetTermBlueprint : public ComplexLeafBlueprint { - HitEstimate _estimate; fef::MatchDataLayout _layout; FieldSpec _children_field; std::vector<int32_t> _weights; @@ -31,7 +30,10 @@ public: // used by create visitor void reserve(size_t num_children); - void addTerm(Blueprint::UP term, int32_t weight); + void addTerm(Blueprint::UP term, int32_t weight, HitEstimate & estimate); + void complete(HitEstimate estimate) { + setEstimate(estimate); + } SearchIteratorUP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const override; SearchIteratorUP createFilterSearch(bool strict, FilterConstraint constraint) const override; diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fake_match_loop.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fake_match_loop.cpp index 95f07bc3191..bb55593f8e3 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fake_match_loop.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fake_match_loop.cpp @@ -32,7 +32,7 @@ public: _tfmda.add(&_md); _md.setNeedNormalFeatures(posting.enable_unpack_normal_features()); _md.setNeedInterleavedFeatures(posting.enable_unpack_interleaved_features()); - _itr.reset(posting.createIterator(_tfmda)); + _itr = posting.createIterator(_tfmda); } ~IteratorState() {} diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp index 9521bed7827..358008f389a 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp @@ -717,23 +717,16 @@ FakeFilterOccEGCompressed64ArrayIterator<bigEndian>::doUnpack(uint32_t docId) } -search::queryeval::SearchIterator * +std::unique_ptr<search::queryeval::SearchIterator> FakeEGCompr64FilterOcc:: createIterator(const fef::TermFieldMatchDataArray &matchData) const { const uint64_t *arr = _compressed.first; - if (_bigEndian) - return new FakeFilterOccEGCompressed64ArrayIterator<true>(arr, - 0, - _hitDocs, - _lastDocId, - matchData); - else - return new FakeFilterOccEGCompressed64ArrayIterator<false>(arr, - 0, - _hitDocs, - _lastDocId, - matchData); + if (_bigEndian) { + return std::make_unique<FakeFilterOccEGCompressed64ArrayIterator<true>>(arr, 0, _hitDocs, _lastDocId, matchData); + } else { + return std::make_unique<FakeFilterOccEGCompressed64ArrayIterator<false>>(arr, 0, _hitDocs, _lastDocId, matchData); + } } @@ -766,7 +759,7 @@ class FakeEGCompr64SkipFilterOcc : public FakeEGCompr64FilterOcc public: FakeEGCompr64SkipFilterOcc(const FakeWord &fw); ~FakeEGCompr64SkipFilterOcc(); - search::queryeval::SearchIterator *createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + std::unique_ptr<search::queryeval::SearchIterator> createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; @@ -1451,7 +1444,7 @@ FakeFilterOccEGCompressed64SkipArrayIterator<doSkip>::doUnpack(uint32_t docId) template <bool doSkip> -search::queryeval::SearchIterator * +std::unique_ptr<search::queryeval::SearchIterator> FakeEGCompr64SkipFilterOcc<doSkip>:: createIterator(const fef::TermFieldMatchDataArray &matchData) const { @@ -1478,15 +1471,16 @@ createIterator(const fef::TermFieldMatchDataArray &matchData) const const uint64_t *l2SkipArr = _l2SkipCompressed.first; const uint64_t *l3SkipArr = _l3SkipCompressed.first; const uint64_t *l4SkipArr = _l4SkipCompressed.first; - return new FakeFilterOccEGCompressed64SkipArrayIterator<doSkip>(docIdBits.getCompr(), - docIdBits.getBitOffset(), - _lastDocId, - l1SkipArr, 0, - l2SkipArr, 0, - l3SkipArr, 0, - l4SkipArr, 0, - getName(), - matchData); + return std::make_unique<FakeFilterOccEGCompressed64SkipArrayIterator<doSkip>> + (docIdBits.getCompr(), + docIdBits.getBitOffset(), + _lastDocId, + l1SkipArr, 0, + l2SkipArr, 0, + l3SkipArr, 0, + l4SkipArr, 0, + getName(), + matchData); } } diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.h b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.h index 6e398a2f0b0..2ef91c70921 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.h @@ -58,7 +58,7 @@ public: int lowLevelSinglePostingScanUnpack() const override; int lowLevelAndPairPostingScan(const FakePosting &rhs) const override; int lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; - queryeval::SearchIterator *createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + std::unique_ptr<queryeval::SearchIterator> createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; } diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakefilterocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakefilterocc.cpp index a412a779006..54710a85a04 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakefilterocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakefilterocc.cpp @@ -176,13 +176,11 @@ FakeFilterOccArrayIterator::doUnpack(uint32_t docId) } -search::queryeval::SearchIterator * +std::unique_ptr<search::queryeval::SearchIterator> FakeFilterOcc:: createIterator(const fef::TermFieldMatchDataArray &matchData) const { - return new FakeFilterOccArrayIterator(&*_uncompressed.begin(), - &*_uncompressed.end(), - matchData); + return std::make_unique<FakeFilterOccArrayIterator>(&*_uncompressed.begin(), &*_uncompressed.end(), matchData); } } diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakefilterocc.h b/searchlib/src/vespa/searchlib/test/fakedata/fakefilterocc.h index ed0855cfb87..c05dc9db342 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakefilterocc.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakefilterocc.h @@ -30,7 +30,7 @@ public: int lowLevelSinglePostingScanUnpack() const override; int lowLevelAndPairPostingScan(const FakePosting &rhs) const override; int lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; - queryeval::SearchIterator * createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + std::unique_ptr<queryeval::SearchIterator> createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; } // namespace fakedata diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp index 99d0fb3b3f1..48820b58a7c 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp @@ -129,14 +129,14 @@ lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const } -search::queryeval::SearchIterator * +std::unique_ptr<search::queryeval::SearchIterator> FakeMemTreeOcc:: createIterator(const fef::TermFieldMatchDataArray &matchData) const { return memoryindex::make_search_iterator<false>(_tree.begin(_allocator), _mgr._featureStore, _packedIndex, - matchData).release(); + matchData); } diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h index ea8699d94b2..28698e29cf9 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h @@ -176,7 +176,7 @@ public: int lowLevelSinglePostingScanUnpack() const override; int lowLevelAndPairPostingScan(const FakePosting &rhs) const override; int lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; - queryeval::SearchIterator *createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + std::unique_ptr<queryeval::SearchIterator> createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; } diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeposting.h b/searchlib/src/vespa/searchlib/test/fakedata/fakeposting.h index 7e32fcc31ad..56a54b2cf85 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakeposting.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeposting.h @@ -72,7 +72,7 @@ public: /* * Iterator factory, for current query evaluation framework. */ - virtual search::queryeval::SearchIterator * + virtual std::unique_ptr<search::queryeval::SearchIterator> createIterator(const fef::TermFieldMatchDataArray &matchData) const = 0; const std::string &getName() const diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakezcbfilterocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakezcbfilterocc.cpp index dc6f546fad0..2f9714f1638 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakezcbfilterocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakezcbfilterocc.cpp @@ -237,14 +237,12 @@ FakeFilterOccZCBArrayIterator::doUnpack(uint32_t docId) } -search::queryeval::SearchIterator * +std::unique_ptr<search::queryeval::SearchIterator> FakeZcbFilterOcc:: createIterator(const fef::TermFieldMatchDataArray &matchData) const { const uint8_t *arr = &*_compressed.begin(); - return new FakeFilterOccZCBArrayIterator(arr, - _hitDocs, - matchData); + return std::make_unique<FakeFilterOccZCBArrayIterator>(arr, _hitDocs, matchData); } } diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakezcbfilterocc.h b/searchlib/src/vespa/searchlib/test/fakedata/fakezcbfilterocc.h index 87d25cb6761..599b9c83d76 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakezcbfilterocc.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakezcbfilterocc.h @@ -29,7 +29,7 @@ public: int lowLevelSinglePostingScanUnpack() const override; int lowLevelAndPairPostingScan(const FakePosting &rhs) const override; int lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; - queryeval::SearchIterator *createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + std::unique_ptr<queryeval::SearchIterator> createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; } // namespace fakedata diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.cpp index 809746a87e6..dc2791fa4f6 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.cpp @@ -502,11 +502,11 @@ FakeFilterOccZCArrayIterator::doUnpack(uint32_t docId) } -SearchIterator * +std::unique_ptr<SearchIterator> FakeZcFilterOcc:: createIterator(const TermFieldMatchDataArray &matchData) const { - return new FakeFilterOccZCArrayIterator(_compressed.first, 0, _posting_params._doc_id_limit, matchData); + return std::make_unique<FakeFilterOccZCArrayIterator>(_compressed.first, 0, _posting_params._doc_id_limit, matchData); } class FakeZcSkipFilterOcc : public FakeZcFilterOcc @@ -516,7 +516,7 @@ public: FakeZcSkipFilterOcc(const FakeWord &fw); ~FakeZcSkipFilterOcc() override; - SearchIterator *createIterator(const TermFieldMatchDataArray &matchData) const override; + std::unique_ptr<SearchIterator> createIterator(const TermFieldMatchDataArray &matchData) const override; }; static FPFactoryInit @@ -534,10 +534,10 @@ FakeZcSkipFilterOcc::FakeZcSkipFilterOcc(const FakeWord &fw) FakeZcSkipFilterOcc::~FakeZcSkipFilterOcc() = default; -SearchIterator * +std::unique_ptr<SearchIterator> FakeZcSkipFilterOcc::createIterator(const TermFieldMatchDataArray &matchData) const { - return create_zc_posocc_iterator(true, _counts, Position(_compressed.first, 0), _compressedBits, _posting_params, _fieldsParams, matchData).release(); + return create_zc_posocc_iterator(true, _counts, Position(_compressed.first, 0), _compressedBits, _posting_params, _fieldsParams, matchData); } @@ -550,7 +550,7 @@ public: ~FakeEGCompr64PosOcc() override; size_t bitSize() const override; bool hasWordPositions() const override; - SearchIterator *createIterator(const TermFieldMatchDataArray &matchData) const override; + std::unique_ptr<SearchIterator> createIterator(const TermFieldMatchDataArray &matchData) const override; }; @@ -587,11 +587,11 @@ FakeEGCompr64PosOcc<bigEndian>::hasWordPositions() const template <bool bigEndian> -SearchIterator * +std::unique_ptr<SearchIterator> FakeEGCompr64PosOcc<bigEndian>:: createIterator(const TermFieldMatchDataArray &matchData) const { - return create_zc_posocc_iterator(bigEndian, _counts, Position(_compressed.first, 0), _compressedBits, _posting_params, _fieldsParams, matchData).release(); + return create_zc_posocc_iterator(bigEndian, _counts, Position(_compressed.first, 0), _compressedBits, _posting_params, _fieldsParams, matchData); } @@ -604,7 +604,7 @@ public: ~FakeEG2Compr64PosOcc() override; size_t bitSize() const override; bool hasWordPositions() const override; - SearchIterator *createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + std::unique_ptr<SearchIterator> createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; @@ -642,11 +642,11 @@ FakeEG2Compr64PosOcc<bigEndian>::hasWordPositions() const template <bool bigEndian> -SearchIterator * +std::unique_ptr<SearchIterator> FakeEG2Compr64PosOcc<bigEndian>:: createIterator(const TermFieldMatchDataArray &matchData) const { - return create_zc_posocc_iterator(bigEndian, _counts, Position(_compressed.first, 0), _compressedBits, _posting_params, _fieldsParams, matchData).release(); + return create_zc_posocc_iterator(bigEndian, _counts, Position(_compressed.first, 0), _compressedBits, _posting_params, _fieldsParams, matchData); } @@ -660,7 +660,7 @@ public: size_t bitSize() const override; bool hasWordPositions() const override; - SearchIterator *createIterator(const TermFieldMatchDataArray &matchData) const override; + std::unique_ptr<SearchIterator> createIterator(const TermFieldMatchDataArray &matchData) const override; }; @@ -699,11 +699,11 @@ FakeZcSkipPosOcc<bigEndian>::hasWordPositions() const template <bool bigEndian> -SearchIterator * +std::unique_ptr<SearchIterator> FakeZcSkipPosOcc<bigEndian>:: createIterator(const TermFieldMatchDataArray &matchData) const { - return create_zc_posocc_iterator(bigEndian, _counts, Position(_compressed.first, 0), _compressedBits, _posting_params, _fieldsParams, matchData).release(); + return create_zc_posocc_iterator(bigEndian, _counts, Position(_compressed.first, 0), _compressedBits, _posting_params, _fieldsParams, matchData); } @@ -720,7 +720,7 @@ public: ~FakeZc4SkipPosOcc() override; size_t bitSize() const override; bool hasWordPositions() const override; - SearchIterator *createIterator(const TermFieldMatchDataArray &matchData) const override; + std::unique_ptr<SearchIterator> createIterator(const TermFieldMatchDataArray &matchData) const override; bool enable_unpack_normal_features() const override { return _unpack_normal_features; } bool enable_unpack_interleaved_features() const override { return _unpack_interleaved_features; } }; @@ -766,7 +766,7 @@ FakeZc4SkipPosOcc<bigEndian>::hasWordPositions() const template <bool bigEndian> -SearchIterator * +std::unique_ptr<SearchIterator> FakeZc4SkipPosOcc<bigEndian>:: createIterator(const TermFieldMatchDataArray &matchData) const { @@ -777,7 +777,7 @@ createIterator(const TermFieldMatchDataArray &matchData) const assert(!_unpack_normal_features); assert(!_unpack_interleaved_features); } -return create_zc_posocc_iterator(bigEndian, _counts, Position(_compressed.first, 0), _compressedBits, _posting_params, _fieldsParams, matchData).release(); + return create_zc_posocc_iterator(bigEndian, _counts, Position(_compressed.first, 0), _compressedBits, _posting_params, _fieldsParams, matchData); } template <bool bigEndian> diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.h b/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.h index bcdd780e1e4..7d0670f993b 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.h @@ -65,7 +65,7 @@ public: int lowLevelSinglePostingScanUnpack() const override; int lowLevelAndPairPostingScan(const FakePosting &rhs) const override; int lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; - queryeval::SearchIterator *createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + std::unique_ptr<queryeval::SearchIterator> createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; } |