Skip to content

Commit

Permalink
Merge pull request #21957 from vespa-engine/toregge/remove-outdated-a…
Browse files Browse the repository at this point in the history
…ndnot-optimization

Remove outdated andnot optimization.
  • Loading branch information
baldersheim authored Apr 3, 2022
2 parents 35c74d9 + b1e3641 commit ab62199
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 94 deletions.
18 changes: 1 addition & 17 deletions searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ LOG_SETUP(".proton.matching.match_thread");

namespace proton::matching {

using search::queryeval::OptimizedAndNotForBlackListing;
using search::queryeval::SearchIterator;
using search::fef::MatchData;
using search::fef::RankProgram;
Expand Down Expand Up @@ -48,17 +47,6 @@ struct SimpleStrategy {
}
};

// seek_next maps to OptimizedAndNotForBlackListing::seekFast
struct FastBlackListingStrategy {
static bool can_use(bool do_rank, bool do_limit, SearchIterator &search) {
return (!do_rank && !do_limit &&
(dynamic_cast<OptimizedAndNotForBlackListing *>(&search) != nullptr));
}
static uint32_t seek_next(SearchIterator &search, uint32_t docid) {
return static_cast<OptimizedAndNotForBlackListing &>(search).seekFast(docid);
}
};

LazyValue get_score_feature(const RankProgram &rankProgram) {
FeatureResolver resolver(rankProgram.get_seeds());
assert(resolver.num_features() == 1u);
Expand Down Expand Up @@ -222,11 +210,7 @@ template <bool do_rank, bool do_limit, bool do_share, bool use_rank_drop_limit>
void
MatchThread::match_loop_helper_rank_limit_share_drop(MatchTools &tools, HitCollector &hits)
{
if (FastBlackListingStrategy::can_use(do_rank, do_limit, tools.search())) {
match_loop<FastBlackListingStrategy, do_rank, do_limit, do_share, use_rank_drop_limit>(tools, hits);
} else {
match_loop<SimpleStrategy, do_rank, do_limit, do_share, use_rank_drop_limit>(tools, hits);
}
match_loop<SimpleStrategy, do_rank, do_limit, do_share, use_rank_drop_limit>(tools, hits);
}

template <bool do_rank, bool do_limit, bool do_share>
Expand Down
32 changes: 1 addition & 31 deletions searchlib/src/vespa/searchlib/queryeval/andnotsearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,41 +105,11 @@ AndNotSearchStrict::internalSeek(uint32_t docid)

} // namespace

OptimizedAndNotForBlackListing::OptimizedAndNotForBlackListing(MultiSearch::Children children) :
AndNotSearchStrictBase(std::move(children))
{
}

void OptimizedAndNotForBlackListing::initRange(uint32_t beginid, uint32_t endid)
{
AndNotSearch::initRange(beginid, endid);
setDocId(internalSeek<false>(beginid));
}

bool OptimizedAndNotForBlackListing::isBlackListIterator(const SearchIterator * iterator)
{
return dynamic_cast<const BlackListIterator *>(iterator) != 0;
}

void OptimizedAndNotForBlackListing::doSeek(uint32_t docid)
{
setDocId(internalSeek<true>(docid));
}

void OptimizedAndNotForBlackListing::doUnpack(uint32_t docid)
{
positive()->doUnpack(docid);
}

std::unique_ptr<SearchIterator>
AndNotSearch::create(ChildrenIterators children_in, bool strict) {
MultiSearch::Children children = std::move(children_in);
if (strict) {
if ((children.size() == 2) && OptimizedAndNotForBlackListing::isBlackListIterator(children[1].get())) {
return std::make_unique<OptimizedAndNotForBlackListing>(std::move(children));
} else {
return std::make_unique<AndNotSearchStrict>(std::move(children));
}
return std::make_unique<AndNotSearchStrict>(std::move(children));
} else {
return SearchIterator::UP(new AndNotSearch(std::move(children)));
}
Expand Down
46 changes: 0 additions & 46 deletions searchlib/src/vespa/searchlib/queryeval/andnotsearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,50 +48,4 @@ class AndNotSearchStrictBase : public AndNotSearch
UP andWith(UP filter, uint32_t estimate) override;
};

/**
* This is a specialized andnot iterator you get when you have no andnot's in you query and only get the blacklist blueprint.
* This one is now constructed at getSearch() phase. However this should be better handled in the AndNotBlueprint.
*/
class OptimizedAndNotForBlackListing : public AndNotSearchStrictBase
{
private:
// This is the actual iterator that should be produced by the documentmetastore in searchcore, but that
// will probably be changed later on. An ordinary bitvector could be even better as that would open up for more optimizations.
//typedef FilterAttributeIteratorT<SingleValueSmallNumericAttribute::SingleSearchContext> BlackListIterator;
typedef AttributeIteratorT<SingleValueSmallNumericAttribute::SingleSearchContext> BlackListIterator;
public:
OptimizedAndNotForBlackListing(MultiSearch::Children children);
static bool isBlackListIterator(const SearchIterator * iterator);

uint32_t seekFast(uint32_t docid) {
return internalSeek<true>(docid);
}
void initRange(uint32_t beginid, uint32_t endid) override;
private:
SearchIterator * positive() { return getChildren()[0].get(); }
BlackListIterator * blackList() { return static_cast<BlackListIterator *>(getChildren()[1].get()); }
template<bool doSeekOnly>
uint32_t internalSeek(uint32_t docid) {
uint32_t curr(docid);
while (true) {
if (doSeekOnly) {
positive()->doSeek(curr);
} else {
positive()->seek(curr);
}
if ( ! positive()->isAtEnd() ) {
curr = positive()->getDocId();
if (! blackList()->seekFast(curr)) {
return curr;
}
curr++;
} else {
return search::endDocId;
}
}
}
void doSeek(uint32_t docid) override;
void doUnpack(uint32_t docid) override;
};

}

0 comments on commit ab62199

Please sign in to comment.