()
| 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 |
nothing calls this directly
no test coverage detected