本文整理了Java中org.apache.tinkerpop.gremlin.structure.Vertex.properties()
方法的一些代码示例,展示了Vertex.properties()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.properties()
方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Vertex
类名称:Vertex
方法名:properties
暂无
代码示例来源: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
private static Map<String, List<VertexProperty>> indexedVertexProperties(final Vertex v) {
final Map<String,List<VertexProperty>> index = new HashMap<>();
v.properties().forEachRemaining(vp -> {
if (!index.containsKey(vp.key())) {
index.put(vp.key(), new ArrayList<>());
}
index.get(vp.key()).add(vp);
});
return index;
}
代码示例来源:origin: apache/tinkerpop
public static Map<String, List<VertexProperty>> vertexPropertyMap(final Vertex vertex, final String... propertyKeys) {
final Map<String, List<VertexProperty>> propertyMap = new HashMap<>();
vertex.properties(propertyKeys).forEachRemaining(property -> {
if (propertyMap.containsKey(property.key()))
propertyMap.get(property.key()).add(property);
else {
final List<VertexProperty> list = new ArrayList<>();
list.add(property);
propertyMap.put(property.key(), list);
}
});
return propertyMap;
}
代码示例来源: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
public static Optional<VertexProperty> getVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Vertex hostVertex) {
final VertexProperty baseVertexProperty = attachableVertexProperty.get();
final Iterator<VertexProperty<Object>> vertexPropertyIterator = hostVertex.properties(baseVertexProperty.key());
while (vertexPropertyIterator.hasNext()) {
final VertexProperty vertexProperty = vertexPropertyIterator.next();
if (ElementHelper.areEqual(vertexProperty, baseVertexProperty))
return Optional.of(vertexProperty);
}
return Optional.empty();
}
代码示例来源:origin: apache/tinkerpop
public static Map<String, List> vertexPropertyValueMap(final Vertex vertex, final String... propertyKeys) {
final Map<String, List> valueMap = new HashMap<>();
vertex.properties(propertyKeys).forEachRemaining(property -> {
if (valueMap.containsKey(property.key()))
valueMap.get(property.key()).add(property.value());
else {
final List list = new ArrayList();
list.add(property.value());
valueMap.put(property.key(), list);
}
});
return valueMap;
}
代码示例来源:origin: apache/tinkerpop
public static Optional<VertexProperty> getVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Graph hostGraph) {
final VertexProperty baseVertexProperty = attachableVertexProperty.get();
final Iterator<Vertex> vertexIterator = hostGraph.vertices(baseVertexProperty.element().id());
if (vertexIterator.hasNext()) {
final Iterator<VertexProperty<Object>> vertexPropertyIterator = vertexIterator.next().properties(baseVertexProperty.key());
while (vertexPropertyIterator.hasNext()) {
final VertexProperty vertexProperty = vertexPropertyIterator.next();
if (ElementHelper.areEqual(vertexProperty, baseVertexProperty))
return Optional.of(vertexProperty);
}
}
return Optional.empty();
}
代码示例来源:origin: apache/tinkerpop
@Override
public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
return IteratorUtils.<VertexProperty<V>, VertexProperty<V>>map(this.getBaseVertex().properties(propertyKeys), property -> new HadoopVertexProperty<>(property, HadoopVertex.this));
}
}
代码示例来源:origin: thinkaurelius/titan
v1.properties(property).forEachRemaining(p -> {
if (p.value().equals(value1)) {
p.remove();
代码示例来源:origin: apache/tinkerpop
@Test
@LoadGraphWith(LoadGraphWith.GraphData.CREW)
public void shouldSerializeVertexPropertyWithProperties() throws Exception {
final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V1_0)).mapper().version(GraphSONVersion.V1_0).create().createMapper();
final VertexProperty vp = IteratorUtils.filter(graph.vertices(convertToVertexId("marko")).next().properties("location"), p -> p.value().equals("brussels")).next();
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));
assertEquals(vp.values("startTime").next(), ((Map) m.get(GraphSONTokens.PROPERTIES)).get("startTime"));
assertEquals(vp.values("endTime").next(), ((Map) m.get(GraphSONTokens.PROPERTIES)).get("endTime"));
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES)
public void shouldOverwriteEarlierKeyValuesWithLaterKeyValuesOnAddVertexIfMultiProperty() {
final Vertex v = graph.addVertex("test", "A", "test", "B", "test", "C");
tryCommit(graph, graph -> {
assertEquals(3, IteratorUtils.count(v.properties("test")));
assertTrue(IteratorUtils.stream(v.values("test")).anyMatch(t -> t.equals("A")));
assertTrue(IteratorUtils.stream(v.values("test")).anyMatch(t -> t.equals("B")));
assertTrue(IteratorUtils.stream(v.values("test")).anyMatch(t -> t.equals("C")));
});
}
代码示例来源:origin: JanusGraph/janusgraph
v1.properties(property).forEachRemaining(p -> {
if (p.value().equals(value1)) {
p.remove();
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
public void shouldReturnEmptyIteratorIfNoProperties() {
final Vertex v = graph.addVertex();
assertEquals(0, IteratorUtils.count(v.properties()));
}
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES, supported = false)
public void shouldOverwriteEarlierKeyValuesWithLaterKeyValuesOnAddVertexIfNoMultiProperty() {
final Vertex v = graph.addVertex("test", "A", "test", "B", "test", "C");
tryCommit(graph, graph -> {
assertEquals(1, IteratorUtils.count(v.properties("test")));
assertTrue(IteratorUtils.stream(v.values("test")).anyMatch(t -> t.equals("C")));
});
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_MULTI_PROPERTIES, supported = false)
public void shouldSupportMultiPropertyIfTheSameKeyCanBeAssignedMoreThanOnce() throws Exception {
try {
final Vertex v = graph.addVertex("name", "stephen", "name", "steve");
if (2 == IteratorUtils.count(v.properties()))
fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), VertexFeatures.FEATURE_MULTI_PROPERTIES));
} catch (Exception ex) {
validateException(VertexProperty.Exceptions.multiPropertiesNotSupported(), ex);
}
}
代码示例来源: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
@Test
@LoadGraphWith(MODERN)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_REMOVE_PROPERTY)
public void g_V_properties_drop() {
final Traversal<Vertex, VertexProperty> traversal = get_g_V_properties_drop();
printTraversalForm(traversal);
assertFalse(traversal.hasNext());
assertEquals(6, IteratorUtils.count(g.V()));
assertEquals(6, IteratorUtils.count(g.E()));
g.V().forEachRemaining(vertex -> assertEquals(0, IteratorUtils.count(vertex.properties())));
}
代码示例来源:origin: apache/tinkerpop
public static Vertex createVertex(final Attachable<Vertex> attachableVertex, final Graph hostGraph) {
final Vertex baseVertex = attachableVertex.get();
final Vertex vertex = hostGraph.features().vertex().willAllowId(baseVertex.id()) ?
hostGraph.addVertex(T.id, baseVertex.id(), T.label, baseVertex.label()) :
hostGraph.addVertex(T.label, baseVertex.label());
baseVertex.properties().forEachRemaining(vp -> {
final VertexProperty vertexProperty = hostGraph.features().vertex().properties().willAllowId(vp.id()) ?
vertex.property(hostGraph.features().vertex().getCardinality(vp.key()), vp.key(), vp.value(), T.id, vp.id()) :
vertex.property(hostGraph.features().vertex().getCardinality(vp.key()), vp.key(), vp.value());
vp.properties().forEachRemaining(p -> vertexProperty.property(p.key(), p.value()));
});
return vertex;
}
代码示例来源:origin: apache/tinkerpop
@Test
@LoadGraphWith(MODERN)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY)
public void g_addVXpersonX_propertyXname_stephenX() {
final Traversal<Vertex, Vertex> traversal = get_g_addVXpersonX_propertyXname_stephenX();
printTraversalForm(traversal);
final Vertex stephen = traversal.next();
assertFalse(traversal.hasNext());
assertEquals("person", stephen.label());
assertEquals("stephen", stephen.value("name"));
assertEquals(1, IteratorUtils.count(stephen.properties()));
assertEquals(7, IteratorUtils.count(g.V()));
}
代码示例来源:origin: apache/tinkerpop
@Test
@LoadGraphWith(MODERN)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY)
public void g_addVXpersonX_propertyXsingle_name_stephenX_propertyXsingle_name_stephenmX() {
final Traversal<Vertex, Vertex> traversal = get_g_addVXpersonX_propertyXsingle_name_stephenX_propertyXsingle_name_stephenmX();
printTraversalForm(traversal);
final Vertex stephen = traversal.next();
assertFalse(traversal.hasNext());
assertEquals("person", stephen.label());
assertEquals("stephenm", stephen.value("name"));
assertEquals(1, IteratorUtils.count(stephen.properties()));
assertEquals(7, IteratorUtils.count(g.V()));
}
内容来源于网络,如有侵权,请联系作者删除!