use of com.palantir.atlasdb.keyvalue.api.RowResult in project atlasdb by palantir.
the class KvsRangeMigrator method copyOneTransactionInternal.
private byte[] copyOneTransactionInternal(RangeRequest range, long rangeId, Transaction readT, Transaction writeT) {
final long maxBytes = TransactionConstants.WARN_LEVEL_FOR_QUEUED_BYTES / 2;
byte[] start = getCheckpoint(rangeId, writeT);
if (start == null) {
return null;
}
RangeRequest.Builder builder = range.getBuilder().startRowInclusive(start);
if (builder.isInvalidRange()) {
return null;
}
RangeRequest rangeToUse = builder.build();
if (log.isTraceEnabled()) {
log.trace("Copying table {} range {} from {} to {}", srcTable, rangeId, BaseEncoding.base16().lowerCase().encode(rangeToUse.getStartInclusive()), BaseEncoding.base16().lowerCase().encode(rangeToUse.getEndExclusive()));
}
BatchingVisitable<RowResult<byte[]>> bv = readT.getRange(srcTable, rangeToUse);
Map<Cell, byte[]> writeMap = Maps.newHashMap();
byte[] lastRow = internalCopyRange(bv, maxBytes, writeMap);
if (log.isTraceEnabled() && (lastRow != null)) {
log.trace("Copying {} bytes for range {} on table {}", lastRow.length, rangeId, srcTable);
}
writeToKvs(writeMap);
byte[] nextRow = getNextRowName(lastRow);
checkpointer.checkpoint(srcTable.getQualifiedName(), rangeId, nextRow, writeT);
return lastRow;
}
use of com.palantir.atlasdb.keyvalue.api.RowResult in project atlasdb by palantir.
the class KvsRangeMigrator method internalCopyRange.
private byte[] internalCopyRange(BatchingVisitable<RowResult<byte[]>> bv, final long maxBytes, @Output final Map<Cell, byte[]> writeMap) {
final Mutable<byte[]> lastRowName = Mutables.newMutable(null);
final MutableLong bytesPut = new MutableLong(0L);
bv.batchAccept(readBatchSize, AbortingVisitors.batching(// even though no exception can be thrown :-(
new AbortingVisitor<RowResult<byte[]>, RuntimeException>() {
@Override
public boolean visit(RowResult<byte[]> rr) throws RuntimeException {
return KvsRangeMigrator.this.internalCopyRow(rr, maxBytes, writeMap, bytesPut, lastRowName);
}
}));
return lastRowName.get();
}
Aggregations