org.apache.tinkerpop.gremlin.structure.Vertex.graph()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(12.6k)|赞(0)|评价(0)|浏览(83)

本文整理了Java中org.apache.tinkerpop.gremlin.structure.Vertex.graph()方法的一些代码示例,展示了Vertex.graph()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.graph()方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Vertex
类名称:Vertex
方法名:graph

Vertex.graph介绍

暂无

代码示例

代码示例来源:origin: apache/tinkerpop

@Override
public Graph graph() {
  return this.inVertex.graph();
}

代码示例来源:origin: apache/tinkerpop

/**
 * {@inheritDoc}
 */
@Override
public default Graph graph() {
  return this.element().graph();
}

代码示例来源:origin: apache/tinkerpop

public static Edge createEdge(final Attachable<Edge> attachableEdge, final Vertex hostVertex) {
  return Method.createEdge(attachableEdge, hostVertex.graph()); // TODO (make local to vertex)
}

代码示例来源:origin: hugegraph/hugegraph

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);
}

代码示例来源:origin: apache/tinkerpop

/**
 * 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]);
  }
}

代码示例来源:origin: apache/tinkerpop

/**
 * 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);
}

代码示例来源:origin: apache/tinkerpop

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;
}

代码示例来源:origin: apache/tinkerpop

@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());
  }
}

代码示例来源:origin: org.apache.tinkerpop/tinkergraph-gremlin

@Override
public Graph graph() {
  return this.inVertex.graph();
}

代码示例来源:origin: io.shiftleft/tinkergraph-gremlin

@Override
public Graph graph() {
  return this.inVertex.graph();
}

代码示例来源:origin: apache/tinkerpop

/**
 * 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;
}

代码示例来源:origin: hugegraph/hugegraph

private Iterator<Edge> edges(Traverser.Admin<Vertex> traverser) {
  HugeGraph graph = (HugeGraph) traverser.get().graph();
  List<HasContainer> conditions = this.hasContainers;

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

/**
 * {@inheritDoc}
 */
@Override
public default Graph graph() {
  return this.element().graph();
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

public static Edge createEdge(final Attachable<Edge> attachableEdge, final Vertex hostVertex) {
  return Method.createEdge(attachableEdge, hostVertex.graph()); // TODO (make local to vertex)
}

代码示例来源:origin: apache/tinkerpop

@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);
  }
}

代码示例来源:origin: MartinHaeusler/chronos

/**
 * 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());
}

代码示例来源:origin: com.baidu.hugegraph/hugegraph-core

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);
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

/**
 * 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]);
  }
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

/**
 * 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);
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

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;
}

相关文章