use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class WholeColumnFamilyIteratorTest method testBug1.
@Test
public void testBug1() throws Exception {
SortedMap<Key, Value> map1 = new TreeMap<>();
pkv(map1, "row1", "cf1", "cq1", "cv1", 5, "foo");
pkv(map1, "row1", "cf1", "cq2", "cv1", 6, "bar");
SortedMap<Key, Value> map2 = new TreeMap<>();
pkv(map2, "row2", "cf1", "cq1", "cv1", 5, "foo");
SortedMap<Key, Value> map = new TreeMap<>();
map.putAll(map1);
map.putAll(map2);
MultiIterator source = new MultiIterator(Collections.singletonList(new SortedMapIterator(map)), new Range(null, true, new Text("row1"), true));
WholeColumnFamilyIterator iter = new WholeColumnFamilyIterator(source);
Range range = new Range(new Text("row1"), true, new Text("row2"), true);
iter.seek(range, new ArrayList<>(), false);
assertTrue(iter.hasTop());
assertEquals(map1, WholeColumnFamilyIterator.decodeColumnFamily(iter.getTopKey(), iter.getTopValue()));
// simulate something continuing using the last key from the iterator
// this is what client and server code will do
range = new Range(iter.getTopKey(), false, range.getEndKey(), range.isEndKeyInclusive());
iter.seek(range, new ArrayList<>(), false);
assertFalse(iter.hasTop());
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class MultiIteratorTest method verify.
void verify(int start, int end, Key seekKey, Text endRow, Text prevEndRow, boolean init, boolean incrRow, List<TreeMap<Key, Value>> maps) throws IOException {
List<SortedKeyValueIterator<Key, Value>> iters = new ArrayList<>(maps.size());
for (TreeMap<Key, Value> map : maps) {
iters.add(new SortedMapIterator(map));
}
MultiIterator mi;
if (endRow == null && prevEndRow == null)
mi = new MultiIterator(iters, init);
else {
Range range = new Range(prevEndRow, false, endRow, true);
if (init)
for (SortedKeyValueIterator<Key, Value> iter : iters) iter.seek(range, Set.of(), false);
mi = new MultiIterator(iters, range);
if (init)
mi.seek(range, Set.of(), false);
}
if (seekKey != null)
mi.seek(new Range(seekKey, null), EMPTY_COL_FAMS, false);
else
mi.seek(new Range(), EMPTY_COL_FAMS, false);
int i = start;
while (mi.hasTop()) {
if (incrRow)
assertEquals(newKey(i, 0), mi.getTopKey());
else
assertEquals(newKey(0, i), mi.getTopKey());
assertEquals("v" + i, mi.getTopValue().toString());
mi.next();
if (incrRow)
i++;
else
i--;
}
assertEquals(end, i, "start=" + start + " end=" + end + " seekKey=" + seekKey + " endRow=" + endRow + " prevEndRow=" + prevEndRow + " init=" + init + " incrRow=" + incrRow + " maps=" + maps);
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class TimeSettingIteratorTest method testEndKeyRangeAtMinLongValue.
@Test
public void testEndKeyRangeAtMinLongValue() throws IOException {
Text row = new Text("a");
Text colf = new Text("b");
Text colq = new Text("c");
Text cv = new Text();
for (boolean inclusiveEndRange : new boolean[] { true, false }) {
TreeMap<Key, Value> sources = new TreeMap<>();
sources.put(new Key(row.getBytes(), colf.getBytes(), colq.getBytes(), cv.getBytes(), Long.MIN_VALUE, true), new Value("00"));
sources.put(new Key(row.getBytes(), colf.getBytes(), colq.getBytes(), cv.getBytes(), Long.MIN_VALUE), new Value("11"));
TimeSettingIterator it = new TimeSettingIterator(new SortedMapIterator(sources), 111L);
IteratorSetting is = new IteratorSetting(1, TimeSettingIterator.class);
it.init(null, is.getOptions(), null);
Key startKey = new Key();
Key endKey = new Key(row, colf, colq, cv, Long.MIN_VALUE);
Range testRange = new Range(startKey, false, endKey, inclusiveEndRange);
it.seek(testRange, new HashSet<>(), false);
assertTrue(it.hasTop());
assertEquals(it.getTopValue(), new Value("00"));
assertEquals(111L, it.getTopKey().getTimestamp());
it.next();
assertTrue(it.hasTop());
assertEquals(it.getTopValue(), new Value("11"));
assertEquals(111L, it.getTopKey().getTimestamp());
it.next();
assertFalse(it.hasTop());
}
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class BigDecimalCombinerTest method testMax.
@Test
public void testMax() throws IOException {
ai = new BigDecimalCombiner.BigDecimalMaxCombiner();
IteratorSetting is = new IteratorSetting(1, BigDecimalCombiner.BigDecimalMaxCombiner.class);
Combiner.setColumns(is, columns);
ai.init(new SortedMapIterator(tm1), is.getOptions(), CombinerTest.SCAN_IE);
ai.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(ai.hasTop());
assertEquals(CombinerTest.newKey(1, 1, 1, 3), ai.getTopKey());
assertEquals(2.3, encoder.decode(ai.getTopValue().get()).doubleValue(), delta);
verify();
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class VisibilityFilterTest method testBadVisibility.
@Test
public void testBadVisibility() throws IOException {
TreeMap<Key, Value> tm = new TreeMap<>();
tm.put(new Key("r1", "cf1", "cq1", "A&"), new Value());
SortedKeyValueIterator<Key, Value> filter = VisibilityFilter.wrap(new SortedMapIterator(tm), new Authorizations("A"), "".getBytes());
filter.seek(new Range(), new HashSet<>(), false);
assertFalse(filter.hasTop());
}
Aggregations