use of com.palantir.atlasdb.table.description.test.StringValue in project atlasdb by palantir.
the class SchemaApiTestV2Table method getSmallRowRangeColumn2.
/**
* Returns a mapping from all the row keys in a rangeRequest to their value at column Column2
* (if that column exists for the row-key). As the Column2 values are all loaded in memory,
* do not use for large amounts of data. The order of results is preserved in the map.
*/
public LinkedHashMap<String, StringValue> getSmallRowRangeColumn2(RangeRequest rangeRequest) {
ColumnSelection colSelection = ColumnSelection.create(ImmutableList.of(PtBytes.toCachedBytes("d")));
rangeRequest = rangeRequest.getBuilder().retainColumns(colSelection).build();
Preconditions.checkArgument(rangeRequest.getColumnNames().size() <= 1, "Must not request columns other than Column2.");
LinkedHashMap<String, StringValue> resultsMap = new LinkedHashMap<>();
BatchingVisitableView.of(t.getRange(tableRef, rangeRequest)).immutableCopy().forEach(entry -> {
SchemaApiTestTable.SchemaApiTestRowResult resultEntry = SchemaApiTestTable.SchemaApiTestRowResult.of(entry);
resultsMap.put(resultEntry.getRowName().getComponent1(), resultEntry.getColumn2());
});
return resultsMap;
}
use of com.palantir.atlasdb.table.description.test.StringValue in project atlasdb by palantir.
the class SchemaApiTestV2Table method getSmallRowRangeColumn2.
/**
* Returns a mapping from the first sizeLimit row keys in a rangeRequest to their value
* at column Column2 (if that column exists). As the Column2 entries are all loaded in memory,
* do not use for large values of sizeLimit. The order of results is preserved in the map.
*/
public LinkedHashMap<String, StringValue> getSmallRowRangeColumn2(RangeRequest rangeRequest, int sizeLimit) {
ColumnSelection colSelection = ColumnSelection.create(ImmutableList.of(PtBytes.toCachedBytes("d")));
rangeRequest = rangeRequest.getBuilder().retainColumns(colSelection).batchHint(sizeLimit).build();
Preconditions.checkArgument(rangeRequest.getColumnNames().size() <= 1, "Must not request columns other than Column2.");
LinkedHashMap<String, StringValue> resultsMap = new LinkedHashMap<>();
BatchingVisitableView.of(t.getRange(tableRef, rangeRequest)).batchAccept(sizeLimit, batch -> {
batch.forEach(entry -> {
SchemaApiTestTable.SchemaApiTestRowResult resultEntry = SchemaApiTestTable.SchemaApiTestRowResult.of(entry);
resultsMap.put(resultEntry.getRowName().getComponent1(), resultEntry.getColumn2());
});
// stops the traversal after the first batch
return false;
});
return resultsMap;
}
Aggregations