Search in sources :

Example 1 with DiscardOutput

use of uk.gov.gchq.gaffer.operation.impl.DiscardOutput in project gaffer-doc by gchq.

the class ExportToGafferResultCacheExample method exportAndGetJobDetails.

public JobDetail exportAndGetJobDetails() {
    // ---------------------------------------------------------
    final OperationChain<JobDetail> exportOpChain = new OperationChain.Builder().first(new GetAllElements()).then(new ExportToGafferResultCache<>()).then(new DiscardOutput()).then(new GetJobDetails()).build();
    // ---------------------------------------------------------
    jobDetail = runExample(exportOpChain, null);
    return jobDetail;
}
Also used : JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) GetJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) ExportToGafferResultCache(uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput)

Example 2 with DiscardOutput

use of uk.gov.gchq.gaffer.operation.impl.DiscardOutput in project gaffer-doc by gchq.

the class GetJobResultsExample method runExamples.

@Override
public void runExamples() {
    try {
        final OperationChain<JobDetail> opChain = new OperationChain.Builder().first(new GetAllElements()).then(new ExportToGafferResultCache<>()).then(new DiscardOutput()).then(new GetJobDetails()).build();
        final JobDetail jobDetails = getGraph().execute(opChain, new User("user01"));
        jobId = jobDetails.getJobId();
    } catch (final OperationException e) {
        throw new RuntimeException(e);
    }
    getJobResults();
}
Also used : JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) GetJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails) User(uk.gov.gchq.gaffer.user.User) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) ExportToGafferResultCache(uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Example 3 with DiscardOutput

use of uk.gov.gchq.gaffer.operation.impl.DiscardOutput in project gaffer-doc by gchq.

the class Subgraphs method run.

@Override
public Iterable<? extends Element> run() throws OperationException, IOException {
    // / [graph] create a graph using our schema and store properties
    // ---------------------------------------------------------
    final Graph graph = new Graph.Builder().config(getDefaultGraphConfig()).addSchemas(StreamUtil.openStreams(getClass(), schemaPath)).storeProperties(getDefaultStoreProperties()).build();
    // ---------------------------------------------------------
    // [user] Create a user
    // ---------------------------------------------------------
    final User user = new User("user01");
    // ---------------------------------------------------------
    // [add] Create a data generator and add the edges to the graph using an operation chain consisting of:
    // generateElements - generating edges from the data (note these are directed edges)
    // addElements - add the edges to the graph
    // ---------------------------------------------------------
    final OperationChain<Void> addOpChain = new OperationChain.Builder().first(new GenerateElements.Builder<String>().generator(new RoadAndRoadUseWithTimesAndCardinalitiesElementGenerator()).input(IOUtils.readLines(StreamUtil.openStream(getClass(), "RoadAndRoadUseWithTimesAndCardinalities/data.txt"))).build()).then(new AddElements()).build();
    graph.execute(addOpChain, user);
    // ---------------------------------------------------------
    print("The elements have been added.");
    // [get] Create a sub graph
    // Start getting related edges with the given seeds.
    // Then update the export with the results
    // Between each hop we need to extract the destination vertices of the
    // previous edges and convert them to EntitySeeds.
    // Finally finish off by returning all the edges in the export.
    // ---------------------------------------------------------
    final OperationChain<Iterable<?>> opChain = new OperationChain.Builder().first(new GetElements.Builder().input(new EntitySeed("M5")).inOutType(IncludeIncomingOutgoingType.OUTGOING).view(new View.Builder().edge("RoadHasJunction").build()).build()).then(new ExportToSet<>()).then(new ToVertices.Builder().edgeVertices(ToVertices.EdgeVertices.DESTINATION).build()).then(new ToEntitySeeds()).then(new GetElements.Builder().inOutType(IncludeIncomingOutgoingType.OUTGOING).view(new View.Builder().edge("RoadUse", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("count").execute(new IsMoreThan(1L)).build()).build()).build()).build()).then(new ExportToSet<>()).then(new DiscardOutput()).then(new GetSetExport()).build();
    // ---------------------------------------------------------
    final Iterable<? extends Element> subGraph = (Iterable<? extends Element>) graph.execute(opChain, user);
    print("\nSub graph:");
    for (final Element edge : subGraph) {
        print("SUB_GRAPH", edge.toString());
    }
    return subGraph;
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) User(uk.gov.gchq.gaffer.user.User) ExportToSet(uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet) ToEntitySeeds(uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds) Element(uk.gov.gchq.gaffer.data.element.Element) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) GetSetExport(uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport) RoadAndRoadUseWithTimesAndCardinalitiesElementGenerator(uk.gov.gchq.gaffer.doc.user.generator.RoadAndRoadUseWithTimesAndCardinalitiesElementGenerator) ToVertices(uk.gov.gchq.gaffer.operation.impl.output.ToVertices) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Graph(uk.gov.gchq.gaffer.graph.Graph) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan)

