listDone.set(subListIndex, true);
}
}
do {
int fieldDocArrayWithSmallestFieldDoc = -1;
FieldDoc smallestFieldDoc = null;
for (int subListIndex = 0; subListIndex < arrayPositions.length; subListIndex++) {
if (!listDone.get(subListIndex)) {
FieldDoc hit = (FieldDoc) sortedFieldDocs[subListIndex][arrayPositions[subListIndex]];
if (smallestFieldDoc == null || comparator.compare(hit.fields, smallestFieldDoc.fields) < 0) {
smallestFieldDoc = hit;
fieldDocArrayWithSmallestFieldDoc = subListIndex;
}
}
}
ScoreDoc[] smallestElementList = sortedFieldDocs[fieldDocArrayWithSmallestFieldDoc];
FieldDoc fieldDoc = (FieldDoc) smallestElementList[arrayPositions[fieldDocArrayWithSmallestFieldDoc]];
arrayPositions[fieldDocArrayWithSmallestFieldDoc]++;
final Hit hit = new Hit(shards[fieldDocArrayWithSmallestFieldDoc], nodeName, fieldDoc.score, fieldDoc.doc);
hit.setSortFields(WritableType.convertComparable(comparator.getFieldTypes(), fieldDoc.fields));
sortedResult.add(hit);
if (arrayPositions[fieldDocArrayWithSmallestFieldDoc] >= smallestElementList.length) {