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

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

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

Vertex.remove介绍

暂无

代码示例

代码示例来源:origin: JanusGraph/janusgraph

private void removeVertex(String property, Object value) {
  final GraphTraversal<Vertex, Vertex> traversal = graph.traversal().V().has(property, value);
  if (traversal.hasNext()) {
    traversal.next().remove();
    graph.tx().commit();
  }
}

代码示例来源:origin: thinkaurelius/titan

newTx();
vs[2] = getV(tx, vs[2]);
vs[2].remove();
vs[3] = getV(tx, vs[3]);
vs[3].property(VertexProperty.Cardinality.single, "name", "Bad Boy Badsy");

代码示例来源:origin: thinkaurelius/titan

String n = u.<String>value("name");
if (n.endsWith("Don")) {
  u.remove();
} else if (n.endsWith("Lewis")) {
  u.property(VertexProperty.Cardinality.single, "name", "Big Brother Bob");

代码示例来源:origin: JanusGraph/janusgraph

newTx();
vs[2] = getV(tx, vs[2]);
vs[2].remove();
vs[3] = getV(tx, vs[3]);
vs[3].property(VertexProperty.Cardinality.single, "name", "Bad Boy Badsy");

代码示例来源:origin: JanusGraph/janusgraph

final String n = u.value("name");
if (n.endsWith("Don")) {
  u.remove();
} else if (n.endsWith("Lewis")) {
  u.property(VertexProperty.Cardinality.single, "name", "Big Brother Bob");

代码示例来源:origin: thinkaurelius/titan

graph.vertices().forEachRemaining(v -> v.remove());
v1 = graph.addVertex();
v1.property(property, value1);

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

@Test
public void testDeleteAndDeleteVertex() {
  HugeGraph graph = graph();
  Vertex vertex = graph.addVertex(T.label, "author", "id", 1,
                  "name", "Tom", "lived", "Beijing");
  vertex.remove();
  vertex.remove();
  graph.tx().commit();
  Assert.assertNull(vertex("author", "id", 1));
}

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

@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_REMOVE_VERTICES, supported = false)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
public void shouldSupportRemoveVerticesIfAVertexCanBeRemoved() throws Exception {
  try {
    graph.addVertex().remove();
    fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), VertexFeatures.FEATURE_REMOVE_VERTICES));
  } catch (Exception e) {
    validateException(Vertex.Exceptions.vertexRemovalNotSupported(), e);
  }
}

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

/**
 * Generate a graph with lots of vertices, then iterate the vertices and remove them from the graph
 */
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_REMOVE_VERTICES)
public void shouldRemoveVerticesWithoutConcurrentModificationException() {
  for (int i = 0; i < 100; i++) {
    graph.addVertex();
  }
  final Iterator<Vertex> vertexIterator = graph.vertices();
  assertTrue(vertexIterator.hasNext());
  while (vertexIterator.hasNext()) {
    vertexIterator.next().remove();
  }
  assertFalse(vertexIterator.hasNext());
  tryCommit(graph, graph -> assertFalse(graph.vertices().hasNext()));
}

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

@Test
public void testRemoveVertexOneByOne() {
  HugeGraph graph = graph();
  init10Vertices();
  List<Vertex> vertexes = graph.traversal().V().toList();
  Assert.assertEquals(10, vertexes.size());
  for (int i = 0; i < vertexes.size(); i++) {
    vertexes.get(i).remove();
    graph.tx().commit();
    Assert.assertEquals(9 - i, graph.traversal().V().toList().size());
  }
}

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

@Test
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_REMOVE_EDGES, supported = false)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
public void shouldSupportRemoveEdgesIfEdgeCanBeRemoved() throws Exception {
  try {
    final Vertex v = graph.addVertex();
    v.addEdge("friend", v);
    v.remove();
    fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), EdgeFeatures.FEATURE_REMOVE_EDGES));
  } catch (Exception ex) {
    validateException(Edge.Exceptions.edgeRemovalNotSupported(), ex);
  }
}

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

