@Override public Graph graph() { return this.inVertex.graph(); }
/** * {@inheritDoc} */ @Override public default Graph graph() { return this.element().graph(); }
public static Edge createEdge(final Attachable<Edge> attachableEdge, final Vertex hostVertex) { return Method.createEdge(attachableEdge, hostVertex.graph()); // TODO (make local to vertex) }
private Iterator<Vertex> vertices(Traverser.Admin<Vertex> traverser) { HugeGraph graph = (HugeGraph) traverser.get().graph(); Vertex vertex = traverser.get(); Iterator<Edge> edges = this.edges(traverser); Iterator<Vertex> vertices = graph.adjacentVertices(edges); if (LOG.isDebugEnabled()) { LOG.debug("HugeVertexStep.vertices(): is there adjacent " + "vertices of {}: {}, has={}", vertex.id(), vertices.hasNext(), this.hasContainers); } if (this.hasContainers.isEmpty()) { return vertices; } // TODO: query by vertex index to optimize return TraversalUtil.filterResult(this.hasContainers, vertices); }
/** * Assign key/value pairs as properties to an {@link org.apache.tinkerpop.gremlin.structure.Vertex}. If the value of {@link T#id} or * {@link T#label} is in the set of pairs, then they are ignored. * The {@link org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality} of the key is determined from the {@link org.apache.tinkerpop.gremlin.structure.Graph.Features.VertexFeatures}. * * @param vertex the graph vertex to assign the {@code propertyKeyValues} * @param propertyKeyValues the key/value pairs to assign to the {@code element} * @throws ClassCastException if the value of the key is not a {@link String} * @throws IllegalArgumentException if the value of {@code element} is null */ public static void attachProperties(final Vertex vertex, final Object... propertyKeyValues) { if (null == vertex) throw Graph.Exceptions.argumentCanNotBeNull("vertex"); for (int i = 0; i < propertyKeyValues.length; i = i + 2) { if (!propertyKeyValues[i].equals(T.id) && !propertyKeyValues[i].equals(T.label)) vertex.property(vertex.graph().features().vertex().getCardinality((String) propertyKeyValues[i]), (String) propertyKeyValues[i], propertyKeyValues[i + 1]); } }
/** * Set the provided key to the provided value using default {@link VertexProperty.Cardinality} for that key. * The default cardinality can be vendor defined and is usually tied to the graph schema. * The default implementation of this method determines the cardinality * {@code graph().features().vertex().getCardinality(key)}. The provided key/values are the properties of the * newly created {@link VertexProperty}. These key/values must be provided in an even number where the odd * numbered arguments are {@link String}. * * @param key the key of the vertex property * @param value The value of the vertex property * @param keyValues the key/value pairs to turn into vertex property properties * @param <V> the type of the value of the vertex property * @return the newly created vertex property */ public default <V> VertexProperty<V> property(final String key, final V value, final Object... keyValues) { return this.property(graph().features().vertex().getCardinality(key), key, value, keyValues); }
public static VertexProperty createVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Vertex hostVertex) { final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.get(); final VertexProperty vertexProperty = hostVertex.graph().features().vertex().properties().willAllowId(baseVertexProperty.id()) ? hostVertex.property(hostVertex.graph().features().vertex().getCardinality(baseVertexProperty.key()), baseVertexProperty.key(), baseVertexProperty.value(), T.id, baseVertexProperty.id()) : hostVertex.property(hostVertex.graph().features().vertex().getCardinality(baseVertexProperty.key()), baseVertexProperty.key(), baseVertexProperty.value()); baseVertexProperty.properties().forEachRemaining(p -> vertexProperty.property(p.key(), p.value())); return vertexProperty; }
@Override public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final Vertex vertex) { kryo.writeClassAndObject(output, vertex.id()); output.writeString(vertex.label()); final Iterator<? extends VertexProperty> properties = vertex.properties(); output.writeBoolean(properties.hasNext()); while (properties.hasNext()) { final VertexProperty vp = properties.next(); kryo.writeClassAndObject(output, vp.id()); output.writeString(vp.label()); kryo.writeClassAndObject(output, vp.value()); if (vp instanceof DetachedVertexProperty || (vertex.graph().features().vertex().supportsMetaProperties())) { writeElementProperties(kryo, output, vp); } else { output.writeBoolean(false); } output.writeBoolean(properties.hasNext()); } }
@Override public Graph graph() { return this.inVertex.graph(); }
@Override public Graph graph() { return this.inVertex.graph(); }
/** * Creates a new {@link StarGraph} from a {@link Vertex}. */ public static StarGraph of(final Vertex vertex) { if (vertex instanceof StarVertex) return (StarGraph) vertex.graph(); // else convert to a star graph final StarGraph starGraph = new StarGraph(); final StarVertex starVertex = (StarVertex) starGraph.addVertex(T.id, vertex.id(), T.label, vertex.label()); final boolean supportsMetaProperties = vertex.graph().features().vertex().supportsMetaProperties(); vertex.properties().forEachRemaining(vp -> { final VertexProperty<?> starVertexProperty = starVertex.property(VertexProperty.Cardinality.list, vp.key(), vp.value(), T.id, vp.id()); if (supportsMetaProperties) vp.properties().forEachRemaining(p -> starVertexProperty.property(p.key(), p.value())); }); vertex.edges(Direction.IN).forEachRemaining(edge -> { final Edge starEdge = starVertex.addInEdge(edge.label(), starGraph.addVertex(T.id, edge.outVertex().id()), T.id, edge.id()); edge.properties().forEachRemaining(p -> starEdge.property(p.key(), p.value())); }); vertex.edges(Direction.OUT).forEachRemaining(edge -> { final Edge starEdge = starVertex.addOutEdge(edge.label(), starGraph.addVertex(T.id, edge.inVertex().id()), T.id, edge.id()); edge.properties().forEachRemaining(p -> starEdge.property(p.key(), p.value())); }); return starGraph; }
private Iterator<Edge> edges(Traverser.Admin<Vertex> traverser) { HugeGraph graph = (HugeGraph) traverser.get().graph(); List<HasContainer> conditions = this.hasContainers;
/** * {@inheritDoc} */ @Override public default Graph graph() { return this.element().graph(); }
public static Edge createEdge(final Attachable<Edge> attachableEdge, final Vertex hostVertex) { return Method.createEdge(attachableEdge, hostVertex.graph()); // TODO (make local to vertex) }
@Override public <V> Property<V> setProperty(final Neo4jVertexProperty vertexProperty, final String key, final V value) { final Neo4jNode vertexPropertyNode = Neo4jHelper.getVertexPropertyNode(vertexProperty); if (null != vertexPropertyNode) { vertexPropertyNode.setProperty(key, value); return new Neo4jProperty<>(vertexProperty, key, value); } else { final Neo4jNode vertexNode = ((Neo4jVertex) vertexProperty.element()).getBaseVertex(); final Neo4jNode newVertexPropertyNode = ((WrappedGraph<Neo4jGraphAPI>) vertexProperty.element().graph()).getBaseGraph().createNode(VERTEX_PROPERTY_LABEL, vertexProperty.label()); newVertexPropertyNode.setProperty(T.key.getAccessor(), vertexProperty.key()); newVertexPropertyNode.setProperty(T.value.getAccessor(), vertexProperty.value()); newVertexPropertyNode.setProperty(vertexProperty.key(), vertexProperty.value()); newVertexPropertyNode.setProperty(key, value); vertexNode.connectTo(newVertexPropertyNode, Graph.Hidden.hide(vertexProperty.key())); vertexNode.setProperty(vertexProperty.key(), VERTEX_PROPERTY_TOKEN); Neo4jHelper.setVertexPropertyNode(vertexProperty, newVertexPropertyNode); return new Neo4jProperty<>(vertexProperty, key, value); } }
/** * Sets the EClass for the EObject represented by the given vertex. * * @param registry The {@linkplain ChronoEPackageRegistry package} to work with. Must not be <code>null</code>. * @param vertex The vertex representing the EObject to set the EClass for. Must not be <code>null</code>. * @param eClass The eClass to use. Must be part of the given package. Must not be <code>null</code>. */ public static void setEClassForEObjectVertex(final ChronoEPackageRegistry registry, final Vertex vertex, final EClass eClass) { checkNotNull(registry, "Precondition violation - argument 'registry' must not be NULL!"); checkNotNull(vertex, "Precondition violation - argument 'vertex' must not be NULL!"); checkNotNull(eClass, "Precondition violation - argument 'eClass' must not be NULL!"); ChronoGraph graph = (ChronoGraph) vertex.graph(); Vertex eClassVertex = getVertexForEClass(registry, graph, eClass); vertex.property(V_PROP__ECLASS_ID, (String) eClassVertex.id()); }
private Iterator<Vertex> vertices(Traverser.Admin<Vertex> traverser) { HugeGraph graph = (HugeGraph) traverser.get().graph(); Vertex vertex = traverser.get(); Iterator<Edge> edges = this.edges(traverser); Iterator<Vertex> vertices = graph.adjacentVertices(edges); if (LOG.isDebugEnabled()) { LOG.debug("HugeVertexStep.vertices(): is there adjacent " + "vertices of {}: {}, has={}", vertex.id(), vertices.hasNext(), this.hasContainers); } if (this.hasContainers.isEmpty()) { return vertices; } // TODO: query by vertex index to optimize return TraversalUtil.filterResult(this.hasContainers, vertices); }
/** * Assign key/value pairs as properties to an {@link org.apache.tinkerpop.gremlin.structure.Vertex}. If the value of {@link T#id} or * {@link T#label} is in the set of pairs, then they are ignored. * The {@link org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality} of the key is determined from the {@link org.apache.tinkerpop.gremlin.structure.Graph.Features.VertexFeatures}. * * @param vertex the graph vertex to assign the {@code propertyKeyValues} * @param propertyKeyValues the key/value pairs to assign to the {@code element} * @throws ClassCastException if the value of the key is not a {@link String} * @throws IllegalArgumentException if the value of {@code element} is null */ public static void attachProperties(final Vertex vertex, final Object... propertyKeyValues) { if (null == vertex) throw Graph.Exceptions.argumentCanNotBeNull("vertex"); for (int i = 0; i < propertyKeyValues.length; i = i + 2) { if (!propertyKeyValues[i].equals(T.id) && !propertyKeyValues[i].equals(T.label)) vertex.property(vertex.graph().features().vertex().getCardinality((String) propertyKeyValues[i]), (String) propertyKeyValues[i], propertyKeyValues[i + 1]); } }
/** * Set the provided key to the provided value using default {@link VertexProperty.Cardinality} for that key. * The default cardinality can be vendor defined and is usually tied to the graph schema. * The default implementation of this method determines the cardinality * {@code graph().features().vertex().getCardinality(key)}. The provided key/values are the properties of the * newly created {@link VertexProperty}. These key/values must be provided in an even number where the odd * numbered arguments are {@link String}. * * @param key the key of the vertex property * @param value The value of the vertex property * @param keyValues the key/value pairs to turn into vertex property properties * @param <V> the type of the value of the vertex property * @return the newly created vertex property */ public default <V> VertexProperty<V> property(final String key, final V value, final Object... keyValues) { return this.property(graph().features().vertex().getCardinality(key), key, value, keyValues); }
public static VertexProperty createVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Vertex hostVertex) { final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.get(); final VertexProperty vertexProperty = hostVertex.graph().features().vertex().properties().willAllowId(baseVertexProperty.id()) ? hostVertex.property(hostVertex.graph().features().vertex().getCardinality(baseVertexProperty.key()), baseVertexProperty.key(), baseVertexProperty.value(), T.id, baseVertexProperty.id()) : hostVertex.property(hostVertex.graph().features().vertex().getCardinality(baseVertexProperty.key()), baseVertexProperty.key(), baseVertexProperty.value()); baseVertexProperty.properties().forEachRemaining(p -> vertexProperty.property(p.key(), p.value())); return vertexProperty; }