Search in sources :

Example 21 with ElementSeed

use of uk.gov.gchq.gaffer.operation.data.ElementSeed in project Gaffer by gchq.

the class AbstractGetIterableOperationTest method shouldCopyFieldsFromGivenOperationWhenConstructing.

@Test
public void shouldCopyFieldsFromGivenOperationWhenConstructing() {
    // Given
    final GetIterableOperation<ElementSeed, ?> operationToCopy = mock(GetIterableOperation.class);
    final View view = mock(View.class);
    final GetOperation.IncludeEdgeType includeEdges = GetOperation.IncludeEdgeType.ALL;
    final boolean includeEntities = true;
    final boolean populateProperties = true;
    final CloseableIterable<ElementSeed> input = mock(CloseableIterable.class);
    given(operationToCopy.getView()).willReturn(view);
    given(operationToCopy.getInput()).willReturn(input);
    // When
    final GetIterableOperationImpl<ElementSeed, Element> operation = new GetIterableOperationImpl<>(operationToCopy);
    // Then
    assertSame(view, operation.getView());
    assertSame(input, operation.getInput());
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) GetIterableOperationImpl(uk.gov.gchq.gaffer.operation.impl.GetIterableOperationImpl) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test)

Example 22 with ElementSeed

use of uk.gov.gchq.gaffer.operation.data.ElementSeed in project Gaffer by gchq.

the class AbstractGetIterableOperationTest method shouldSerialiseAndDeserialiseOperation.

@Test
@Override
public void shouldSerialiseAndDeserialiseOperation() throws SerialisationException {
    // Given
    final String identifier = "identifier";
    final ElementSeed input = new EntitySeed(identifier);
    final GetIterableOperationImpl<ElementSeed, Element> op = new GetIterableOperationImpl<>(Collections.singletonList(input));
    // When
    byte[] json = serialiser.serialise(op, true);
    final GetIterableOperationImpl<ElementSeed, Element> deserialisedOp = serialiser.deserialise(json, GetIterableOperationImpl.class);
    // Then
    assertNotNull(deserialisedOp);
    assertEquals(identifier, ((EntitySeed) deserialisedOp.getInput().iterator().next()).getVertex());
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) GetIterableOperationImpl(uk.gov.gchq.gaffer.operation.impl.GetIterableOperationImpl) Test(org.junit.Test)

Example 23 with ElementSeed

use of uk.gov.gchq.gaffer.operation.data.ElementSeed in project Gaffer by gchq.

the class AbstractGetOperationTest method shouldSerialiseAndDeserialiseOperation.

@Test
@Override
public void shouldSerialiseAndDeserialiseOperation() throws SerialisationException {
    // Given
    final String identifier = "identifier";
    final ElementSeed input = new EntitySeed(identifier);
    final GetOperationImpl<ElementSeed, Element> op = new GetOperationImpl<>(Collections.singletonList(input));
    // When
    byte[] json = serialiser.serialise(op, true);
    final GetOperationImpl<ElementSeed, Element> deserialisedOp = serialiser.deserialise(json, GetOperationImpl.class);
    // Then
    assertNotNull(deserialisedOp);
    assertEquals(identifier, ((EntitySeed) deserialisedOp.getInput().iterator().next()).getVertex());
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) GetOperationImpl(uk.gov.gchq.gaffer.operation.impl.GetOperationImpl) Test(org.junit.Test)

Example 24 with ElementSeed

use of uk.gov.gchq.gaffer.operation.data.ElementSeed in project Gaffer by gchq.

the class GetJavaRDDOfElementsExample method getJavaRddOfElementsReturningEdgesOnly.

public void getJavaRddOfElementsReturningEdgesOnly(final JavaSparkContext sc, final Graph graph) throws OperationException {
    ROOT_LOGGER.setLevel(Level.INFO);
    log("#### get Java RDD of elements returning edges only\n");
    printGraph();
    ROOT_LOGGER.setLevel(Level.OFF);
    final GetJavaRDDOfElements<ElementSeed> operation = new GetJavaRDDOfElements.Builder<>().addSeed(new EdgeSeed(1, 2, true)).addSeed(new EdgeSeed(2, 3, true)).includeEntities(false).javaSparkContext(sc).build();
    final JavaRDD<Element> rdd = graph.execute(operation, new User("user01"));
    final List<Element> elements = rdd.collect();
    ROOT_LOGGER.setLevel(Level.INFO);
    printJava("GetJavaRDDOfElements<ElementSeed> operation = new GetJavaRDDOfElements.Builder<>()\n" + "                .addSeed(new EdgeSeed(1, 2, true))\n" + "                .addSeed(new EdgeSeed(2, 3, true))\n" + "                .includeEntities(false)\n" + "                .javaSparkContext(sc)\n" + "                .build();\n" + "JavaRDD<Element> rdd = graph.execute(operation, new User(\"user01\"));\n" + "List<Element> elements = rdd.collect();");
    log("The results are:");
    log("```");
    for (final Element e : elements) {
        log(e.toString());
    }
    log("```");
    ROOT_LOGGER.setLevel(Level.OFF);
}
Also used : User(uk.gov.gchq.gaffer.user.User) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) Element(uk.gov.gchq.gaffer.data.element.Element) GetJavaRDDOfElements(uk.gov.gchq.gaffer.spark.operation.javardd.GetJavaRDDOfElements) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed)

Example 25 with ElementSeed

use of uk.gov.gchq.gaffer.operation.data.ElementSeed in project Gaffer by gchq.

the class ExamplesService method getEdges.

@Override
public GetEdges getEdges() {
    final GetEdges op = new GetEdges();
    final List<ElementSeed> seeds = new ArrayList<>();
    if (hasEntities()) {
        seeds.add(getEntitySeed(1));
    } else if (hasEdges()) {
        seeds.add(new EntitySeed(getEdgeSeed(1, 2).getSource()));
    }
    if (hasEdges()) {
        seeds.add(getEdgeSeed(1, 2));
    }
    op.setSeeds(seeds);
    populateOperation(op);
    return op;
}
Also used : GetEdges(uk.gov.gchq.gaffer.operation.impl.get.GetEdges) ArrayList(java.util.ArrayList) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed)

Aggregations

ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)41 Element (uk.gov.gchq.gaffer.data.element.Element)26 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)26 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)19 HashSet (java.util.HashSet)13 User (uk.gov.gchq.gaffer.user.User)13 Test (org.junit.Test)12 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)12 IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)9 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)9 Edge (uk.gov.gchq.gaffer.data.element.Edge)8 ArrayList (java.util.ArrayList)7 GetElementsInRanges (uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges)6 Pair (uk.gov.gchq.gaffer.accumulostore.utils.Pair)6 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)6 Entity (uk.gov.gchq.gaffer.data.element.Entity)4 Range (org.apache.accumulo.core.data.Range)3 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)3 LinkedList (java.util.LinkedList)2 ByteSequence (org.apache.accumulo.core.data.ByteSequence)2