如何使用Tinkerpop 3 Java API加载特定类型的顶点。使用Tinkerpop 2.x,可以使用“ @class”属性。这似乎不适用于TP 3.x。
@Test
public void testOrientDB() {
try (OrientGraphFactory graph = new OrientGraphFactory()) {
graph.setupPool(10, 100);
try (OrientGraph tx = graph.getTx()) {
for (int e = 0; e < 10_000; e++) {
Vertex v = tx.addVertex("Person");
v.property("name", "blab" + e);
Vertex v2 = tx.addVertex("Job");
v2.property("name", "blub" + e);
}
tx.commit();
}
try (OrientGraph tx = graph.getTx()) {
System.out.println("Persons: " + tx.traversal().V().has("@class", "Person").count().next());
}
}
}
答案 0 :(得分:0)
可以使用hasLabel步骤查找元素:
tx.traversal().V().hasLabel("Person").count().next()