use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class FirstEntryInRowTest method test2.
@Test
public void test2() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
for (int r = 0; r < 5; r++) {
for (int cf = r; cf < 100; cf++) {
for (int cq = 3; cq < 6; cq++) {
put(tm1, r, cf, cq, 6, r * cf * cq);
}
}
}
FirstEntryInRowIterator fei = new FirstEntryInRowIterator();
fei.init(new SortedMapIterator(tm1), EMPTY_MAP, null);
fei.seek(new Range(newKey(0, 10, 0, 0), null), EMPTY_SET, false);
testAndCallNext(fei, 1, 1, 3, 6, 1 * 1 * 3);
testAndCallNext(fei, 2, 2, 3, 6, 2 * 2 * 3);
testAndCallNext(fei, 3, 3, 3, 6, 3 * 3 * 3);
testAndCallNext(fei, 4, 4, 3, 6, 4 * 4 * 3);
assertFalse(fei.hasTop());
fei.seek(new Range(newKey(1, 1, 3, 6), newKey(3, 3, 3, 6)), EMPTY_SET, false);
testAndCallNext(fei, 1, 1, 3, 6, 1 * 1 * 3);
testAndCallNext(fei, 2, 2, 3, 6, 2 * 2 * 3);
testAndCallNext(fei, 3, 3, 3, 6, 3 * 3 * 3);
assertFalse(fei.hasTop());
fei.seek(new Range(newKey(1, 1, 3, 6), false, newKey(3, 3, 3, 6), false), EMPTY_SET, false);
testAndCallNext(fei, 2, 2, 3, 6, 2 * 2 * 3);
assertFalse(fei.hasTop());
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class FirstEntryInRowTest method test1.
@Test
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");
put(tm1, "r2", "cf2", "cq4", 5, "v4");
put(tm1, "r2", "cf2", "cq5", 5, "v5");
put(tm1, "r3", "cf3", "cq6", 5, "v6");
FirstEntryInRowIterator fei = new FirstEntryInRowIterator();
fei.init(new SortedMapIterator(tm1), EMPTY_MAP, null);
fei.seek(new Range(), EMPTY_SET, false);
testAndCallNext(fei, "r1", "cf1", "cq1", 5, "v1");
testAndCallNext(fei, "r2", "cf1", "cq1", 5, "v3");
testAndCallNext(fei, "r3", "cf3", "cq6", 5, "v6");
assertFalse(fei.hasTop());
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class ColumnFamilySkippingIteratorTest method test1.
@Test
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");
put(tm1, "r2", "cf2", "cq4", 5, "v4");
put(tm1, "r2", "cf2", "cq5", 5, "v5");
put(tm1, "r3", "cf3", "cq6", 5, "v6");
ColumnFamilySkippingIterator cfi = new ColumnFamilySkippingIterator(new SortedMapIterator(tm1));
cfi.seek(new Range(), EMPTY_SET, true);
assertFalse(cfi.hasTop());
cfi.seek(new Range(), EMPTY_SET, false);
assertTrue(cfi.hasTop());
TreeMap<Key, Value> tm2 = new TreeMap<>();
while (cfi.hasTop()) {
tm2.put(cfi.getTopKey(), cfi.getTopValue());
cfi.next();
}
assertEquals(tm1, tm2);
HashSet<ByteSequence> colfams = new HashSet<>();
colfams.add(new ArrayByteSequence("cf2"));
cfi.seek(new Range(), colfams, true);
testAndCallnext(cfi, "r2", "cf2", "cq4", 5, "v4");
testAndCallnext(cfi, "r2", "cf2", "cq5", 5, "v5");
assertFalse(cfi.hasTop());
colfams.add(new ArrayByteSequence("cf3"));
colfams.add(new ArrayByteSequence("cf4"));
cfi.seek(new Range(), colfams, true);
testAndCallnext(cfi, "r2", "cf2", "cq4", 5, "v4");
testAndCallnext(cfi, "r2", "cf2", "cq5", 5, "v5");
testAndCallnext(cfi, "r3", "cf3", "cq6", 5, "v6");
assertFalse(cfi.hasTop());
cfi.seek(new Range(), colfams, false);
testAndCallnext(cfi, "r1", "cf1", "cq1", 5, "v1");
testAndCallnext(cfi, "r1", "cf1", "cq3", 5, "v2");
testAndCallnext(cfi, "r2", "cf1", "cq1", 5, "v3");
assertFalse(cfi.hasTop());
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class DeletingIteratorTest method test1.
@Test
public void test1() {
Text colf = new Text("a");
Text colq = new Text("b");
Value dvOld = new Value("old");
Value dvDel = new Value("old");
Value dvNew = new Value("new");
TreeMap<Key, Value> tm = new TreeMap<>();
Key k;
for (int i = 0; i < 2; i++) {
for (long j = 0; j < 5; j++) {
k = new Key(new Text(String.format("%03d", i)), colf, colq, j);
tm.put(k, dvOld);
}
}
k = new Key(new Text(String.format("%03d", 0)), colf, colq, 5);
k.setDeleted(true);
tm.put(k, dvDel);
for (int i = 0; i < 2; i++) {
for (long j = 6; j < 11; j++) {
k = new Key(new Text(String.format("%03d", i)), colf, colq, j);
tm.put(k, dvNew);
}
}
assertEquals(21, tm.size(), "Initial size was " + tm.size());
Text checkRow = new Text("000");
try {
SortedKeyValueIterator<Key, Value> it = DeletingIterator.wrap(new SortedMapIterator(tm), false, Behavior.PROCESS);
it.seek(new Range(), EMPTY_COL_FAMS, false);
TreeMap<Key, Value> tmOut = new TreeMap<>();
while (it.hasTop()) {
tmOut.put(it.getTopKey(), it.getTopValue());
it.next();
}
assertEquals(15, tmOut.size(), "size after no propagation was " + tmOut.size());
for (Entry<Key, Value> e : tmOut.entrySet()) {
if (e.getKey().getRow().equals(checkRow)) {
byte[] b = e.getValue().get();
assertEquals('n', b[0]);
assertEquals('e', b[1]);
assertEquals('w', b[2]);
}
}
} catch (IOException e) {
fail();
}
try {
SortedKeyValueIterator<Key, Value> it = DeletingIterator.wrap(new SortedMapIterator(tm), true, Behavior.PROCESS);
it.seek(new Range(), EMPTY_COL_FAMS, false);
TreeMap<Key, Value> tmOut = new TreeMap<>();
while (it.hasTop()) {
tmOut.put(it.getTopKey(), it.getTopValue());
it.next();
}
assertEquals(16, tmOut.size(), "size after propagation was " + tmOut.size());
for (Entry<Key, Value> e : tmOut.entrySet()) {
if (e.getKey().getRow().equals(checkRow)) {
byte[] b = e.getValue().get();
if (e.getKey().isDeleted()) {
assertEquals('o', b[0]);
assertEquals('l', b[1]);
assertEquals('d', b[2]);
} else {
assertEquals('n', b[0]);
assertEquals('e', b[1]);
assertEquals('w', b[2]);
}
}
}
} catch (IOException e) {
fail();
}
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class DeletingIteratorTest method test4.
// test range inclusiveness
@Test
public void test4() 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");
SortedKeyValueIterator<Key, Value> it = DeletingIterator.wrap(new SortedMapIterator(tm), false, Behavior.PROCESS);
it.seek(newRange("r000", 3), 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", 3, false), EMPTY_COL_FAMS, false);
assertFalse(it.hasTop());
}
Aggregations