From e9fe8ec469ee88548f7fad06e678f55c17bd744c Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Mon, 28 Nov 2011 23:47:31 +0200 Subject: [PATCH] sync with latest Lucene block join, init parentDoc to -1, which makes the assert commented out valid again --- .../index/search/nested/BlockJoinQuery.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/search/nested/BlockJoinQuery.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/search/nested/BlockJoinQuery.java index 40f83632932..1c19a285979 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/search/nested/BlockJoinQuery.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/search/nested/BlockJoinQuery.java @@ -211,7 +211,7 @@ public class BlockJoinQuery extends Query { private final FixedBitSet parentBits; private final ScoreMode scoreMode; private final Collector childCollector; - private int parentDoc; + private int parentDoc = -1; private float parentScore; private int nextChildDoc; @@ -349,18 +349,20 @@ public class BlockJoinQuery extends Query { return parentDoc = NO_MORE_DOCS; } - // CHANGE: Remove this and if parentTarget is 0, we can simply call nextdoc - // Every parent must have at least one child: - // assert parentTarget != 0; if (parentTarget == 0) { + // Callers should only be passing in a docID from + // the parent space, so this means this parent + // has no children (it got docID 0), so it cannot + // possibly match. We must handle this case + // separately otherwise we pass invalid -1 to + // prevSetBit below: return nextDoc(); } final int prevParentDoc = parentBits.prevSetBit(parentTarget - 1); //System.out.println(" rolled back to prevParentDoc=" + prevParentDoc + " vs parentDoc=" + parentDoc); - // CHANGE: Commented out the assert because it might happen with a single nested and parent doc reader - //assert prevParentDoc >= parentDoc; + assert prevParentDoc >= parentDoc; if (prevParentDoc > nextChildDoc) { nextChildDoc = childScorer.advance(prevParentDoc); // System.out.println(" childScorer advanced to child docID=" + nextChildDoc);