@Override public boolean filterRowKey(Cell cell) throws IOException { if (filterAllRemaining()) return true; boolean value = filter.filterRowKey(cell); changeFAR(value); return value; }
/** * Tests the the {@link WhileMatchFilter} works in combination with a * {@link Filter} that uses the * {@link Filter#filterRowKey(Cell)} method. * * See HBASE-2258. * * @throws Exception */ @Test public void testWhileMatchFilterWithFilterRowKey() throws Exception { Scan s = new Scan(); String prefix = "testRowOne"; WhileMatchFilter filter = new WhileMatchFilter(new PrefixFilter(Bytes.toBytes(prefix))); s.setFilter(filter); InternalScanner scanner = this.region.getScanner(s); while (true) { ArrayList<Cell> values = new ArrayList<>(); boolean isMoreResults = scanner.next(values); if (!isMoreResults || !Bytes.toString(CellUtil.cloneRow(values.get(0))).startsWith(prefix)) { assertTrue("The WhileMatchFilter should now filter all remaining", filter.filterAllRemaining()); } if (!isMoreResults) { break; } } }
@Test public void testWhileMatchFilterWithFilterRowKeyWithReverseScan() throws Exception { Scan s = new Scan(); String prefix = "testRowOne"; WhileMatchFilter filter = new WhileMatchFilter(new PrefixFilter( Bytes.toBytes(prefix))); s.setFilter(filter); s.setReversed(true); InternalScanner scanner = this.region.getScanner(s); while (true) { ArrayList<Cell> values = new ArrayList<>(); boolean isMoreResults = scanner.next(values); if (!isMoreResults || !Bytes.toString(CellUtil.cloneRow(values.get(0))).startsWith(prefix)) { Assert.assertTrue( "The WhileMatchFilter should now filter all remaining", filter.filterAllRemaining()); } if (!isMoreResults) { break; } } scanner.close(); }
/** * Tests the the {@link WhileMatchFilter} works in combination with a * {@link Filter} that uses the {@link Filter#filterCell(Cell)} method. * * See HBASE-2258. * * @throws Exception */ @Test public void testWhileMatchFilterWithFilterCell() throws Exception { Scan s = new Scan(); WhileMatchFilter filter = new WhileMatchFilter( new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS_ONE[0], CompareOperator.EQUAL, Bytes.toBytes("foo")) ); s.setFilter(filter); InternalScanner scanner = this.region.getScanner(s); while (true) { ArrayList<Cell> values = new ArrayList<>(); boolean isMoreResults = scanner.next(values); assertTrue("The WhileMatchFilter should now filter all remaining", filter.filterAllRemaining()); if (!isMoreResults) { break; } } }
/** * Tests the the {@link WhileMatchFilter} works in combination with a * {@link Filter} that uses the * {@link Filter#filterRow()} method. * * See HBASE-2258. * * @throws Exception */ @Test public void testWhileMatchFilterWithFilterRow() throws Exception { final int pageSize = 4; Scan s = new Scan(); WhileMatchFilter filter = new WhileMatchFilter(new PageFilter(pageSize)); s.setFilter(filter); InternalScanner scanner = this.region.getScanner(s); int scannerCounter = 0; while (true) { boolean isMoreResults = scanner.next(new ArrayList<>()); scannerCounter++; if (scannerCounter >= pageSize) { assertTrue("The WhileMatchFilter should now filter all remaining", filter.filterAllRemaining()); } if (!isMoreResults) { break; } } assertEquals("The page filter returned more rows than expected", pageSize, scannerCounter); }
@Test public void testWhileMatchFilterWithFilterRowWithReverseScan() throws Exception { final int pageSize = 4; Scan s = new Scan(); s.setReversed(true); WhileMatchFilter filter = new WhileMatchFilter(new PageFilter(pageSize)); s.setFilter(filter); InternalScanner scanner = this.region.getScanner(s); int scannerCounter = 0; while (true) { boolean isMoreResults = scanner.next(new ArrayList<>()); scannerCounter++; if (scannerCounter >= pageSize) { Assert.assertTrue( "The WhileMatchFilter should now filter all remaining", filter.filterAllRemaining()); } if (!isMoreResults) { break; } } scanner.close(); Assert.assertEquals("The page filter returned more rows than expected", pageSize, scannerCounter); }
@Override public boolean filterRowKey(Cell cell) throws IOException { if (filterAllRemaining()) return true; boolean value = filter.filterRowKey(cell); changeFAR(value); return value; }
@Override public boolean filterRowKey(Cell cell) throws IOException { if (filterAllRemaining()) return true; boolean value = filter.filterRowKey(cell); changeFAR(value); return value; }
/** * Tests the the {@link WhileMatchFilter} works in combination with a * {@link Filter} that uses the * {@link Filter#filterRowKey(Cell)} method. * * See HBASE-2258. * * @throws Exception */ @Test public void testWhileMatchFilterWithFilterRowKey() throws Exception { Scan s = new Scan(); String prefix = "testRowOne"; WhileMatchFilter filter = new WhileMatchFilter(new PrefixFilter(Bytes.toBytes(prefix))); s.setFilter(filter); InternalScanner scanner = this.region.getScanner(s); while (true) { ArrayList<Cell> values = new ArrayList<>(); boolean isMoreResults = scanner.next(values); if (!isMoreResults || !Bytes.toString(CellUtil.cloneRow(values.get(0))).startsWith(prefix)) { assertTrue("The WhileMatchFilter should now filter all remaining", filter.filterAllRemaining()); } if (!isMoreResults) { break; } } }
@Test public void testWhileMatchFilterWithFilterRowKeyWithReverseScan() throws Exception { Scan s = new Scan(); String prefix = "testRowOne"; WhileMatchFilter filter = new WhileMatchFilter(new PrefixFilter( Bytes.toBytes(prefix))); s.setFilter(filter); s.setReversed(true); InternalScanner scanner = this.region.getScanner(s); while (true) { ArrayList<Cell> values = new ArrayList<>(); boolean isMoreResults = scanner.next(values); if (!isMoreResults || !Bytes.toString(CellUtil.cloneRow(values.get(0))).startsWith(prefix)) { Assert.assertTrue( "The WhileMatchFilter should now filter all remaining", filter.filterAllRemaining()); } if (!isMoreResults) { break; } } scanner.close(); }
/** * Tests the the {@link WhileMatchFilter} works in combination with a * {@link Filter} that uses the {@link Filter#filterCell(Cell)} method. * * See HBASE-2258. * * @throws Exception */ @Test public void testWhileMatchFilterWithFilterCell() throws Exception { Scan s = new Scan(); WhileMatchFilter filter = new WhileMatchFilter( new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS_ONE[0], CompareOperator.EQUAL, Bytes.toBytes("foo")) ); s.setFilter(filter); InternalScanner scanner = this.region.getScanner(s); while (true) { ArrayList<Cell> values = new ArrayList<>(); boolean isMoreResults = scanner.next(values); assertTrue("The WhileMatchFilter should now filter all remaining", filter.filterAllRemaining()); if (!isMoreResults) { break; } } }
/** * Tests the the {@link WhileMatchFilter} works in combination with a * {@link Filter} that uses the * {@link Filter#filterRow()} method. * * See HBASE-2258. * * @throws Exception */ @Test public void testWhileMatchFilterWithFilterRow() throws Exception { final int pageSize = 4; Scan s = new Scan(); WhileMatchFilter filter = new WhileMatchFilter(new PageFilter(pageSize)); s.setFilter(filter); InternalScanner scanner = this.region.getScanner(s); int scannerCounter = 0; while (true) { boolean isMoreResults = scanner.next(new ArrayList<>()); scannerCounter++; if (scannerCounter >= pageSize) { assertTrue("The WhileMatchFilter should now filter all remaining", filter.filterAllRemaining()); } if (!isMoreResults) { break; } } assertEquals("The page filter returned more rows than expected", pageSize, scannerCounter); }
@Test public void testWhileMatchFilterWithFilterRowWithReverseScan() throws Exception { final int pageSize = 4; Scan s = new Scan(); s.setReversed(true); WhileMatchFilter filter = new WhileMatchFilter(new PageFilter(pageSize)); s.setFilter(filter); InternalScanner scanner = this.region.getScanner(s); int scannerCounter = 0; while (true) { boolean isMoreResults = scanner.next(new ArrayList<>()); scannerCounter++; if (scannerCounter >= pageSize) { Assert.assertTrue( "The WhileMatchFilter should now filter all remaining", filter.filterAllRemaining()); } if (!isMoreResults) { break; } } scanner.close(); Assert.assertEquals("The page filter returned more rows than expected", pageSize, scannerCounter); }