use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class VersioningIteratorTest method test6.
@Test
public void test6() 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);
VersioningIterator it2 = it.deepCopy(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);
it2.seek(new Range(seekKey, false, null, true), EMPTY_COL_FAMS, false);
assertTrue(it.hasTop());
assertTrue(it.getTopKey().getTimestamp() == 18);
assertTrue(it2.hasTop());
assertTrue(it2.getTopKey().getTimestamp() == 18);
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class VersioningIteratorTest method test3.
@Test
public void test3() {
Text colf = new Text("a");
Text colq = new Text("b");
TreeMap<Key, Value> tm = new TreeMap<>();
createTestData(tm, colf, colq);
try {
VersioningIterator it = new VersioningIterator();
IteratorSetting is = new IteratorSetting(1, VersioningIterator.class);
VersioningIterator.setMaxVersions(is, 3);
it.init(new SortedMapIterator(tm), is.getOptions(), null);
// after doing this seek, should get zero keys for row 1
Key seekKey = new Key(new Text(String.format("%03d", 1)), colf, colq, 15);
it.seek(new Range(seekKey, null), EMPTY_COL_FAMS, false);
TreeMap<Key, Value> tmOut = iteratorOverTestData(it);
for (Entry<Key, Value> e : tmOut.entrySet()) {
assertTrue(e.getValue().get().length == 8);
assertTrue(16 < encoder.decode(e.getValue().get()));
}
assertTrue("size after seeking past versions was " + tmOut.size(), tmOut.size() == 0);
// after doing this seek, should get zero keys for row 0 and 3 keys for row 1
seekKey = new Key(new Text(String.format("%03d", 0)), colf, colq, 15);
it.seek(new Range(seekKey, null), EMPTY_COL_FAMS, false);
tmOut = iteratorOverTestData(it);
for (Entry<Key, Value> e : tmOut.entrySet()) {
assertTrue(e.getValue().get().length == 8);
assertTrue(16 < encoder.decode(e.getValue().get()));
}
assertTrue("size after seeking past versions was " + tmOut.size(), tmOut.size() == 3);
} catch (IOException e) {
assertFalse(true);
} catch (Exception e) {
log.error("{}", e.getMessage(), e);
assertFalse(true);
}
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class VersioningIteratorTest method test1.
@Test
public void test1() {
Text colf = new Text("a");
Text colq = new Text("b");
TreeMap<Key, Value> tm = new TreeMap<>();
createTestData(tm, colf, colq);
try {
VersioningIterator it = new VersioningIterator();
IteratorSetting is = new IteratorSetting(1, VersioningIterator.class);
VersioningIterator.setMaxVersions(is, 3);
it.init(new SortedMapIterator(tm), is.getOptions(), null);
it.seek(new Range(), EMPTY_COL_FAMS, false);
TreeMap<Key, Value> tmOut = iteratorOverTestData(it);
for (Entry<Key, Value> e : tmOut.entrySet()) {
assertTrue(e.getValue().get().length == 8);
assertTrue(16 < encoder.decode(e.getValue().get()));
}
assertTrue("size after keeping 3 versions was " + tmOut.size(), tmOut.size() == 6);
} catch (IOException e) {
assertFalse(true);
} catch (Exception e) {
log.error("{}", e.getMessage(), e);
assertFalse(true);
}
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class VersioningIteratorTest method test_maxLongExclusiveKey.
@Test
public void test_maxLongExclusiveKey() throws IOException {
Text row = new Text("a");
Text colf = new Text("b");
Text colq = new Text("c");
Text cv = new Text();
TreeMap<Key, Value> tm = new TreeMap<>();
tm.put(new Key(row, colf, colq, cv, Long.MAX_VALUE), new Value("00".getBytes()));
tm.put(new Key(row, colf, colq, cv, Long.MAX_VALUE - 1), new Value("11".getBytes()));
VersioningIterator it = new VersioningIterator();
IteratorSetting is = new IteratorSetting(1, VersioningIterator.class);
VersioningIterator.setMaxVersions(is, 1);
it.init(new SortedMapIterator(tm), is.getOptions(), null);
Key startKey = new Key(row, colf, colq, cv, Long.MAX_VALUE);
Range testRange = new Range(startKey, false, startKey.followingKey(PartialKey.ROW), true);
it.seek(testRange, EMPTY_COL_FAMS, false);
assertFalse(it.hasTop());
}
use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.
the class VersioningIteratorTest method test_maxLongInclusiveKey.
@Test
public void test_maxLongInclusiveKey() throws IOException {
Text row = new Text("a");
Text colf = new Text("b");
Text colq = new Text("c");
Text cv = new Text();
TreeMap<Key, Value> tm = new TreeMap<>();
tm.put(new Key(row, colf, colq, cv, Long.MAX_VALUE), new Value("00".getBytes()));
tm.put(new Key(row, colf, colq, cv, Long.MAX_VALUE - 1), new Value("11".getBytes()));
VersioningIterator it = new VersioningIterator();
IteratorSetting is = new IteratorSetting(1, VersioningIterator.class);
VersioningIterator.setMaxVersions(is, 1);
it.init(new SortedMapIterator(tm), is.getOptions(), null);
Key startKey = new Key(row, colf, colq, cv, Long.MAX_VALUE);
Range testRange = new Range(startKey, true, startKey.followingKey(PartialKey.ROW), true);
it.seek(testRange, EMPTY_COL_FAMS, false);
assertTrue(it.hasTop());
assertTrue(it.getTopValue().contentEquals("00".getBytes()));
it.next();
assertFalse(it.hasTop());
}
Aggregations