@Test
public void testInsertAndDeleteVertex() {
  HugeGraph graph = graph();
  Vertex vertex = graph.addVertex(T.label, "author", "id", 1,
                  "name", "Tom", "lived", "Beijing");
  vertex.remove();
  graph.tx().commit();
  Assert.assertNull(vertex("author", "id", 1));
}

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

@Test
public void testAppendAndDeleteVertex() {
  HugeGraph graph = graph();
  Vertex vertex = graph.addVertex(T.label, "author", "id", 1,
                  "name", "Tom", "lived", "Beijing");
  vertex.property("lived", "Wuhan");
  vertex.remove();
  graph.tx().commit();
  Assert.assertNull(vertex("author", "id", 1));
}

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

@Test
public void testDeleteAndAppendVertex() {
  HugeGraph graph = graph();
  Vertex vertex = graph.addVertex(T.label, "author", "id", 1,
                  "name", "Tom", "lived", "Beijing");
  vertex.remove();
  vertex.property("lived", "Shanghai");
  graph.tx().commit();
  Assert.assertNull(vertex("author", "id", 1));
}

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

public void testRemoveVertexAfterAddVertexWithTx() {
  HugeGraph graph = graph();
  GraphTransaction tx = graph.openTransaction();
  Vertex java1 = tx.addVertex(T.label, "book", "name", "java-1");
  tx.addVertex(T.label, "book", "name", "java-2");
  tx.commit();
  java1.remove();
  tx.commit();
  tx.close();
  List<Vertex> vertexes = graph.traversal().V().toList();
  Assert.assertEquals(1, vertexes.size());
  assertNotContains(vertexes, T.label, "book", "name", "java-2");
}

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

@Test
public void testDeleteAndEliminateVertex() {
  HugeGraph graph = graph();
  Vertex vertex = graph.addVertex(T.label, "author", "id", 1,
                  "name", "Tom", "lived", "Beijing");
  vertex.remove();
  vertex.property("lived").remove();
  graph.tx().commit();
  Assert.assertNull(vertex("author", "id", 1));
}

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

@Test
public void testEliminateAndDeleteVertex() {
  HugeGraph graph = graph();
  Vertex vertex = graph.addVertex(T.label, "author", "id", 1,
                  "name", "Tom", "lived", "Beijing");
  vertex.property("lived").remove();
  vertex.remove();
  graph.tx().commit();
  Assert.assertNull(vertex("author", "id", 1));
}

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

@Test
public void testRemoveVertex() {
  HugeGraph graph = graph();
  init10Vertices();
  List<Vertex> vertexes = graph.traversal().V().toList();
  Assert.assertEquals(10, vertexes.size());
  assertContains(vertexes,
          T.label, "author", "id", 1, "name", "James Gosling",
          "age", 62, "lived", "Canadian");
  Vertex vertex = vertex("author", "id", 1);
  vertex.remove();
  graph.tx().commit();
  vertexes = graph.traversal().V().toList();
  Assert.assertEquals(9, vertexes.size());
  assertNotContains(vertexes,
           T.label, "author", "id", 1, "name", "James Gosling",
           "age", 62, "lived", "Canadian");
}

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

@Test
public void testUpdateVertexPropertyOfRemovingVertex() {
  HugeGraph graph = graph();
  Vertex vertex = graph.addVertex(T.label, "author", "id", 1,
                  "name", "Tom", "lived", "Beijing");
  graph.tx().commit();
  vertex.remove();
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    vertex.property("lived").remove();
  });
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    vertex.property("lived", "Shanghai");
  });
}

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

@Test
public void testDeleteAndInsertVertex() {
  HugeGraph graph = graph();
  graph.addVertex(T.label, "author", "id", 1,
          "name", "Tom", "lived", "Beijing");
  graph.traversal().V().hasLabel("author").has("id", 1).next().remove();
  graph.addVertex(T.label, "author", "id", 1,
          "name", "Tom", "lived", "Shanghai");
  graph.tx().commit();
  Vertex vertex = vertex("author", "id", 1);
  Assert.assertTrue(vertex.property("lived").isPresent());
  Assert.assertEquals("Shanghai", vertex.property("lived").value());
}

相关文章