Search in sources :

Example 26 with EntitySeed

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;
}
Also used : EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ArrayList(java.util.ArrayList) Edge(uk.gov.gchq.gaffer.data.element.Edge)

Example 27 with EntitySeed

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();
}
Also used : GetElementsInRanges(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges) Element(uk.gov.gchq.gaffer.data.element.Element) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) HashSet(java.util.HashSet) Pair(uk.gov.gchq.gaffer.accumulostore.utils.Pair)

Example 28 with EntitySeed

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();
}
Also used : User(uk.gov.gchq.gaffer.user.User) GetElementsInRanges(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges) Element(uk.gov.gchq.gaffer.data.element.Element) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) HashSet(java.util.HashSet) Pair(uk.gov.gchq.gaffer.accumulostore.utils.Pair)

Example 29 with EntitySeed

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());
}
Also used : EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.Test)

Example 30 with EntitySeed

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());
}
Also used : EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Iterator(java.util.Iterator) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed)

Aggregations

EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)107 Test (org.junit.Test)51 Element (uk.gov.gchq.gaffer.data.element.Element)50 User (uk.gov.gchq.gaffer.user.User)43 HashSet (java.util.HashSet)34 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)33 Entity (uk.gov.gchq.gaffer.data.element.Entity)28 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)28 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)26 Edge (uk.gov.gchq.gaffer.data.element.Edge)22 Graph (uk.gov.gchq.gaffer.graph.Graph)22 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)21 ArrayList (java.util.ArrayList)20 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)14 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)12 GetEntities (uk.gov.gchq.gaffer.operation.impl.get.GetEntities)12 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)11 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)11 GetEdges (uk.gov.gchq.gaffer.operation.impl.get.GetEdges)11 Pair (uk.gov.gchq.gaffer.accumulostore.utils.Pair)9