use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class FilterTest method testNoVisFilter.
@Test
public void testNoVisFilter() throws IOException {
TreeMap<Key, Value> tm = new TreeMap<>();
Value v = new Value();
for (int i = 0; i < 1000; i++) {
Key k = new Key(String.format("%03d", i), "a", "b", i % 10 == 0 ? "vis" : "");
tm.put(k, v);
}
assertEquals(1000, tm.size());
Filter filter = new ReqVisFilter();
filter.init(new SortedMapIterator(tm), EMPTY_OPTS, null);
filter.seek(new Range(), EMPTY_COL_FAMS, false);
int size = size(filter);
assertEquals(100, size);
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class CountingIteratorTest method testDeepCopyCount.
@Test
public void testDeepCopyCount() throws IOException {
TreeMap<Key, Value> tm = new TreeMap<>();
tm.put(new Key("r1", "cf1", "cq1"), new Value("data1"));
tm.put(new Key("r2", "cf1", "cq1"), new Value("data2"));
SortedMapIterator smi = new SortedMapIterator(tm);
CountingIterator ci = new CountingIterator(smi, new AtomicLong(0));
CountingIterator dc1 = ci.deepCopy(null);
CountingIterator dc2 = ci.deepCopy(null);
readAll(ci);
readAll(dc1);
readAll(dc2);
assertEquals(6, ci.getCount());
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class IterConfigUtilTest method test5.
@Test
public void test5() throws IOException {
ConfigurationCopy conf = new ConfigurationCopy();
// create an iterator that ages off
conf.set(Property.TABLE_ITERATOR_PREFIX + IteratorScope.minc.name() + ".filter", "1," + AgeOffFilter.class.getName());
conf.set(Property.TABLE_ITERATOR_PREFIX + IteratorScope.minc.name() + ".filter.opt.ttl", "100");
conf.set(Property.TABLE_ITERATOR_PREFIX + IteratorScope.minc.name() + ".filter.opt.currentTime", "1000");
TreeMap<Key, Value> tm = new TreeMap<>();
MultiIteratorTest.newKeyValue(tm, 1, 850, false, "1");
MultiIteratorTest.newKeyValue(tm, 2, 950, false, "2");
SortedMapIterator source = new SortedMapIterator(tm);
SortedKeyValueIterator<Key, Value> iter = createIter(IteratorScope.minc, source, conf);
iter.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(iter.hasTop());
assertEquals(iter.getTopKey(), MultiIteratorTest.newKey(2, 950));
iter.next();
assertFalse(iter.hasTop());
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class CombinerTest method test1.
@Test
public void test1() throws IOException {
Encoder<Long> encoder = LongCombiner.VAR_LEN_ENCODER;
TreeMap<Key, Value> tm1 = new TreeMap<>();
// keys that do not aggregate
newKeyValue(tm1, 1, 1, 1, 1, false, 2L, encoder);
newKeyValue(tm1, 1, 1, 1, 2, false, 3L, encoder);
newKeyValue(tm1, 1, 1, 1, 3, false, 4L, encoder);
Combiner ai = new SummingCombiner();
IteratorSetting is = new IteratorSetting(1, SummingCombiner.class);
LongCombiner.setEncodingType(is, SummingCombiner.Type.VARLEN);
Combiner.setColumns(is, Collections.singletonList(new IteratorSetting.Column("2")));
ai.init(new SortedMapIterator(tm1), is.getOptions(), SCAN_IE);
ai.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(ai.hasTop());
assertEquals(newKey(1, 1, 1, 3), ai.getTopKey());
assertEquals("4", encoder.decode(ai.getTopValue().get()).toString());
ai.next();
assertTrue(ai.hasTop());
assertEquals(newKey(1, 1, 1, 2), ai.getTopKey());
assertEquals("3", encoder.decode(ai.getTopValue().get()).toString());
ai.next();
assertTrue(ai.hasTop());
assertEquals(newKey(1, 1, 1, 1), ai.getTopKey());
assertEquals("2", encoder.decode(ai.getTopValue().get()).toString());
ai.next();
assertFalse(ai.hasTop());
// try seeking
ai.seek(newRow(1, 1, 1, 2), EMPTY_COL_FAMS, false);
assertTrue(ai.hasTop());
assertEquals(newKey(1, 1, 1, 2), ai.getTopKey());
assertEquals("3", encoder.decode(ai.getTopValue().get()).toString());
ai.next();
assertTrue(ai.hasTop());
assertEquals(newKey(1, 1, 1, 1), ai.getTopKey());
assertEquals("2", encoder.decode(ai.getTopValue().get()).toString());
ai.next();
assertFalse(ai.hasTop());
// seek after everything
ai.seek(newRow(1, 1, 1, 0), EMPTY_COL_FAMS, false);
assertFalse(ai.hasTop());
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class CombinerTest method maxMinTest.
@Test
public void maxMinTest() throws IOException {
Encoder<Long> encoder = LongCombiner.VAR_LEN_ENCODER;
TreeMap<Key, Value> tm1 = new TreeMap<>();
// keys that aggregate
newKeyValue(tm1, 1, 1, 1, 1, false, 4L, encoder);
newKeyValue(tm1, 1, 1, 1, 2, false, 3L, encoder);
newKeyValue(tm1, 1, 1, 1, 3, false, 2L, encoder);
Combiner ai = new MaxCombiner();
IteratorSetting is = new IteratorSetting(1, SummingCombiner.class);
LongCombiner.setEncodingType(is, SummingCombiner.Type.VARLEN);
Combiner.setColumns(is, Collections.singletonList(new IteratorSetting.Column("cf001")));
ai.init(new SortedMapIterator(tm1), is.getOptions(), SCAN_IE);
ai.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(ai.hasTop());
assertEquals(newKey(1, 1, 1, 3), ai.getTopKey());
assertEquals("4", encoder.decode(ai.getTopValue().get()).toString());
ai.next();
assertFalse(ai.hasTop());
ai = new MinCombiner();
ai.init(new SortedMapIterator(tm1), is.getOptions(), SCAN_IE);
ai.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(ai.hasTop());
assertEquals(newKey(1, 1, 1, 3), ai.getTopKey());
assertEquals("2", encoder.decode(ai.getTopValue().get()).toString());
ai.next();
assertFalse(ai.hasTop());
}
Aggregations