cur = readers.get(i).getCurrentKey();
// We need to loop in case of Grouping Comparators
while (comparator.compare(min, cur) == 0
&& (!min.isNull() || (min.isNull() && i == minIndex))) {
Iterable<Object> vals = readers.get(i).getCurrentValues();
bag = bags[i] == null ? new InternalCachedBag(numInputs) : bags[i];
for (Object val : vals) {
NullableTuple nTup = (NullableTuple) val;
int index = nTup.getIndex();
Tuple tup = pkgr.getValueTuple(keyWritable, nTup, index);
bag.add(tup);
}
bags[i] = bag;
finished[i] = !readers.get(i).next();
if (finished[i]) {
break;
}
cur = readers.get(i).getCurrentKey();
}
}
if (bag == null) {
bags[i] = new InternalCachedBag(numInputs);
}
}
}
pkgr.attachInput(key, bags, readOnce);