@Benchmark public List<Edge> g_E_hasLabelXwrittenByX_whereXinV_inEXsungByX_count_isX0XX_subgraphXsgX() throws Exception { return g.E().hasLabel("writtenBy").where(__.inV().inE("sungBy").count().is(0)).subgraph("sg").toList(); } }
assertNumStep(10, 1, gts.V(sv[0]).local(__.outE("knows").has("weight", 1).order().by("weight", incr).limit(10)), TitanVertexStep.class); assertNumStep(5, 1, gts.V(sv[0]).local(__.outE("knows").has("weight", 1).has("weight", 1).order().by("weight", incr).range(10, 15)), LocalStep.class); assertNumStep(1, 1, gts.V(sv[0]).outE("knows").filter(__.inV().is(vs[50])), TitanVertexStep.class); assertNumStep(1, 1, gts.V(sv[0]).outE("knows").filter(__.otherV().is(vs[50])), TitanVertexStep.class); assertNumStep(1, 1, gts.V(sv[0]).bothE("knows").filter(__.otherV().is(vs[50])), TitanVertexStep.class); assertNumStep(1, 2, gts.V(sv[0]).bothE("knows").filter(__.inV().is(vs[50])), TitanVertexStep.class, TraversalFilterStep.class);
/** * {@inheritDoc} */ @Override public Edge getOrCreateEdge(final Edge edge, final Vertex outVertex, final Vertex inVertex, final Graph graph, final GraphTraversalSource g) { final Edge e; final Traversal<Vertex, Edge> t = g.V(outVertex).outE(edge.label()).filter(__.inV().is(inVertex)); if (t.hasNext()) { e = t.next(); edge.properties().forEachRemaining(property -> { final Property<?> existing = e.property(property.key()); if (!existing.isPresent() || !existing.value().equals(property.value())) { e.property(property.key(), property.value()); } }); } else { e = createEdge(edge, outVertex, inVertex, graph, g); } return e; }
assertNumStep(1, 1, gts.V(sv[0]).outE("knows").filter(__.inV().is(vs[50])), JanusGraphVertexStep.class); assertNumStep(1, 1, gts.V(sv[0]).outE("knows").filter(__.otherV().is(vs[50])), JanusGraphVertexStep.class); assertNumStep(1, 1, gts.V(sv[0]).bothE("knows").filter(__.otherV().is(vs[50])), JanusGraphVertexStep.class); assertNumStep(1, 2, gts.V(sv[0]).bothE("knows").filter(__.inV().is(vs[50])), JanusGraphVertexStep.class, TraversalFilterStep.class);
private SubgraphStrategy(final Builder builder) { this.vertexCriterion = null == builder.vertexCriterion ? null : builder.vertexCriterion.asAdmin().clone(); this.checkAdjacentVertices = builder.checkAdjacentVertices; // if there is no vertex predicate there is no need to test either side of the edge - also this option can // be simply configured in the builder to not be used if (null == this.vertexCriterion || !checkAdjacentVertices) { this.edgeCriterion = null == builder.edgeCriterion ? null : builder.edgeCriterion.asAdmin().clone(); } else { final Traversal.Admin<Edge, ?> vertexPredicate; vertexPredicate = __.<Edge>and( __.inV().filter(this.vertexCriterion), __.outV().filter(this.vertexCriterion)).asAdmin(); // if there is a vertex predicate then there is an implied edge filter on vertices even if there is no // edge predicate provided by the user. this.edgeCriterion = null == builder.edgeCriterion ? vertexPredicate : builder.edgeCriterion.asAdmin().clone().addStep(new TraversalFilterStep<>(builder.edgeCriterion.asAdmin(), vertexPredicate)); } this.vertexPropertyCriterion = null == builder.vertexPropertyCriterion ? null : builder.vertexPropertyCriterion.asAdmin().clone(); if (null != this.vertexCriterion) TraversalHelper.applyTraversalRecursively(t -> t.getStartStep().addLabel(MARKER), this.vertexCriterion); if (null != this.edgeCriterion) TraversalHelper.applyTraversalRecursively(t -> t.getStartStep().addLabel(MARKER), this.edgeCriterion); if (null != this.vertexPropertyCriterion) TraversalHelper.applyTraversalRecursively(t -> t.getStartStep().addLabel(MARKER), this.vertexPropertyCriterion); }
connectingTraversal = __.outE(labelInfo.getLabel()); } else if(!leftTableDef.isVertex && rightTableDef.isVertex) { connectingTraversal = __.inV(); } else { throw new ParseException("Illegal join of two edge tables.");
@Override public void onRemoveFromCollection(Collection collection, Optional<Vertex> oldVertex, Vertex newVertex) { String type = collection.getEntityTypeName(); final GraphTraversal<Vertex, Vertex> hasEntityNode = findEntityNodeForEntityTypeName(type); final GraphTraversal<Vertex, Edge> edgeToRemove = hasEntityNode.outE(Collection.HAS_ENTITY_RELATION_NAME) .where(__.inV().is(newVertex)); if (edgeToRemove.hasNext()) { edgeToRemove.next().remove(); } }
/** * {@inheritDoc} */ @Override public Edge getOrCreateEdge(final Edge edge, final Vertex outVertex, final Vertex inVertex, final Graph graph, final GraphTraversalSource g) { final Edge e; final Traversal<Vertex, Edge> t = g.V(outVertex).outE(edge.label()).filter(__.inV().is(inVertex)); if (t.hasNext()) { e = t.next(); edge.properties().forEachRemaining(property -> { final Property<?> existing = e.property(property.key()); if (!existing.isPresent() || !existing.value().equals(property.value())) { e.property(property.key(), property.value()); } }); } else { e = createEdge(edge, outVertex, inVertex, graph, g); } return e; }
private SubgraphStrategy(final Builder builder) { this.vertexCriterion = null == builder.vertexCriterion ? null : builder.vertexCriterion.asAdmin().clone(); this.checkAdjacentVertices = builder.checkAdjacentVertices; // if there is no vertex predicate there is no need to test either side of the edge - also this option can // be simply configured in the builder to not be used if (null == this.vertexCriterion || !checkAdjacentVertices) { this.edgeCriterion = null == builder.edgeCriterion ? null : builder.edgeCriterion.asAdmin().clone(); } else { final Traversal.Admin<Edge, ?> vertexPredicate; vertexPredicate = __.<Edge>and( __.inV().filter(this.vertexCriterion), __.outV().filter(this.vertexCriterion)).asAdmin(); // if there is a vertex predicate then there is an implied edge filter on vertices even if there is no // edge predicate provided by the user. this.edgeCriterion = null == builder.edgeCriterion ? vertexPredicate : builder.edgeCriterion.asAdmin().clone().addStep(new TraversalFilterStep<>(builder.edgeCriterion.asAdmin(), vertexPredicate)); } this.vertexPropertyCriterion = null == builder.vertexPropertyCriterion ? null : builder.vertexPropertyCriterion.asAdmin().clone(); if (null != this.vertexCriterion) TraversalHelper.applyTraversalRecursively(t -> t.getStartStep().addLabel(MARKER), this.vertexCriterion); if (null != this.edgeCriterion) TraversalHelper.applyTraversalRecursively(t -> t.getStartStep().addLabel(MARKER), this.edgeCriterion); if (null != this.vertexPropertyCriterion) TraversalHelper.applyTraversalRecursively(t -> t.getStartStep().addLabel(MARKER), this.vertexPropertyCriterion); }