/** * Tests that scan on a table throws {@link RetriesExhaustedException} when the operation takes * longer than 'hbase.client.scanner.timeout.period'. */ @Test(expected = RetriesExhaustedException.class) public void testScanTimeout() throws Exception { DELAY_SCAN = 600; ResultScanner scanner = table.getScanner(new Scan()); scanner.next(); }
private static Result [] getResult(Table table, Scan scan) throws IOException { ResultScanner scanner = table.getScanner(scan); Result[] next = scanner.next(1); assertTrue(next.length == 1); return next; }
private Result getReverseScanResult(byte[] tableName, byte[] row, byte[] family) throws IOException { Scan scan = new Scan(row); scan.setReversed(true); scan.addFamily(family); scan.setStartRow(row); try (Table table = getTable(tableName); ResultScanner scanner = table.getScanner(scan)) { return scanner.next(); } }
private List<Result> doScan(Scan scan) throws IOException { List<Result> results = new ArrayList<>(); try (Table table = TEST_UTIL.getConnection().getTable(TABLE_NAME); ResultScanner scanner = table.getScanner(scan)) { for (Result r; (r = scanner.next()) != null;) { results.add(r); } } return assertAndCreateCompleteResults(results); }
private void verifyRowCount(Table table, int expectedRegionNum) throws IOException { ResultScanner scanner = table.getScanner(new Scan()); int rowCount = 0; while (scanner.next() != null) { rowCount++; } assertEquals(expectedRegionNum, rowCount); scanner.close(); }
private boolean peerHasAllNormalRows() throws IOException { try (ResultScanner scanner = htable2.getScanner(new Scan())) { Result[] results = scanner.next(ROWS_COUNT); if (results.length != ROWS_COUNT) { return false; } for (int i = 0; i < results.length; i++) { Assert.assertArrayEquals(generateRowKey(i), results[i].getRow()); } return true; } }
public void testEquivalenceOfScanResults(Table table, Scan scan1, Scan scan2) throws Exception { ResultScanner scanner1 = table.getScanner(scan1); ResultScanner scanner2 = table.getScanner(scan2); Result r1 = null; Result r2 = null; int count = 0; while ((r1 = scanner1.next()) != null) { r2 = scanner2.next(); assertTrue(r2 != null); compareResults(r1, r2, "Comparing result #" + count); count++; } r2 = scanner2.next(); assertTrue("r2: " + r2 + " Should be null", r2 == null); scanner1.close(); scanner2.close(); }
@Override void testRow(final int i) throws IOException { if (this.testScanner == null) { Scan scan = new Scan(format(this.startRow)); scan.addColumn(FAMILY_NAME, QUALIFIER_NAME); this.testScanner = table.getScanner(scan); } testScanner.next(); }
@Test public void testDontThrowUnknowScannerExceptionToClient() throws Exception { Table table = createTestTable(TableName.valueOf(name.getMethodName()), ROWS, FAMILIES, QUALIFIERS, VALUE); Scan scan = new Scan(); scan.setCaching(1); ResultScanner scanner = table.getScanner(scan); scanner.next(); Thread.sleep(timeout * 2); int count = 1; while (scanner.next() != null) { count++; } assertEquals(NUM_ROWS, count); scanner.close(); }
private int cellsCount(Table table, Filter filter) throws IOException { Scan scan = new Scan().setFilter(filter).readAllVersions(); try (ResultScanner scanner = table.getScanner(scan)) { List<Cell> results = new ArrayList<>(); Result result; while ((result = scanner.next()) != null) { result.listCells().forEach(results::add); } return results.size(); } }
protected static void runSmallBatchTest() throws IOException, InterruptedException { // normal Batch tests loadData("", row); Scan scan = new Scan(); ResultScanner scanner1 = htable1.getScanner(scan); Result[] res1 = scanner1.next(NB_ROWS_IN_BATCH); scanner1.close(); assertEquals(NB_ROWS_IN_BATCH, res1.length); waitForReplication(NB_ROWS_IN_BATCH, NB_RETRIES); }
private void verifyRecordNotPresentInQuotaTable() throws Exception { // Verify that the record doesn't exist in the QuotaTableUtil.QUOTA_TABLE_NAME try (Table quotaTable = TEST_UTIL.getConnection().getTable(QuotaTableUtil.QUOTA_TABLE_NAME); ResultScanner scanner = quotaTable.getScanner(new Scan())) { assertNull("Did not expect to find a quota entry", scanner.next()); } }
@Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(tableName)) { Scan s = new Scan(); ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(1, next.length); } return null; } };
private Result getReverseScanResult(Table table, byte[] row, byte[] fam) throws IOException { Scan scan = new Scan(row); scan.setSmall(true); scan.setReversed(true); scan.setCaching(1); scan.addFamily(fam); try (ResultScanner scanner = table.getScanner(scan)) { return scanner.next(); } }
@Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(tableName)) { Scan s = new Scan(); ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); } return null; } };
@Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(tableName)) { Scan s = new Scan(); ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); } return null; } };
@Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(tableName)) { Scan s = new Scan(); ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(1, next.length); } return null; } };
private void scan(Table table) throws IOException { Scan scan = new Scan(); scan.setCaching(1); scan.setCacheBlocks(false); ResultScanner scanner = table.getScanner(scan); try { scanner.next(); } finally { scanner.close(); } } }
@Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(tableName)) { Scan s = new Scan(); ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); } return null; } };
@Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(tableName)) { Scan s = new Scan(); ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); } return null; } };