Example 4 with DiscardOutput

use of uk.gov.gchq.gaffer.operation.impl.DiscardOutput in project Gaffer by gchq.

the class OperationControllerTest method shouldNotIncludeAnyOutputClassForOperationWithoutOutput.

@Test
public void shouldNotIncludeAnyOutputClassForOperationWithoutOutput() throws Exception {
    // Given
    when(store.getSupportedOperations()).thenReturn(Sets.newHashSet(DiscardOutput.class));
    when(examplesFactory.generateExample(GetElements.class)).thenReturn(new DiscardOutput());
    // When
    OperationDetail operationDetail = operationController.getOperationDetails(DiscardOutput.class.getName());
    byte[] serialised = JSONSerialiser.serialise(operationDetail);
    // Then
    assertFalse(new String(serialised).contains("outputClassName"));
}
Also used : OperationDetail(uk.gov.gchq.gaffer.rest.model.OperationDetail) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput) Test(org.junit.jupiter.api.Test)

Example 5 with DiscardOutput

use of uk.gov.gchq.gaffer.operation.impl.DiscardOutput in project Gaffer by gchq.

the class AddOperationsToChainTest method shouldAddAllOperationsGivenJson.

@Test
public void shouldAddAllOperationsGivenJson() throws IOException {
    // Given
    final byte[] bytes;
    try (final InputStream inputStream = StreamUtil.openStream(getClass(), ADD_OPERATIONS_TO_CHAIN_RESOURCE_PATH)) {
        bytes = IOUtils.toByteArray(inputStream);
    }
    final AddOperationsToChain hook = fromJson(bytes);
    Operation discardOutput = new DiscardOutput();
    Operation splitStore = new SplitStoreFromFile();
    Operation validate = new Validate();
    Operation getAdjacentIds = new GetAdjacentIds();
    Operation count = new Count<>();
    Operation countGroups = new CountGroups();
    Operation getElements = new GetElements();
    Operation getAllElements = new GetAllElements();
    Operation limit = new Limit<>();
    final OperationChain opChain = new OperationChain.Builder().first(getAdjacentIds).then(getElements).then(getAllElements).build();
    // When
    hook.preExecute(opChain, new Context(new User()));
    // Then
    final OperationChain expectedOpChain = new OperationChain.Builder().first(discardOutput).then(splitStore).then(validate).then(getAdjacentIds).then(count).then(discardOutput).then(countGroups).then(getElements).then(getAllElements).then(limit).then(validate).then(count).build();
    JsonAssert.assertEquals(JSONSerialiser.serialise(expectedOpChain), JSONSerialiser.serialise(opChain));
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) User(uk.gov.gchq.gaffer.user.User) InputStream(java.io.InputStream) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Operation(uk.gov.gchq.gaffer.operation.Operation) Count(uk.gov.gchq.gaffer.operation.impl.Count) SplitStoreFromFile(uk.gov.gchq.gaffer.operation.impl.SplitStoreFromFile) CountGroups(uk.gov.gchq.gaffer.operation.impl.CountGroups) Validate(uk.gov.gchq.gaffer.operation.impl.Validate) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput) Limit(uk.gov.gchq.gaffer.operation.impl.Limit) Test(org.junit.jupiter.api.Test)

Aggregations

DiscardOutput (uk.gov.gchq.gaffer.operation.impl.DiscardOutput)24 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)17 Test (org.junit.jupiter.api.Test)16 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)15 User (uk.gov.gchq.gaffer.user.User)12 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)11 Context (uk.gov.gchq.gaffer.store.Context)10 GetAdjacentIds (uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds)8 JobDetail (uk.gov.gchq.gaffer.jobtracker.JobDetail)7 Operation (uk.gov.gchq.gaffer.operation.Operation)7 SplitStoreFromFile (uk.gov.gchq.gaffer.operation.impl.SplitStoreFromFile)7 Count (uk.gov.gchq.gaffer.operation.impl.Count)6 CountGroups (uk.gov.gchq.gaffer.operation.impl.CountGroups)5 GetJobDetails (uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails)5 Builder (uk.gov.gchq.gaffer.operation.OperationChain.Builder)4 Validate (uk.gov.gchq.gaffer.operation.impl.Validate)4 ExportToGafferResultCache (uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache)4 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)3 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)3 Limit (uk.gov.gchq.gaffer.operation.impl.Limit)3