use of org.apache.accumulo.core.iterators.IteratorEnvironment in project accumulo by apache.
the class CombinerTest method testDeleteHandling.
@Test
public void testDeleteHandling() throws Exception {
Encoder<Long> encoder = LongCombiner.STRING_ENCODER;
TreeMap<Key, Value> input = new TreeMap<>();
IteratorEnvironment paritalMajcIe = new CombinerIteratorEnvironment(IteratorScope.majc, false);
IteratorEnvironment fullMajcIe = new CombinerIteratorEnvironment(IteratorScope.majc, true);
// keys that aggregate
newKeyValue(input, 1, 1, 1, 1, false, 4l, encoder);
newKeyValue(input, 1, 1, 1, 2, true, 0l, encoder);
newKeyValue(input, 1, 1, 1, 3, false, 2l, encoder);
newKeyValue(input, 1, 1, 1, 4, false, 9l, encoder);
TreeMap<Key, Value> expected = new TreeMap<>();
newKeyValue(expected, 1, 1, 1, 1, false, 4l, encoder);
newKeyValue(expected, 1, 1, 1, 2, true, 0l, encoder);
newKeyValue(expected, 1, 1, 1, 4, false, 11l, encoder);
runDeleteHandlingTest(input, input, true, paritalMajcIe);
runDeleteHandlingTest(input, expected, true, fullMajcIe);
runDeleteHandlingTest(input, expected, true, SCAN_IE);
runDeleteHandlingTest(input, expected, false, fullMajcIe, ".*ERROR.*ACCUMULO-2232.*");
runDeleteHandlingTest(input, expected, false, SCAN_IE);
runDeleteHandlingTest(input, expected, false, paritalMajcIe, ".*ERROR.*SummingCombiner.*ACCUMULO-2232.*");
runDeleteHandlingTest(input, expected, null, paritalMajcIe, ".*ERROR.*SummingCombiner.*ACCUMULO-2232.*");
runDeleteHandlingTest(input, expected, null, fullMajcIe, ".*ERROR.*SummingCombiner.*ACCUMULO-2232.*");
}
use of org.apache.accumulo.core.iterators.IteratorEnvironment in project accumulo-examples by apache.
the class CutoffIntersectingIterator method init.
@Override
public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException {
super.init(source, options, env);
IteratorEnvironment sampleEnv = env.cloneWithSamplingEnabled();
setMax(sampleEnv, options);
SortedKeyValueIterator<Key, Value> sampleDC = source.deepCopy(sampleEnv);
sampleII = new IntersectingIterator();
sampleII.init(sampleDC, options, env);
}
use of org.apache.accumulo.core.iterators.IteratorEnvironment in project Gaffer by gchq.
the class RFileReaderIterator method applyIterator.
private SortedKeyValueIterator<Key, Value> applyIterator(final SortedKeyValueIterator<Key, Value> source, final IteratorSetting is) {
try {
SortedKeyValueIterator<Key, Value> result = Class.forName(is.getIteratorClass()).asSubclass(SortedKeyValueIterator.class).newInstance();
result.init(source, is.getOptions(), new IteratorEnvironment() {
@Override
public SortedKeyValueIterator<Key, Value> reserveMapFileReader(final String mapFileName) {
return null;
}
@Override
public AccumuloConfiguration getConfig() {
return null;
}
@Override
public IteratorUtil.IteratorScope getIteratorScope() {
return IteratorUtil.IteratorScope.majc;
}
@Override
public boolean isFullMajorCompaction() {
return false;
}
@Override
public void registerSideChannel(final SortedKeyValueIterator<Key, Value> iter) {
}
@Override
public Authorizations getAuthorizations() {
return null;
}
@Override
public IteratorEnvironment cloneWithSamplingEnabled() {
return null;
}
@Override
public boolean isSamplingEnabled() {
return false;
}
@Override
public SamplerConfiguration getSamplerConfiguration() {
return null;
}
});
return result;
} catch (final IOException | InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException("Exception creating iterator of class " + is.getIteratorClass());
}
}
use of org.apache.accumulo.core.iterators.IteratorEnvironment in project Gaffer by gchq.
the class AggregatorIteratorTest method shouldGetGroupFromElementConverter.
@Test
public void shouldGetGroupFromElementConverter() throws IOException {
MockAccumuloElementConverter.cleanUp();
// Given
MockAccumuloElementConverter.mock = mock(AccumuloElementConverter.class);
final Key key = mock(Key.class);
final List<Value> values = Arrays.asList(mock(Value.class), mock(Value.class));
final Schema schema = new Schema.Builder().edge(TestGroups.ENTITY, new SchemaEdgeDefinition()).build();
final ByteSequence colFamData = mock(ByteSequence.class);
final byte[] colFam = StringUtil.toBytes(TestGroups.ENTITY);
final SortedKeyValueIterator sortedKeyValueIterator = mock(SortedKeyValueIterator.class);
final IteratorEnvironment iteratorEnvironment = mock(IteratorEnvironment.class);
final Map<String, String> options = new HashMap();
options.put("columns", "test");
options.put(AccumuloStoreConstants.SCHEMA, new String(schema.toCompactJson()));
options.put(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, MockAccumuloElementConverter.class.getName());
given(colFamData.getBackingArray()).willReturn(colFam);
given(key.getColumnFamilyData()).willReturn(colFamData);
given(MockAccumuloElementConverter.mock.getGroupFromColumnFamily(colFam)).willReturn(TestGroups.ENTITY);
final AggregatorIterator aggregatorIterator = new AggregatorIterator();
// When
aggregatorIterator.init(sortedKeyValueIterator, options, iteratorEnvironment);
aggregatorIterator.reduce(key, values.iterator());
// Then
verify(MockAccumuloElementConverter.mock, times(1)).getGroupFromColumnFamily(colFam);
MockAccumuloElementConverter.cleanUp();
}
use of org.apache.accumulo.core.iterators.IteratorEnvironment in project accumulo by apache.
the class TransformingIteratorTest method setUpTransformIterator.
private void setUpTransformIterator(Class<? extends TransformingIterator> clazz, boolean setupAuths) throws IOException {
SortedMapIterator source = new SortedMapIterator(data);
ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(source);
SortedKeyValueIterator<Key, Value> visFilter = VisibilityFilter.wrap(cfsi, authorizations, new byte[0]);
ReuseIterator reuserIter = new ReuseIterator();
reuserIter.init(visFilter, EMPTY_OPTS, null);
try {
titer = clazz.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
IteratorEnvironment iterEnv = EasyMock.createMock(IteratorEnvironment.class);
EasyMock.expect(iterEnv.getIteratorScope()).andReturn(IteratorScope.scan).anyTimes();
EasyMock.replay(iterEnv);
Map<String, String> opts;
if (setupAuths) {
IteratorSetting cfg = new IteratorSetting(21, clazz);
TransformingIterator.setAuthorizations(cfg, new Authorizations("vis0", "vis1", "vis2", "vis3"));
opts = cfg.getOptions();
} else {
opts = ImmutableMap.of();
}
titer.init(reuserIter, opts, iterEnv);
}
Aggregations