@Override
protected void transformRange(
final SortedKeyValueIterator<Key, Value> input,
final KVBuffer output )
throws IOException {
Mergeable currentMergeable = null;
Key outputKey = null;
while (input.hasTop()) {
final Value val = input.getTopValue();
// the SortedKeyValueIterator uses the same instance of topKey to hold keys (a wrapper)
final Key currentKey = new Key(input.getTopKey());
if (outputKey == null) {
outputKey = currentKey;
} else if (currentMergeable != null &&
!outputKey.getRowData().equals(currentKey.getRowData())) {
output.append(
outputKey,
new Value(
PersistenceUtils.toBinary(currentMergeable)));
currentMergeable = null;
outputKey = currentKey;
continue;
}
else {
final Text combinedVisibility = new Text(
combineVisibilities(
currentKey.getColumnVisibility().getBytes(),
outputKey.getColumnVisibility().getBytes()));
outputKey = replaceColumnVisibility(
outputKey,
combinedVisibility);
}
Mergeable mergeable = PersistenceUtils.fromBinary(
val.get(),
Mergeable.class);
// hopefully its never the case that null mergeables are stored,
// but just in case, check
mergeable = transform(