use of uk.gov.gchq.gaffer.hbasestore.serialisation.LazyElementCell in project Gaffer by gchq.
the class CellUtil method getLazyCells.
public static Pair<LazyElementCell, LazyElementCell> getLazyCells(final Pair<Put, Put> puts, final ElementSerialisation serialisation, final boolean includeMatchedVertex) {
final Pair<Cell, Cell> cells = getCells(puts);
final Pair<LazyElementCell, LazyElementCell> lazyCells = new Pair<>();
lazyCells.setFirst(new LazyElementCell(cells.getFirst(), serialisation, includeMatchedVertex));
if (null != cells.getSecond()) {
lazyCells.setSecond(new LazyElementCell(cells.getSecond(), serialisation, includeMatchedVertex));
}
return lazyCells;
}
use of uk.gov.gchq.gaffer.hbasestore.serialisation.LazyElementCell in project Gaffer by gchq.
the class StoreAggregationProcessor 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 if (!HBaseUtil.compareKeys(firstElementCell.getCell(), elementCell.getCell())) {
output(firstElementCell, aggregatedProperties, output);
firstElementCell = elementCell;
aggregatedProperties = null;
aggregator = null;
} else {
final String group = firstElementCell.getGroup();
if (null == aggregator) {
aggregator = schema.getElement(group).getIngestAggregator();
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 ElementDedupeFilterProcessorTest method shouldOnlyAcceptUndirectedEdges.
@Test
public void shouldOnlyAcceptUndirectedEdges() throws OperationException, SerialisationException {
// Given
final ElementDedupeFilterProcessor processor = new ElementDedupeFilterProcessor(false, true, DirectedType.UNDIRECTED);
// When / Then
for (final Element element : ELEMENTS) {
final boolean expectedResult = element instanceof Edge && !((Edge) element).isDirected();
final Pair<LazyElementCell, LazyElementCell> cells = CellUtil.getLazyCells(element, serialisation);
assertEquals(expectedResult, processor.test(cells.getFirst()), "Failed for element: " + element.toString());
if (null != cells.getSecond()) {
// self elements are not added the other way round
assertEquals(false, processor.test(cells.getSecond()), "Failed for element: " + element.toString());
}
}
}
use of uk.gov.gchq.gaffer.hbasestore.serialisation.LazyElementCell in project Gaffer by gchq.
the class ElementDedupeFilterProcessorTest method shouldOnlyAcceptDirectedEdges.
@Test
public void shouldOnlyAcceptDirectedEdges() throws OperationException, SerialisationException {
// Given
final ElementDedupeFilterProcessor processor = new ElementDedupeFilterProcessor(false, true, DirectedType.DIRECTED);
// When / Then
for (final Element element : ELEMENTS) {
final boolean expectedResult = element instanceof Edge && ((Edge) element).isDirected();
final Pair<LazyElementCell, LazyElementCell> cells = CellUtil.getLazyCells(element, serialisation);
assertEquals(expectedResult, processor.test(cells.getFirst()), "Failed for element: " + element.toString());
if (null != cells.getSecond()) {
// self elements are not added the other way round
assertEquals(false, processor.test(cells.getSecond()), "Failed for element: " + element.toString());
}
}
}
use of uk.gov.gchq.gaffer.hbasestore.serialisation.LazyElementCell in project Gaffer by gchq.
the class ElementDedupeFilterProcessor method test.
@Override
public boolean test(final LazyElementCell elementCell) {
final Cell cell = elementCell.getCell();
final byte flag = getFlag(cell);
final boolean isEdge = flag != HBaseStoreConstants.ENTITY;
if (!edges && isEdge) {
return false;
}
if (!entities && !isEdge) {
return false;
}
return !isEdge || testEdge(flag, cell);
}
Aggregations