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

x33g5p2x  于2022-01-26 转载在 其他  
字(12.3k)|赞(0)|评价(0)|浏览(114)

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

Property.remove介绍

[英]Remove the property from the associated element.
[中]从关联元素中删除属性。

代码示例

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

@Override
public void remove() {
  this.baseProperty.remove();
}

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

@Override
public void remove() {
  this.property.remove();
}

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

@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
public void shouldGetPropertyKeysOnEdge() {
  final Vertex v = graph.addVertex();
  final Edge e = v.addEdge("friend", v, "name", "marko", "location", "desert", "status", "dope");
  Set<String> keys = e.keys();
  assertEquals(3, keys.size());
  assertTrue(keys.contains("name"));
  assertTrue(keys.contains("location"));
  assertTrue(keys.contains("status"));
  final List<Property<Object>> m = IteratorUtils.list(e.properties());
  assertEquals(3, m.size());
  assertTrue(m.stream().anyMatch(p -> p.key().equals("name")));
  assertTrue(m.stream().anyMatch(p -> p.key().equals("location")));
  assertTrue(m.stream().anyMatch(p -> p.key().equals("status")));
  assertEquals("marko", m.stream().filter(p -> p.key().equals("name")).map(Property::value).findAny().orElse(null));
  assertEquals("desert", m.stream().filter(p -> p.key().equals("location")).map(Property::value).findAny().orElse(null));
  assertEquals("dope", m.stream().filter(p -> p.key().equals("status")).map(Property::value).findAny().orElse(null));
  e.property("status").remove();
  keys = e.keys();
  assertEquals(2, keys.size());
  assertTrue(keys.contains("name"));
  assertTrue(keys.contains("location"));
  e.properties().forEachRemaining(Property::remove);
  keys = e.keys();
  assertEquals(0, keys.size());
}

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

@Test
public void testRemoveEdgePropertyOfSortKey() {
  Edge edge = initEdgeTransfer();
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    edge.property("id").remove();
  });
}

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

@Test
  @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
  @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_REMOVE_PROPERTY)
  @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_INTEGER_VALUES)
  public void shouldAllowRemovalFromEdgeWhenAlreadyRemoved() {
    final Vertex v = graph.addVertex("name", "marko");
    tryCommit(graph);
    final Vertex v1 = graph.vertices(v.id()).next();
    try {
      final Edge edge = v1.addEdge("knows", graph.addVertex());
      final Property p = edge.property("stars", 5);
      p.remove();
      p.remove();
      edge.property("stars").remove();
      edge.property("stars").remove();
    } catch (Exception ex) {
      fail("Removing an edge property that was already removed should not throw an exception");
    }
  }
}

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

edge.property(key, value);
} else {
  edge.property(key).remove();

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

@Test
public void testRemoveEdgePropertyNonNullWithIndex() {
  HugeGraph graph = graph();
  Vertex louise = graph.addVertex(T.label, "person", "name", "Louise",
                  "city", "Beijing", "age", 21);
  Vertex sean = graph.addVertex(T.label, "person", "name", "Sean",
                 "city", "Beijing", "age", 23);
  long current = System.currentTimeMillis();
  Edge edge = louise.addEdge("strike", sean, "id", 1,
                "timestamp", current, "place", "park",
                "tool", "shovel", "reason", "jeer",
                "arrested", false);
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    edge.property("timestamp").remove();
  });
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    edge.property("place").remove();
  });
}

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

@Test
  @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = EdgeFeatures.FEATURE_REMOVE_PROPERTY, supported = false)
  @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
  public void shouldSupportRemovePropertyIfAPropertyCanBeRemoved() throws Exception {
    try {
      final Vertex v = graph.addVertex();
      final Edge e = v.addEdge("self", v, "name", "foo");
      e.property("name").remove();
      fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), EdgeFeatures.FEATURE_REMOVE_PROPERTY));
    } catch (Exception ex) {
      validateException(Property.Exceptions.propertyRemovalNotSupported(), ex);
    }
  }
}

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

@Test
@FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = VertexPropertyFeatures.FEATURE_REMOVE_PROPERTY, supported = false)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_META_PROPERTIES)
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldSupportRemovePropertyIfAPropertyCanBeRemoved() throws Exception {
  try {
    final Vertex v = graph.addVertex();
    final VertexProperty p = v.property(VertexProperty.Cardinality.single, "name", "me", "test", "this");
    p.property("test").remove();
    fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), VertexPropertyFeatures.FEATURE_REMOVE_PROPERTY));
  } catch (Exception ex) {
    validateException(Property.Exceptions.propertyRemovalNotSupported(), ex);
  }
}

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

@Test
public void testRemoveEdgePropertyNonNullWithoutIndex() {
  HugeGraph graph = graph();
  Vertex louise = graph.addVertex(T.label, "person", "name", "Louise",
                  "city", "Beijing", "age", 21);
  Vertex sean = graph.addVertex(T.label, "person", "name", "Sean",
                 "city", "Beijing", "age", 23);
  long current = System.currentTimeMillis();
  Edge edge = louise.addEdge("strike", sean, "id", 1,
                "timestamp", current, "place", "park",
                "tool", "shovel", "reason", "jeer",
                "arrested", false);
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    edge.property("arrested").remove();
  });
}

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

