use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class SourceSwitchingIteratorTest method testSetInterrupt.
public void testSetInterrupt() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
put(tm1, "r1", "cf1", "cq1", 5, "v1");
SortedMapIterator smi = new SortedMapIterator(tm1);
TestDataSource tds = new TestDataSource(smi);
SourceSwitchingIterator ssi = new SourceSwitchingIterator(tds, false);
AtomicBoolean flag = new AtomicBoolean();
ssi.setInterruptFlag(flag);
assertSame(flag, tds.iflag);
ssi.seek(new Range("r1"), new ArrayList<>(), false);
testAndCallNext(ssi, "r1", "cf1", "cq1", 5, "v1", true);
assertFalse(ssi.hasTop());
flag.set(true);
try {
ssi.seek(new Range("r1"), new ArrayList<>(), false);
fail("expected to see IterationInterruptedException");
} catch (IterationInterruptedException iie) {
}
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class SourceSwitchingIteratorTest method test2.
public void test2() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
put(tm1, "r1", "cf1", "cq1", 5, "v1");
put(tm1, "r1", "cf1", "cq3", 5, "v2");
put(tm1, "r2", "cf1", "cq1", 5, "v3");
SortedMapIterator smi = new SortedMapIterator(tm1);
TestDataSource tds = new TestDataSource(smi);
SourceSwitchingIterator ssi = new SourceSwitchingIterator(tds);
ssi.seek(new Range(), new ArrayList<>(), false);
testAndCallNext(ssi, "r1", "cf1", "cq1", 5, "v1", true);
TreeMap<Key, Value> tm2 = new TreeMap<>();
put(tm2, "r1", "cf1", "cq1", 5, "v4");
put(tm2, "r1", "cf1", "cq3", 5, "v5");
put(tm2, "r2", "cf1", "cq1", 5, "v6");
SortedMapIterator smi2 = new SortedMapIterator(tm2);
TestDataSource tds2 = new TestDataSource(smi2);
tds.next = tds2;
testAndCallNext(ssi, "r1", "cf1", "cq3", 5, "v2", true);
testAndCallNext(ssi, "r2", "cf1", "cq1", 5, "v6", true);
assertFalse(ssi.hasTop());
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class TimeSettingIteratorTest method testAvoidKeyCopy.
@Test
public void testAvoidKeyCopy() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
final Key k = new Key("r0", "cf1", "cq1", 9l);
tm1.put(k, new Value("v0".getBytes()));
TimeSettingIterator tsi = new TimeSettingIterator(new SortedMapIterator(tm1), 50);
tsi.seek(new Range(), new HashSet<>(), false);
assertTrue(tsi.hasTop());
final Key topKey = tsi.getTopKey();
assertTrue("Expected the topKey to be the same object", k == topKey);
assertEquals(new Key("r0", "cf1", "cq1", 50l), topKey);
assertEquals("v0", tsi.getTopValue().toString());
tsi.next();
assertFalse(tsi.hasTop());
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class TimeSettingIteratorTest method test1.
@Test
public void test1() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
tm1.put(new Key("r0", "cf1", "cq1", 9l), new Value("v0".getBytes()));
tm1.put(new Key("r1", "cf1", "cq1", Long.MAX_VALUE), new Value("v1".getBytes()));
tm1.put(new Key("r1", "cf1", "cq1", 90l), new Value("v2".getBytes()));
tm1.put(new Key("r1", "cf1", "cq1", 0l), new Value("v3".getBytes()));
tm1.put(new Key("r2", "cf1", "cq1", 6l), new Value("v4".getBytes()));
TimeSettingIterator tsi = new TimeSettingIterator(new SortedMapIterator(tm1), 50);
tsi.seek(new Range(new Key("r1", "cf1", "cq1", 50l), true, new Key("r1", "cf1", "cq1", 50l), true), new HashSet<>(), false);
assertTrue(tsi.hasTop());
assertEquals(new Key("r1", "cf1", "cq1", 50l), tsi.getTopKey());
assertEquals("v1", tsi.getTopValue().toString());
tsi.next();
assertTrue(tsi.hasTop());
assertEquals(new Key("r1", "cf1", "cq1", 50l), tsi.getTopKey());
assertEquals("v2", tsi.getTopValue().toString());
tsi.next();
assertTrue(tsi.hasTop());
assertEquals(new Key("r1", "cf1", "cq1", 50l), tsi.getTopKey());
assertEquals("v3", tsi.getTopValue().toString());
tsi.next();
assertFalse(tsi.hasTop());
tsi.seek(new Range(new Key("r1", "cf1", "cq1", 50l), false, null, true), new HashSet<>(), false);
assertTrue(tsi.hasTop());
assertEquals(new Key("r2", "cf1", "cq1", 50l), tsi.getTopKey());
assertEquals("v4", tsi.getTopValue().toString());
tsi.next();
assertFalse(tsi.hasTop());
tsi.seek(new Range(null, true, new Key("r1", "cf1", "cq1", 50l), false), new HashSet<>(), false);
assertTrue(tsi.hasTop());
assertEquals(new Key("r0", "cf1", "cq1", 50l), tsi.getTopKey());
assertEquals("v0", tsi.getTopValue().toString());
tsi.next();
assertFalse(tsi.hasTop());
tsi.seek(new Range(new Key("r1", "cf1", "cq1", 51l), true, new Key("r1", "cf1", "cq1", 50l), false), new HashSet<>(), false);
assertFalse(tsi.hasTop());
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class BigDecimalCombinerTest method testMin.
@Test
public void testMin() throws IOException {
ai = new BigDecimalCombiner.BigDecimalMinCombiner();
IteratorSetting is = new IteratorSetting(1, BigDecimalCombiner.BigDecimalMinCombiner.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(-14.0, encoder.decode(ai.getTopValue().get()).doubleValue(), delta);
verify();
}
Aggregations