Skip to content

Commit

Permalink
always prefer BMW
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzq50 committed Dec 13, 2024
1 parent 214d207 commit c975bb2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/storage/invertedindex/search/blockmax_wand_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ bool BlockMaxWandIterator::Next(RowID doc_id){
});
// remove exhausted lists
for (int i = int(num_iterators) - 1; i >= 0 && sorted_iterators_[i]->DocID() == INVALID_ROWID; i--) {
if (SHOULD_LOG_DEBUG()) {
if (SHOULD_LOG_TRACE()) {
OStringStream oss;
sorted_iterators_[i]->PrintTree(oss, "Exhaused: ", true);
LOG_DEBUG(oss.str());
LOG_TRACE(oss.str());
}
bm25_score_upper_bound_ -= sorted_iterators_[i]->BM25ScoreUpperBound();
sorted_iterators_.pop_back();
Expand Down Expand Up @@ -148,10 +148,10 @@ bool BlockMaxWandIterator::Next(RowID doc_id){
if (ok) [[likely]] {
sum_score_bm += sorted_iterators_[i]->BlockMaxBM25Score();
} else {
if (SHOULD_LOG_DEBUG()) {
if (SHOULD_LOG_TRACE()) {
OStringStream oss;
sorted_iterators_[i]->PrintTree(oss, "Exhausted: ", true);
LOG_DEBUG(oss.str());
LOG_TRACE(oss.str());
}
sorted_iterators_.erase(sorted_iterators_.begin() + i);
num_iterators = sorted_iterators_.size();
Expand Down
13 changes: 12 additions & 1 deletion src/storage/invertedindex/search/query_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ std::unique_ptr<DocIterator> OrQueryNode::CreateSearch(const CreateSearchParams
}
}
};
auto term_num_threshold = [](const u32 topn) -> u32 {
[[maybe_unused]] auto term_num_threshold = [](const u32 topn) -> u32 {
if (topn < 5u) {
return std::numeric_limits<u32>::max();
}
Expand Down Expand Up @@ -597,13 +597,24 @@ std::unique_ptr<DocIterator> OrQueryNode::CreateSearch(const CreateSearchParams
auto choose_algo = EarlyTermAlgo::kNaive;
switch (params.early_term_algo) {
case EarlyTermAlgo::kAuto: {
if (params.topn) {
// always prefer BMW
choose_algo = EarlyTermAlgo::kBMW;
} else if (term_children_need_batch()) {
// topn == 0, case of filter
choose_algo = EarlyTermAlgo::kBatch;
} else {
choose_algo = EarlyTermAlgo::kNaive;
}
/* TODO: now always use BMW
if ((params.topn == 0u || sub_doc_iters.size() > term_num_threshold(params.topn)) && term_children_need_batch()) {
choose_algo = EarlyTermAlgo::kBatch;
} else if (params.topn == 0u) {
choose_algo = EarlyTermAlgo::kNaive;
} else {
choose_algo = EarlyTermAlgo::kBMW;
}
*/
break;
}
case EarlyTermAlgo::kBMW:
Expand Down

0 comments on commit c975bb2

Please sign in to comment.