use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class RowDeletingIteratorTest method test1.
@Test
public void test1() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
put(tm1, "r1", "", "", 10, RowDeletingIterator.DELETE_ROW_VALUE);
put(tm1, "r1", "cf1", "cq1", 5, "v1");
put(tm1, "r1", "cf1", "cq3", 5, "v1");
put(tm1, "r2", "cf1", "cq1", 5, "v1");
RowDeletingIterator rdi = new RowDeletingIterator();
rdi.init(new SortedMapIterator(tm1), null, new TestIE(IteratorScope.scan, false));
rdi.seek(new Range(), new ArrayList<>(), false);
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
for (int i = 0; i < 5; i++) {
rdi.seek(new Range(newKey("r1", "cf1", "cq" + i, 5), null), new ArrayList<>(), false);
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
}
rdi.seek(new Range(newKey("r11", "cf1", "cq1", 5), null), new ArrayList<>(), false);
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
put(tm1, "r2", "", "", 10, RowDeletingIterator.DELETE_ROW_VALUE);
rdi.seek(new Range(), new ArrayList<>(), false);
assertFalse(rdi.hasTop());
for (int i = 0; i < 5; i++) {
rdi.seek(new Range(newKey("r1", "cf1", "cq" + i, 5), null), new ArrayList<>(), false);
assertFalse(rdi.hasTop());
}
put(tm1, "r0", "cf1", "cq1", 5, "v1");
rdi.seek(new Range(), new ArrayList<>(), false);
testAssertions(rdi, "r0", "cf1", "cq1", 5, "v1");
rdi.next();
assertFalse(rdi.hasTop());
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class RowDeletingIteratorTest method test4.
@Test
public void test4() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
put(tm1, "r1", "", "", 10, RowDeletingIterator.DELETE_ROW_VALUE);
put(tm1, "r1", "cf1", "cq1", 5, "v1");
put(tm1, "r1", "cf1", "cq3", 15, "v1");
put(tm1, "r1", "cf1", "cq4", 5, "v1");
put(tm1, "r2", "cf1", "cq1", 5, "v1");
RowDeletingIterator rdi = new RowDeletingIterator();
rdi.init(new SortedMapIterator(tm1), null, new TestIE(IteratorScope.minc, false));
rdi.seek(new Range(), new ArrayList<>(), false);
testAssertions(rdi, "r1", "", "", 10, RowDeletingIterator.DELETE_ROW_VALUE.toString());
rdi.next();
testAssertions(rdi, "r1", "cf1", "cq3", 15, "v1");
rdi.next();
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
rdi.seek(new Range(newKey("r1", "cf1", "cq3", 20), null), new ArrayList<>(), false);
testAssertions(rdi, "r1", "cf1", "cq3", 15, "v1");
rdi.next();
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
rdi.seek(new Range(newKey("r1", "", "", 42), null), new ArrayList<>(), false);
testAssertions(rdi, "r1", "", "", 10, RowDeletingIterator.DELETE_ROW_VALUE.toString());
rdi.next();
testAssertions(rdi, "r1", "cf1", "cq3", 15, "v1");
rdi.next();
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class RowDeletingIteratorTest method test3.
@Test
public void test3() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
put(tm1, "r1", "", "", 10, RowDeletingIterator.DELETE_ROW_VALUE);
put(tm1, "r1", "", "cq1", 5, "v1");
put(tm1, "r1", "cf1", "cq1", 5, "v1");
put(tm1, "r2", "", "cq1", 5, "v1");
put(tm1, "r2", "cf1", "cq1", 5, "v1");
RowDeletingIterator rdi = new RowDeletingIterator();
rdi.init(new ColumnFamilySkippingIterator(new SortedMapIterator(tm1)), null, new TestIE(IteratorScope.scan, false));
HashSet<ByteSequence> cols = new HashSet<>();
cols.add(new ArrayByteSequence("cf1".getBytes()));
rdi.seek(new Range(), cols, true);
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
cols.clear();
cols.add(new ArrayByteSequence("".getBytes()));
rdi.seek(new Range(), cols, false);
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
cols.clear();
rdi.seek(new Range(), cols, false);
testAssertions(rdi, "r2", "", "cq1", 5, "v1");
rdi.next();
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class VersioningIteratorTest method test4.
@Test
public void test4() {
Text colf = new Text("a");
Text colq = new Text("b");
TreeMap<Key, Value> tm = new TreeMap<>();
createTestData(tm, colf, colq);
for (int i = 1; i <= 30; i++) {
try {
VersioningIterator it = new VersioningIterator();
IteratorSetting is = new IteratorSetting(1, VersioningIterator.class);
VersioningIterator.setMaxVersions(is, i);
it.init(new SortedMapIterator(tm), is.getOptions(), null);
it.seek(new Range(), EMPTY_COL_FAMS, false);
TreeMap<Key, Value> tmOut = iteratorOverTestData(it);
assertEquals(tmOut.size(), Math.min(40, 2 * i), "size after keeping " + i + " versions was " + tmOut.size());
} catch (IOException e) {
fail();
} catch (Exception e) {
log.error("{}", e.getMessage(), e);
fail();
}
}
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class VersioningIteratorTest method test5.
@Test
public void test5() throws IOException {
Text colf = new Text("a");
Text colq = new Text("b");
TreeMap<Key, Value> tm = new TreeMap<>();
createTestData(tm, colf, colq);
VersioningIterator it = new VersioningIterator();
IteratorSetting is = new IteratorSetting(1, VersioningIterator.class);
VersioningIterator.setMaxVersions(is, 3);
it.init(new SortedMapIterator(tm), is.getOptions(), null);
Key seekKey = new Key(new Text(String.format("%03d", 1)), colf, colq, 19);
it.seek(new Range(seekKey, false, null, true), EMPTY_COL_FAMS, false);
assertTrue(it.hasTop());
assertEquals(18, it.getTopKey().getTimestamp());
}
Aggregations