Small tweak to IntervalQuery#visit logic (#1007)

This commit is contained in:
Greg Miller 2022-07-19 12:27:41 -07:00 committed by GitHub
parent 11e7fe6618
commit a35dee5b27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 18 additions and 52 deletions

View File

@ -138,6 +138,9 @@ Optimizations
* LUCENE-10657: CopyBytes now saves one memory copy on ByteBuffersDataOutput. (luyuncheng)
* GITHUB#1007: Optimize IntersectVisitor#visit implementations for certain bulk-add cases.
(Greg Miller)
Changes in runtime behavior
---------------------

View File

@ -271,10 +271,7 @@ final class LatLonPointDistanceQuery extends Query {
@Override
public void visit(DocIdSetIterator iterator, byte[] packedValue) throws IOException {
if (matches(packedValue)) {
int docID;
while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
visit(docID);
}
adder.add(iterator);
}
}
@ -311,10 +308,7 @@ final class LatLonPointDistanceQuery extends Query {
@Override
public void visit(DocIdSetIterator iterator, byte[] packedValue) throws IOException {
if (matches(packedValue) == false) {
int docID;
while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
visit(docID);
}
visit(iterator);
}
}

View File

@ -481,10 +481,7 @@ public abstract class RangeFieldQuery extends Query {
@Override
public void visit(DocIdSetIterator iterator, byte[] leaf) throws IOException {
if (queryType.matches(ranges, leaf, numDims, bytesPerDim)) {
int docID;
while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
visit(docID);
}
adder.add(iterator);
}
}

View File

@ -437,10 +437,7 @@ abstract class SpatialQuery extends Query {
@Override
public void visit(DocIdSetIterator iterator, byte[] t) throws IOException {
if (leafPredicate.test(t)) {
int docID;
while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
visit(docID);
}
adder.add(iterator);
}
}
@ -486,10 +483,7 @@ abstract class SpatialQuery extends Query {
@Override
public void visit(DocIdSetIterator iterator, byte[] t) throws IOException {
if (leafPredicate.test(t)) {
int docID;
while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
visit(docID);
}
visit(iterator);
}
}
@ -539,14 +533,10 @@ abstract class SpatialQuery extends Query {
@Override
public void visit(DocIdSetIterator iterator, byte[] t) throws IOException {
boolean matches = leafPredicate.test(t);
int docID;
while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
if (matches) {
visit(docID);
} else {
excluded.set(docID);
}
if (leafPredicate.test(t)) {
visit(iterator);
} else {
excluded.or(iterator);
}
}
@ -653,10 +643,7 @@ abstract class SpatialQuery extends Query {
@Override
public void visit(DocIdSetIterator iterator, byte[] t) throws IOException {
if (leafPredicate.test(t) == false) {
int docID;
while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
visit(docID);
}
visit(iterator);
}
}

View File

@ -104,10 +104,7 @@ final class XYPointInGeometryQuery extends Query {
double x = XYEncodingUtils.decode(packedValue, 0);
double y = XYEncodingUtils.decode(packedValue, Integer.BYTES);
if (tree.contains(x, y)) {
int docID;
while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
visit(docID);
}
adder.add(iterator);
}
}

View File

@ -252,10 +252,7 @@ public abstract class PointInSetQuery extends Query implements Accountable {
@Override
public void visit(DocIdSetIterator iterator, byte[] packedValue) throws IOException {
if (matches(packedValue)) {
int docID;
while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
visit(docID);
}
adder.add(iterator);
}
}
@ -360,10 +357,7 @@ public abstract class PointInSetQuery extends Query implements Accountable {
assert packedValue.length == pointBytes.length;
if (Arrays.equals(packedValue, pointBytes)) {
// The point for this set of docs matches the point we are querying on
int docID;
while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
visit(docID);
}
adder.add(iterator);
}
}

View File

@ -195,10 +195,7 @@ public abstract class PointRangeQuery extends Query {
@Override
public void visit(DocIdSetIterator iterator, byte[] packedValue) throws IOException {
if (matches(packedValue)) {
int docID;
while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
visit(docID);
}
adder.add(iterator);
}
}
@ -235,10 +232,7 @@ public abstract class PointRangeQuery extends Query {
@Override
public void visit(DocIdSetIterator iterator, byte[] packedValue) throws IOException {
if (matches(packedValue) == false) {
int docID;
while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
visit(docID);
}
visit(iterator);
}
}