Package com.tinkerpop.gremlin.process

Examples of com.tinkerpop.gremlin.process.Path


        final Traversal<Vertex, Path> traversal = get_g_v1_out_name_injectXdanielX_asXaX_mapXlengthX_path(convertToVertexId("marko"));
        printTraversalForm(traversal);
        int counter = 0;
        while (traversal.hasNext()) {
            counter++;
            final Path path = traversal.next();
            if (path.get("a").equals("daniel")) {
                assertEquals(2, path.size());
                assertEquals(6, (int) path.get(1));
            } else {
                assertEquals(4, path.size());
                assertEquals(path.<String>get("a").length(), (int) path.get(3));
            }
        }
        assertEquals(4, counter);
    }
View Full Code Here


        this.selectFunction = traverser -> {
            final S start = traverser.get();
            final Map<String, E> bindings = new LinkedHashMap<>();

            if (this.requiresPaths && this.onGraphComputer) {   ////// PROCESS STEP BINDINGS
                final Path path = traverser.path();
                this.selectLabels.forEach(label -> {
                    if (path.hasLabel(label))
                        bindings.put(label, (E) this.functionRing.next().apply(path.get(label)));
                });
            } else {
                this.selectLabels.forEach(label -> { ////// PROCESS SIDE-EFFECTS
                    if (traverser.sideEffects().exists(label))
                        bindings.put(label, (E) this.functionRing.next().apply(traverser.get(label)));
View Full Code Here

    @Test
    @LoadGraphWith(MODERN)
    public void g_v1_name_path() {
        final Traversal<Vertex, Path> traversal = get_g_v1_name_path(convertToVertexId("marko"));
        printTraversalForm(traversal);
        final Path path = traversal.next();
        assertFalse(traversal.hasNext());
        assertEquals(2, path.size());
        assertEquals(convertToVertexId("marko"), ((Vertex) path.get(0)).<String>id());
        assertEquals("marko", path.<String>get(1));
        assertFalse(traversal.hasNext());
    }
View Full Code Here

        this.functionRing = new FunctionRing(branchFunctions);
        TraversalHelper.verifySideEffectKeyIsNotAStepLabel(this.sideEffectKey, this.traversal);
        this.traversal.sideEffects().registerSupplierIfAbsent(this.sideEffectKey, Tree::new);
        this.setConsumer(traverser -> {
            Tree depth = this.getTraversal().sideEffects().get(this.sideEffectKey);
            final Path path = traverser.path();
            for (int i = 0; i < path.size(); i++) {
                final Object object = functionRing.next().apply(path.get(i));
                if (!depth.containsKey(object))
                    depth.put(object, new Tree<>());
                depth = (Tree) depth.get(object);
            }
            this.functionRing.reset();
View Full Code Here

        printTraversalForm(traversal);
        int counter = 0;
        final Set<String> names = new HashSet<>();
        while (traversal.hasNext()) {
            counter++;
            final Path path = traversal.next();
            assertEquals(Integer.valueOf(29), path.<Integer>get(0));
            assertTrue(path.get(1).equals("josh") || path.get(1).equals("vadas") || path.get(1).equals("lop"));
            names.add(path.get(1));
        }
        assertEquals(3, counter);
        assertEquals(3, names.size());
    }
View Full Code Here

        final Traversal<Vertex, Path> traversal = get_g_V_asXxX_out_jumpXx_loops_lt_2X_pathXit__name__langX();
        printTraversalForm(traversal);
        int counter = 0;
        while (traversal.hasNext()) {
            counter++;
            final Path path = traversal.next();
            assertEquals(3, path.size());
            assertEquals("marko", ((Vertex) path.get(0)).<String>value("name"));
            assertEquals("josh", path.<String>get(1));
            assertEquals("java", path.<String>get(2));
        }
        assertEquals(2, counter);
    }
View Full Code Here

        final Traversal<Vertex, Path> traversal = get_g_V_asXxX_out_jumpXx_2X_pathXit_name_langX();
        printTraversalForm(traversal);
        int counter = 0;
        while (traversal.hasNext()) {
            counter++;
            final Path path = traversal.next();
            assertEquals(3, path.size());
            assertEquals("marko", ((Vertex) path.get(0)).<String>value("name"));
            assertEquals("josh", path.<String>get(1));
            assertEquals("java", path.<String>get(2));
        }
        assertEquals(2, counter);
    }
View Full Code Here

        final Traversal<Vertex, Path> traversal = get_g_V_out_out_pathXname_ageX();
        printTraversalForm(traversal);
        int counter = 0;
        while (traversal.hasNext()) {
            counter++;
            final Path path = traversal.next();
            assertEquals(3, path.size());
            assertEquals("marko", path.<String>get(0));
            assertEquals(Integer.valueOf(32), path.<Integer>get(1));
            assertTrue(path.get(2).equals("lop") || path.get(2).equals("ripple"));
        }
        assertEquals(2, counter);
    }
View Full Code Here

        final Traversal<Vertex, Path> traversal = get_g_v1_outXcreatedX_inXcreatedX_cyclicPath_path(convertToVertexId("marko"));
        printTraversalForm(traversal);
        int counter = 0;
        while (traversal.hasNext()) {
            counter++;
            Path path = traversal.next();
            assertFalse(path.isSimple());
        }
        assertEquals(1, counter);
        assertFalse(traversal.hasNext());
    }
View Full Code Here

            }
        });
    }

    public Path attach(final Graph graph) {
        final Path path = MutablePath.make();
        this.forEach((as, object) -> {
            if (object instanceof DetachedVertex) {
                path.extend(as, ((DetachedVertex) object).attach(graph));
            } else if (object instanceof DetachedEdge) {
                path.extend(as, ((DetachedEdge) object).attach(graph));
            } else if (object instanceof DetachedVertexProperty) {
                path.extend(as, ((DetachedVertexProperty) object).attach(graph));
            } else if (object instanceof DetachedProperty) {
                path.extend(as, ((DetachedProperty) object).attach(graph));
            } else {
                path.extend(as, object);
            }
        });
        return path;
    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.gremlin.process.Path

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.