Skip to content

Commit

Permalink
Fix negative cost in some IntersectVisitor implementations after apac…
Browse files Browse the repository at this point in the history
…he#14138 (apache#14150)

Introduced in apache#14138, we need to prevent negative scores when subtracting the added hits in LatLonPointDistanceQuery, SpatialQuery and PointRangeQuery.
  • Loading branch information
iverase authored Jan 18, 2025
1 parent a4434ca commit dce24c8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public void visit(IntsRef ref) {
for (int i = 0; i < ref.length; i++) {
result.clear(ref.ints[ref.offset + i]);
}
cost[0] = -ref.length;
cost[0] = Math.max(0, cost[0] - ref.length);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ public void visit(IntsRef ref) {
for (int i = 0; i < ref.length; i++) {
result.clear(ref.ints[ref.offset + i]);
}
cost[0] -= ref.length;
cost[0] = Math.max(0, cost[0] - ref.length);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public void visit(IntsRef ref) {
for (int i = ref.offset; i < ref.offset + ref.length; i++) {
result.clear(ref.ints[i]);
}
cost[0] -= ref.length;
cost[0] = Math.max(0, cost[0] - ref.length);
}

@Override
Expand Down

0 comments on commit dce24c8

Please sign in to comment.