use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator 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.SortedMapIterator in project accumulo by apache.
the class RowDeletingIteratorTest method test2.
@Test
public void test2() 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, "r1", "cf1", "cq5", 15, "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, "r1", "cf1", "cq3", 15, "v1");
rdi.next();
testAssertions(rdi, "r1", "cf1", "cq5", 15, "v1");
rdi.next();
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
rdi.seek(new Range(newKey("r1", "cf1", "cq1", 5), null), new ArrayList<>(), false);
testAssertions(rdi, "r1", "cf1", "cq3", 15, "v1");
rdi.next();
testAssertions(rdi, "r1", "cf1", "cq5", 15, "v1");
rdi.next();
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
rdi.seek(new Range(newKey("r1", "cf1", "cq4", 5), null), new ArrayList<>(), false);
testAssertions(rdi, "r1", "cf1", "cq5", 15, "v1");
rdi.next();
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
rdi.seek(new Range(newKey("r1", "cf1", "cq5", 20), null), new ArrayList<>(), false);
testAssertions(rdi, "r1", "cf1", "cq5", 15, "v1");
rdi.next();
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
rdi.seek(new Range(newKey("r1", "cf1", "cq9", 20), null), new ArrayList<>(), false);
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
}
use of org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator in project accumulo by apache.
the class TestCfCqSlice method testStackedFilters.
@Test
public void testStackedFilters() throws Exception {
Map<String, String> firstOpts = new HashMap<>();
Map<String, String> secondOpts = new HashMap<>();
boolean[][][] foundKvs = new boolean[LR_DIM][LR_DIM][LR_DIM];
long sliceMinCf = 20;
long sliceMaxCf = 25;
long sliceMinCq = 30;
long sliceMaxCq = 35;
assertTrue(sliceMinCf < LR_DIM, "slice param must be less than LR_DIM");
assertTrue(sliceMinCq < LR_DIM, "slice param must be less than LR_DIM");
assertTrue(sliceMaxCf < LR_DIM, "slice param must be less than LR_DIM");
assertTrue(sliceMaxCq < LR_DIM, "slice param must be less than LR_DIM");
firstOpts.put(CfCqSliceOpts.OPT_MIN_CF, new String(LONG_LEX.encode(sliceMinCf), UTF_8));
firstOpts.put(CfCqSliceOpts.OPT_MAX_CF, new String(LONG_LEX.encode(sliceMaxCf), UTF_8));
secondOpts.put(CfCqSliceOpts.OPT_MIN_CQ, new String(LONG_LEX.encode(sliceMinCq), UTF_8));
secondOpts.put(CfCqSliceOpts.OPT_MAX_CQ, new String(LONG_LEX.encode(sliceMaxCq), UTF_8));
SortedKeyValueIterator<Key, Value> skvi = getFilterClass().getDeclaredConstructor().newInstance();
skvi.init(new SortedMapIterator(data), firstOpts, null);
loadKvs(skvi.deepCopy(null), foundKvs, secondOpts, INFINITY);
for (int i = 0; i < LR_DIM; i++) {
for (int j = 0; j < LR_DIM; j++) {
for (int k = 0; k < LR_DIM; k++) {
if (j >= sliceMinCf && j <= sliceMaxCf && k >= sliceMinCq && k <= sliceMaxCq) {
assertTrue(foundKvs[i][j][k], "(r, cf, cq) == (" + i + ", " + j + ", " + k + ") must be found in scan");
} else {
assertFalse(foundKvs[i][j][k], "(r, cf, cq) == (" + i + ", " + j + ", " + k + ") must not be found in scan");
}
}
}
}
}
use of org.apache.accumulo.core.iteratorsImpl.system.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()) {
assertEquals(8, e.getValue().get().length);
assertTrue(16 < encoder.decode(e.getValue().get()));
}
assertEquals(6, tmOut.size(), "size after keeping 3 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 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"));
tm.put(new Key(row, colf, colq, cv, Long.MAX_VALUE - 1), new Value("11"));
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());
}
Aggregations