use of org.apache.accumulo.core.iteratorsImpl.system.CountingIterator in project accumulo by apache.
the class ColumnFamilySkippingIteratorTest method test3.
@Test
public void test3() throws Exception {
// construct test where ColumnFamilySkippingIterator might try to seek past the end of the user
// supplied range
TreeMap<Key, Value> tm1 = new TreeMap<>();
for (int r = 0; r < 3; r++) {
for (int cf = 4; cf < 1000; cf++) {
for (int cq = 0; cq < 1; cq++) {
put(tm1, r, cf, cq, 6, r * cf * cq);
}
}
}
CountingIterator ci = new CountingIterator(new SortedMapIterator(tm1));
ColumnFamilySkippingIterator cfi = new ColumnFamilySkippingIterator(ci);
HashSet<ByteSequence> colfams = new HashSet<>();
colfams.add(new ArrayByteSequence(String.format("%06d", 4)));
Range range = new Range(newKey(0, 4, 0, 6), true, newKey(0, 400, 0, 6), true);
cfi.seek(range, colfams, true);
assertTrue(cfi.hasTop());
assertEquals(newKey(0, 4, 0, 6), cfi.getTopKey());
cfi.next();
assertFalse(cfi.hasTop());
colfams.add(new ArrayByteSequence(String.format("%06d", 500)));
cfi.seek(range, colfams, true);
assertTrue(cfi.hasTop());
assertEquals(newKey(0, 4, 0, 6), cfi.getTopKey());
cfi.next();
assertFalse(cfi.hasTop());
range = new Range(newKey(0, 4, 0, 6), true, newKey(1, 400, 0, 6), true);
cfi.seek(range, colfams, true);
assertTrue(cfi.hasTop());
assertEquals(newKey(0, 4, 0, 6), cfi.getTopKey());
cfi.next();
assertTrue(cfi.hasTop());
assertEquals(newKey(0, 500, 0, 6), cfi.getTopKey());
cfi.next();
assertTrue(cfi.hasTop());
assertEquals(newKey(1, 4, 0, 6), cfi.getTopKey());
cfi.next();
assertFalse(cfi.hasTop());
// System.out.println(ci.getCount());
}
use of org.apache.accumulo.core.iteratorsImpl.system.CountingIterator in project accumulo by apache.
the class FirstEntryInRowIteratorTest method process.
private static long process(TreeMap<Key, Value> sourceMap, TreeMap<Key, Value> resultMap, Range range, IteratorSetting iteratorSetting) throws IOException {
SortedMapIterator source = new SortedMapIterator(sourceMap);
CountingIterator counter = new CountingIterator(source);
FirstEntryInRowIterator feiri = new FirstEntryInRowIterator();
IteratorEnvironment env = new DefaultIteratorEnvironment();
feiri.init(counter, iteratorSetting.getOptions(), env);
feiri.seek(range, Set.of(), false);
while (feiri.hasTop()) {
resultMap.put(feiri.getTopKey(), feiri.getTopValue());
feiri.next();
}
return counter.getCount();
}
Aggregations