use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.
the class ElementConverterFunction method call.
@Override
public Iterator<Tuple2<Key, Value>> call(final Element e) throws Exception {
final List<Tuple2<Key, Value>> tuples = new ArrayList<>(2);
final Pair<Key> keys = converterBroadcast.value().getKeysFromElement(e);
final Value value = converterBroadcast.value().getValueFromElement(e);
tuples.add(new Tuple2<>(keys.getFirst(), value));
final Key second = keys.getSecond();
if (second != null) {
tuples.add(new Tuple2<>(second, value));
}
return tuples.listIterator();
}
use of org.apache.accumulo.core.data.Key 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> 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 (first != null) {
buf.$plus$eq(new Tuple2<>(first, value));
}
final Key second = keys.getSecond();
if (second != null) {
buf.$plus$eq(new Tuple2<>(second, value));
}
return buf;
}
use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.
the class RowIDAggregator method deepCopy.
@Override
public SortedKeyValueIterator<Key, Value> deepCopy(final IteratorEnvironment env) {
RowIDAggregator rowIDAggregator = new RowIDAggregator();
rowIDAggregator.topKey = this.topKey;
rowIDAggregator.topValue = this.topValue;
rowIDAggregator.schema = this.schema;
rowIDAggregator.aggregator = this.aggregator;
rowIDAggregator.elementConverter = this.elementConverter;
Key newWorkKey = new Key();
newWorkKey.set(workKey);
rowIDAggregator.workKey = newWorkKey;
return rowIDAggregator;
}
use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.
the class RowIDAggregator method seek.
@Override
public void seek(final Range range, final Collection<ByteSequence> columnFamilies, final boolean inclusive) throws IOException {
topKey = null;
workKey = new Key();
super.seek(range, columnFamilies, inclusive);
currentRange = range;
currentColumnFamilies = columnFamilies;
currentColumnFamiliesInclusive = inclusive;
findTop();
}
use of org.apache.accumulo.core.data.Key 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(topProperties));
} catch (AccumuloElementConversionException e) {
throw new RuntimeException(e);
}
}
Aggregations