本文整理了Java中org.apache.tinkerpop.gremlin.structure.Vertex.value()
方法的一些代码示例,展示了Vertex.value()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.value()
方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Vertex
类名称:Vertex
方法名:value
暂无
代码示例来源:origin: thinkaurelius/titan
@Override
public void execute(Vertex vertex, Messenger<Double> messenger, Memory memory) {
if (memory.isInitialIteration()) {
messenger.sendMessage(inE, 1D);
} else if (1 == memory.getIteration()) {
double initialPageRank = 1D / vertexCount;
double edgeCount = IteratorUtils.stream(messenger.receiveMessages()).reduce(0D, (a, b) -> a + b);
vertex.property(VertexProperty.Cardinality.single, PAGE_RANK, initialPageRank);
vertex.property(VertexProperty.Cardinality.single, OUTGOING_EDGE_COUNT, edgeCount);
messenger.sendMessage(outE, initialPageRank / edgeCount);
} else {
double newPageRank = IteratorUtils.stream(messenger.receiveMessages()).reduce(0D, (a, b) -> a + b);
newPageRank = (dampingFactor * newPageRank) + ((1D - dampingFactor) / vertexCount);
vertex.property(VertexProperty.Cardinality.single, PAGE_RANK, newPageRank);
messenger.sendMessage(outE, newPageRank / vertex.<Double>value(OUTGOING_EDGE_COUNT));
}
}
代码示例来源:origin: thinkaurelius/titan
@Test
public void testSimpleUpdate() {
PropertyKey name = makeKey("name", String.class);
EdgeLabel knows = makeLabel("knows");
mgmt.buildIndex("namev", Vertex.class).addKey(name).buildMixedIndex(INDEX);
mgmt.buildIndex("namee", Edge.class).addKey(name).buildMixedIndex(INDEX);
finishSchema();
TitanVertex v = tx.addVertex("name", "Marko Rodriguez");
Edge e = v.addEdge("knows", v, "name", "Hulu Bubab");
assertCount(1, tx.query().has("name", Text.CONTAINS, "marko").vertices());
assertCount(1, tx.query().has("name", Text.CONTAINS, "Hulu").edges());
for (Vertex u : tx.getVertices()) assertEquals("Marko Rodriguez", u.value("name"));
clopen();
assertCount(1, tx.query().has("name", Text.CONTAINS, "marko").vertices());
assertCount(1, tx.query().has("name", Text.CONTAINS, "Hulu").edges());
for (Vertex u : tx.getVertices()) assertEquals("Marko Rodriguez", u.value("name"));
v = getOnlyVertex(tx.query().has("name", Text.CONTAINS, "marko"));
v.property(VertexProperty.Cardinality.single, "name", "Marko");
e = getOnlyEdge(v.query().direction(Direction.OUT));
e.property("name", "Tubu Rubu");
assertCount(1, tx.query().has("name", Text.CONTAINS, "marko").vertices());
assertCount(1, tx.query().has("name", Text.CONTAINS, "Rubu").edges());
assertCount(0, tx.query().has("name", Text.CONTAINS, "Hulu").edges());
for (Vertex u : tx.getVertices()) assertEquals("Marko", u.value("name"));
clopen();
assertCount(1, tx.query().has("name", Text.CONTAINS, "marko").vertices());
assertCount(1, tx.query().has("name", Text.CONTAINS, "Rubu").edges());
assertCount(0, tx.query().has("name", Text.CONTAINS, "Hulu").edges());
for (Vertex u : tx.getVertices()) assertEquals("Marko", u.value("name"));
}
代码示例来源:origin: thinkaurelius/titan
@Test
public void testDualMapping() {
if (!indexFeatures.supportsStringMapping(Mapping.TEXTSTRING)) return;
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");
} else if (n.endsWith("Mabel")) {
u.property("name").remove();
代码示例来源:origin: apache/tinkerpop
@Test
@LoadGraphWith(MODERN)
public void g_V_order_byXoutE_count_descX() {
Arrays.asList(get_g_V_order_byXoutE_count_descX()).forEach(traversal -> {
printTraversalForm(traversal);
final List<Vertex> vertices = traversal.toList();
assertEquals(vertices.size(), 6);
assertEquals("marko", vertices.get(0).value("name"));
assertEquals("josh", vertices.get(1).value("name"));
assertEquals("peter", vertices.get(2).value("name"));
assertTrue(vertices.get(3).value("name").equals("vadas") || vertices.get(3).value("name").equals("ripple") || vertices.get(3).value("name").equals("lop"));
assertTrue(vertices.get(4).value("name").equals("vadas") || vertices.get(4).value("name").equals("ripple") || vertices.get(4).value("name").equals("lop"));
assertTrue(vertices.get(5).value("name").equals("vadas") || vertices.get(5).value("name").equals("ripple") || vertices.get(5).value("name").equals("lop"));
});
}
代码示例来源:origin: hugegraph/hugegraph
@Test
public void testQueryVertexWithNullablePropertyInCompositeIndex() {
HugeGraph graph = graph();
initComputerIndex();
graph.addVertex(T.label, "computer", "name", "1st", "band", "10Gbps",
"cpu", "2GHz", "ram", "8GB", "price", 1000);
graph.tx().commit();
List<Vertex> vl = graph.traversal().V().has("cpu", "2GHz").toList();
Assert.assertEquals(1, vl.size());
Assert.assertEquals("1st", vl.get(0).value("name"));
vl = graph.traversal().V().has("cpu", "2GHz")
.has("ram", "8GB").toList();
Assert.assertEquals(1, vl.size());
Assert.assertEquals("1st", vl.get(0).value("name"));
}
代码示例来源:origin: apache/tinkerpop
private void assert_g_v1_out(final Traversal<Vertex, Vertex> traversal) {
printTraversalForm(traversal);
int counter = 0;
final Set<Vertex> vertices = new HashSet<>();
while (traversal.hasNext()) {
counter++;
final Vertex vertex = traversal.next();
vertices.add(vertex);
assertTrue(vertex.value("name").equals("vadas") ||
vertex.value("name").equals("josh") ||
vertex.value("name").equals("lop"));
}
assertEquals(3, counter);
assertEquals(3, vertices.size());
}
代码示例来源:origin: apache/tinkerpop
@Override
public void execute(final Vertex vertex, final Messenger<Object> messenger, final Memory memory) {
try {
vertex.property(VertexProperty.Cardinality.single, "blah", "blah");
fail("Should throw an IllegalArgumentException");
} catch (final IllegalArgumentException e) {
assertEquals(GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey("blah").getMessage(), e.getMessage());
} catch (final Exception e) {
fail("Should throw an IllegalArgumentException: " + e);
}
memory.add("a", 1);
if (memory.isInitialIteration()) {
vertex.property(VertexProperty.Cardinality.single, "nameLengthCounter", vertex.<String>value("name").length());
memory.add("b", vertex.<String>value("name").length());
} else {
vertex.property(VertexProperty.Cardinality.single, "nameLengthCounter", vertex.<String>value("name").length() + vertex.<Integer>value("nameLengthCounter"));
}
}
代码示例来源:origin: apache/tinkerpop
@Override
public Traversal<Vertex, Vertex> get_g_V_filterXname_startsWith_m_OR_name_startsWith_pX() {
return g.V().filter(v -> {
final String name = v.get().value("name");
return name.startsWith("m") || name.startsWith("p");
});
}
代码示例来源:origin: apache/tinkerpop
@Test
@LoadGraphWith(MODERN)
public void g_VX4X_bothE_otherV() {
final Traversal<Vertex, Vertex> traversal = get_g_VX4X_bothE_otherV(convertToVertexId("josh"));
printTraversalForm(traversal);
final List<Vertex> vertices = traversal.toList();
assertEquals(3, vertices.size());
assertTrue(vertices.stream().anyMatch(v -> v.value("name").equals("marko")));
assertTrue(vertices.stream().anyMatch(v -> v.value("name").equals("ripple")));
assertTrue(vertices.stream().anyMatch(v -> v.value("name").equals("lop")));
assertFalse(traversal.hasNext());
}
代码示例来源:origin: hugegraph/hugegraph
@Test
public void testQueryWithTxNotCommittedByIntProp() {
HugeGraph graph = graph();
initPersonIndex(false);
graph.addVertex(T.label, "person", "name", "marko",
"age", 18, "city", "Beijing");
List<Vertex> vertices;
vertices = graph.traversal().V().has("age", 18).toList();
Assert.assertEquals(1, vertices.size());
Assert.assertEquals(18, (int) vertices.get(0).<Integer>value("age"));
graph.tx().rollback();
vertices = graph.traversal().V("person:marko").toList();
Assert.assertEquals(0, vertices.size());
// TODO: add test for: append, eliminate, remove
}
代码示例来源:origin: JanusGraph/janusgraph
@Test
public void testSimpleUpdate() {
final PropertyKey name = makeKey("name", String.class);
makeLabel("knows");
mgmt.buildIndex("namev", Vertex.class).addKey(name).buildMixedIndex(INDEX);
mgmt.buildIndex("namee", Edge.class).addKey(name).buildMixedIndex(INDEX);
finishSchema();
JanusGraphVertex v = tx.addVertex("name", "Marko Rodriguez");
Edge e = v.addEdge("knows", v, "name", "Hulu Bubab");
assertCount(1, tx.query().has("name", Text.CONTAINS, "marko").vertices());
assertCount(1, tx.query().has("name", Text.CONTAINS, "Hulu").edges());
for (final Vertex u : tx.getVertices()) assertEquals("Marko Rodriguez", u.value("name"));
clopen();
assertCount(1, tx.query().has("name", Text.CONTAINS, "marko").vertices());
assertCount(1, tx.query().has("name", Text.CONTAINS, "Hulu").edges());
for (final Vertex u : tx.getVertices()) assertEquals("Marko Rodriguez", u.value("name"));
v = getOnlyVertex(tx.query().has("name", Text.CONTAINS, "marko"));
v.property(VertexProperty.Cardinality.single, "name", "Marko");
e = getOnlyEdge(v.query().direction(Direction.OUT));
e.property("name", "Tubu Rubu");
assertCount(1, tx.query().has("name", Text.CONTAINS, "marko").vertices());
assertCount(1, tx.query().has("name", Text.CONTAINS, "Rubu").edges());
assertCount(0, tx.query().has("name", Text.CONTAINS, "Hulu").edges());
for (final Vertex u : tx.getVertices()) assertEquals("Marko", u.value("name"));
clopen();
assertCount(1, tx.query().has("name", Text.CONTAINS, "marko").vertices());
assertCount(1, tx.query().has("name", Text.CONTAINS, "Rubu").edges());
assertCount(0, tx.query().has("name", Text.CONTAINS, "Hulu").edges());
for (final Vertex u : tx.getVertices()) assertEquals("Marko", u.value("name"));
}
代码示例来源:origin: apache/tinkerpop
private void assert_g_v1_outXknowsX(final Traversal<Vertex, Vertex> traversal) {
printTraversalForm(traversal);
int counter = 0;
final Set<Vertex> vertices = new HashSet<>();
while (traversal.hasNext()) {
counter++;
final Vertex vertex = traversal.next();
vertices.add(vertex);
assertTrue(vertex.value("name").equals("vadas") ||
vertex.value("name").equals("josh"));
}
assertEquals(2, counter);
assertEquals(2, vertices.size());
}
代码示例来源:origin: JanusGraph/janusgraph
@Test
public void testDualMapping() {
if (!indexFeatures.supportsStringMapping(Mapping.TEXTSTRING)) return;
1, new boolean[]{true, true}, "mixed");
for (final Vertex u : tx.getVertices()) {
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");
} else if (n.endsWith("Mabel")) {
u.property("name").remove();
代码示例来源:origin: apache/tinkerpop
@Override
public Traversal<Vertex, Map<Integer, Integer>> get_g_VX1X_hasXlabel_personX_mapXmapXint_ageXX_orderXlocalX_byXvalues_descX_byXkeys_ascX(final Object v1Id) {
return g.V(v1Id).hasLabel("person").map(v -> {
final Map<Integer, Integer> map = new HashMap<>();
map.put(1, (int) v.get().value("age"));
map.put(2, (int) v.get().value("age") * 2);
map.put(3, (int) v.get().value("age") * 3);
map.put(4, (int) v.get().value("age"));
return map;
}).order(Scope.local).by(Column.values, Order.desc).by(Column.keys, Order.asc);
}
代码示例来源:origin: JanusGraph/janusgraph
@Override
public void execute(Vertex vertex, Messenger<Double> messenger, Memory memory) {
if (memory.isInitialIteration()) {
messenger.sendMessage(inE, 1D);
} else if (1 == memory.getIteration()) {
double initialPageRank = 1D / vertexCount;
double edgeCount = IteratorUtils.stream(messenger.receiveMessages()).reduce(0D, (a, b) -> a + b);
vertex.property(VertexProperty.Cardinality.single, PAGE_RANK, initialPageRank);
vertex.property(VertexProperty.Cardinality.single, OUTGOING_EDGE_COUNT, edgeCount);
messenger.sendMessage(outE, initialPageRank / edgeCount);
} else {
double newPageRank = IteratorUtils.stream(messenger.receiveMessages()).reduce(0D, (a, b) -> a + b);
newPageRank = (dampingFactor * newPageRank) + ((1D - dampingFactor) / vertexCount);
vertex.property(VertexProperty.Cardinality.single, PAGE_RANK, newPageRank);
messenger.sendMessage(outE, newPageRank / vertex.<Double>value(OUTGOING_EDGE_COUNT));
}
}
代码示例来源:origin: apache/tinkerpop
@Test
@LoadGraphWith(MODERN)
public void g_VX4X_out_asXhereX_hasXlang_javaX_selectXhereX() {
final Traversal<Vertex, Vertex> traversal = get_g_VX4X_out_asXhereX_hasXlang_javaX_selectXhereX(convertToVertexId("josh"));
printTraversalForm(traversal);
int counter = 0;
while (traversal.hasNext()) {
counter++;
final Vertex vertex = traversal.next();
assertEquals("java", vertex.<String>value("lang"));
assertTrue(vertex.value("name").equals("ripple") || vertex.value("name").equals("lop"));
}
assertEquals(2, counter);
}
代码示例来源:origin: hugegraph/hugegraph
@Test
public void testQueryVertexBeforeAfterUpdatePropertyWithSecondaryIndex() {
HugeGraph graph = graph();
initPersonIndex(true);
Vertex vertex = graph.addVertex(T.label, "person", "name", "Baby",
"city", "Hongkong", "age", 3);
graph.tx().commit();
List<Vertex> vl = graph.traversal().V().has("city", "Hongkong").toList();
Assert.assertEquals(1, vl.size());
Assert.assertEquals("Baby", vl.get(0).value("name"));
vl = graph.traversal().V().has("city", "Shanghai").toList();
Assert.assertEquals(0, vl.size());
vertex.property("city", "Shanghai");
graph.tx().commit();
vl = graph.traversal().V().has("city", "Hongkong").toList();
Assert.assertEquals(0, vl.size());
vl = graph.traversal().V().has("city", "Shanghai").toList();
Assert.assertEquals(1, vl.size());
Assert.assertEquals("Baby", vl.get(0).value("name"));
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
public void shouldAllowReferenceOfVertexOutsideOfOriginalTransactionalContextAuto() {
final Vertex v1 = graph.addVertex("name", "stephen");
g.tx().commit();
assertEquals("stephen", v1.value("name"));
g.tx().rollback();
assertEquals("stephen", v1.value("name"));
}
代码示例来源:origin: apache/tinkerpop
@Override
public Traversal<Vertex, String> get_g_VX1X_mapXnameX(final Object v1Id) {
return g.V(v1Id).<String>map(v -> v.get().value("name"));
}
代码示例来源:origin: apache/tinkerpop
@Override
public void execute(final Vertex vertex, final Messenger messenger, final Memory memory) {
vertex.property("money", vertex.<String>value("name").length());
}
内容来源于网络,如有侵权,请联系作者删除!