use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.
the class SchemaApiTestV2Impl method getRangeSecondColumnOnlyFirstTwoResults.
@Override
protected Map<String, StringValue> getRangeSecondColumnOnlyFirstTwoResults(Transaction transaction, String startRowKey, String endRowKey) {
SchemaApiTestV2Table table = tableFactory.getSchemaApiTestV2Table(transaction);
RangeRequest rangeRequest = RangeRequest.builder().startRowInclusive(SchemaApiTestTable.SchemaApiTestRow.of(startRowKey).persistToBytes()).endRowExclusive(SchemaApiTestTable.SchemaApiTestRow.of(endRowKey).persistToBytes()).build();
return table.getSmallRowRangeColumn2(rangeRequest, 2);
}
use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.
the class SchemaApiTestImpl method getRangeSecondColumnOnlyFirstTwoResults.
@Override
protected Map<String, StringValue> getRangeSecondColumnOnlyFirstTwoResults(Transaction transaction, String startRowKey, String endRowKey) {
SchemaApiTestTable table = tableFactory.getSchemaApiTestTable(transaction);
ColumnSelection secondColSelection = SchemaApiTestTable.getColumnSelection(SchemaApiTestTable.SchemaApiTestNamedColumn.COLUMN2);
RangeRequest rangeRequest = RangeRequest.builder().startRowInclusive(SchemaApiTestRow.of(startRowKey).persistToBytes()).endRowExclusive(SchemaApiTestRow.of(endRowKey).persistToBytes()).retainColumns(secondColSelection).batchHint(2).build();
BatchingVisitableView<SchemaApiTestRowResult> rangeRequestResult = table.getRange(rangeRequest);
return BatchingVisitables.take(rangeRequestResult, 2).stream().collect(Collectors.toMap(entry -> entry.getRowName().getComponent1(), SchemaApiTestTable.SchemaApiTestRowResult::getColumn2));
}
use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.
the class SnapshotTransaction method getRanges.
@Override
public Iterable<BatchingVisitable<RowResult<byte[]>>> getRanges(final TableReference tableRef, Iterable<RangeRequest> rangeRequests) {
checkGetPreconditions(tableRef);
if (perfLogger.isDebugEnabled()) {
perfLogger.debug("Passed {} ranges to getRanges({}, {})", Iterables.size(rangeRequests), tableRef, rangeRequests);
}
if (!Iterables.isEmpty(rangeRequests)) {
hasReads = true;
}
return FluentIterable.from(Iterables.partition(rangeRequests, BATCH_SIZE_GET_FIRST_PAGE)).transformAndConcat(input -> {
Timer.Context timer = getTimer("processedRangeMillis").time();
Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> firstPages = keyValueService.getFirstBatchForRanges(tableRef, input, getStartTimestamp());
validateExternalAndCommitLocksIfNecessary(tableRef, getStartTimestamp());
SortedMap<Cell, byte[]> postFiltered = postFilterPages(tableRef, firstPages.values());
List<BatchingVisitable<RowResult<byte[]>>> ret = Lists.newArrayListWithCapacity(input.size());
for (RangeRequest rangeRequest : input) {
TokenBackedBasicResultsPage<RowResult<Value>, byte[]> prePostFilter = firstPages.get(rangeRequest);
byte[] nextStartRowName = getNextStartRowName(rangeRequest, prePostFilter);
List<Entry<Cell, byte[]>> mergeIterators = getPostFilteredWithLocalWrites(tableRef, postFiltered, rangeRequest, prePostFilter.getResults(), nextStartRowName);
ret.add(new AbstractBatchingVisitable<RowResult<byte[]>>() {
@Override
protected <K extends Exception> void batchAcceptSizeHint(int batchSizeHint, ConsistentVisitor<RowResult<byte[]>, K> visitor) throws K {
checkGetPreconditions(tableRef);
final Iterator<RowResult<byte[]>> rowResults = Cells.createRowView(mergeIterators);
while (rowResults.hasNext()) {
if (!visitor.visit(ImmutableList.of(rowResults.next()))) {
return;
}
}
if ((nextStartRowName.length == 0) || !prePostFilter.moreResultsAvailable()) {
return;
}
RangeRequest newRange = rangeRequest.getBuilder().startRowInclusive(nextStartRowName).build();
getRange(tableRef, newRange).batchAccept(batchSizeHint, visitor);
}
});
}
long processedRangeMillis = TimeUnit.NANOSECONDS.toMillis(timer.stop());
log.trace("Processed {} range requests for {} in {}ms", SafeArg.of("numRequests", input.size()), LoggingArgs.tableRef(tableRef), SafeArg.of("millis", processedRangeMillis));
return ret;
});
}
use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.
the class TableTasks method executeDiffTask.
private static void executeDiffTask(DiffStrategy strategy, TableReference plusTable, TableReference minusTable, DiffStats stats, DiffTask task, MutableRange range) throws InterruptedException {
final RangeRequest request = range.getRangeRequest();
long startTime = System.currentTimeMillis();
PartialDiffStats partialStats = task.call(request, range, strategy);
stats.rowsOnlyInSource.addAndGet(partialStats.rowsOnlyInSource);
stats.rowsPartiallyInCommon.addAndGet(partialStats.rowsPartiallyInCommon);
stats.rowsCompletelyInCommon.addAndGet(partialStats.rowsCompletelyInCommon);
stats.rowsVisited.addAndGet(partialStats.rowsVisited);
stats.cellsOnlyInSource.addAndGet(partialStats.cellsOnlyInSource);
stats.cellsInCommon.addAndGet(partialStats.cellsInCommon);
if (log.isInfoEnabled()) {
log.info("Processed diff of " + "{} rows " + "{} rows only in source " + "{} rows partially in common " + "{} rows completely in common " + "{} cells only in source " + "{} cells in common " + "between {} and {} in {} ms.", SafeArg.of("rowsVisited", partialStats.rowsVisited), SafeArg.of("rowsOnlyInSource", partialStats.rowsOnlyInSource), SafeArg.of("rowsPartiallyInCommon", partialStats.rowsPartiallyInCommon), SafeArg.of("rowsCompletelyInCommon", partialStats.rowsCompletelyInCommon), SafeArg.of("cellsOnlyInSource", partialStats.cellsOnlyInSource), SafeArg.of("cellsInCommon", partialStats.cellsInCommon), LoggingArgs.tableRef("plusTable", plusTable), LoggingArgs.tableRef("minusTable", minusTable), SafeArg.of("timeTaken", System.currentTimeMillis() - startTime));
}
}
use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.
the class SchemaApiTestImpl method getRangeSecondColumn.
@Override
protected Map<String, StringValue> getRangeSecondColumn(Transaction transaction, String startRowKey, String endRowKey) {
SchemaApiTestTable table = tableFactory.getSchemaApiTestTable(transaction);
ColumnSelection secondColSelection = SchemaApiTestTable.getColumnSelection(SchemaApiTestTable.SchemaApiTestNamedColumn.COLUMN2);
RangeRequest rangeRequest = RangeRequest.builder().startRowInclusive(SchemaApiTestRow.of(startRowKey).persistToBytes()).endRowExclusive(SchemaApiTestRow.of(endRowKey).persistToBytes()).retainColumns(secondColSelection).build();
BatchingVisitableView<SchemaApiTestRowResult> rangeRequestResult = table.getRange(rangeRequest);
return rangeRequestResult.immutableCopy().stream().collect(Collectors.toMap(entry -> entry.getRowName().getComponent1(), SchemaApiTestTable.SchemaApiTestRowResult::getColumn2));
}
Aggregations