use of com.google.bigtable.v2.Row in project beam by apache.
the class BigtableIOTest method makeTableData.
/** Helper function to create a table and return the rows that it created. */
private static List<Row> makeTableData(String tableId, int numRows) {
service.createTable(tableId);
Map<ByteString, ByteString> testData = service.getTable(tableId);
List<Row> testRows = new ArrayList<>(numRows);
for (int i = 0; i < numRows; ++i) {
ByteString key = ByteString.copyFromUtf8(String.format("key%09d", i));
ByteString value = ByteString.copyFromUtf8(String.format("value%09d", i));
testData.put(key, value);
testRows.add(makeRow(key, value));
}
return testRows;
}
use of com.google.bigtable.v2.Row in project beam by apache.
the class BigtableIOTest method testReadingWithFilter.
/** Tests reading all rows using a filter. */
@Test
public void testReadingWithFilter() throws Exception {
final String table = "TEST-FILTER-TABLE";
final int numRows = 1001;
List<Row> testRows = makeTableData(table, numRows);
String regex = ".*17.*";
final KeyMatchesRegex keyPredicate = new KeyMatchesRegex(regex);
Iterable<Row> filteredRows = Iterables.filter(testRows, new Predicate<Row>() {
@Override
public boolean apply(@Nullable Row input) {
verifyNotNull(input, "input");
return keyPredicate.apply(input.getKey());
}
});
RowFilter filter = RowFilter.newBuilder().setRowKeyRegexFilter(ByteString.copyFromUtf8(regex)).build();
service.setupSampleRowKeys(table, 5, 10L);
runReadTest(defaultRead.withTableId(table).withRowFilter(filter), Lists.newArrayList(filteredRows));
}
Aggregations