Package org.apache.accumulo.core.iterators

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


   
    Key k1 = nkv(tm, "boo1", "yup", "20080201", "dog");
    Key k2 = nkv(tm, "boo1", "yap", "20080202", "cat");
    Key k3 = nkv(tm, "boo2", "yip", "20080203", "hamster");
   
    RegExIterator rei = new RegExIterator();
   
    HashMap<String,String> options = new HashMap<String,String>();
   
    options.put(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(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(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(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(RegExFilter.VALUE_REGEX, ".*ap");
    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
   
    assertFalse(rei.hasTop());
   
    // -----------------------------------------------------
    options.clear();
   
    options.put(RegExFilter.COLF_REGEX, "ya.*");
    options.put(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(RegExFilter.COLF_REGEX, "ya.*");
    options.put(RegExFilter.VALUE_REGEX, ".*ap");
    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
   
    assertFalse(rei.hasTop());
   
    // -----------------------------------------------------
    options.clear();
   
    options.put(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());
  }
View Full Code Here

TOP

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

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.