use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class SourceSwitchingIteratorTest method test3.
public void test3() throws Exception {
// test switching after a row
TreeMap<Key, Value> tm1 = new TreeMap<>();
put(tm1, "r1", "cf1", "cq1", 5, "v1");
put(tm1, "r1", "cf1", "cq2", 5, "v2");
put(tm1, "r1", "cf1", "cq3", 5, "v3");
put(tm1, "r1", "cf1", "cq4", 5, "v4");
put(tm1, "r3", "cf1", "cq1", 5, "v5");
put(tm1, "r3", "cf1", "cq2", 5, "v6");
SortedMapIterator smi = new SortedMapIterator(tm1);
TestDataSource tds = new TestDataSource(smi);
SourceSwitchingIterator ssi = new SourceSwitchingIterator(tds, true);
ssi.seek(new Range(), new ArrayList<>(), false);
testAndCallNext(ssi, "r1", "cf1", "cq1", 5, "v1", true);
TreeMap<Key, Value> tm2 = new TreeMap<>(tm1);
// should not see this because it should not switch until the row is finished
put(tm2, "r1", "cf1", "cq5", 5, "v7");
// should see this new row after it switches
put(tm2, "r2", "cf1", "cq1", 5, "v8");
// setup a new data source, but it should not switch until the current row is finished
SortedMapIterator smi2 = new SortedMapIterator(tm2);
TestDataSource tds2 = new TestDataSource(smi2);
tds.next = tds2;
testAndCallNext(ssi, "r1", "cf1", "cq2", 5, "v2", true);
testAndCallNext(ssi, "r1", "cf1", "cq3", 5, "v3", true);
testAndCallNext(ssi, "r1", "cf1", "cq4", 5, "v4", true);
testAndCallNext(ssi, "r2", "cf1", "cq1", 5, "v8", true);
testAndCallNext(ssi, "r3", "cf1", "cq1", 5, "v5", true);
testAndCallNext(ssi, "r3", "cf1", "cq2", 5, "v6", true);
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class SourceSwitchingIteratorTest method test5.
public void test5() throws Exception {
// esnure switchNow() works w/ deepCopy()
TreeMap<Key, Value> tm1 = new TreeMap<>();
put(tm1, "r1", "cf1", "cq1", 5, "v1");
put(tm1, "r1", "cf1", "cq2", 5, "v2");
SortedMapIterator smi = new SortedMapIterator(tm1);
TestDataSource tds = new TestDataSource(smi);
SourceSwitchingIterator ssi = new SourceSwitchingIterator(tds, false);
SortedKeyValueIterator<Key, Value> dc1 = ssi.deepCopy(null);
TreeMap<Key, Value> tm2 = new TreeMap<>();
put(tm2, "r1", "cf1", "cq1", 6, "v3");
put(tm2, "r2", "cf1", "cq2", 6, "v4");
SortedMapIterator smi2 = new SortedMapIterator(tm2);
TestDataSource tds2 = new TestDataSource(smi2);
tds.setNext(tds2);
ssi.switchNow();
ssi.seek(new Range("r1"), new ArrayList<>(), false);
dc1.seek(new Range("r2"), new ArrayList<>(), false);
testAndCallNext(ssi, "r1", "cf1", "cq1", 6, "v3", true);
assertFalse(ssi.hasTop());
testAndCallNext(dc1, "r2", "cf1", "cq2", 6, "v4", true);
assertFalse(dc1.hasTop());
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class SourceSwitchingIteratorTest method test4.
public void test4() throws Exception {
// ensure switch is done on initial seek
TreeMap<Key, Value> tm1 = new TreeMap<>();
put(tm1, "r1", "cf1", "cq1", 5, "v1");
put(tm1, "r1", "cf1", "cq2", 5, "v2");
SortedMapIterator smi = new SortedMapIterator(tm1);
TestDataSource tds = new TestDataSource(smi);
SourceSwitchingIterator ssi = new SourceSwitchingIterator(tds, false);
TreeMap<Key, Value> tm2 = new TreeMap<>();
put(tm2, "r1", "cf1", "cq1", 6, "v3");
put(tm2, "r1", "cf1", "cq2", 6, "v4");
SortedMapIterator smi2 = new SortedMapIterator(tm2);
TestDataSource tds2 = new TestDataSource(smi2);
tds.next = tds2;
ssi.seek(new Range(), new ArrayList<>(), false);
testAndCallNext(ssi, "r1", "cf1", "cq1", 6, "v3", true);
testAndCallNext(ssi, "r1", "cf1", "cq2", 6, "v4", true);
}
use of org.apache.accumulo.core.iterators.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".getBytes()));
sources.put(new Key(row.getBytes(), colf.getBytes(), colq.getBytes(), cv.getBytes(), Long.MIN_VALUE), new Value("11".getBytes()));
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());
assertTrue(it.getTopValue().equals(new Value("00".getBytes())));
assertTrue(it.getTopKey().getTimestamp() == 111L);
it.next();
assertTrue(it.hasTop());
assertTrue(it.getTopValue().equals(new Value("11".getBytes())));
assertTrue(it.getTopKey().getTimestamp() == 111L);
it.next();
assertFalse(it.hasTop());
}
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class VisibilityFilterTest method testBadVisibility.
public void testBadVisibility() throws IOException {
TreeMap<Key, Value> tm = new TreeMap<>();
tm.put(new Key("r1", "cf1", "cq1", "A&"), new Value(new byte[0]));
SortedKeyValueIterator<Key, Value> filter = VisibilityFilter.wrap(new SortedMapIterator(tm), new Authorizations("A"), "".getBytes());
// suppress logging
Level prevLevel = Logger.getLogger(VisibilityFilter.class).getLevel();
Logger.getLogger(VisibilityFilter.class).setLevel(Level.FATAL);
filter.seek(new Range(), new HashSet<>(), false);
assertFalse(filter.hasTop());
Logger.getLogger(VisibilityFilter.class).setLevel(prevLevel);
}
Aggregations