// case we don't want to pay the penalty all the time.
// Additionally, if there is a merge join(on a different key) following POCollectedGroup
// default bags should be used. But since we don't allow anything
// before Merge Join currently we are good.
: new InternalCachedBag(1);
outputBag.add((Tuple)tup.get(1));
continue;
}
// no key change
if (prevKey == null && curKey == null) {
outputBag.add((Tuple)tup.get(1));
continue;
}
// no key change
if (prevKey != null && curKey != null && ((Comparable)curKey).compareTo(prevKey) == 0) {
outputBag.add((Tuple)tup.get(1));
continue;
}
// key change
Tuple tup2 = mTupleFactory.newTuple(2);
tup2.set(0, prevKey);
tup2.set(1, outputBag);
res.result = tup2;
prevKey = curKey;
outputBag = useDefaultBag ? BagFactory.getInstance().newDefaultBag()
: new InternalCachedBag(1);
outputBag.add((Tuple)tup.get(1));
return res;
}