Package com.tinkerpop.gremlin.process

Examples of com.tinkerpop.gremlin.process.Traversal


        final Vertex utf8Name = g.addVertex(T.id, "2", "name", "轉注", "age", 32);

        final ScriptEngine engine = new GremlinGroovyScriptEngine();

        engine.put("g", g);
        Traversal eval = (Traversal) engine.eval("g.V().has('name', 'marko')");
        assertEquals(nonUtf8, eval.next());
        eval = (Traversal) engine.eval("g.V().has('name','轉注')");
        assertEquals(utf8Name, eval.next());
    }
View Full Code Here


    @Test
    @Ignore
    public void testPlay() {
        System.out.println((float)1l / (float)7l);
        Graph g = TinkerFactory.createModern();
        Traversal t = g.V().has("name","marko").out().out().values("name");
        System.out.println(t);
        t.forEachRemaining(System.out::println);
        System.out.println(t);
        System.out.println("!!!!!!!!");
        t = g.V().has("name","marko").out().out().values("name");
        System.out.println(t);
        t.forEachRemaining(System.out::println);
        System.out.println(t);
    }
View Full Code Here

    public void shouldExecuteCypherAndBackToGremlin() throws Exception {
        this.g.addVertex("name", "marko", "age", 29, "color", "red");
        this.g.addVertex("name", "marko", "age", 30, "color", "yellow");

        this.g.tx().commit();
        final Traversal result = g.cypher("MATCH (a {name:\"marko\"}) RETURN a").select("a").has("age", 29).values("color");
        assertNotNull(result);
        assertTrue(result.hasNext());
        assertEquals("red", result.next().toString());
    }
View Full Code Here

    }

    @Test
    public void shouldChainTogetherStepsWithNextPreviousInALinkedListStructure() {
        Traversal traversal = new DefaultTraversal<>();
        traversal.addStep(new IdentityStep(traversal));
        traversal.addStep(new HasStep(traversal, null));
        traversal.addStep(new FilterStep(traversal));
        validateToyTraversal(traversal);
    }
View Full Code Here

        validateToyTraversal(traversal);
    }

    @Test
    public void shouldInsertCorrectly() {
        Traversal traversal = new DefaultTraversal<>();
        TraversalHelper.insertStep(new FilterStep(traversal), 0, traversal);
        TraversalHelper.insertStep(new HasStep(traversal, null), 0, traversal);
        TraversalHelper.insertStep(new IdentityStep(traversal), 0, traversal);
        validateToyTraversal(traversal);
View Full Code Here

        validateToyTraversal(traversal);
    }

    @Test
    public void shouldRemovesCorrectly() {
        Traversal traversal = new DefaultTraversal<>();
        traversal.addStep(new IdentityStep(traversal));
        traversal.addStep(new HasStep(traversal, null));
        traversal.addStep(new FilterStep(traversal));

        traversal.addStep(new PropertiesStep(traversal, PropertyType.VALUE, "marko"));
        TraversalHelper.removeStep(3, traversal);
        validateToyTraversal(traversal);

        TraversalHelper.insertStep(new PropertiesStep(traversal, PropertyType.PROPERTY, "marko"), 0, traversal);
        TraversalHelper.removeStep(0, traversal);
View Full Code Here

        validateToyTraversal(traversal);
    }

    @Test
    public void shouldIsolateSteps() {
        Traversal traversal = new DefaultTraversal<>();
        Step step1 = new IdentityStep(traversal);
        Step step2 = new TimeLimitStep<>(traversal, 100);
        Step step3 = new RandomStep<>(traversal, 0.5);
        Step step4 = new PropertyMapStep(traversal, PropertyType.PROPERTY, "name");
        Step step5 = new ShuffleStep<>(traversal);
        traversal.addStep(step1);
        traversal.addStep(step2);
        traversal.addStep(step3);
        traversal.addStep(step4);
        traversal.addStep(step5);

        List<Step> steps;

        steps = TraversalHelper.isolateSteps(step1, step5);
        assertEquals(3, steps.size());
View Full Code Here

            TraversalHelper.insertStep(new StartStep<>(traversal, vertex), 0, traversal);
            return (T) traversal;
        }

        public <T extends Traversal<Vertex, Vertex>> T vertices(final Vertex vertex) {
            final Traversal traversal = this.incidentTraversal.get();
            final VertexStep step = TraversalHelper.getLastStep(traversal, VertexStep.class).get();
            TraversalHelper.insertStep(new EdgeVertexStep(traversal, step.getDirection().opposite()), traversal.getSteps().size(), traversal);
            TraversalHelper.insertStep(new StartStep<>(traversal, vertex), 0, traversal);
            return (T) traversal;
        }
View Full Code Here

            TraversalHelper.insertStep(new StartStep<>(traversal, vertex), 0, traversal);
            return (T) traversal;
        }

        public Direction getDirection() {
            final Traversal traversal = this.incidentTraversal.get();
            final VertexStep step = TraversalHelper.getLastStep(traversal, VertexStep.class).get();
            return step.getDirection();
        }
View Full Code Here

TOP

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

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.