use of uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition 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.data.elementdefinition.view.ViewElementDefinition in project Gaffer by gchq.
the class FederatedStoreUtilTest method shouldUpdateOperationViewAndReturnNullIfViewHasNoGroups.
@Test
public void shouldUpdateOperationViewAndReturnNullIfViewHasNoGroups() {
// Given
final Graph graph = createGraph();
final GetElements operation = new GetElements.Builder().view(new View.Builder().edge(TestGroups.EDGE_2, new ViewElementDefinition()).entity(TestGroups.ENTITY_2, new ViewElementDefinition()).build()).build();
// When
final GetElements updatedOp = FederatedStoreUtil.updateOperationForGraph(operation, graph);
// Then
assertNull(updatedOp);
}
Aggregations