Package org.apache.hadoop.hbase.filter

Examples of org.apache.hadoop.hbase.filter.Filter


        HTable table = getTable(tableName);
        byte [][] columnsArray = null;
        columnsArray = columns.toArray(new byte[0][]);
        Scan scan = new Scan(startAndPrefix);
        scan.addColumns(columnsArray);
        Filter f = new WhileMatchFilter(
            new PrefixFilter(startAndPrefix));
        scan.setFilter(f);
        return addScanner(table.getScanner(scan));
      } catch (IOException e) {
        throw new IOError(e.getMessage());
View Full Code Here


 
  public void testFilters() throws IOException {
    try {
      this.r = createNewHRegion(REGION_INFO.getTableDesc(), null, null);
      addContent(this.r, HConstants.CATALOG_FAMILY);
      Filter newFilter = new PrefixFilter(Bytes.toBytes("ab"));
      Scan scan = new Scan();
      scan.setFilter(newFilter);
      rowPrefixFilter(scan);
      RowFilterInterface oldFilter = new PrefixRowFilter(Bytes.toBytes("ab"));
      scan = new Scan();
View Full Code Here

      scan = new Scan(startRow);
      byte [] prefix = Bytes.toBytes(getName());
      scan.setFilter(new PrefixFilter(prefix));
      sb = Writables.getBytes(scan);
      desScan = (Scan)Writables.getWritable(sb, new Scan());
      Filter f = desScan.getFilter();
      assertTrue(f instanceof PrefixFilter);
    }
   
    assertEquals(scan.getMaxVersions(), desScan.getMaxVersions());
    TimeRange tr = scan.getTimeRange();
View Full Code Here

        if (scanner != null) scanner.close();
      }
    }

    protected Scan constructScan(byte[] valuePrefix) throws IOException {
      Filter filter = new SingleColumnValueFilter(
          FAMILY_NAME, QUALIFIER_NAME, CompareFilter.CompareOp.EQUAL,
          new BinaryComparator(valuePrefix)
      );
      Scan scan = new Scan();
      scan.addColumn(FAMILY_NAME, QUALIFIER_NAME);
View Full Code Here

    // 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;
  }
View Full Code Here

      put.add(FAMILY, QUALIFIERS[i], VALUE);
      ht.put(put);
    }
    Scan scan = new Scan();
    scan.addFamily(FAMILY);
    Filter filter = new QualifierFilter(CompareOp.EQUAL,
      new RegexStringComparator("col[1-5]"));
    scan.setFilter(filter);
    ResultScanner scanner = ht.getScanner(scan);
    int expectedIndex = 1;
    for(Result result : ht.getScanner(scan)) {
View Full Code Here

      put.add(FAMILY, QUALIFIERS[i], VALUE);
      ht.put(put);
    }
    Scan scan = new Scan();
    scan.addFamily(FAMILY);
    Filter filter = new KeyOnlyFilter(true);
    scan.setFilter(filter);
    ResultScanner scanner = ht.getScanner(scan);
    int count = 0;
    for(Result result : ht.getScanner(scan)) {
      assertEquals(result.size(), 1);
View Full Code Here

      // Check two things:
      // 1. result list contains expected values
      // 2. result list is sorted properly

      Scan scan = new Scan();
      Filter filter = new SingleColumnValueExcludeFilter(cf_essential, col_normal,
          CompareOp.NOT_EQUAL, filtered_val);
      scan.setFilter(filter);
      scan.setLoadColumnFamiliesOnDemand(true);
      InternalScanner s = region.getScanner(scan);
View Full Code Here

        region.put(put);
      }

      Scan scan = new Scan();
      scan.setLoadColumnFamiliesOnDemand(true);
      Filter bogusFilter = new FilterBase() {
        @Override
        public boolean isFamilyEssential(byte[] name) {
          return Bytes.equals(name, cf_first);
        }
      };
View Full Code Here

       
        mayHaveRows = mayHaveRows || Bytes.compareTo(scan.getStartRow(), scan.getStopRow()) < 0;
       
        // If the scan is using skip scan filter, intersect and replace the filter.
        if (mayHaveRows && useSkipScan) {
            Filter filter = scan.getFilter();
            if (filter instanceof SkipScanFilter) {
                SkipScanFilter oldFilter = (SkipScanFilter)filter;
                SkipScanFilter newFilter = oldFilter.intersect(startKey, stopKey);
                if (newFilter == null) {
                    return false;
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.filter.Filter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.