Package org.apache.accumulo.core.iterators

Examples of org.apache.accumulo.core.iterators.FilteringIterator


  public Iterator<Entry<Key,Value>> iterator() {
    SortedKeyValueIterator<Key,Value> i = new SortedMapIterator(table.table);
    try {
      i = createFilter(i);
      i.seek(range, createColumnBSS(columns), !columns.isEmpty());
      return new IteratorAdapter(new FilteringIterator(i, Collections.singletonList(new RangeFilter(range))));
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
   
  }
View Full Code Here


    for (Range range : ranges) {
      SortedKeyValueIterator<Key,Value> i = new SortedMapIterator(table.table);
      try {
        i = createFilter(i);
        i.seek(range, createColumnBSS(columns), !columns.isEmpty());
        chain.addIterator(new IteratorAdapter(new FilteringIterator(i, Collections.singletonList(new RangesFilter(ranges)))));
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
    return chain;
View Full Code Here

   
    int size = filter(tm, f);
    assertTrue("size = " + size, size == 100);
   
    try {
      FilteringIterator fi = new FilteringIterator(new SortedMapIterator(tm), f);
      Key k = new Key(new Text("500"));
      fi.seek(new Range(k, null), EMPTY_COL_FAMS, false);
      TreeMap<Key,Value> tmOut = new TreeMap<Key,Value>();
      while (fi.hasTop()) {
        tmOut.put(fi.getTopKey(), fi.getTopValue());
        fi.next();
      }
      assertTrue(tmOut.size() == 50);
    } catch (IOException e) {
      assertFalse(true);
    }
View Full Code Here

    assertTrue("size was " + size, size == 1000);
  }
 
  private int filter(TreeMap<Key,Value> tm, ArrayList<Filter> f) {
    try {
      FilteringIterator fi = new FilteringIterator(new SortedMapIterator(tm), f);
      TreeMap<Key,Value> tmOut = new TreeMap<Key,Value>();
      while (fi.hasTop()) {
        tmOut.put(fi.getTopKey(), fi.getTopValue());
        fi.next();
      }
      return tmOut.size();
    } catch (IOException ex) {
      fail(ex.getMessage());
      return -1;
View Full Code Here

   
    Key k1 = nkv(tm, "boo1", "yup", "20080201", "dog");
    Key k2 = nkv(tm, "boo1", "yap", "20080202", "cat");
    Key k3 = nkv(tm, "boo2", "yip", "20080203", "hamster");
   
    FilteringIterator rei = new FilteringIterator();
   
    HashMap<String,String> options = new HashMap<String,String>();
   
    options.put("0", RegExFilter.class.getName());
    options.put("0." + RegExFilter.ROW_REGEX, ".*2");
    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
   
    assertTrue(rei.hasTop());
    assertTrue(rei.getTopKey().equals(k3));
    rei.next();
    assertFalse(rei.hasTop());
   
    // -----------------------------------------------------
    options.clear();
   
    options.put("0", RegExFilter.class.getName());
    options.put("0." + RegExFilter.COLF_REGEX, "ya.*");
    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
   
    assertTrue(rei.hasTop());
    assertTrue(rei.getTopKey().equals(k2));
    rei.next();
    assertFalse(rei.hasTop());
   
    // -----------------------------------------------------
    options.clear();
   
    options.put("0", RegExFilter.class.getName());
    options.put("0." + RegExFilter.COLQ_REGEX, ".*01");
    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
   
    assertTrue(rei.hasTop());
    assertTrue(rei.getTopKey().equals(k1));
    rei.next();
    assertFalse(rei.hasTop());
   
    // -----------------------------------------------------
    options.clear();
   
    options.put("0", RegExFilter.class.getName());
    options.put("0." + RegExFilter.VALUE_REGEX, ".*at");
    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
   
    assertTrue(rei.hasTop());
    assertTrue(rei.getTopKey().equals(k2));
    rei.next();
    assertFalse(rei.hasTop());
   
    // -----------------------------------------------------
    options.clear();
   
    options.put("0", RegExFilter.class.getName());
    options.put("0." + RegExFilter.VALUE_REGEX, ".*ap");
    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
   
    assertFalse(rei.hasTop());
   
    // -----------------------------------------------------
    options.clear();
   
    options.put("0", RegExFilter.class.getName());
    options.put("0." + RegExFilter.COLF_REGEX, "ya.*");
    options.put("0." + RegExFilter.VALUE_REGEX, ".*at");
    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
   
    assertTrue(rei.hasTop());
    assertTrue(rei.getTopKey().equals(k2));
    rei.next();
    assertFalse(rei.hasTop());
   
    // -----------------------------------------------------
    options.clear();
   
    options.put("0", RegExFilter.class.getName());
    options.put("0." + RegExFilter.COLF_REGEX, "ya.*");
    options.put("0." + RegExFilter.VALUE_REGEX, ".*ap");
    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
   
    assertFalse(rei.hasTop());
   
    // -----------------------------------------------------
    options.clear();
   
    options.put("0", RegExFilter.class.getName());
    options.put("0." + RegExFilter.ROW_REGEX, "boo1");
    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
   
    assertTrue(rei.hasTop());
    assertTrue(rei.getTopKey().equals(k2));
    rei.next();
    assertTrue(rei.hasTop());
    assertTrue(rei.getTopKey().equals(k1));
    rei.next();
    assertFalse(rei.hasTop());
   
    // -----------------------------------------------------
    options.clear();
   
    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
   
    assertTrue(rei.hasTop());
    assertTrue(rei.getTopKey().equals(k2));
    rei.next();
    assertTrue(rei.hasTop());
    assertTrue(rei.getTopKey().equals(k1));
    rei.next();
    assertTrue(rei.hasTop());
    assertTrue(rei.getTopKey().equals(k3));
    rei.next();
    assertFalse(rei.hasTop());
   
    // -----------------------------------------------------
    options.clear();
   
    options.put("0", RegExFilter.class.getName());
    options.put("0." + RegExFilter.ROW_REGEX, "hamster");
    options.put("0." + RegExFilter.COLQ_REGEX, "hamster");
    options.put("0." + RegExFilter.VALUE_REGEX, "hamster");
    options.put("0." + RegExFilter.OR_FIELDS, "true");
    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
   
    assertTrue(rei.hasTop());
    assertTrue(rei.getTopKey().equals(k3));
    rei.next();
    assertFalse(rei.hasTop());
  }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.iterators.FilteringIterator

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.