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;
}
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();
}
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;
}
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"));
}
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));
}
Aggregations