use of uk.gov.gchq.gaffer.accumulostore.key.exception.AggregationException in project Gaffer by gchq.
the class CoreKeyGroupByAggregatorIterator method validateOptions.
@Override
public boolean validateOptions(final Map<String, String> options) {
if (!super.validateOptions(options)) {
return false;
}
try {
final Class<?> elementConverterClass = Class.forName(options.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS));
elementConverter = (AccumuloElementConverter) elementConverterClass.getConstructor(Schema.class).newInstance(schema);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new AggregationException("Failed to load element converter from class name provided : " + options.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS), e);
}
return true;
}
use of uk.gov.gchq.gaffer.accumulostore.key.exception.AggregationException in project Gaffer by gchq.
the class AggregatorIterator method reduce.
@Override
public Value reduce(final Key key, final Iterator<Value> iter) {
// Get first Value. If this is the only Value then return it straight
// away;
Value value = iter.next();
if (!iter.hasNext()) {
return value;
}
final String group;
try {
group = new String(key.getColumnFamilyData().getBackingArray(), CommonConstants.UTF_8);
} catch (final UnsupportedEncodingException e) {
throw new AggregationException("Failed to recreate a graph element from a key and value", e);
}
Properties properties;
final ElementAggregator aggregator;
try {
properties = elementConverter.getPropertiesFromValue(group, value);
} catch (final AccumuloElementConversionException e) {
throw new AggregationException("Failed to recreate a graph element from a key and value", e);
}
aggregator = schema.getElement(group).getAggregator();
aggregator.aggregate(properties);
while (iter.hasNext()) {
value = iter.next();
try {
properties = elementConverter.getPropertiesFromValue(group, value);
} catch (final AccumuloElementConversionException e) {
throw new AggregationException("Failed to recreate a graph element from a key and value", e);
}
aggregator.aggregate(properties);
}
properties = new Properties();
aggregator.state(properties);
try {
return elementConverter.getValueFromProperties(group, properties);
} catch (final AccumuloElementConversionException e) {
throw new AggregationException("Failed to create an accumulo value from an elements properties", e);
}
}
use of uk.gov.gchq.gaffer.accumulostore.key.exception.AggregationException in project Gaffer by gchq.
the class RowIDAggregator method validateOptions.
@Override
public boolean validateOptions(final Map<String, String> options) {
if (!options.containsKey(AccumuloStoreConstants.SCHEMA)) {
throw new IllegalArgumentException("Must specify the " + AccumuloStoreConstants.SCHEMA);
}
if (!options.containsKey(AccumuloStoreConstants.COLUMN_FAMILY)) {
throw new IllegalArgumentException("Must specify the " + AccumuloStoreConstants.COLUMN_FAMILY);
}
try {
schema = Schema.fromJson(options.get(AccumuloStoreConstants.SCHEMA).getBytes(CommonConstants.UTF_8));
} catch (final UnsupportedEncodingException e) {
throw new SchemaException("Unable to deserialise the schema", e);
}
try {
final Class<?> elementConverterClass = Class.forName(options.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS));
elementConverter = (AccumuloElementConverter) elementConverterClass.getConstructor(Schema.class).newInstance(schema);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new AggregationException("Failed to load element converter from class name provided : " + options.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS), e);
}
group = options.get(AccumuloStoreConstants.COLUMN_FAMILY);
aggregator = schema.getElement(group).getAggregator();
return true;
}
use of uk.gov.gchq.gaffer.accumulostore.key.exception.AggregationException in project Gaffer by gchq.
the class AggregatorIterator method validateOptions.
@Override
public boolean validateOptions(final Map<String, String> options) {
if (!super.validateOptions(options)) {
return false;
}
if (!options.containsKey(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS)) {
throw new IllegalArgumentException("Must specify the " + AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS);
}
if (!options.containsKey(AccumuloStoreConstants.SCHEMA)) {
throw new IllegalArgumentException("Must specify the " + AccumuloStoreConstants.SCHEMA);
}
try {
schema = Schema.fromJson(options.get(AccumuloStoreConstants.SCHEMA).getBytes(CommonConstants.UTF_8));
} catch (final UnsupportedEncodingException e) {
throw new SchemaException("Unable to deserialise the schema from json", e);
}
try {
final Class<?> elementConverterClass = Class.forName(options.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS));
elementConverter = (AccumuloElementConverter) elementConverterClass.getConstructor(Schema.class).newInstance(schema);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new AggregationException("Failed to load element converter from class name provided : " + options.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS), e);
}
return true;
}
Aggregations