IteratorSetting is = new IteratorSetting(1, RegExFilter.class);
RegExFilter.setRegexs(is, ".*2", null, null, null, false);
assertTrue(rei.validateOptions(is.getOptions()));
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(rei.hasTop());
assertTrue(rei.getTopKey().equals(k3));
rei.next();
assertFalse(rei.hasTop());
// -----------------------------------------------------
is.clearOptions();
RegExFilter.setRegexs(is, null, "ya.*", null, null, false);
assertTrue(rei.validateOptions(is.getOptions()));
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(rei.hasTop());
assertTrue(rei.getTopKey().equals(k2));
rei.next();
assertFalse(rei.hasTop());
// -----------------------------------------------------
is.clearOptions();
RegExFilter.setRegexs(is, null, null, ".*01", null, false);
assertTrue(rei.validateOptions(is.getOptions()));
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(rei.hasTop());
assertTrue(rei.getTopKey().equals(k1));
rei.next();
assertFalse(rei.hasTop());
// -----------------------------------------------------
is.clearOptions();
RegExFilter.setRegexs(is, null, null, null, ".*at", false);
assertTrue(rei.validateOptions(is.getOptions()));
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(rei.hasTop());
assertTrue(rei.getTopKey().equals(k2));
rei.next();
assertFalse(rei.hasTop());
// -----------------------------------------------------
is.clearOptions();
RegExFilter.setRegexs(is, null, null, null, ".*ap", false);
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
assertFalse(rei.hasTop());
// -----------------------------------------------------
is.clearOptions();
RegExFilter.setRegexs(is, null, "ya.*", null, ".*at", false);
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(rei.hasTop());
assertTrue(rei.getTopKey().equals(k2));
rei.next();
assertFalse(rei.hasTop());
// -----------------------------------------------------
is.clearOptions();
RegExFilter.setRegexs(is, null, "ya.*", null, ".*ap", false);
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
assertFalse(rei.hasTop());
// -----------------------------------------------------
is.clearOptions();
RegExFilter.setRegexs(is, "boo1", null, null, null, false);
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(rei.hasTop());
assertTrue(rei.getTopKey().equals(k2));
rei.next();
assertTrue(rei.hasTop());
assertTrue(rei.getTopKey().equals(k1));
rei.next();
assertFalse(rei.hasTop());
// -----------------------------------------------------
is.clearOptions();
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
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());
// -----------------------------------------------------
is.clearOptions();
RegExFilter.setRegexs(is, "hamster", null, "hamster", "hamster", true);
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(rei.hasTop());
assertTrue(rei.getTopKey().equals(k3));
rei.next();
assertFalse(rei.hasTop());
// -----------------------------------------------------
is.clearOptions();
RegExFilter.setRegexs(is, null, "ya.*", "hamster", null, true);
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(rei.hasTop());
assertTrue(rei.getTopKey().equals(k2));
rei.next();
assertFalse(rei.hasTop());
is.clearOptions();
RegExFilter.setRegexs(is, null, "ya.*", "hamster", null, true);
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
rei.deepCopy(new DefaultIteratorEnvironment());
// -----------------------------------------------------
String multiByteText = new String("\u6d67" + "\u6F68" + "\u7067");
String multiByteRegex = new String(".*" + "\u6F68" + ".*");
Key k4 = new Key("boo4".getBytes(), "hoo".getBytes(), "20080203".getBytes(), "".getBytes(), 1l);
Value inVal = new Value(multiByteText.getBytes("UTF-8"));
tm.put(k4, inVal);
is.clearOptions();
RegExFilter.setRegexs(is, null, null, null, multiByteRegex, true);
rei.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
rei.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(rei.hasTop());
Value outValue = rei.getTopValue();
String outVal = new String(outValue.get(), "UTF-8");