MCPcopy Index your code
hub / github.com/OpenTSDB/asynchbase / basicScanMultipleRegions

Method basicScanMultipleRegions

test/TestIntegration.java:319–368  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

317 }
318
319 @Test
320 public void basicScanMultipleRegions() throws Exception {
321 splitTable(table, "s10");
322 splitTable(table, "s20");
323 splitTable(table, "s30");
324 List<Deferred<Object>> list = new ArrayList<Deferred<Object>>();
325 for(int i = 0 ; i < 40; i++) {
326 String key = String.format("s%02d", i);
327 PutRequest putRequest = new PutRequest(table, key, family, "q" + i, "v" + i);
328 list.add(client.put(putRequest));
329 }
330
331 Deferred.groupInOrder(list).join();
332
333 final Scanner scanner = client.newScanner(table);
334 scanner.setFamily(family);
335 scanner.setStartKey("s15");
336 scanner.setStopKey("s35");
337
338 class cb implements Callback<Object, ArrayList<ArrayList<KeyValue>>> {
339 private int n = 15;
340 public Object call(final ArrayList<ArrayList<KeyValue>> rows) {
341 if (rows == null) {
342 return null;
343 }
344
345 try {
346 assertSizeIs(5, rows);
347 final ArrayList<KeyValue> kvs = rows.get(0);
348 final KeyValue kv = kvs.get(0);
349 assertSizeIs(1, kvs);
350 assertEq(String.format("s%02d", n), kv.key());
351 assertEq("q" + n, kv.qualifier());
352 assertEq("v" + n, kv.value());
353 n += 5;
354 return scanner.nextRows(5).addCallback(this);
355 } catch (AssertionError e) {
356 // Deferred doesn't catch Errors on purpose, so transform any
357 // assertion failure into an Exception.
358 throw new RuntimeException("Asynchronous failure", e);
359 }
360 }
361 }
362
363 try {
364 scanner.nextRows(5).addCallback(new cb()).join();
365 } finally {
366 scanner.close().join();
367 }
368 }
369
370 /** Basic scan test. */
371 @Test

Callers

nothing calls this directly

Calls 9

splitTableMethod · 0.95
setFamilyMethod · 0.95
setStartKeyMethod · 0.95
setStopKeyMethod · 0.95
nextRowsMethod · 0.95
closeMethod · 0.95
putMethod · 0.80
newScannerMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected