use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class ColumnFilterTest method test1.
public void test1() {
TreeMap<Key, Value> data = new TreeMap<>();
data.put(newKey("r1", "cf1", "cq1"), new Value(""));
data.put(newKey("r1", "cf2", "cq1"), new Value(""));
HashSet<Column> columns = new HashSet<>();
columns.add(newColumn("cf1"));
SortedMapIterator smi = new SortedMapIterator(data);
SortedKeyValueIterator<Key, Value> cf = ColumnQualifierFilter.wrap(smi, columns);
Assert.assertSame(smi, cf);
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class DeletingIteratorTest method test3.
// test delete with same timestamp as existing key
public void test3() throws IOException {
TreeMap<Key, Value> tm = new TreeMap<>();
newKeyValue(tm, "r000", 3, false, "v3");
newKeyValue(tm, "r000", 2, false, "v2");
newKeyValue(tm, "r000", 2, true, "");
newKeyValue(tm, "r000", 1, false, "v1");
DeletingIterator it = new DeletingIterator(new SortedMapIterator(tm), false);
it.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(it.hasTop());
assertEquals(newKey("r000", 3), it.getTopKey());
assertEquals("v3", it.getTopValue().toString());
it.next();
assertFalse(it.hasTop());
it.seek(newRange("r000", 2), EMPTY_COL_FAMS, false);
assertFalse(it.hasTop());
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class MultiIteratorTest method test7.
public void test7() throws IOException {
// TEst setting an endKey
TreeMap<Key, Value> tm1 = new TreeMap<>();
newKeyValue(tm1, 0, 3, false, "1");
newKeyValue(tm1, 0, 2, false, "2");
newKeyValue(tm1, 0, 1, false, "3");
newKeyValue(tm1, 0, 0, false, "4");
newKeyValue(tm1, 1, 2, false, "5");
newKeyValue(tm1, 1, 1, false, "6");
newKeyValue(tm1, 1, 0, false, "7");
newKeyValue(tm1, 2, 1, false, "8");
newKeyValue(tm1, 2, 0, false, "9");
List<SortedKeyValueIterator<Key, Value>> skvil = new ArrayList<>(1);
skvil.add(new SortedMapIterator(tm1));
KeyExtent extent = new KeyExtent(Table.ID.of("tablename"), newRow(1), newRow(0));
MultiIterator mi = new MultiIterator(skvil, extent);
Range r1 = new Range((Text) null, (Text) null);
mi.seek(r1, EMPTY_COL_FAMS, false);
assertTrue(mi.hasTop());
assertTrue(mi.getTopValue().toString().equals("5"));
mi.next();
assertTrue(mi.hasTop());
assertTrue(mi.getTopValue().toString().equals("6"));
mi.next();
assertTrue(mi.hasTop());
assertTrue(mi.getTopValue().toString().equals("7"));
mi.next();
assertFalse(mi.hasTop());
Range r2 = new Range(newKey(0, 0), true, newKey(1, 1), true);
mi.seek(r2, EMPTY_COL_FAMS, false);
assertTrue(mi.hasTop());
assertTrue(mi.getTopValue().toString().equals("5"));
mi.next();
assertTrue(mi.hasTop());
assertTrue(mi.getTopValue().toString().equals("6"));
mi.next();
assertFalse(mi.hasTop());
Range r3 = new Range(newKey(0, 0), false, newKey(1, 1), false);
mi.seek(r3, EMPTY_COL_FAMS, false);
assertTrue(mi.hasTop());
assertTrue(mi.getTopValue().toString().equals("5"));
mi.next();
assertFalse(mi.hasTop());
Range r4 = new Range(newKey(1, 2), true, newKey(1, 1), false);
mi.seek(r4, EMPTY_COL_FAMS, false);
assertTrue(mi.hasTop());
assertTrue(mi.getTopValue().toString().equals("5"));
mi.next();
assertFalse(mi.hasTop());
Range r5 = new Range(newKey(1, 2), false, newKey(1, 1), true);
mi.seek(r5, EMPTY_COL_FAMS, false);
assertTrue(mi.hasTop());
assertTrue(mi.getTopValue().toString().equals("6"));
mi.next();
assertFalse(mi.hasTop());
Range r6 = new Range(newKey(2, 1), true, newKey(2, 0), true);
mi.seek(r6, EMPTY_COL_FAMS, false);
assertFalse(mi.hasTop());
Range r7 = new Range(newKey(0, 3), true, newKey(0, 1), true);
mi.seek(r7, EMPTY_COL_FAMS, false);
assertFalse(mi.hasTop());
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class SourceSwitchingIteratorTest method test1.
public void test1() 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);
testAndCallNext(ssi, "r1", "cf1", "cq3", 5, "v2", true);
testAndCallNext(ssi, "r2", "cf1", "cq1", 5, "v3", true);
assertFalse(ssi.hasTop());
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class SourceSwitchingIteratorTest method testYield.
public void testYield() 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);
YieldingIterator ymi = new YieldingIterator(smi);
TestDataSource tds = new TestDataSource(ymi);
SourceSwitchingIterator ssi = new SourceSwitchingIterator(tds);
YieldCallback<Key> yield = new YieldCallback<>();
ssi.enableYielding(yield);
Range r = new Range();
ssi.seek(r, new ArrayList<>(), false);
r = yield(r, ssi, yield);
testAndCallNext(ssi, "r1", "cf1", "cq1", 5, "v1", true);
r = yield(r, ssi, yield);
testAndCallNext(ssi, "r1", "cf1", "cq3", 5, "v2", true);
r = yield(r, ssi, yield);
testAndCallNext(ssi, "r2", "cf1", "cq1", 5, "v3", true);
r = yield(r, ssi, yield);
assertFalse(ssi.hasTop());
}
Aggregations