Package com.tinkerpop.gremlin.process.computer

Examples of com.tinkerpop.gremlin.process.computer.ComputerResult


    @Override
    public Future<Traversal<S, E>> traversal() {
        return CompletableFuture.<Traversal<S, E>>supplyAsync(() -> {
            try {
                final TraversalVertexProgram vertexProgram = this.program();
                final ComputerResult result = this.graphComputer.program(vertexProgram).submit().get();
                final GraphTraversal<S, S> traversal = result.graph().<S>of();
                return traversal.addStep(new ComputerResultStep<>(traversal, result, vertexProgram, true));
            } catch (final Exception e) {
                throw new IllegalStateException(e.getMessage(), e);
            }
        });
View Full Code Here


        try {
            final GroovyTraversalScript<?, ?> traversal = GroovyTraversalScript.of(RemoteAcceptor.getScript(String.join(SPACE, args), this.shell)).over(this.giraphGraph).using(this.giraphGraph.compute());
            if (this.useSugarPlugin)
                traversal.withSugar();
            final TraversalVertexProgram vertexProgram = traversal.program();
            final ComputerResult computerResult = traversal.result().get();
            this.shell.getInterp().getContext().setProperty(RESULT, computerResult);

            final GraphTraversal traversal2 = new DefaultGraphTraversal<>();
            traversal2.addStep(new ComputerResultStep<>(traversal2, computerResult, vertexProgram, false));
            traversal2.range(0, 19);
View Full Code Here

     */
    public default Traversal<S, E> submit(final GraphComputer computer) {
        try {
            this.applyStrategies(TraversalEngine.COMPUTER);
            final TraversalVertexProgram vertexProgram = TraversalVertexProgram.build().traversal(this::clone).create();
            final ComputerResult result = computer.program(vertexProgram).submit().get();
            final GraphTraversal<S, S> traversal = result.graph().of();
            return traversal.addStep(new ComputerResultStep<>(traversal, result, vertexProgram, true));
        } catch (final Exception e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
View Full Code Here

            } catch (Exception e) {
                e.printStackTrace();
                throw new IllegalStateException(e.getMessage(), e);
            }
            this.memory.complete(System.currentTimeMillis() - startTime);
            return new ComputerResult(GiraphHelper.getOutputGraph(this.giraphGraph), this.memory);
        });
    }
View Full Code Here

                }
            }
            // update runtime and return the newly computed graph
            this.memory.setRuntime(System.currentTimeMillis() - time);
            this.memory.complete();
            return new ComputerResult(this.graph, this.memory);
        });
    }
View Full Code Here

    }

    @Test
    @LoadGraphWith(MODERN)
    public void shouldExecutePageRank() throws Exception {
        final ComputerResult result = g.compute().program(PageRankVertexProgram.build().create()).submit().get();
        result.graph().V().forEachRemaining(v -> {
            assertTrue(v.keys().contains("name"));
            assertTrue(v.hiddenKeys().contains(Graph.Key.unHide(PageRankVertexProgram.PAGE_RANK)));
            final String name = v.value("name");
            final Double pageRank = v.value(PageRankVertexProgram.PAGE_RANK);
            if (name.equals("marko"))
                assertTrue(pageRank > 0.14 && pageRank < 0.16);
            else if (name.equals("vadas"))
                assertTrue(pageRank > 0.19 && pageRank < 0.20);
            else if (name.equals("lop"))
                assertTrue(pageRank > 0.40 && pageRank < 0.41);
            else if (name.equals("josh"))
                assertTrue(pageRank > 0.19 && pageRank < 0.20);
            else if (name.equals("ripple"))
                assertTrue(pageRank > 0.23 && pageRank < 0.24);
            else if (name.equals("peter"))
                assertTrue(pageRank > 0.14 && pageRank < 0.16);
            else
                throw new IllegalStateException("The following vertex should not exist in the graph: " + name);
        });
        assertEquals(result.memory().getIteration(), 30);
        assertEquals(result.memory().asMap().size(), 0);
    }
View Full Code Here

        final GiraphGraphProvider provider = new GiraphGraphProvider();
        final Map<String, Object> map = provider.getBaseConfiguration("gremlin.giraph", GiraphGraphComputerIntegrateTest.class, "shouldNotDeriveMemoryIfToldSo");
        map.put(Constants.GREMLIN_GIRAPH_DERIVE_MEMORY, false);
        final GiraphGraph g = (GiraphGraph) GraphFactory.open(map);
        provider.loadGraphData(g, LoadGraphWith.GraphData.CLASSIC);
        final ComputerResult result = g.compute().program(LambdaVertexProgram.build().
                setup(memory -> {
                }).
                execute((vertex, messenger, memory) -> {
                }).
                terminate(memory -> memory.getIteration() > 2).create()).submit().get();
        assertEquals(result.memory().getIteration(), -1);
    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.gremlin.process.computer.ComputerResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.