use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class FilterTest method testDeletes.
@Test
public void testDeletes() throws IOException {
Text colf = new Text("a");
Text colq = new Text("b");
Value dv = new Value();
TreeMap<Key, Value> tm = new TreeMap<>();
Key k = new Key(new Text("0"), colf, colq);
tm.put(k, dv);
k = new Key(new Text("1"), colf, colq, 10);
k.setDeleted(true);
tm.put(k, dv);
k = new Key(new Text("1"), colf, colq, 5);
tm.put(k, dv);
k = new Key(new Text("10"), colf, colq);
tm.put(k, dv);
assertEquals(4, tm.size());
Filter filter = new SimpleFilter();
filter.init(new SortedMapIterator(tm), EMPTY_OPTS, null);
filter.seek(new Range(), EMPTY_COL_FAMS, false);
int size = size(filter);
assertEquals(3, size);
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class FilterTest method test2a.
@Test
public void test2a() 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);
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(902, 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(102, 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(902, size(a));
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class FilterTest method ncqf.
private SortedKeyValueIterator<Key, Value> ncqf(TreeMap<Key, Value> tm, Column... columns) throws IOException {
HashSet<Column> hsc = new HashSet<>();
Collections.addAll(hsc, columns);
SortedKeyValueIterator<Key, Value> a = ColumnQualifierFilter.wrap(new SortedMapIterator(tm), hsc);
a.seek(new Range(), EMPTY_COL_FAMS, false);
return a;
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class FilterTest method test4.
@Test
public void test4() throws IOException {
Value dv = new Value();
TreeMap<Key, Value> tm = new TreeMap<>();
ColumnVisibility le1 = new ColumnVisibility("L1");
ColumnVisibility le2 = new ColumnVisibility("L0&OFFICIAL");
ColumnVisibility le3 = new ColumnVisibility("L1&L2");
ColumnVisibility le4 = new ColumnVisibility("L1&L2&G1");
ColumnVisibility[] lea = { le1, le2, le3, le4 };
Authorizations auths = new Authorizations("L1", "L2", "L0", "OFFICIAL");
for (int i = 0; i < 1000; i++) {
Key k = new Key(new Text(String.format("%03d", i)), new Text("a"), new Text("b"), new Text(lea[i % 4].getExpression()));
tm.put(k, dv);
}
assertEquals(1000, tm.size());
SortedKeyValueIterator<Key, Value> a = VisibilityFilter.wrap(new SortedMapIterator(tm), auths, le2.getExpression());
a.seek(new Range(), EMPTY_COL_FAMS, false);
int size = size(a);
assertEquals(750, size);
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class FilterTest method test1.
@Test
public void test1() throws IOException {
Text colf = new Text("a");
Text colq = new Text("b");
Value dv = new Value();
TreeMap<Key, Value> tm = new TreeMap<>();
for (int i = 0; i < 1000; i++) {
Key k = new Key(new Text(String.format("%03d", i)), colf, colq);
tm.put(k, dv);
}
assertEquals(1000, tm.size());
Filter filter1 = new SimpleFilter();
filter1.init(new SortedMapIterator(tm), EMPTY_OPTS, null);
filter1.seek(new Range(), EMPTY_COL_FAMS, false);
int size = size(filter1);
assertEquals(100, size);
Filter fi = new SimpleFilter();
fi.init(new SortedMapIterator(tm), EMPTY_OPTS, null);
Key k = new Key(new Text("500"));
fi.seek(new Range(k, null), EMPTY_COL_FAMS, false);
size = size(fi);
assertEquals(50, size);
filter1 = new SimpleFilter();
filter1.init(new SortedMapIterator(tm), EMPTY_OPTS, null);
Filter filter2 = new SimpleFilter2();
filter2.init(filter1, EMPTY_OPTS, null);
filter2.seek(new Range(), EMPTY_COL_FAMS, false);
size = size(filter2);
assertEquals(0, size);
}
Aggregations