Search in sources :

Example 41 with SortedMapIterator

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;
}
Also used : ColumnFamilySkippingIterator(org.apache.accumulo.core.iteratorsImpl.system.ColumnFamilySkippingIterator) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator)

Example 42 with SortedMapIterator

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");
}
Also used : Value(org.apache.accumulo.core.data.Value) TreeMap(java.util.TreeMap) SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key) Test(org.junit.jupiter.api.Test)

Example 43 with SortedMapIterator

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");
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) Value(org.apache.accumulo.core.data.Value) SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) Key(org.apache.accumulo.core.data.Key) Test(org.junit.jupiter.api.Test)

Example 44 with SortedMapIterator

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();
    }
}
Also used : IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Value(org.apache.accumulo.core.data.Value) Text(org.apache.hadoop.io.Text) IOException(java.io.IOException) TreeMap(java.util.TreeMap) SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 45 with SortedMapIterator

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());
}
Also used : IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Value(org.apache.accumulo.core.data.Value) Text(org.apache.hadoop.io.Text) TreeMap(java.util.TreeMap) SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey) Test(org.junit.jupiter.api.Test)

Aggregations

SortedMapIterator (org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator)109 Test (org.junit.jupiter.api.Test)97 Range (org.apache.accumulo.core.data.Range)93 Key (org.apache.accumulo.core.data.Key)89 Value (org.apache.accumulo.core.data.Value)89 TreeMap (java.util.TreeMap)82 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)38 Text (org.apache.hadoop.io.Text)29 PartialKey (org.apache.accumulo.core.data.PartialKey)16 Combiner (org.apache.accumulo.core.iterators.Combiner)12 LongCombiner (org.apache.accumulo.core.iterators.LongCombiner)12 TypedValueCombiner (org.apache.accumulo.core.iterators.TypedValueCombiner)12 ArrayList (java.util.ArrayList)11 HashSet (java.util.HashSet)9 DefaultIteratorEnvironment (org.apache.accumulo.core.iterators.DefaultIteratorEnvironment)8 ColumnFamilySkippingIterator (org.apache.accumulo.core.iteratorsImpl.system.ColumnFamilySkippingIterator)8 MultiIterator (org.apache.accumulo.core.iteratorsImpl.system.MultiIterator)8 ByteSequence (org.apache.accumulo.core.data.ByteSequence)7 SortedKeyValueIterator (org.apache.accumulo.core.iterators.SortedKeyValueIterator)7 SourceSwitchingIterator (org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator)7