use of org.apache.accumulo.core.iterators.DefaultIteratorEnvironment in project accumulo by apache.
the class RowFilterTest method testChainedRowFilters.
@Test
public void testChainedRowFilters() throws Exception {
SortedMapIterator source = new SortedMapIterator(createKeyValues());
RowFilter filter0 = new TrueFilter();
filter0.init(source, Collections.emptyMap(), new DefaultIteratorEnvironment());
RowFilter filter = new TrueFilter();
filter.init(filter0, Collections.emptyMap(), new DefaultIteratorEnvironment());
filter.seek(new Range(), Collections.emptySet(), false);
assertEquals(new HashSet<>(Arrays.asList("0", "1", "2", "3", "4")), getRows(filter));
}
use of org.apache.accumulo.core.iterators.DefaultIteratorEnvironment in project accumulo by apache.
the class FilterTest method test2aNegate.
/**
* Test for fix to ACCUMULO-1604: ColumnAgeOffFilter was throwing an error when using negate
*/
@Test
public void test2aNegate() throws IOException {
Text colf = new Text("a");
Text colq = new Text("b");
Value dv = new Value();
TreeMap<Key, Value> tm = new TreeMap<>();
IteratorSetting is = new IteratorSetting(1, ColumnAgeOffFilter.class);
ColumnAgeOffFilter.addTTL(is, new IteratorSetting.Column("a"), 901l);
ColumnAgeOffFilter.setNegate(is, true);
long ts = System.currentTimeMillis();
for (long i = 0; i < 1000; i++) {
Key k = new Key(new Text(String.format("%03d", i)), colf, colq, ts - i);
tm.put(k, dv);
}
assertEquals(1000, tm.size());
ColumnAgeOffFilter a = new ColumnAgeOffFilter();
assertTrue(a.validateOptions(is.getOptions()));
a.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
a.overrideCurrentTime(ts);
a.seek(new Range(), EMPTY_COL_FAMS, false);
assertEquals(98, size(a));
ColumnAgeOffFilter.addTTL(is, new IteratorSetting.Column("a", "b"), 101l);
a.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
a.overrideCurrentTime(ts);
a.seek(new Range(), EMPTY_COL_FAMS, false);
assertEquals(898, size(a));
ColumnAgeOffFilter.removeTTL(is, new IteratorSetting.Column("a", "b"));
a.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
a = (ColumnAgeOffFilter) a.deepCopy(null);
a.overrideCurrentTime(ts);
a.seek(new Range(), EMPTY_COL_FAMS, false);
assertEquals(98, size(a));
}
use of org.apache.accumulo.core.iterators.DefaultIteratorEnvironment in project accumulo by apache.
the class RowFilterTest method test1.
@Test
public void test1() throws Exception {
ColumnFamilySkippingIterator source = new ColumnFamilySkippingIterator(new SortedMapIterator(createKeyValues()));
RowFilter filter = new SummingRowFilter();
filter.init(source, Collections.emptyMap(), new DefaultIteratorEnvironment());
filter.seek(new Range(), Collections.emptySet(), false);
assertEquals(new HashSet<>(Arrays.asList("2", "3")), getRows(filter));
ByteSequence cf = new ArrayByteSequence("cf2");
filter.seek(new Range(), ImmutableSet.of(cf), true);
assertEquals(new HashSet<>(Arrays.asList("1", "3", "0", "4")), getRows(filter));
filter.seek(new Range("0", "4"), Collections.emptySet(), false);
assertEquals(new HashSet<>(Arrays.asList("2", "3")), getRows(filter));
filter.seek(new Range("2"), Collections.emptySet(), false);
assertEquals(new HashSet<>(Arrays.asList("2")), getRows(filter));
filter.seek(new Range("4"), Collections.emptySet(), false);
assertEquals(new HashSet<String>(), getRows(filter));
filter.seek(new Range("4"), ImmutableSet.of(cf), true);
assertEquals(new HashSet<>(Arrays.asList("4")), getRows(filter));
}
use of org.apache.accumulo.core.iterators.DefaultIteratorEnvironment in project accumulo by apache.
the class RowFilterTest method testFilterConjunction.
@Test
public void testFilterConjunction() throws Exception {
SortedMapIterator source = new SortedMapIterator(createKeyValues());
RowFilter filter0 = new RowZeroOrOneFilter();
filter0.init(source, Collections.emptyMap(), new DefaultIteratorEnvironment());
RowFilter filter = new RowOneOrTwoFilter();
filter.init(filter0, Collections.emptyMap(), new DefaultIteratorEnvironment());
filter.seek(new Range(), Collections.emptySet(), false);
assertEquals(new HashSet<>(Arrays.asList("1")), getRows(filter));
}
Aggregations