use of uk.gov.gchq.gaffer.hbasestore.serialisation.LazyElementCell in project Gaffer by gchq.
the class QueryAggregationProcessor method process.
@Override
public List<LazyElementCell> process(final List<LazyElementCell> elementCells) {
if (elementCells.size() <= 1) {
return elementCells;
}
final List<LazyElementCell> output = new ArrayList<>();
ElementAggregator aggregator = null;
Properties aggregatedProperties = null;
LazyElementCell firstElementCell = null;
for (final LazyElementCell elementCell : elementCells) {
if (elementCell.isDeleted()) {
continue;
}
if (!aggregatedGroups.contains(elementCell.getGroup())) {
if (null != firstElementCell) {
output(firstElementCell, aggregatedProperties, output);
firstElementCell = null;
}
output(elementCell, null, output);
aggregatedProperties = null;
aggregator = null;
} else if (null == firstElementCell) {
firstElementCell = elementCell;
aggregatedProperties = null;
aggregator = null;
} else {
final String group = elementCell.getGroup();
final Set<String> schemaGroupBy = schema.getElement(group).getGroupBy();
final ViewElementDefinition elementDef = view.getElement(group);
final Set<String> groupBy = null != elementDef ? elementDef.getGroupBy() : null;
if (!compareGroupByKeys(firstElementCell.getCell(), elementCell.getCell(), group, schemaGroupBy, groupBy)) {
output(firstElementCell, aggregatedProperties, output);
firstElementCell = elementCell;
aggregatedProperties = null;
aggregator = null;
} else {
if (null == aggregator) {
final ElementAggregator viewAggregator = null != elementDef ? elementDef.getAggregator() : null;
aggregator = schema.getElement(group).getQueryAggregator(groupBy, viewAggregator);
aggregatedProperties = firstElementCell.getElement().getProperties();
}
final Properties properties = elementCell.getElement().getProperties();
aggregatedProperties = aggregator.apply(properties, aggregatedProperties);
}
}
}
output(firstElementCell, aggregatedProperties, output);
return output;
}
use of uk.gov.gchq.gaffer.hbasestore.serialisation.LazyElementCell in project Gaffer by gchq.
the class QueryAggregationProcessor method output.
private void output(final LazyElementCell elementCell, final Properties aggregatedProperties, final List<LazyElementCell> output) {
if (null == aggregatedProperties) {
if (null != elementCell) {
output.add(elementCell);
}
} else {
try {
final Cell firstCell = elementCell.getCell();
final Element element = elementCell.getElement();
element.copyProperties(aggregatedProperties);
final Cell aggregatedCell = CellUtil.createCell(CellUtil.cloneRow(firstCell), CellUtil.cloneFamily(firstCell), serialisation.getColumnQualifier(element), serialisation.getTimestamp(element), firstCell.getTypeByte(), serialisation.getValue(element), CellUtil.getTagArray(firstCell), 0);
elementCell.setCell(aggregatedCell);
elementCell.setElement(element);
output.add(elementCell);
} catch (final SerialisationException e) {
throw new RuntimeException(e);
}
}
}
use of uk.gov.gchq.gaffer.hbasestore.serialisation.LazyElementCell in project Gaffer by gchq.
the class StoreAggregationProcessor method output.
private void output(final LazyElementCell elementCell, final Properties aggregatedProperties, final List<LazyElementCell> output) {
if (null == aggregatedProperties) {
if (null != elementCell) {
output.add(elementCell);
}
} else {
try {
final Cell firstCell = elementCell.getCell();
final Element element = elementCell.getElement();
element.copyProperties(aggregatedProperties);
final Cell aggregatedCell = CellUtil.createCell(CellUtil.cloneRow(firstCell), CellUtil.cloneFamily(firstCell), CellUtil.cloneQualifier(firstCell), serialisation.getTimestamp(element), firstCell.getTypeByte(), serialisation.getValue(element), CellUtil.getTagArray(firstCell), 0);
elementCell.setCell(aggregatedCell);
elementCell.setElement(element);
output.add(elementCell);
} catch (final SerialisationException e) {
throw new RuntimeException(e);
}
}
}
Aggregations