use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class GetAdjacentEntitySeedsHandler method doOperation.
private List<EntitySeed> doOperation(final GetAdjacentEntitySeeds operation, final ArrayListStore store) {
final EntitySeed[] reuseableTuple = new EntitySeed[2];
final List<EntitySeed> result = new ArrayList<>();
for (final Edge edge : store.getEdges()) {
if (operation.validateFlags(edge)) {
extractOtherEndOfSeededEdge(edge, operation, reuseableTuple);
if ((null != reuseableTuple[0] || null != reuseableTuple[1]) && operation.validatePreAggregationFilter(edge)) {
if (null != reuseableTuple[0]) {
result.add(reuseableTuple[0]);
}
if (null != reuseableTuple[1]) {
result.add(reuseableTuple[1]);
}
}
}
}
return result;
}
use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class GetElementsinRangesHandlerTest method shouldReturnNothingWhenNoEdgesSet.
private void shouldReturnNothingWhenNoEdgesSet(final AccumuloStore store) throws OperationException {
// Create set to query for
final Set<Pair<ElementSeed>> simpleEntityRanges = new HashSet<>();
//get Everything between 0 and 1 (Note we are using strings and string serialisers, with this ordering 0999 is before 1)
simpleEntityRanges.add(new Pair<ElementSeed>(new EntitySeed("0"), new EntitySeed("1")));
final View view = new View.Builder(defaultView).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy().build()).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().groupBy().build()).build();
final GetElementsInRanges<Pair<ElementSeed>, Element> operation = new GetElementsInRanges<>(view, simpleEntityRanges);
//All Edges stored should be outgoing from our provided seeds.
operation.setIncludeEdges(IncludeEdgeType.UNDIRECTED);
final GetElementsInRangesHandler handler = new GetElementsInRangesHandler();
final CloseableIterable<Element> elements = handler.doOperation(operation, user, store);
final int count = Iterables.size(elements);
//There should be no incoming edges to the provided range
assertEquals(0, count);
elements.close();
}
use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class GetElementsinRangesHandlerTest method shouldHaveNoIncomingEdges.
private void shouldHaveNoIncomingEdges(final AccumuloStore store) throws OperationException {
// Create set to query for
final Set<Pair<ElementSeed>> simpleEntityRanges = new HashSet<>();
final User user = new User();
//get Everything between 0 and 1 (Note we are using strings and string serialisers, with this ordering 0999 is before 1)
simpleEntityRanges.add(new Pair<ElementSeed>(new EntitySeed("0"), new EntitySeed("1")));
final View view = new View.Builder(defaultView).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy().build()).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().groupBy().build()).build();
final GetElementsInRanges<Pair<ElementSeed>, Element> operation = new GetElementsInRanges<>(view, simpleEntityRanges);
//All Edges stored should be outgoing from our provided seeds.
operation.setIncludeIncomingOutGoing(IncludeIncomingOutgoingType.INCOMING);
final GetElementsInRangesHandler handler = new GetElementsInRangesHandler();
final CloseableIterable<Element> elements = handler.doOperation(operation, user, store);
final int count = Iterables.size(elements);
//There should be no incoming edges to the provided range
assertEquals(0, count);
elements.close();
}
use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class GetEdgesTest method shouldSetSeedMatchingTypeToRelated.
@Test
public void shouldSetSeedMatchingTypeToRelated() {
// Given
final EntitySeed seed1 = new EntitySeed("identifier1");
// When
final GetEdges op = new GetEdges(Collections.singletonList(seed1));
// Then
assertEquals(GetOperation.SeedMatchingType.RELATED, op.getSeedMatching());
}
use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class GetElementsTest method shouldSerialiseAndDeserialiseOperationWithElementSeeds.
private void shouldSerialiseAndDeserialiseOperationWithElementSeeds() throws SerialisationException {
// Given
final ElementSeed elementSeed1 = new EntitySeed("identifier");
final ElementSeed elementSeed2 = new EdgeSeed("source2", "destination2", true);
final GetElements op = new GetElements(Arrays.asList(elementSeed1, elementSeed2));
// When
byte[] json = serialiser.serialise(op, true);
final GetElements deserialisedOp = serialiser.deserialise(json, GetElements.class);
// Then
final Iterator itr = deserialisedOp.getSeeds().iterator();
assertEquals(elementSeed1, itr.next());
assertEquals(elementSeed2, itr.next());
assertFalse(itr.hasNext());
}
Aggregations