Package com.tinkerpop.gremlin.structure

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


                                      final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException {
            ser(directionalVertex, jsonGenerator);
        }

        public void ser(final GraphSONVertex directionalVertex, final JsonGenerator jsonGenerator) throws IOException {
            final Vertex vertex = directionalVertex.getVertexToSerialize();
            final Map<String, Object> m = new HashMap<>();
            m.put(GraphSONTokens.ID, vertex.id());
            m.put(GraphSONTokens.LABEL, vertex.label());
            m.put(GraphSONTokens.TYPE, GraphSONTokens.VERTEX);

            final Object properties = StreamFactory.stream(vertex.iterators().propertyIterator())
                    .collect(Collectors.groupingBy(vp -> vp.key()));
            final Object hiddens = StreamFactory.stream(vertex.iterators().hiddenPropertyIterator())
                    .collect(Collectors.groupingBy(vp -> vp.key()));
            m.put(GraphSONTokens.PROPERTIES, properties);
            m.put(GraphSONTokens.HIDDENS, hiddens);

            if (directionalVertex.getDirection() == Direction.BOTH || directionalVertex.getDirection() == Direction.OUT) {
                m.put(GraphSONTokens.OUT_E, StreamFactory.stream(vertex.iterators().edgeIterator(Direction.OUT)).collect(Collectors.toList()));
            }

            if (directionalVertex.getDirection() == Direction.BOTH || directionalVertex.getDirection() == Direction.IN) {
                m.put(GraphSONTokens.IN_E, StreamFactory.stream(vertex.iterators().edgeIterator(Direction.IN)).collect(Collectors.toList()));
            }

            jsonGenerator.writeObject(m);
        }
View Full Code Here


            final Map<String,Object> hiddens = StreamFactory.stream(edge.iterators().hiddenPropertyIterator()).collect(Collectors.toMap(Property::key, Property::value));

            m.put(GraphSONTokens.PROPERTIES, properties);
            m.put(GraphSONTokens.HIDDENS, hiddens);

            final Vertex inV = edge.iterators().vertexIterator(Direction.IN).next();
            m.put(GraphSONTokens.IN, inV.id());
            m.put(GraphSONTokens.IN_LABEL, inV.label());

            final Vertex outV = edge.iterators().vertexIterator(Direction.OUT).next();
            m.put(GraphSONTokens.OUT, outV.id());
            m.put(GraphSONTokens.OUT_LABEL, outV.label());

            jsonGenerator.writeObject(m);
        }
View Full Code Here

        public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
            if (!BatchVertex.class.isInstance(inVertex))
                throw new IllegalArgumentException("Given element was not created in this baseGraph");
            nextElement();

            final Vertex ov = getCachedVertex(externalID);
            final Vertex iv = getCachedVertex(inVertex.id());

            previousOutVertexId = externalID;  //keep track of the previous out vertex id

            if (!incrementalLoading) {
                final Optional<Object[]> kvs = baseSupportsSuppliedEdgeId && T.id.getAccessor().equals(edgeIdKey) ?
View Full Code Here

    ////////////// STRUCTURE API METHODS //////////////////

    @Override
    public Vertex v(final Object id) {
        if (null == id) throw Graph.Exceptions.elementNotFound(Vertex.class, null);
        final Vertex vertex = this.vertices.get(id);
        if (null == vertex)
            throw Graph.Exceptions.elementNotFound(Vertex.class, id);
        else
            return vertex;
    }
View Full Code Here

                throw Exceptions.vertexWithIdAlreadyExists(idValue);
        } else {
            idValue = TinkerHelper.getNextId(this);
        }

        final Vertex vertex = new TinkerVertex(idValue, label, this);
        this.vertices.put(vertex.id(), vertex);
        ElementHelper.attachProperties(vertex, keyValues);
        return vertex;
    }
View Full Code Here

     */
    protected boolean same(final Graph g1, final Graph g2) {
        return g1.V().toList().stream()
                .map(v -> Triplet.<Integer, List<Vertex>, List<Vertex>>with(v.value("oid"), v.in().toList(), v.out().toList()))
                .allMatch(p -> {
                    final Vertex v = (Vertex) g2.V().has("oid", p.getValue0()).next();
                    return sameInVertices(v, p.getValue1()) && sameOutVertices(v, p.getValue2());
                });
    }
View Full Code Here

    public void newTransaction() {
        for (String id : mapKeysInCurrentTx) {
            final Object o = map.get(id);
            assert null != o;
            if (o instanceof Vertex) {
                Vertex v = (Vertex) o;
                map.put(id, v.id());
            }
        }
        mapKeysInCurrentTx.clear();
    }
View Full Code Here

    public void newTransaction() {
        for (Object id : mapKeysInCurrentTx) {
            Object o = map.get(id);
            assert null != o;
            if (o instanceof Vertex) {
                Vertex v = (Vertex) o;
                map.put(id, v.id());
            }
        }
        mapKeysInCurrentTx.clear();
    }
View Full Code Here

    private Vertex retrieveFromCache(final Object externalID) {
        final Object internal = cache.getEntry(externalID);
        if (internal instanceof Vertex) {
            return (Vertex) internal;
        } else if (internal != null) { //its an internal id
            final Vertex v = baseGraph.v(internal);
            cache.set(v, externalID);
            return v;
        } else return null;
    }
View Full Code Here

            return v;
        } else return null;
    }

    private Vertex getCachedVertex(final Object externalID) {
        final Vertex v = retrieveFromCache(externalID);
        if (v == null) throw new IllegalArgumentException("Vertex for given ID cannot be found: " + externalID);
        return v;
    }
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.