You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2016/04/27 18:04:35 UTC
lucene-solr:branch_6x: LUCENE-7259: speed up MatchingPoints cost
estimation
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x dbb28f3cb -> 71c2c31ee
LUCENE-7259: speed up MatchingPoints cost estimation
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/71c2c31e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/71c2c31e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/71c2c31e
Branch: refs/heads/branch_6x
Commit: 71c2c31ee2ccb60d4043e5c97fd51713506d35f3
Parents: dbb28f3
Author: Robert Muir <rm...@apache.org>
Authored: Wed Apr 27 12:01:44 2016 -0400
Committer: Robert Muir <rm...@apache.org>
Committed: Wed Apr 27 12:03:00 2016 -0400
----------------------------------------------------------------------
.../lucene/document/LatLonPointBoxQuery.java | 5 +++++
.../lucene/document/LatLonPointDistanceQuery.java | 5 +++++
.../document/LatLonPointInPolygonQuery.java | 5 +++++
.../apache/lucene/document/MatchingPoints.java | 18 +++++++++++++++---
4 files changed, 30 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/71c2c31e/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointBoxQuery.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointBoxQuery.java b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointBoxQuery.java
index 423af05..8d36946 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointBoxQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointBoxQuery.java
@@ -109,6 +109,11 @@ abstract class LatLonPointBoxQuery extends Query {
new IntersectVisitor() {
@Override
+ public void grow(int count) {
+ result.grow(count);
+ }
+
+ @Override
public void visit(int docID) {
result.add(docID);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/71c2c31e/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
index 0759ce1..f746dee 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
@@ -122,6 +122,11 @@ final class LatLonPointDistanceQuery extends Query {
values.intersect(field,
new IntersectVisitor() {
@Override
+ public void grow(int count) {
+ result.grow(count);
+ }
+
+ @Override
public void visit(int docID) {
result.add(docID);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/71c2c31e/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointInPolygonQuery.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointInPolygonQuery.java b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointInPolygonQuery.java
index 506e6b9..9c0ac77 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointInPolygonQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointInPolygonQuery.java
@@ -115,6 +115,11 @@ final class LatLonPointInPolygonQuery extends Query {
values.intersect(field,
new IntersectVisitor() {
@Override
+ public void grow(int count) {
+ result.grow(count);
+ }
+
+ @Override
public void visit(int docID) {
result.add(docID);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/71c2c31e/lucene/sandbox/src/java/org/apache/lucene/document/MatchingPoints.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/MatchingPoints.java b/lucene/sandbox/src/java/org/apache/lucene/document/MatchingPoints.java
index 2b6c124..4ef8ca9 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/MatchingPoints.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/MatchingPoints.java
@@ -30,6 +30,9 @@ import org.apache.lucene.util.SparseFixedBitSet;
* Add matches with ({@link #add(int)}) and call {@link #iterator()} for
* an iterator over the results.
* <p>
+ * <b>NOTE:</b> it is required that you implement the optional {@code grow()}
+ * method in your IntersectVisitor, this is used for cost computation.
+ * <p>
* This implementation currently optimizes bitset structure (sparse vs dense)
* and {@link DocIdSetIterator#cost()} (cardinality) based on index statistics.
* This API may change as point values evolves.
@@ -76,15 +79,24 @@ final class MatchingPoints {
*/
public void add(int doc) {
bits.set(doc);
- counter++;
+ }
+
+ /**
+ * Grows cardinality counter by the given amount.
+ */
+ public void grow(int amount) {
+ counter += amount;
}
/**
* Returns an iterator over the recorded matches.
*/
public DocIdSetIterator iterator() {
- // if single-valued (docCount == numPoints), then this is exact
- // otherwise its approximate based on field stats
+ // ensure caller implements the grow() api
+ assert counter > 0 || bits.cardinality() == 0 : "the IntersectVisitor is missing grow()";
+
+ // if single-valued (docCount == numPoints), then we know 1 point == 1 doc
+ // otherwise we approximate based on field stats
return new BitSetIterator(bits, (long) (counter * (docCount / (double) numPoints)));
}
}