// Pulls out child doc and scores for all join queries:
  private void copyGroups(OneGroup og) {
    // While rare, it's possible top arrays could be too
    // short if join query had null scorer on first
    // segment(s) but then became non-null on later segments
    final int numSubScorers = joinScorers.length;
    if (og.docs.length < numSubScorers) {
      // While rare, this could happen if join query had
      // null scorer on first segment(s) but then became
      // non-null on later segments
      og.docs = ArrayUtil.grow(og.docs);
    }
    if (og.counts.length < numSubScorers) {
      og.counts = ArrayUtil.grow(og.counts);
    }
    if (trackScores && og.scores.length < numSubScorers) {
      og.scores = ArrayUtil.grow(og.scores);
    }

    // System.out.println("\ncopyGroups parentDoc=" + og.doc);
    for (int scorerIDX = 0; scorerIDX < numSubScorers; scorerIDX++) {
      final ToParentBlockJoinQuery.BlockJoinScorer joinScorer = joinScorers[scorerIDX];
      // System.out.println("  scorer=" + joinScorer);
      if (joinScorer != null && docBase + joinScorer.getParentDoc() == og.doc) {
        og.counts[scorerIDX] = joinScorer.getChildCount();
        // System.out.println("    count=" + og.counts[scorerIDX]);
        og.docs[scorerIDX] = joinScorer.swapChildDocs(og.docs[scorerIDX]);
        assert og.docs[scorerIDX].length >= og.counts[scorerIDX]
            : "length=" + og.docs[scorerIDX].length + " vs count=" + og.counts[scorerIDX];
        // System.out.println("    len=" + og.docs[scorerIDX].length);
        /*
          for(int idx=0;idx<og.counts[scorerIDX];idx++) {
          System.out.println("    docs[" + idx + "]=" + og.docs[scorerIDX][idx]);
          }
        */
        if (trackScores) {
          // System.out.println("    copy scores");
          og.scores[scorerIDX] = joinScorer.swapChildScores(og.scores[scorerIDX]);
          assert og.scores[scorerIDX].length >= og.counts[scorerIDX]
              : "length=" + og.scores[scorerIDX].length + " vs count=" + og.counts[scorerIDX];
        }
      } else {
        og.counts[scorerIDX] = 0;
      }
    }
  }
 private void enroll(ToParentBlockJoinQuery query, ToParentBlockJoinQuery.BlockJoinScorer scorer) {
   scorer.trackPendingChildHits();
   final Integer slot = joinQueryID.get(query);
   if (slot == null) {
     joinQueryID.put(query, joinScorers.length);
     // System.out.println("found JQ: " + query + " slot=" + joinScorers.length);
     final ToParentBlockJoinQuery.BlockJoinScorer[] newArray =
         new ToParentBlockJoinQuery.BlockJoinScorer[1 + joinScorers.length];
     System.arraycopy(joinScorers, 0, newArray, 0, joinScorers.length);
     joinScorers = newArray;
     joinScorers[joinScorers.length - 1] = scorer;
   } else {
     joinScorers[slot] = scorer;
   }
 }