本文整理了Java中org.apache.tinkerpop.gremlin.structure.Vertex.id()
方法的一些代码示例,展示了Vertex.id()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.id()
方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Vertex
类名称:Vertex
方法名:id
暂无
代码示例来源:origin: thinkaurelius/titan
assertEquals(v1, getOnlyElement(graph.query().has(property, value1).vertices()));
v1 = getV(graph, v1.id());
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 = getV(graph, v1.id());
v1.properties(property).forEachRemaining(p -> {
if (p.value().equals(value1)) {
v1 = getV(graph, v1.id());
v1.property(property, value1);
assertEquals(v1, getOnlyElement(graph.query().has(property, value1).vertices()));
v1 = getV(graph, v1.id());
v1.property(property, value1);
代码示例来源:origin: JanusGraph/janusgraph
assertEquals(v1, getOnlyElement(graph.query().has(property, value1).vertices()));
v1 = getV(graph, v1.id());
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 = getV(graph, v1.id());
v1.properties(property).forEachRemaining(p -> {
if (p.value().equals(value1)) {
v1 = getV(graph, v1.id());
v1.property(property, value1);
assertEquals(v1, getOnlyElement(graph.query().has(property, value1).vertices()));
v1 = getV(graph, v1.id());
v1.property(property, value1);
g.V().drop().iterate();
v1 = g.addV().property(property, value1).property(property, value2).next();
g.addV().property(property, value1).property(property, value2).next();
assertEquals(2, g.V().has(property, value1).toList().size());
g.V().properties().drop().iterate();
代码示例来源:origin: apache/tinkerpop
/**
* {@inheritDoc}
*/
@Override
public Vertex getVertex(final Vertex vertex, final Graph graph, final GraphTraversalSource g) {
return useUserSuppliedIds()
? getVertexById(vertex.id(), graph, g)
: g.V().has(vertex.label(), bulkLoaderVertexId, vertex.id().toString()).next();
}
代码示例来源:origin: apache/tinkerpop
@Test
@LoadGraphWith(MODERN)
public void shouldThrowExceptionWhenIdsMixed() {
final List<Vertex> vertices = g.V().toList();
try {
g.V(vertices.get(0), vertices.get(1).id()).toList();
} catch (Exception ex) {
validateException(Graph.Exceptions.idArgsMustBeEitherIdOrElement(), ex);
}
}
代码示例来源:origin: apache/tinkerpop
private void assertCommonA(Traversal<Vertex, Map<String, Collection<Vertex>>> traversal) {
final Map<String, Collection<Vertex>> map = traversal.next();
assertEquals(6, map.size());
map.forEach((key, values) -> {
assertEquals(1, values.size());
assertEquals(convertToVertexId(key), values.iterator().next().id());
});
assertFalse(traversal.hasNext());
}
代码示例来源:origin: apache/tinkerpop
private static void assertGraphEquality(final Graph source, final Graph target, final Function<Vertex, Object> idAccessor) {
final GraphTraversalSource tg = target.traversal();
assertEquals(IteratorUtils.count(source.vertices()), IteratorUtils.count(target.vertices()));
assertEquals(IteratorUtils.count(target.edges()), IteratorUtils.count(target.edges()));
source.vertices().forEachRemaining(originalVertex -> {
Vertex tmpVertex = null;
final Iterator<Vertex> vertexIterator = target.vertices();
while (vertexIterator.hasNext()) {
final Vertex v = vertexIterator.next();
if (idAccessor.apply(v).toString().equals(originalVertex.id().toString())) {
tmpVertex = v;
break;
assertEquals(IteratorUtils.count(originalVertex.edges(Direction.IN)), IteratorUtils.count(clonedVertex.edges(Direction.IN)));
assertEquals(IteratorUtils.count(originalVertex.edges(Direction.OUT)), IteratorUtils.count(clonedVertex.edges(Direction.OUT)));
assertEquals(originalVertex.label(), clonedVertex.label());
final Iterator<VertexProperty<Object>> vertexPropertyIterator = clonedVertex.properties(originalProperty.key());
while (vertexPropertyIterator.hasNext()) {
final VertexProperty p = vertexPropertyIterator.next();
if (p.value().equals(originalProperty.value())) {
clonedProperty = p;
});
originalVertex.edges(Direction.OUT).forEachRemaining(originalEdge -> {
GraphTraversal t = tg.V(clonedVertex).outE(originalEdge.label());
originalEdge.properties().forEachRemaining(p -> t.has(p.key(), p.value()));
assertTrue(t.hasNext());
代码示例来源:origin: apache/tinkerpop
/**
* {@inheritDoc}
*/
@Override
public Vertex getOrCreateVertex(final Vertex vertex, final Graph graph, final GraphTraversalSource g) {
final Iterator<Vertex> iterator = useUserSuppliedIds()
? g.V().hasId(vertex.id())
: g.V().has(vertex.label(), bulkLoaderVertexId, vertex.id().toString());
return iterator.hasNext()
? iterator.next()
: useUserSuppliedIds()
? g.addV(vertex.label()).property(T.id, vertex.id()).next()
: g.addV(vertex.label()).property(bulkLoaderVertexId, vertex.id().toString()).next();
}
代码示例来源:origin: apache/tinkerpop
/**
* Creates a clone of the given vertex in the given graph.
*/
@Override
public Vertex getOrCreateVertex(final Vertex vertex, final Graph graph, final GraphTraversalSource g) {
final GraphTraversal<Vertex, Vertex> t = g.addV(vertex.label());
return (useUserSuppliedIds() ? t.property(T.id, vertex.id()) : t).next();
}
代码示例来源:origin: thinkaurelius/titan
@Test
public void testConsistencyModifier() throws InterruptedException {
PropertyKey sig = makeKey("sig",Integer.class);
assertEquals(6.0,v.<Double>value("weight").doubleValue(),0.00001);
VertexProperty p = getOnlyElement(v.properties("weight"));
assertEquals(wintx,p.<Integer>value("sig").intValue());
p = getOnlyElement(v.properties("name"));
assertEquals("Bob",p.value());
assertEquals(wintx,p.<Integer>value("sig").intValue());
p = getOnlyElement(v.properties("value"));
assertCount(2,v.properties("valuef"));
for (Iterator<VertexProperty<Object>> ppiter = v.properties("valuef"); ppiter.hasNext(); ) {
VertexProperty pp = ppiter.next();
assertNotEquals(rs[3].longId(),getId(pp));
assertEquals(2,pp.value());
for (Edge ee : v.query().direction(OUT).labels("emf").edges()) {
assertNotEquals(rs[5].longId(),getId(ee));
assertEquals(uid,ee.inVertex().id());
代码示例来源:origin: hugegraph/hugegraph
@Test
public void testQueryInEdgesOfVertexByLabel() {
HugeGraph graph = graph();
init18Edges();
Vertex java3 = vertex("book", "name", "java-3");
List<Edge> edges = graph.traversal().V(java3.id()).inE().toList();
Assert.assertEquals(5, edges.size());
edges = graph.traversal().V(java3.id()).inE("look").toList();
Assert.assertEquals(4, edges.size());
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-core
/**
* {@inheritDoc}
*/
@Override
public Vertex getOrCreateVertex(final Vertex vertex, final Graph graph, final GraphTraversalSource g) {
final Iterator<Vertex> iterator = useUserSuppliedIds()
? g.V().hasId(vertex.id())
: g.V().has(vertex.label(), bulkLoaderVertexId, vertex.id().toString());
return iterator.hasNext()
? iterator.next()
: useUserSuppliedIds()
? g.addV(vertex.label()).property(T.id, vertex.id()).next()
: g.addV(vertex.label()).property(bulkLoaderVertexId, vertex.id().toString()).next();
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-core
/**
* {@inheritDoc}
*/
@Override
public Vertex getVertex(final Vertex vertex, final Graph graph, final GraphTraversalSource g) {
return useUserSuppliedIds()
? getVertexById(vertex.id(), graph, g)
: g.V().has(vertex.label(), bulkLoaderVertexId, vertex.id().toString()).next();
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-core
/**
* Creates a clone of the given vertex in the given graph.
*/
@Override
public Vertex getOrCreateVertex(final Vertex vertex, final Graph graph, final GraphTraversalSource g) {
final GraphTraversal<Vertex, Vertex> t = g.addV(vertex.label());
return (useUserSuppliedIds() ? t.property(T.id, vertex.id()) : t).next();
}
代码示例来源:origin: JanusGraph/janusgraph
@Test
public void testConsistencyModifier() throws InterruptedException {
makeKey("sig",Integer.class);
assertEquals(6.0, v.<Double>value("weight"),0.00001);
VertexProperty p = getOnlyElement(v.properties("weight"));
assertEquals(wintx,p.<Integer>value("sig").intValue());
p = getOnlyElement(v.properties("name"));
assertEquals("Bob",p.value());
assertEquals(wintx,p.<Integer>value("sig").intValue());
p = getOnlyElement(v.properties("value"));
assertCount(2,v.properties("valuef"));
for (Iterator<VertexProperty<Object>> ppiter = v.properties("valuef"); ppiter.hasNext(); ) {
VertexProperty pp = ppiter.next();
assertNotEquals(rs[3].longId(),getId(pp));
assertEquals(2,pp.value());
Edge ee = (Edge) o;
assertNotEquals(rs[5].longId(),getId(ee));
assertEquals(uid,ee.inVertex().id());
代码示例来源:origin: hugegraph/hugegraph
@Test
public void testQueryBothVerticesOfVertex() {
HugeGraph graph = graph();
init18Edges();
Vertex jeff = vertex("person", "name", "Jeff");
List<Vertex> vertices = graph.traversal().V(jeff.id())
.both("friend").toList();
Assert.assertEquals(2, vertices.size());
vertices = ImmutableList.copyOf(
jeff.vertices(Direction.BOTH, "friend"));
Assert.assertEquals(2, vertices.size());
}
代码示例来源:origin: apache/atlas
private void postProcess(long startIndex) {
LOG.info("postProcess: Starting... : counter at: {}", counter.get());
try {
PostProcessManager.WorkItemsManager wim = PostProcessManager.create(bulkLoadGraph, relationshipCache.getPropertiesToPostProcess(), batchSize, numWorkers);
GraphTraversal query = bulkLoadGraph.traversal().V();
while (query.hasNext()) {
handleInterrupt(bulkLoadGraph, counter.incrementAndGet());
if(shouldSkip(startIndex, counter.get())) {
continue;
}
Vertex v = (Vertex) query.next();
wim.produce(v.id());
updateStatusConditionally(bulkLoadGraph, counter.get());
}
wim.shutdown();
} catch (Exception ex) {
LOG.error("postProcess: failed!", ex);
} finally {
LOG.info("postProcess: Done! : [{}]", counter.get());
readerStatusManager.update(bulkLoadGraph, counter.get(), true);
}
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_CUSTOM_IDS)
public void shouldIterateVerticesWithCustomIdSupportUsingStringRepresentation() {
final Vertex v1 = graph.addVertex();
graph.addVertex();
tryCommit(graph, graph -> {
final Vertex v = graph.vertices(v1.id().toString()).next();
assertEquals(v1.id(), v.id());
});
}
代码示例来源:origin: hugegraph/hugegraph
@Test
public void testQueryInEdgesOfVertexBySortkey() {
HugeGraph graph = graph();
init18Edges();
Vertex java3 = vertex("book", "name", "java-3");
List<Edge> edges = graph.traversal().V(java3.id())
.inE("look").toList();
Assert.assertEquals(4, edges.size());
edges = graph.traversal().V(java3.id())
.inE("look").has("time", "2017-5-27").toList();
Assert.assertEquals(3, edges.size());
}
代码示例来源:origin: HuygensING/timbuctoo
private Vertex getLastProperty() {
return graphWrapper.getGraph().traversal().V(vertex.id())
.out(HAS_INITIAL_PROPERTY_RELATION_NAME)
.until(__.not(__.outE(HAS_NEXT_PROPERTY_RELATION_NAME)))
.repeat(__.out(HAS_NEXT_PROPERTY_RELATION_NAME))
.next();
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_CUSTOM_IDS)
public void shouldIterateVerticesWithCustomIdSupportUsingVertexId() {
final Vertex v1 = graph.addVertex();
graph.addVertex();
tryCommit(graph, graph -> {
final Vertex v = graph.vertices(v1.id()).next();
assertEquals(v1.id(), v.id());
});
}
内容来源于网络,如有侵权,请联系作者删除!