@Test
public void testRemoveEdgePropertyNullableWithIndex() {
  HugeGraph graph = graph();
  Vertex louise = graph.addVertex(T.label, "person", "name", "Louise",
                  "city", "Beijing", "age", 21);
  Vertex sean = graph.addVertex(T.label, "person", "name", "Sean",
                 "city", "Beijing", "age", 23);
  long current = System.currentTimeMillis();
  Edge edge = louise.addEdge("strike", sean, "id", 1,
                "timestamp", current, "place", "park",
                "tool", "shovel", "reason", "jeer",
                "arrested", false);
  edge.property("tool").remove();
  graph.tx().commit();
}

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

@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_REMOVE_PROPERTY)
public void shouldAllowRemovalFromVertexWhenAlreadyRemoved() {
  final Vertex v = graph.addVertex("name", "marko");
  tryCommit(graph);
  final Vertex v1 = graph.vertices(v.id()).next();
  try {
    final Property p = v1.property("name");
    p.remove();
    p.remove();
    v1.property("name").remove();
    v1.property("name").remove();
  } catch (Exception ex) {
    fail("Removing a vertex property that was already removed should not throw an exception");
  }
}

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

@Test
public void testRemoveEdgePropertyNullableWithoutIndex() {
  HugeGraph graph = graph();
  Vertex louise = graph.addVertex(T.label, "person", "name", "Louise",
                  "city", "Beijing", "age", 21);
  Vertex sean = graph.addVertex(T.label, "person", "name", "Sean",
                 "city", "Beijing", "age", 23);
  long current = System.currentTimeMillis();
  Edge edge = louise.addEdge("strike", sean, "id", 1,
                "timestamp", current, "place", "park",
                "tool", "shovel", "reason", "jeer",
                "hurt", true, "arrested", false);
  edge.property("hurt").remove();
  graph.tx().commit();
}

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

@Test
public void testUpdateEdgePropertyOfRemovingEdge() {
  Edge edge = initEdgeTransfer();
  edge.remove();
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    edge.property("message").remove();
  });
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    edge.property("message", "*");
  });
}

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

@Test
public void testRemoveEdgePropertyTwice() {
  HugeGraph graph = graph();
  Edge edge = initEdgeTransfer();
  Assert.assertEquals(500.00F, edge.property("amount").value());
  Assert.assertEquals("Happy birthday!",
            edge.property("message").value());
  // Remove property twice
  edge.property("message").remove();
  edge.property("message").remove();
  graph.tx().commit();
  List<Edge> edges = graph.traversal().E().toList();
  Assert.assertEquals(1, edges.size());
  Assert.assertFalse(edges.get(0).property("message").isPresent());
}

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

@Test
public void testRemoveEdgeProperty() {
  HugeGraph graph = graph();
  Edge edge = initEdgeTransfer();
  Assert.assertEquals("Happy birthday!",
            edge.property("message").value());
  // Remove property
  edge.property("message").remove();
  graph.tx().commit();
  List<Edge> edges = graph.traversal().E().toList();
  Assert.assertEquals(1, edges.size());
  Assert.assertFalse(edges.get(0).property("message").isPresent());
}

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

toRemove.remove();
} else
  throw new IllegalStateException("The incoming object is not removable: " + s);

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

@Test
public void testUpdateEdgePropertyWithRemoveAndSet() {
  HugeGraph graph = graph();
  Vertex louise = graph.addVertex(T.label, "person", "name", "Louise",
                  "city", "Beijing", "age", 21);
  Vertex sean = graph.addVertex(T.label, "person", "name", "Sean",
                 "city", "Beijing", "age", 23);
  long current = System.currentTimeMillis();
  Edge edge = louise.addEdge("transfer", sean, "id", 1,
                "amount", 500.00F, "timestamp", current,
                "message", "Happy birthday!");
  graph.tx().commit();
  edge.property("message").remove();
  edge.property("message", "Happy birthday ^-^");
  graph.tx().commit();
  List<Edge> edges = graph.traversal().E().toList();
  Assert.assertEquals(1, edges.size());
  assertContains(edges, "transfer", louise, sean, "id", 1,
          "amount", 500.00F, "timestamp", current,
          "message", "Happy birthday ^-^");
}

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

@Test
public void testUpdateEdgePropertyOfAddingEdge() {
  Edge edge = initEdgeTransfer();
  Vertex louise = vertex("person", "name", "Louise");
  Vertex sean = vertex("person", "name", "Sean");
  louise.addEdge("transfer", sean, "id", 1, "amount", 500.00F,
          "timestamp", edge.value("timestamp"),
          "message", "Happy birthday!");
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    edge.property("message").remove();
  });
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    edge.property("message", "*");
  });
}

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

@Test
public void testUpdateEdgePropertyOfRemovingEdgeWithDrop() {
  HugeGraph graph = graph();
  Edge edge = initEdgeTransfer();
  graph.traversal().E(edge.id()).drop().iterate();
  // Update on dirty vertex
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    edge.property("message").remove();
  });
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    edge.property("message", "*");
  });
}

相关文章