本文整理了Java中org.apache.tinkerpop.gremlin.structure.Vertex.label()
方法的一些代码示例,展示了Vertex.label()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.label()
方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Vertex
类名称:Vertex
方法名:label
暂无
代码示例来源:origin: apache/tinkerpop
@Override
public void vertexRemoved(final Vertex element) {
assertEquals(v, element);
assertEquals(id, element.id());
assertEquals(label, element.label());
triggered.set(true);
}
};
代码示例来源:origin: apache/tinkerpop
@Override
public void vertexAdded(final Vertex element) {
eventedVertex.set(element);
assertEquals("thing", element.label());
assertThat(element.properties("here").hasNext(), is(false));
triggered.set(true);
}
};
代码示例来源:origin: apache/tinkerpop
@Override
public void vertexAdded(final Vertex element) {
assertThat(element, instanceOf(ReferenceVertex.class));
assertEquals("thing", element.label());
assertThat(element.properties("here").hasNext(), is(false));
triggered.set(true);
}
};
代码示例来源:origin: apache/tinkerpop
@Override
public void vertexAdded(final Vertex element) {
assertThat(element, instanceOf(DetachedVertex.class));
assertEquals("thing", element.label());
assertEquals("there", element.value("here"));
triggered.set(true);
}
};
代码示例来源:origin: apache/tinkerpop
@Override
public void vertexRemoved(final Vertex element) {
assertThat(element, instanceOf(DetachedVertex.class));
assertEquals(id, element.id());
assertEquals(label, element.label());
triggered.set(true);
}
};
代码示例来源:origin: apache/tinkerpop
@Override
public void vertexRemoved(final Vertex element) {
assertThat(element, instanceOf(ReferenceVertex.class));
assertEquals(id, element.id());
assertEquals(label, element.label());
triggered.set(true);
}
};
代码示例来源:origin: apache/tinkerpop
@Override
public void vertexPropertyChanged(final Vertex element, final VertexProperty oldValue, final Object setValue, final Object... vertexPropertyKeyValues) {
assertEquals(v, element);
assertEquals(label, element.label());
assertEquals(id, element.id());
assertEquals("to-change", oldValue.key());
assertEquals("blah", oldValue.value());
assertEquals("dah", setValue);
triggered.set(true);
}
};
代码示例来源:origin: apache/tinkerpop
@Override
public void vertexPropertyChanged(final Vertex element, final VertexProperty oldValue, final Object setValue, final Object... vertexPropertyKeyValues) {
assertEquals(v, element);
assertEquals(label, element.label());
assertEquals(id, element.id());
assertThat(oldValue, instanceOf(KeyedVertexProperty.class));
assertEquals("new", oldValue.key());
assertEquals("dah", setValue);
triggered.set(true);
}
};
代码示例来源:origin: apache/tinkerpop
@Override
public void vertexPropertyChanged(final Vertex element, final VertexProperty oldValue, final Object setValue, final Object... vertexPropertyKeyValues) {
assertThat(element, instanceOf(ReferenceVertex.class));
assertEquals(label, element.label());
assertEquals(id, element.id());
assertThat(oldValue, instanceOf(KeyedVertexProperty.class));
assertEquals("new", oldValue.key());
assertEquals("dah", setValue);
triggered.set(true);
}
};
代码示例来源:origin: apache/tinkerpop
@Override
public void vertexPropertyChanged(final Vertex element, final VertexProperty oldValue, final Object setValue, final Object... vertexPropertyKeyValues) {
assertThat(element, instanceOf(DetachedVertex.class));
assertEquals(label, element.label());
assertEquals(id, element.id());
assertEquals("to-change", oldValue.key());
assertEquals("blah", oldValue.value());
assertEquals("dah", setValue);
triggered.set(true);
}
};
代码示例来源:origin: apache/tinkerpop
@Override
public void vertexPropertyChanged(final Vertex element, final VertexProperty oldValue, final Object setValue, final Object... vertexPropertyKeyValues) {
assertThat(element, instanceOf(DetachedVertex.class));
assertEquals(label, element.label());
assertEquals(id, element.id());
assertThat(oldValue, instanceOf(KeyedVertexProperty.class));
assertEquals("new", oldValue.key());
assertEquals("dah", setValue);
triggered.set(true);
}
};
代码示例来源:origin: apache/tinkerpop
@Override
public void vertexPropertyChanged(final Vertex element, final VertexProperty oldValue, final Object setValue, final Object... vertexPropertyKeyValues) {
assertThat(element, instanceOf(ReferenceVertex.class));
assertEquals(label, element.label());
assertEquals(id, element.id());
assertEquals("to-change", oldValue.key());
assertEquals("blah", oldValue.value());
assertEquals("dah", setValue);
triggered.set(true);
}
};
代码示例来源:origin: apache/tinkerpop
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_both_asXbX_dedupXa_bX_byXlabelX_selectXa_bX() {
final Traversal<Vertex, Map<String, Vertex>> traversal = get_g_V_asXaX_both_asXbX_dedupXa_bX_byXlabelX_selectXa_bX();
printTraversalForm(traversal);
int personPersonCounter = 0;
int personSoftwareCounter = 0;
int softwarePersonCounter = 0;
while (traversal.hasNext()) {
final Map<String, Vertex> map = traversal.next();
assertEquals(2, map.size());
if (map.get("a").label().equals("person") && map.get("b").label().equals("person"))
personPersonCounter++;
else if (map.get("a").label().equals("person") && map.get("b").label().equals("software"))
personSoftwareCounter++;
else if (map.get("a").label().equals("software") && map.get("b").label().equals("person"))
softwarePersonCounter++;
else
fail("Bad result type: " + map);
}
assertEquals(1, personPersonCounter);
assertEquals(1, personSoftwareCounter);
assertEquals(1, softwarePersonCounter);
}
代码示例来源:origin: apache/tinkerpop
@Test
@LoadGraphWith(MODERN)
public void g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX() {
final Traversal<Vertex, Map<String, Vertex>> traversal = get_g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX();
printTraversalForm(traversal);
int counter = 0;
final Set<List<String>> results = new HashSet<>();
while (traversal.hasNext()) {
final Map<String, Vertex> map = traversal.next();
assertEquals(3, map.size());
assertTrue(results.add(Arrays.asList(map.get("a").label(), map.get("b").label())));
counter++;
}
assertEquals(3, counter);
assertEquals(results.size(), counter);
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldUseDefaultLabelIfNotSpecified() {
final Vertex v = graph.addVertex("name", "marko");
assertEquals(Vertex.DEFAULT_LABEL, v.label());
}
代码示例来源:origin: apache/tinkerpop
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertex() throws Exception {
final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V1_0)).mapper().version(GraphSONVersion.V1_0).create().createMapper();
final Vertex v = graph.vertices(convertToVertexId("marko")).next();
final String json = mapper.writeValueAsString(v);
final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
assertEquals(GraphSONTokens.VERTEX, m.get(GraphSONTokens.TYPE));
assertEquals(v.label(), m.get(GraphSONTokens.LABEL));
assertNotNull(m.get(GraphSONTokens.ID));
final Map<String,List<Map<String,Object>>> properties = (Map<String,List<Map<String,Object>>>) m.get(GraphSONTokens.PROPERTIES);
assertEquals(v.value("name").toString(), properties.get("name").get(0).get(GraphSONTokens.VALUE).toString());
assertEquals((Integer) v.value("age"), properties.get("age").get(0).get(GraphSONTokens.VALUE));
assertEquals(1, properties.get("name").size());
assertEquals(1, properties.get("age").size());
assertEquals(2, properties.size());
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldAddVertexWithLabel() {
final Vertex v = graph.addVertex("person");
this.tryCommit(graph, graph -> assertEquals("person", v.label()));
}
代码示例来源:origin: apache/tinkerpop
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldCreateVertex() {
final DetachedVertex detachedVertex = new DetachedVertex(23, "dog", Collections.emptyMap());
detachedVertex.attach(Attachable.Method.create(graph));
assertEquals(7, IteratorUtils.count(graph.vertices()));
final AtomicInteger dogTimes = new AtomicInteger(0);
graph.vertices().forEachRemaining(vertex -> {
if (vertex.label().equals("dog")) {
dogTimes.incrementAndGet();
}
});
assertEquals(1, dogTimes.get());
}
代码示例来源:origin: apache/tinkerpop
@Test
@LoadGraphWith(MODERN)
public void shouldSupportPreExistingComputeKeys() throws Exception {
final ComputerResult result = graphProvider.getGraphComputer(graph).program(new VertexProgramN()).submit().get();
result.graph().vertices().forEachRemaining(vertex -> {
if (vertex.label().equals("person")) {
if (vertex.value("name").equals("marko"))
assertEquals(32, vertex.<Integer>value("age").intValue());
else if (vertex.value("name").equals("peter"))
assertEquals(38, vertex.<Integer>value("age").intValue());
else if (vertex.value("name").equals("vadas"))
assertEquals(30, vertex.<Integer>value("age").intValue());
else if (vertex.value("name").equals("josh"))
assertEquals(35, vertex.<Integer>value("age").intValue());
else
throw new IllegalStateException("This vertex should not have been accessed: " + vertex);
}
});
}
代码示例来源:origin: apache/tinkerpop
@Test
public void shouldConstructDetachedEdgeFromParts() {
final Map<String, Object> properties = new HashMap<>();
properties.put("x", "a");
properties.put("y", "b");
final DetachedEdge de = new DetachedEdge(10, "bought", properties, 1, "person", 2, "product");
assertEquals(10, de.id());
assertEquals("bought", de.label());
assertEquals("person", de.vertices(Direction.OUT).next().label());
assertEquals(1, de.vertices(Direction.OUT).next().id());
assertEquals("product", de.vertices(Direction.IN).next().label());
assertEquals(2, de.vertices(Direction.IN).next().id());
assertEquals("a", de.properties("x").next().value());
assertEquals(1, IteratorUtils.count(de.properties("x")));
assertEquals("a", de.property("x").value());
assertEquals("x", de.property("x").key());
assertEquals("b", de.property("y").value());
assertEquals("y", de.property("y").key());
}
内容来源于网络,如有侵权,请联系作者删除!