Package com.tinkerpop.gremlin.structure

Examples of com.tinkerpop.gremlin.structure.Vertex$Iterators


            throw new IllegalArgumentException("If a directionRequested is specified then an edgeAdder function should also be specified");

        this.headerReader.read(kryo, input);

        final DetachedVertex detachedVertex = (DetachedVertex) kryo.readClassAndObject(input);
        final Vertex v = vertexMaker.apply(detachedVertex);

        final boolean streamContainsEdgesInSomeDirection = input.readBoolean();
        if (!streamContainsEdgesInSomeDirection && directionRequested != null)
            throw new IllegalStateException(String.format("The direction %s was requested but no attempt was made to serialize edges into this stream", directionRequested));
View Full Code Here


            // in this case the outId is the id assigned by the graph
            Object next = kryo.readClassAndObject(input);
            while (!next.equals(EdgeTerminator.INSTANCE)) {
                final List<Object> edgeArgs = new ArrayList<>();
                final DetachedEdge detachedEdge = (DetachedEdge) next;
                final Vertex vOut = graphToWriteTo.v(detachedEdge.iterators().vertexIterator(Direction.OUT).next().id());
                final Vertex inV = graphToWriteTo.v(detachedEdge.iterators().vertexIterator(Direction.IN).next().id());

                detachedEdge.iterators().propertyIterator().forEachRemaining(p -> edgeArgs.addAll(Arrays.asList(p.key(), p.value())));
                detachedEdge.iterators().hiddenPropertyIterator().forEachRemaining(p -> edgeArgs.addAll(Arrays.asList(Graph.Key.hide(p.key()), p.value())));

                appendToArgList(edgeArgs, T.id, detachedEdge.id());
View Full Code Here

        assertEquals(true, result.get(Boolean.class));
    }

    @Test
    public void shouldGetVertex() {
        final Vertex v = g.v(1);
        final ResponseMessage msg = ResponseMessage.build(id).result(v).create();
        final Result result = new Result(msg);

        assertEquals(v, result.getVertex());
        assertEquals(v, result.get(Vertex.class));
View Full Code Here

    }

    @Test
    public void serializeEdge() throws Exception {
        final Graph g = TinkerGraph.open();
        final Vertex v1 = g.addVertex();
        final Vertex v2 = g.addVertex();
        final Edge e = v1.addEdge("test", v2);
        e.property("abc", 123);

        final Iterable<Edge> iterable = g.E().toList();
View Full Code Here

    }

    @Test
    public void serializeVertexWithEmbeddedMap() throws Exception {
        final Graph g = TinkerGraph.open();
        final Vertex v = g.addVertex();
        final Map<String, Object> map = new HashMap<>();
        map.put("x", 500);
        map.put("y", "some");

        final ArrayList<Object> friends = new ArrayList<>();
        friends.add("x");
        friends.add(5);
        friends.add(map);

        v.property("friends", friends);

        final List list = g.V().toList();

        final ResponseMessage response = convert(list);
        assertCommon(response);
View Full Code Here

        assertCommon(response);

        final Map<Vertex, Integer> deserializedMap = (Map<Vertex, Integer>) response.getResult().getData();
        assertEquals(1, deserializedMap.size());

        final Vertex deserializedMarko = deserializedMap.keySet().iterator().next();
        assertEquals("marko", deserializedMarko.iterators().valueIterator("name").next().toString());
        assertEquals(1, deserializedMarko.id());
        assertEquals(Vertex.DEFAULT_LABEL, deserializedMarko.label());
        assertEquals(new Integer(29), (Integer) deserializedMarko.iterators().valueIterator("age").next());
        assertEquals(2, StreamFactory.stream(deserializedMarko.iterators().propertyIterator()).count());

        assertEquals(new Integer(1000), deserializedMap.values().iterator().next());
    }
View Full Code Here

    /**
     * Construct the representation for a {@link com.tinkerpop.gremlin.structure.Edge}.
     */
    public static String edgeString(final Edge edge) {
        final Vertex inV = edge.iterators().vertexIterator(Direction.IN).next();
        final Vertex outV = edge.iterators().vertexIterator(Direction.OUT).next();
        return E + L_BRACKET + edge.id() + R_BRACKET + L_BRACKET + outV.id() + DASH + edge.label() + ARROW + inV.id() + R_BRACKET;
    }
View Full Code Here

        printTraversalForm(traversal);
        int counter = 0;
        Set<Vertex> vertices = new HashSet<>();
        while (traversal.hasNext()) {
            counter++;
            Vertex vertex = traversal.next();
            vertices.add(vertex);
            assertTrue(vertex.value("name").equals("josh") || vertex.value("name").equals("lop"));
        }
        assertEquals(2, counter);
        assertEquals(2, vertices.size());
    }
View Full Code Here

        final Traversal<Vertex, Vertex> traversal = get_g_v1_outXcreatedX_inXcreatedX_cyclicPath(convertToVertexId("marko"));
        printTraversalForm(traversal);
        int counter = 0;
        while (traversal.hasNext()) {
            counter++;
            Vertex vertex = traversal.next();
            assertEquals("marko", vertex.<String>value("name"));
        }
        assertEquals(1, counter);
        assertFalse(traversal.hasNext());
    }
View Full Code Here

            }
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
        final Traverser.Admin<Vertex> traverser = this.starts.next();
        final Vertex vertex = traverser.get();
        return traverser.makeChild(this.getLabel(), new Pair<>(vertex, (Double) this.resultantGraph.v(vertex.id()).value(PageRankVertexProgram.PAGE_RANK)));
    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.gremlin.structure.Vertex$Iterators

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.