currentRow = persistedScanner.next();
} else if (order < 0) {
// buffer row comes first or persisted scanner is empty
Map<byte[], byte[]> persistedRow = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
mergeToPersisted(persistedRow, buffer.get(currentKey), null);
result = new Result(copy(currentKey), persistedRow);
currentKey = keyIter.hasNext() ? keyIter.next() : null;
} else {
// if currentKey and currentRow are equal, merge and advance both
Map<byte[], byte[]> persisted = currentRow.getColumns();
mergeToPersisted(persisted, buffer.get(currentKey), null);
result = new Result(currentRow.getRow(), persisted);
currentRow = persistedScanner.next();
currentKey = keyIter.hasNext() ? keyIter.next() : null;
}
return result;