Mikep86 commented on code in PR #13697: URL: https://github.com/apache/lucene/pull/13697#discussion_r1752115832
########## lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java: ########## @@ -242,14 +242,25 @@ public int nextDoc() throws IOException { @Override public int advance(int target) throws IOException { - if (target >= parentBits.length()) { - return doc = NO_MORE_DOCS; - } - final int firstChildTarget = target == 0 ? 0 : parentBits.prevSetBit(target - 1) + 1; + final int prevParent = + target == 0 ? 0 : parentBits.prevSetBit(Math.min(target, parentBits.length()) - 1); + int childDoc = childApproximation.docID(); - if (childDoc < firstChildTarget) { - childDoc = childApproximation.advance(firstChildTarget); + if (childDoc < prevParent) { + childDoc = childApproximation.advance(prevParent); + } + + // TODO: Can we assume that doc 0 is never a real parent that also matches the child query? Review Comment: ~~Because we use 0 to indicate "no previous parent doc", we cannot detect the case when: - A real parent doc exists at 0 - That parent doc matches the child query I don't think this is a problem since any real parent doc at 0 would never be returned by `ToParentBlockJoinQuery` since it cannot have child docs. Thoughts?~~ This question is based on a misunderstanding on my part. Reworking this part of the code now. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org