use of uk.gov.gchq.gaffer.accumulostore.key.exception.AccumuloElementConversionException in project Gaffer by gchq.
the class AbstractCoreKeyAccumuloElementConverter method getPropertiesFromColumnQualifier.
@Override
public Properties getPropertiesFromColumnQualifier(final String group, final byte[] bytes) {
final Properties properties = new Properties();
if (null != bytes && bytes.length != 0) {
int delimiterPosition = 0;
final int arrayLength = bytes.length;
final SchemaElementDefinition elementDefinition = getSchemaElementDefinition(group);
final Iterator<String> propertyNames = elementDefinition.getGroupBy().iterator();
while (propertyNames.hasNext() && delimiterPosition < arrayLength) {
final String propertyName = propertyNames.next();
try {
delimiterPosition = addDeserialisedProperty(bytes, delimiterPosition, properties, elementDefinition, propertyName);
} catch (final SerialisationException e) {
throw new AccumuloElementConversionException("Failed to deserialise property " + propertyName, e);
}
}
}
return properties;
}
use of uk.gov.gchq.gaffer.accumulostore.key.exception.AccumuloElementConversionException in project Gaffer by gchq.
the class AbstractCoreKeyAccumuloElementConverter method getPropertiesFromValue.
@Override
public Properties getPropertiesFromValue(final String group, final Value value) {
final Properties properties = new Properties();
if (isNotEmpty(value)) {
final byte[] bytes = value.get();
int delimiterPosition = 0;
final int arrayLength = bytes.length;
final SchemaElementDefinition elementDefinition = getSchemaElementDefinition(group);
final Iterator<String> propertyNames = elementDefinition.getProperties().iterator();
while (propertyNames.hasNext() && delimiterPosition < arrayLength) {
final String propertyName = propertyNames.next();
try {
if (isStoredInValue(propertyName, elementDefinition)) {
delimiterPosition = addDeserialisedProperty(bytes, delimiterPosition, properties, elementDefinition, propertyName);
}
} catch (final SerialisationException e) {
throw new AccumuloElementConversionException("Failed to deserialise property " + propertyName, e);
}
}
}
return properties;
}
use of uk.gov.gchq.gaffer.accumulostore.key.exception.AccumuloElementConversionException in project Gaffer by gchq.
the class CoreKeyGroupByCombiner method findTop.
/**
* Sets the topKey and topValue based on the top key of the source.
*/
private void findTop() {
// check if aggregation is needed
if (super.hasTop()) {
workKey.set(super.getTopKey());
if (workKey.isDeleted()) {
return;
}
if (null != aggregatedGroups && !aggregatedGroups.contains(workKey)) {
return;
}
final byte[] columnFamily = workKey.getColumnFamilyData().getBackingArray();
final String group;
try {
group = elementConverter.getGroupFromColumnFamily(columnFamily);
} catch (final AccumuloElementConversionException e) {
throw new RuntimeException(e);
}
final ViewElementDefinition elementDef = view.getElement(group);
Set<String> groupBy = elementDef.getGroupBy();
if (null == groupBy) {
groupBy = schema.getElement(group).getGroupBy();
}
final Iterator<Properties> iter = new KeyValueIterator(getSource(), group, elementConverter, schema, groupBy);
final Properties aggregatedProperties = reduce(group, workKey, iter, groupBy, elementDef.getAggregator());
try {
final Properties properties = elementConverter.getPropertiesFromColumnQualifier(group, workKey.getColumnQualifierData().getBackingArray());
properties.putAll(elementConverter.getPropertiesFromColumnVisibility(group, workKey.getColumnVisibilityData().getBackingArray()));
properties.putAll(aggregatedProperties);
topValue = elementConverter.getValueFromProperties(group, properties);
topKey = new Key(workKey.getRowData().getBackingArray(), columnFamily, elementConverter.buildColumnQualifier(group, properties), elementConverter.buildColumnVisibility(group, properties), elementConverter.buildTimestamp(group, properties));
} catch (final AccumuloElementConversionException e) {
throw new RuntimeException(e);
}
while (iter.hasNext()) {
iter.next();
}
}
}
use of uk.gov.gchq.gaffer.accumulostore.key.exception.AccumuloElementConversionException in project Gaffer by gchq.
the class ElementConverterFunction method apply.
@Override
public TraversableOnce<Tuple2<Key, Value>> apply(final Element element) {
final ArrayBuffer<Tuple2<Key, Value>> buf = new ArrayBuffer<>();
Pair<Key, Key> keys = new Pair<>();
Value value = null;
try {
keys = converterBroadcast.value().getKeysFromElement(element);
value = converterBroadcast.value().getValueFromElement(element);
} catch (final AccumuloElementConversionException e) {
LOGGER.error(e.getMessage(), e);
}
final Key first = keys.getFirst();
if (null != first) {
buf.$plus$eq(new Tuple2<>(first, value));
}
final Key second = keys.getSecond();
if (null != second) {
buf.$plus$eq(new Tuple2<>(second, value));
}
return buf;
}
use of uk.gov.gchq.gaffer.accumulostore.key.exception.AccumuloElementConversionException in project Gaffer by gchq.
the class RowIDAggregator method findTop.
/**
* Given the current position in the source}, filter to only the columns specified. Sets topKey and topValue to non-null on success
*
* @throws IOException Failure to seek
*/
protected void findTop() throws IOException {
if (!source.hasTop()) {
return;
}
PropertiesIterator iter = new PropertiesIterator(source, currentRange, currentColumnFamilies, currentColumnFamiliesInclusive, group, workKey, elementConverter);
Properties topProperties = reduce(iter);
try {
topValue = elementConverter.getValueFromProperties(group, topProperties);
topKey = new Key(workKey.getRowData().getBackingArray(), group.getBytes(CommonConstants.UTF_8), elementConverter.buildColumnQualifier(group, topProperties), elementConverter.buildColumnVisibility(group, topProperties), elementConverter.buildTimestamp(group, topProperties));
} catch (final AccumuloElementConversionException e) {
throw new RuntimeException(e);
}
}
Aggregations