Search in sources :

Example 1 with BaseIteratorEnvironment

use of org.apache.accumulo.core.client.impl.BaseIteratorEnvironment in project accumulo by apache.

the class FirstEntryInRowIteratorTest method process.

private static long process(TreeMap<Key, Value> sourceMap, TreeMap<Key, Value> resultMap, Range range, IteratorSetting iteratorSetting) throws IOException {
    org.apache.accumulo.core.iterators.SortedMapIterator source = new SortedMapIterator(sourceMap);
    CountingIterator counter = new CountingIterator(source);
    FirstEntryInRowIterator feiri = new FirstEntryInRowIterator();
    IteratorEnvironment env = new BaseIteratorEnvironment();
    feiri.init(counter, iteratorSetting.getOptions(), env);
    feiri.seek(range, LocalityGroupUtil.EMPTY_CF_SET, false);
    while (feiri.hasTop()) {
        resultMap.put(feiri.getTopKey(), feiri.getTopValue());
        feiri.next();
    }
    return counter.getCount();
}
Also used : BaseIteratorEnvironment(org.apache.accumulo.core.client.impl.BaseIteratorEnvironment) CountingIterator(org.apache.accumulo.core.iterators.system.CountingIterator) BaseIteratorEnvironment(org.apache.accumulo.core.client.impl.BaseIteratorEnvironment)

Example 2 with BaseIteratorEnvironment

use of org.apache.accumulo.core.client.impl.BaseIteratorEnvironment in project accumulo by apache.

the class SortedMapIteratorTest method testSampleNotPresent.

@Test(expected = SampleNotPresentException.class)
public void testSampleNotPresent() {
    SortedMapIterator smi = new SortedMapIterator(new TreeMap<>());
    smi.deepCopy(new BaseIteratorEnvironment() {

        @Override
        public boolean isSamplingEnabled() {
            return true;
        }

        @Override
        public SamplerConfiguration getSamplerConfiguration() {
            return new SamplerConfiguration(RowSampler.class.getName());
        }
    });
}
Also used : BaseIteratorEnvironment(org.apache.accumulo.core.client.impl.BaseIteratorEnvironment) SamplerConfiguration(org.apache.accumulo.core.client.sample.SamplerConfiguration) Test(org.junit.Test)

Example 3 with BaseIteratorEnvironment

use of org.apache.accumulo.core.client.impl.BaseIteratorEnvironment in project accumulo by apache.

the class MetadataBulkLoadFilterTest method testBasic.

@Test
public void testBasic() throws IOException {
    TreeMap<Key, Value> tm1 = new TreeMap<>();
    TreeMap<Key, Value> expected = new TreeMap<>();
    // following should not be deleted by filter
    put(tm1, "2;m", TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN, "/t1");
    put(tm1, "2;m", DataFileColumnFamily.NAME, "/t1/file1", new DataFileValue(1, 1).encodeAsString());
    put(tm1, "2;m", TabletsSection.BulkFileColumnFamily.NAME, "/t1/file1", "5");
    put(tm1, "2;m", TabletsSection.BulkFileColumnFamily.NAME, "/t1/file3", "7");
    put(tm1, "2;m", TabletsSection.BulkFileColumnFamily.NAME, "/t1/file4", "9");
    put(tm1, "2<", TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN, "/t2");
    put(tm1, "2<", DataFileColumnFamily.NAME, "/t2/file2", new DataFileValue(1, 1).encodeAsString());
    put(tm1, "2<", TabletsSection.BulkFileColumnFamily.NAME, "/t2/file6", "5");
    put(tm1, "2<", TabletsSection.BulkFileColumnFamily.NAME, "/t2/file7", "7");
    put(tm1, "2<", TabletsSection.BulkFileColumnFamily.NAME, "/t2/file8", "9");
    put(tm1, "2<", TabletsSection.BulkFileColumnFamily.NAME, "/t2/fileC", null);
    expected.putAll(tm1);
    // the following should be deleted by filter
    put(tm1, "2;m", TabletsSection.BulkFileColumnFamily.NAME, "/t1/file5", "8");
    put(tm1, "2<", TabletsSection.BulkFileColumnFamily.NAME, "/t2/file9", "8");
    put(tm1, "2<", TabletsSection.BulkFileColumnFamily.NAME, "/t2/fileA", "2");
    TestMetadataBulkLoadFilter iter = new TestMetadataBulkLoadFilter();
    iter.init(new SortedMapIterator(tm1), new HashMap<>(), new BaseIteratorEnvironment() {

        @Override
        public boolean isFullMajorCompaction() {
            return false;
        }

        @Override
        public IteratorScope getIteratorScope() {
            return IteratorScope.majc;
        }
    });
    iter.seek(new Range(), new ArrayList<>(), false);
    TreeMap<Key, Value> actual = new TreeMap<>();
    while (iter.hasTop()) {
        actual.put(iter.getTopKey(), iter.getTopValue());
        iter.next();
    }
    Assert.assertEquals(expected, actual);
}
Also used : DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) TreeMap(java.util.TreeMap) SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) BaseIteratorEnvironment(org.apache.accumulo.core.client.impl.BaseIteratorEnvironment) DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) Value(org.apache.accumulo.core.data.Value) IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Aggregations

BaseIteratorEnvironment (org.apache.accumulo.core.client.impl.BaseIteratorEnvironment)3 Test (org.junit.Test)2 TreeMap (java.util.TreeMap)1 SamplerConfiguration (org.apache.accumulo.core.client.sample.SamplerConfiguration)1 Key (org.apache.accumulo.core.data.Key)1 Range (org.apache.accumulo.core.data.Range)1 Value (org.apache.accumulo.core.data.Value)1 IteratorScope (org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope)1 SortedMapIterator (org.apache.accumulo.core.iterators.SortedMapIterator)1 CountingIterator (org.apache.accumulo.core.iterators.system.CountingIterator)1 DataFileValue (org.apache.accumulo.core.metadata.schema.DataFileValue)1