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

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

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

Vertex.property介绍

[英]Get the VertexProperty for the provided key. If the property does not exist, return VertexProperty#empty. If there are more than one vertex properties for the provided key, then throw Vertex.Exceptions#multiplePropertiesExistForProvidedKey.
[中]获取提供的关键点的VertexProperty。如果属性不存在,请返回VertexProperty#empty。如果提供的关键点有多个顶点属性,则抛出顶点。例外情况#providedkey存在多个属性。

代码示例

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

private void updateVertexWithProperties(String propertyKey, Object propertyValue, Map<Object, Object> map) {
  if (graph.traversal().V().has(propertyKey, propertyValue).hasNext()) {
    final Vertex v = graph.traversal().V().has(propertyKey, propertyValue).next();
    map.forEach((key, value) -> v.property((String) key, value));
    graph.tx().commit();
  }
}

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

@Test
public void testNestedTransactions() {
  Vertex v1 = graph.addVertex();
  newTx();
  Vertex v2 = tx.addVertex();
  v2.property("name", "foo");
  tx.commit();
  v1.addEdge("related", graph.traversal().V(v2).next());
  graph.tx().commit();
  assertCount(1, v1.edges(OUT));
}

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

@Test
public void testTransactionalScopeOfSchemaTypes() {
  makeVertexIndexedUniqueKey("domain", String.class);
  v1 = tx.addVertex();
  try {
    v1.property(VertexProperty.Cardinality.single, "domain", "unique1");
  } catch (SchemaViolationException e) {
  v1.property("domain", "unique1");
  try {
    v2 = tx.addVertex();
    v2.property("domain", "unique1");
    fail();
  } catch (SchemaViolationException e) {
  v1.property("domain", "unique1");
  assertCount(1, tx.query().has("domain", "unique1").vertices());
  try {
    v2 = tx.addVertex();
    v2.property("domain", "unique1");
    fail();
  } catch (SchemaViolationException e) {

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

@Category({BrittleTests.class})
@Test
public void testIndexReplay() throws Exception {
  final TimestampProvider times = graph.getConfiguration().getTimestampProvider();
  vs[2].remove();
  vs[3] = getV(tx, vs[3]);
  vs[3].property(VertexProperty.Cardinality.single, "name", "Bad Boy Badsy");
  vs[3].property("age").remove();
  newTx();
  vs[0] = getV(tx, vs[0]);
  vs[0].property(VertexProperty.Cardinality.single, "age", 66);
  newTx();
  assertEquals(1, recoveryStats[0]); //schema transaction was successful
  assertEquals(4, recoveryStats[1]); //all 4 index transaction had provoked errors in the indexing backend

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

@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
public void shouldNotBeEqualsPropertiesAsIdIsDifferent() {
  final Vertex v = graph.addVertex();
  final VertexProperty vp1 = v.property(VertexProperty.Cardinality.single, "test", "this");
  final ReferenceVertexProperty mp1 = ReferenceFactory.detach(vp1);
  final VertexProperty vp2 = v.property(VertexProperty.Cardinality.single, "testing", "this");
  final ReferenceVertexProperty mp2 = ReferenceFactory.detach(vp2);
  assertFalse(mp1.equals(mp2));
}

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

@Test
public void testUpdateVertexPropertyOfRemovingVertexWithDrop() {
  HugeGraph graph = graph();
  Vertex vertex = graph.addVertex(T.label, "author", "id", 1,
                  "name", "Tom", "lived", "Beijing");
  graph.tx().commit();
  graph.traversal().V(vertex.id()).drop().iterate();
  // Update on dirty vertex
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    vertex.property("lived").remove();
  });
  Assert.assertThrows(IllegalArgumentException.class, () -> {
    vertex.property("lived", "Shanghai");
  });
}

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

v1.property(property, value1);
assertEquals(v1, getOnlyElement(graph.query().has(property, value1).vertices()));
v1.property(property, value2);
assertEquals(v1, getOnlyElement(graph.query().has(property, value1).vertices()));
assertEquals(v1, getOnlyElement(graph.query().has(property, value2).vertices()));
assertEquals(v1, getOnlyElement(graph.query().has(property, value1).vertices()));
v1.property(property, value1);
assertEquals(v1, getOnlyElement(graph.query().has(property, value1).vertices()));
assertEquals(v1, getOnlyElement(graph.query().has(property, value2).vertices()));
v1.property(property, value1);
v1.property(property, value1);
v1.property(property, value2);
assertEquals(v1, getOnlyElement(graph.query().has(property, value1).vertices()));

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

@Override
public Traversal<Vertex, Vertex> get_g_V_filterXlang_eq_javaX() {
  return g.V().filter(v -> v.get().<String>property("lang").orElse("none").equals("java"));
}

代码示例来源:origin: HuygensING/timbuctoo

@Override
public void setVreImage(String vreName, byte[] uploadedBytes, MediaType mediaType) {
 final GraphTraversal<Vertex, Vertex> vreT = getVreTraversal(vreName);
 if (vreT.hasNext()) {
  final Vertex vreVertex = vreT.next();
  final Integer imageRev = vreVertex.property(Vre.IMAGE_REV_PROPERTY_NAME).isPresent() ?
   vreVertex.<Integer>value(Vre.IMAGE_REV_PROPERTY_NAME) + 1 : 1;
  vreVertex.property(Vre.IMAGE_REV_PROPERTY_NAME, imageRev);
  vreVertex.property(Vre.IMAGE_BLOB_PROPERTY_NAME, uploadedBytes);
  vreVertex.property(Vre.IMAGE_MEDIA_TYPE_PROPERTY_NAME, mediaType.toString());
 }
}

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

@Test
public void testNestedTransactions() {
  Vertex v1 = graph.addVertex();
  newTx();
  Vertex v2 = tx.addVertex();
  v2.property("name", "foo");
  tx.commit();
  v1.addEdge("related", graph.traversal().V(v2).next());
  graph.tx().commit();
  assertCount(1, v1.edges(OUT));
}

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

@Category({BrittleTests.class})
@Test
public void testIndexReplay() throws Exception {
  final TimestampProvider times = graph.getConfiguration().getTimestampProvider();
  vs[2].remove();
  vs[3] = getV(tx, vs[3]);
  vs[3].property(VertexProperty.Cardinality.single, "name", "Bad Boy Badsy");
  vs[3].property("age").remove();
  newTx();
  vs[0] = getV(tx, vs[0]);
  vs[0].property(VertexProperty.Cardinality.single, "age", 66);
  newTx();
  assertEquals(1, recoveryStats[0]); //schema transaction was successful
  assertEquals(4, recoveryStats[1]); //all 4 index transaction had provoked errors in the indexing backend

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

@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
public void shouldNotBeEqualsPropertiesAsIdIsDifferent() {
  final Vertex v = graph.addVertex();
  final VertexProperty vp1 = v.property(VertexProperty.Cardinality.single, "test", "this");
  final DetachedVertexProperty mp1 = DetachedFactory.detach(vp1, true);
  final VertexProperty vp2 = v.property(VertexProperty.Cardinality.single, "testing", "this");
  final DetachedVertexProperty mp2 = DetachedFactory.detach(vp2, true);
  assertFalse(mp1.equals(mp2));
}

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

@Test
public void testQueryByIntPropUsingInsideWithOneResult() {
  Assume.assumeTrue("Not support range condition query",
           storeFeatures().supportsQueryWithRangeCondition());
  HugeGraph graph = graph();
  initPersonIndex(false);
  init5Persons();
  // 3 < age && age < 20 (that's age == 19)
  List<Vertex> vertexes = graph.traversal().V()
              .hasLabel("person").has("age", P.inside(3, 20))
              .toList();
  Assert.assertEquals(1, vertexes.size());
  Assert.assertEquals(19, vertexes.get(0).property("age").value());
}

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

@Test
public void testTransactionalScopeOfSchemaTypes() {
  makeVertexIndexedUniqueKey("domain", String.class);
  v1 = tx.addVertex();
  try {
    v1.property(VertexProperty.Cardinality.single, "domain", "unique1");
  } catch (SchemaViolationException ignored) {
  v1.property("domain", "unique1");
  try {
    v2 = tx.addVertex();
    v2.property("domain", "unique1");
    fail();
  } catch (SchemaViolationException ignored) {
  v1.property("domain", "unique1");
  assertCount(1, tx.query().has("domain", "unique1").vertices());
  try {
    v2 = tx.addVertex();
    v2.property("domain", "unique1");
    fail();
  } catch (SchemaViolationException ignored) {

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

@Override
public void map(final Vertex vertex, final MapEmitter emitter) {
  assertFalse(vertex.property("v1").isPresent());
  assertFalse(vertex.property("v2").isPresent());
  assertTrue(vertex.property("v3").isPresent());
  assertTrue(vertex.property("name").isPresent());
  assertEquals(3, IteratorUtils.count(vertex.properties()));
  assertEquals(3, IteratorUtils.count(vertex.values()));
}

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

@Override
public Traversal<Vertex, Vertex> get_g_VX1X_filterXage_gt_30X(final Object v1Id) {
  return g.V(v1Id).filter(v -> v.get().<Integer>property("age").orElse(0) > 30);
}

代码示例来源:origin: HuygensING/timbuctoo

@Override
public void saveRmlMappingState(String vreName, String rdfData) {
 final GraphTraversal<Vertex, Vertex>
  vreT = getVreTraversal(vreName);
 if (vreT.hasNext()) {
  vreT.next().property(SAVED_MAPPING_STATE, rdfData);
 }
}

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

@Test
public void testTinkerPopCardinality() {
  PropertyKey id = mgmt.makePropertyKey("id").cardinality(Cardinality.SINGLE).dataType(Integer.class).make();
  PropertyKey name = mgmt.makePropertyKey("name").cardinality(Cardinality.SINGLE).dataType(String.class).make();
  PropertyKey names = mgmt.makePropertyKey("names").cardinality(Cardinality.LIST).dataType(String.class).make();
  mgmt.buildIndex("byId", Vertex.class).addKey(id).buildCompositeIndex();
  finishSchema();
  GraphTraversalSource gts;
  Vertex v;
  v = graph.addVertex("id", 1);
  v.property(single, "name", "t1");
  graph.addVertex("id", 2, "names", "n1", "names", "n2");
  graph.tx().commit();
  gts = graph.traversal();
  v = gts.V().has("id", 1).next();
  v.property(single, "name", "t2");
  v = gts.V().has("id", 1).next();
  v.property(single, "name", "t3");
  assertCount(1, gts.V(v).properties("name"));
  assertCount(2, gts.V().has("id", 2).properties("names"));
  assertCount(2, gts.V().hasLabel("vertex"));
}

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

@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexProperty() throws Exception {
  final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V1_0)).mapper().version(GraphSONVersion.V1_0).create().createMapper();
  final VertexProperty vp = graph.vertices(convertToVertexId("marko")).next().property("name");
  final String json = mapper.writeValueAsString(vp);
  final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
  assertEquals(vp.label(), m.get(GraphSONTokens.LABEL));
  assertNotNull(m.get(GraphSONTokens.ID));
  assertEquals(vp.value(), m.get(GraphSONTokens.VALUE));
}

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

@Test(expected = IllegalStateException.class)
@FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
public void shouldNotSupportRemove() {
  final Vertex v = graph.addVertex();
  final VertexProperty vp = v.property(VertexProperty.Cardinality.single, "test", "this");
  DetachedFactory.detach(vp, true).remove();
}

相关文章