Search in sources :

Example 1 with WhileMatchFilter

use of org.apache.hadoop.hbase.filter.WhileMatchFilter in project hbase by apache.

the class TestScanner method testFilters.

@Test
public void testFilters() throws IOException {
    try {
        this.region = TEST_UTIL.createLocalHRegion(TESTTABLEDESC, null, null);
        HBaseTestCase.addContent(this.region, HConstants.CATALOG_FAMILY);
        byte[] prefix = Bytes.toBytes("ab");
        Filter newFilter = new PrefixFilter(prefix);
        Scan scan = new Scan();
        scan.setFilter(newFilter);
        rowPrefixFilter(scan);
        byte[] stopRow = Bytes.toBytes("bbc");
        newFilter = new WhileMatchFilter(new InclusiveStopFilter(stopRow));
        scan = new Scan();
        scan.setFilter(newFilter);
        rowInclusiveStopFilter(scan, stopRow);
    } finally {
        HBaseTestingUtility.closeRegionAndWAL(this.region);
    }
}
Also used : PrefixFilter(org.apache.hadoop.hbase.filter.PrefixFilter) InclusiveStopFilter(org.apache.hadoop.hbase.filter.InclusiveStopFilter) WhileMatchFilter(org.apache.hadoop.hbase.filter.WhileMatchFilter) PrefixFilter(org.apache.hadoop.hbase.filter.PrefixFilter) Filter(org.apache.hadoop.hbase.filter.Filter) WhileMatchFilter(org.apache.hadoop.hbase.filter.WhileMatchFilter) InclusiveStopFilter(org.apache.hadoop.hbase.filter.InclusiveStopFilter) Scan(org.apache.hadoop.hbase.client.Scan) Test(org.junit.Test)

Example 2 with WhileMatchFilter

use of org.apache.hadoop.hbase.filter.WhileMatchFilter in project hbase by apache.

the class TestFromClientSide method createScanWithRowFilter.

/*
   * @param key
   * @param op
   * @param startRow
   * @return Scan with RowFilter that does CompareOp op on passed key.
   */
private Scan createScanWithRowFilter(final byte[] key, final byte[] startRow, CompareFilter.CompareOp op) {
    // Make sure key is of some substance... non-null and > than first key.
    assertTrue(key != null && key.length > 0 && Bytes.BYTES_COMPARATOR.compare(key, new byte[] { 'a', 'a', 'a' }) >= 0);
    LOG.info("Key=" + Bytes.toString(key));
    Scan s = startRow == null ? new Scan() : new Scan(startRow);
    Filter f = new RowFilter(op, new BinaryComparator(key));
    f = new WhileMatchFilter(f);
    s.setFilter(f);
    return s;
}
Also used : RowFilter(org.apache.hadoop.hbase.filter.RowFilter) FirstKeyOnlyFilter(org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter) WhileMatchFilter(org.apache.hadoop.hbase.filter.WhileMatchFilter) PrefixFilter(org.apache.hadoop.hbase.filter.PrefixFilter) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter) KeyOnlyFilter(org.apache.hadoop.hbase.filter.KeyOnlyFilter) CompareFilter(org.apache.hadoop.hbase.filter.CompareFilter) InclusiveStopFilter(org.apache.hadoop.hbase.filter.InclusiveStopFilter) RowFilter(org.apache.hadoop.hbase.filter.RowFilter) Filter(org.apache.hadoop.hbase.filter.Filter) SingleColumnValueFilter(org.apache.hadoop.hbase.filter.SingleColumnValueFilter) WhileMatchFilter(org.apache.hadoop.hbase.filter.WhileMatchFilter) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator)

Aggregations

Filter (org.apache.hadoop.hbase.filter.Filter)2 InclusiveStopFilter (org.apache.hadoop.hbase.filter.InclusiveStopFilter)2 PrefixFilter (org.apache.hadoop.hbase.filter.PrefixFilter)2 WhileMatchFilter (org.apache.hadoop.hbase.filter.WhileMatchFilter)2 Scan (org.apache.hadoop.hbase.client.Scan)1 BinaryComparator (org.apache.hadoop.hbase.filter.BinaryComparator)1 CompareFilter (org.apache.hadoop.hbase.filter.CompareFilter)1 FirstKeyOnlyFilter (org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter)1 KeyOnlyFilter (org.apache.hadoop.hbase.filter.KeyOnlyFilter)1 QualifierFilter (org.apache.hadoop.hbase.filter.QualifierFilter)1 RowFilter (org.apache.hadoop.hbase.filter.RowFilter)1 SingleColumnValueFilter (org.apache.hadoop.hbase.filter.SingleColumnValueFilter)1 Test (org.junit.Test)1