use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.
the class WhereClausesTest method endOnly.
@Test
public void endOnly() {
RangeRequest request = RangeRequest.builder().endRowExclusive(END).build();
WhereClauses whereClauses = WhereClauses.create("i", request);
List<String> expectedClauses = ImmutableList.of("i.row_name < ?");
assertEquals(whereClauses.getClauses(), expectedClauses);
checkWhereArguments(whereClauses, ImmutableList.of(END));
}
use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.
the class DbKvsGetRanges method getFirstPages.
private Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> getFirstPages(TableReference tableRef, List<RangeRequest> requests, long timestamp) {
List<String> subQueries = Lists.newArrayList();
List<Object> argsList = Lists.newArrayList();
for (int i = 0; i < requests.size(); i++) {
RangeRequest request = requests.get(i);
Pair<String, List<Object>> queryAndArgs = getRangeQueryAndArgs(tableRef, request.getStartInclusive(), request.getEndExclusive(), request.isReverse(), request.getBatchHint() == null ? 1 : request.getBatchHint(), i);
subQueries.add(queryAndArgs.lhSide);
argsList.addAll(queryAndArgs.rhSide);
}
String query = Joiner.on(") UNION ALL (").appendTo(new StringBuilder("("), subQueries).append(")").toString();
Object[] args = argsList.toArray();
TimingState timer = logTimer.begin("Table: " + tableRef.getQualifiedName() + " get_page");
try {
return getFirstPagesFromDb(tableRef, requests, timestamp, query, args);
} finally {
timer.end();
}
}
use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.
the class KeyValueServiceValidator method validateTable.
private void validateTable(TableReference table, int limit, Transaction t1, Transaction t2) {
RangeRequest.Builder builder = RangeRequest.builder().batchHint(limit);
byte[] nextRowName = new byte[0];
while (nextRowName != null) {
RangeRequest range = builder.startRowInclusive(nextRowName).build();
nextRowName = validateAndGetNextRowName(table, limit, t1, t2, range);
}
}
use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.
the class KeyValueServicePuncherStore method get.
@Override
public Long get(Long timeMillis) {
byte[] row = EncodingUtils.encodeUnsignedVarLong(timeMillis);
EncodingUtils.flipAllBitsInPlace(row);
RangeRequest rangeRequest = RangeRequest.builder().startRowInclusive(row).batchHint(1).build();
ClosableIterator<RowResult<Value>> result = keyValueService.getRange(AtlasDbConstants.PUNCH_TABLE, rangeRequest, Long.MAX_VALUE);
try {
if (result.hasNext()) {
return EncodingUtils.decodeUnsignedVarLong(result.next().getColumns().get(COLUMN).getContents());
} else {
return Long.MIN_VALUE;
}
} finally {
result.close();
}
}
use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.
the class KeyValueServicePuncherStore method getMillisForTimestamp.
public static long getMillisForTimestamp(KeyValueService kvs, long timestamp) {
long timestampExclusive = timestamp + 1;
// punch table is keyed by the real value we're trying to find so we have to do a whole table
// scan, which is fine because this table should be really small
byte[] startRow = EncodingUtils.encodeUnsignedVarLong(Long.MAX_VALUE);
EncodingUtils.flipAllBitsInPlace(startRow);
RangeRequest rangeRequest = RangeRequest.builder().startRowInclusive(startRow).batchHint(1).build();
ClosableIterator<RowResult<Value>> result = kvs.getRange(AtlasDbConstants.PUNCH_TABLE, rangeRequest, timestampExclusive);
try {
if (result.hasNext()) {
byte[] encodedMillis = result.next().getRowName();
EncodingUtils.flipAllBitsInPlace(encodedMillis);
return EncodingUtils.decodeUnsignedVarLong(encodedMillis);
} else {
return 0L;
}
} finally {
result.close();
}
}
Aggregations