You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mv...@apache.org on 2013/10/01 10:54:45 UTC
svn commit: r1527975 - in /lucene/dev/trunk/lucene: CHANGES.txt
join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java
join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
Author: mvg
Date: Tue Oct 1 08:54:45 2013
New Revision: 1527975
URL: http://svn.apache.org/r1527975
Log:
LUCENE-5225: The ToParentBlockJoinQuery only keeps tracks of the the child doc ids and child scores if the ToParentBlockJoinCollector is used.
Modified:
lucene/dev/trunk/lucene/CHANGES.txt
lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java
lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1527975&r1=1527974&r2=1527975&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Tue Oct 1 08:54:45 2013
@@ -96,6 +96,12 @@ API Changes:
with IndexSearcher when an ExecutorService is specified.
(Ryan Ernst, Mike McCandless, Robert Muir)
+Optimizations
+
+* LUCENE-5225: The ToParentBlockJoinQuery only keeps tracks of the the child
+ doc ids and child scores if the ToParentBlockJoinCollector is used.
+ (Martijn van Groningen)
+
Documentation
* LUCENE-5211: Better javadocs and error checking of 'format' option in
Modified: lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java?rev=1527975&r1=1527974&r2=1527975&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java (original)
+++ lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java Tue Oct 1 08:54:45 2013
@@ -283,6 +283,7 @@ public class ToParentBlockJoinCollector
}
private void enroll(ToParentBlockJoinQuery query, ToParentBlockJoinQuery.BlockJoinScorer scorer) {
+ scorer.trackPendingChildHits();
final Integer slot = joinQueryID.get(query);
if (slot == null) {
joinQueryID.put(query, joinScorers.length);
Modified: lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java?rev=1527975&r1=1527974&r2=1527975&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java (original)
+++ lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java Tue Oct 1 08:54:45 2013
@@ -17,15 +17,9 @@ package org.apache.lucene.search.join;
* limitations under the License.
*/
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Locale;
-import java.util.Set;
-
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriter; // javadocs
+import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.ComplexExplanation;
import org.apache.lucene.search.DocIdSet;
@@ -41,6 +35,12 @@ import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.FixedBitSet;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Locale;
+import java.util.Set;
+
/**
* This query requires that you index
* children and parent docs as a single block, using the
@@ -218,8 +218,7 @@ public class ToParentBlockJoinQuery exte
private float parentScore;
private int parentFreq;
private int nextChildDoc;
-
- private int[] pendingChildDocs = new int[5];
+ private int[] pendingChildDocs;
private float[] pendingChildScores;
private int childDocUpto;
@@ -230,9 +229,6 @@ public class ToParentBlockJoinQuery exte
this.childScorer = childScorer;
this.scoreMode = scoreMode;
this.acceptDocs = acceptDocs;
- if (scoreMode != ScoreMode.None) {
- pendingChildScores = new float[5];
- }
nextChildDoc = firstChildDoc;
}
@@ -321,18 +317,22 @@ public class ToParentBlockJoinQuery exte
do {
//System.out.println(" c=" + nextChildDoc);
- if (pendingChildDocs.length == childDocUpto) {
+ if (pendingChildDocs != null && pendingChildDocs.length == childDocUpto) {
pendingChildDocs = ArrayUtil.grow(pendingChildDocs);
}
- if (scoreMode != ScoreMode.None && pendingChildScores.length == childDocUpto) {
+ if (pendingChildScores != null && scoreMode != ScoreMode.None && pendingChildScores.length == childDocUpto) {
pendingChildScores = ArrayUtil.grow(pendingChildScores);
}
- pendingChildDocs[childDocUpto] = nextChildDoc;
+ if (pendingChildDocs != null) {
+ pendingChildDocs[childDocUpto] = nextChildDoc;
+ }
if (scoreMode != ScoreMode.None) {
// TODO: specialize this into dedicated classes per-scoreMode
final float childScore = childScorer.score();
final int childFreq = childScorer.freq();
- pendingChildScores[childDocUpto] = childScore;
+ if (pendingChildScores != null) {
+ pendingChildScores[childDocUpto] = childScore;
+ }
maxScore = Math.max(childScore, maxScore);
totalScore += childScore;
parentFreq += childFreq;
@@ -432,6 +432,16 @@ public class ToParentBlockJoinQuery exte
public long cost() {
return childScorer.cost();
}
+
+ /**
+ * Instructs this scorer to keep track of the child docIds and score ids for retrieval purposes.
+ */
+ public void trackPendingChildHits() {
+ pendingChildDocs = new int[5];
+ if (scoreMode != ScoreMode.None) {
+ pendingChildScores = new float[5];
+ }
+ }
}
@Override