Skip to content

Commit d05a569

Browse files
lgrzelshize
authored andcommitted
tools/compute_intersection: do not print empty intersections
1 parent 95f95be commit d05a569

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

include/pisa/intersection.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace intersection {
2525
/// Returns a filtered copy of `query` containing only terms indicated by ones in the bit mask.
2626
[[nodiscard]] inline auto filter(Query const& query, Mask const& mask) -> Query {
2727
if (query.terms().size() > MAX_QUERY_LEN) {
28-
throw std::invalid_argument("Queries can be at most 2^32 terms long");
28+
throw std::invalid_argument("Queries can be at most 2^31 terms long");
2929
}
3030
std::vector<std::uint32_t> terms;
3131
std::vector<float> weights;

tools/compute_intersection.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ void intersect(
4848

4949
auto print_intersection = [&](auto const& query, auto const& mask) {
5050
auto intersection = Intersection::compute(index, wdata, scorer, query, mask);
51+
if (0U == intersection.length) {
52+
return;
53+
}
5154
std::cout << fmt::format(
5255
"{}\t{}\t{}\t{}\n",
5356
query.id() ? *query.id() : std::to_string(qid),
@@ -62,6 +65,9 @@ void intersect(
6265
for_all_subsets(query, max_term_count, print_intersection);
6366
} else {
6467
auto intersection = Intersection::compute(index, wdata, scorer, query);
68+
if (0U == intersection.length) {
69+
continue;
70+
}
6571
std::cout << fmt::format(
6672
"{}\t{}\t{}\n",
6773
query.id() ? *query.id() : std::to_string(qid),

0 commit comments

Comments
 (0)