protected Graph createExampleGraph() { final Graph graph = new Graph.Builder() .addSchemas(StreamUtil.openStreams(getClass(), "/example/operation/schema")) .storeProperties(StreamUtil.openStream(getClass(), "/example/operation/mockaccumulostore.properties")) .build(); // Create data generator final DataGenerator dataGenerator = new DataGenerator(); // Load data into memory final List<String> data = DataUtils.loadData(StreamUtil.openStream(getClass(), "/example/operation/data.txt", true)); //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 addOpChain = new OperationChain.Builder() .first(new GenerateElements.Builder<String>() .generator(dataGenerator) .objects(data) .build()) .then(new AddElements()) .build(); try { graph.execute(addOpChain, new User()); } catch (OperationException e) { throw new RuntimeException(e); } return graph; }
@Override public void runExamples() { try { final OperationChain<JobDetail> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToGafferResultCache()) .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(); }
public Map<String, CloseableIterable<?>> exportMultipleResultsToGafferResultCacheAndGetAllResults() { // --------------------------------------------------------- final OperationChain<Map<String, CloseableIterable<?>>> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToGafferResultCache.Builder() .key("edges") .build()) .then(new GetAllEntities()) .then(new ExportToGafferResultCache.Builder() .key("entities") .build()) .then(new GetExports.Builder() .exports(new GetGafferResultCacheExport.Builder() .key("edges") .build(), new GetGafferResultCacheExport.Builder() .key("entities") .build()) .build()) .build(); // --------------------------------------------------------- return runExample(opChain); } }
public Map<String, CloseableIterable<?>> exportMultipleResultsToSetAndGetAllResults() { // --------------------------------------------------------- final OperationChain<Map<String, CloseableIterable<?>>> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToSet.Builder() .key("edges") .build()) .then(new GetAllEntities()) .then(new ExportToSet.Builder() .key("entities") .build()) .then(new GetExports.Builder() .exports(new GetSetExport.Builder() .key("edges") .build(), new GetSetExport.Builder() .key("entities") .build()) .build()) .build(); // --------------------------------------------------------- return runExample(opChain); } }
public Map<String, CloseableIterable<?>> exportMultipleResultsToGafferResultCacheAndGetAllResults() { // --------------------------------------------------------- final OperationChain<Map<String, CloseableIterable<?>>> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToGafferResultCache.Builder() .key("edges") .build()) .then(new GetAllEntities()) .then(new ExportToGafferResultCache.Builder() .key("entities") .build()) .then(new GetExports.Builder() .exports(new GetGafferResultCacheExport.Builder() .key("edges") .build(), new GetGafferResultCacheExport.Builder() .key("entities") .build()) .build()) .build(); // --------------------------------------------------------- return runExample(opChain); } }
public Map<String, CloseableIterable<?>> exportMultipleResultsToSetAndGetAllResults() { // --------------------------------------------------------- final OperationChain<Map<String, CloseableIterable<?>>> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToSet.Builder() .key("edges") .build()) .then(new GetAllEntities()) .then(new ExportToSet.Builder() .key("entities") .build()) .then(new GetExports.Builder() .exports(new GetSetExport.Builder() .key("edges") .build(), new GetSetExport.Builder() .key("entities") .build()) .build()) .build(); // --------------------------------------------------------- return runExample(opChain); } }
public void addNamedOperation() { // --------------------------------------------------------- final AddNamedOperation operation = new AddNamedOperation.Builder() .operationChain(new OperationChain.Builder() .first(new GetAdjacentEntitySeeds.Builder() .inOutType(GetOperation.IncludeIncomingOutgoingType.OUTGOING) .build()) .then(new GetAdjacentEntitySeeds.Builder() .inOutType(GetOperation.IncludeIncomingOutgoingType.OUTGOING) .deduplicate(true) .build()) .build()) .description("2 hop query") .name("2-hop") .readAccessRoles("read-user") .writeAccessRoles("write-user") .overwrite() .build(); // --------------------------------------------------------- runExampleNoResult(operation); }
public CloseableIterable<?> simpleExportAndGetWithPagination() { // --------------------------------------------------------- final OperationChain<CloseableIterable<?>> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToSet()) .then(new GetSetExport.Builder() .start(2) .end(4) .build()) .build(); // --------------------------------------------------------- return runExample(opChain); }
public GroupCounts countAllElementGroups() { // --------------------------------------------------------- final OperationChain<GroupCounts> opChain = new OperationChain.Builder() .first(new GetAllElements<>()) .then(new CountGroups()) .build(); // --------------------------------------------------------- return runExample(opChain); }
public JobDetail exportAndGetJobDetails() { // --------------------------------------------------------- final OperationChain<JobDetail> exportOpChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToGafferResultCache()) .then(new GetJobDetails()) .build(); // --------------------------------------------------------- jobDetail = runExample(exportOpChain); return jobDetail; }
public JobDetail exportAndGetJobDetails() { // --------------------------------------------------------- final OperationChain<JobDetail> exportOpChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToGafferResultCache()) .then(new GetJobDetails()) .build(); // --------------------------------------------------------- jobDetail = runExample(exportOpChain); return jobDetail; }
public Iterable<Edge> withDeduplicateEdgesChain() { // --------------------------------------------------------- final OperationChain<CloseableIterable<Edge>> opChain = new OperationChain.Builder() .first(new GetEdges.Builder<>() .addSeed(new EntitySeed(1)) .addSeed(new EntitySeed(2)) .build()) .then(new Deduplicate<Edge>()) .build(); // --------------------------------------------------------- return runExample(opChain); } }
public CloseableIterable<?> simpleExportAndGet() { // --------------------------------------------------------- final OperationChain<CloseableIterable<?>> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToSet()) .then(new GetSetExport()) .build(); // --------------------------------------------------------- return runExample(opChain); }
public JobDetail getJobDetailsInOperationChain() { // --------------------------------------------------------- final OperationChain<JobDetail> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new GetJobDetails()) .build(); // --------------------------------------------------------- final JobDetail jobDetail = runExample(opChain); jobId = jobDetail.getJobId(); return jobDetail; } }
public Iterable<Element> limitElementsTo3InChain() { // --------------------------------------------------------- final OperationChain<CloseableIterable<Element>> opChain = new OperationChain.Builder() .first(new GetAllElements<>()) .then(new Limit.Builder<Element>() .limitResults(3) .build()) .build(); // --------------------------------------------------------- return runExample(opChain); } }
public CloseableIterable<?> simpleExportAndGetWithPagination() { // --------------------------------------------------------- final OperationChain<CloseableIterable<?>> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToSet()) .then(new GetSetExport.Builder() .start(2) .end(4) .build()) .build(); // --------------------------------------------------------- return runExample(opChain); }
public CloseableIterable<?> simpleExportAndGet() { // --------------------------------------------------------- final OperationChain<CloseableIterable<?>> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToGafferResultCache()) .then(new GetGafferResultCacheExport()) .build(); // --------------------------------------------------------- return runExample(opChain); }
public GroupCounts countAllElementGroupsWithLimit() { // --------------------------------------------------------- final OperationChain<GroupCounts> opChain = new OperationChain.Builder() .first(new GetAllElements<>()) .then(new CountGroups(5)) .build(); // --------------------------------------------------------- return runExample(opChain); } }
public CloseableIterable<?> simpleExportAndGet() { // --------------------------------------------------------- final OperationChain<CloseableIterable<?>> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToSet()) .then(new GetSetExport()) .build(); // --------------------------------------------------------- return runExample(opChain); }
public CloseableIterable<?> simpleExportAndGet() { // --------------------------------------------------------- final OperationChain<CloseableIterable<?>> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToGafferResultCache()) .then(new GetGafferResultCacheExport()) .build(); // --------------------------------------------------------- return runExample(opChain); }