use of org.apache.accumulo.core.iteratorsImpl.system.ColumnFamilySkippingIterator 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.ColumnFamilySkippingIterator in project accumulo by apache.
the class LargeRowFilterTest method setupIterator.
private LargeRowFilter setupIterator(TreeMap<Key, Value> testData, int maxColumns, IteratorScope scope) throws IOException {
SortedMapIterator smi = new SortedMapIterator(testData);
LargeRowFilter lrfi = new LargeRowFilter();
IteratorSetting is = new IteratorSetting(1, LargeRowFilter.class);
LargeRowFilter.setMaxColumns(is, maxColumns);
lrfi.init(new ColumnFamilySkippingIterator(smi), is.getOptions(), new RowDeletingIteratorTest.TestIE(scope, false));
return lrfi;
}
use of org.apache.accumulo.core.iteratorsImpl.system.ColumnFamilySkippingIterator in project accumulo by apache.
the class InMemoryMapTest method testBug1.
@Test
public void testBug1() throws Exception {
InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath());
for (int i = 0; i < 20; i++) {
mutate(imm, "r1", "foo:cq" + i, 3, "bar" + i);
}
for (int i = 0; i < 20; i++) {
mutate(imm, "r2", "foo:cq" + i, 3, "bar" + i);
}
MemoryIterator ski1 = imm.skvIterator(null);
ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(ski1);
imm.delete(0);
ArrayList<ByteSequence> columns = new ArrayList<>();
columns.add(new ArrayByteSequence("bar"));
// this seek resulted in an infinite loop before a bug was fixed
cfsi.seek(new Range("r1"), columns, true);
assertFalse(cfsi.hasTop());
ski1.close();
}
use of org.apache.accumulo.core.iteratorsImpl.system.ColumnFamilySkippingIterator in project accumulo by apache.
the class CollectTabletStats method createScanIterator.
private static SortedKeyValueIterator<Key, Value> createScanIterator(KeyExtent ke, Collection<SortedKeyValueIterator<Key, Value>> mapfiles, Authorizations authorizations, byte[] defaultLabels, HashSet<Column> columnSet, List<IterInfo> ssiList, Map<String, Map<String, String>> ssio, boolean useTableIterators, TableConfiguration conf) throws IOException {
SortedMapIterator smi = new SortedMapIterator(new TreeMap<>());
List<SortedKeyValueIterator<Key, Value>> iters = new ArrayList<>(mapfiles.size() + 1);
iters.addAll(mapfiles);
iters.add(smi);
MultiIterator multiIter = new MultiIterator(iters, ke);
SortedKeyValueIterator<Key, Value> delIter = DeletingIterator.wrap(multiIter, false, Behavior.PROCESS);
ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(delIter);
SortedKeyValueIterator<Key, Value> colFilter = ColumnQualifierFilter.wrap(cfsi, columnSet);
SortedKeyValueIterator<Key, Value> visFilter = VisibilityFilter.wrap(colFilter, authorizations, defaultLabels);
if (useTableIterators) {
IterLoad il = IterConfigUtil.loadIterConf(IteratorScope.scan, ssiList, ssio, conf);
return IterConfigUtil.loadIterators(visFilter, il.useAccumuloClassLoader(true));
}
return visFilter;
}
use of org.apache.accumulo.core.iteratorsImpl.system.ColumnFamilySkippingIterator in project accumulo by apache.
the class ColumnFamilySkippingIteratorTest method test3.
@Test
public void test3() throws Exception {
// construct test where ColumnFamilySkippingIterator might try to seek past the end of the user
// supplied range
TreeMap<Key, Value> tm1 = new TreeMap<>();
for (int r = 0; r < 3; r++) {
for (int cf = 4; cf < 1000; cf++) {
for (int cq = 0; cq < 1; cq++) {
put(tm1, r, cf, cq, 6, r * cf * cq);
}
}
}
CountingIterator ci = new CountingIterator(new SortedMapIterator(tm1));
ColumnFamilySkippingIterator cfi = new ColumnFamilySkippingIterator(ci);
HashSet<ByteSequence> colfams = new HashSet<>();
colfams.add(new ArrayByteSequence(String.format("%06d", 4)));
Range range = new Range(newKey(0, 4, 0, 6), true, newKey(0, 400, 0, 6), true);
cfi.seek(range, colfams, true);
assertTrue(cfi.hasTop());
assertEquals(newKey(0, 4, 0, 6), cfi.getTopKey());
cfi.next();
assertFalse(cfi.hasTop());
colfams.add(new ArrayByteSequence(String.format("%06d", 500)));
cfi.seek(range, colfams, true);
assertTrue(cfi.hasTop());
assertEquals(newKey(0, 4, 0, 6), cfi.getTopKey());
cfi.next();
assertFalse(cfi.hasTop());
range = new Range(newKey(0, 4, 0, 6), true, newKey(1, 400, 0, 6), true);
cfi.seek(range, colfams, true);
assertTrue(cfi.hasTop());
assertEquals(newKey(0, 4, 0, 6), cfi.getTopKey());
cfi.next();
assertTrue(cfi.hasTop());
assertEquals(newKey(0, 500, 0, 6), cfi.getTopKey());
cfi.next();
assertTrue(cfi.hasTop());
assertEquals(newKey(1, 4, 0, 6), cfi.getTopKey());
cfi.next();
assertFalse(cfi.hasTop());
// System.out.println(ci.getCount());
}
Aggregations