Examples of FilteringIterator


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

   
    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
Copyright © 2018 www.massapi.com. 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.