@Override default JanusGraphVertex inVertex() { return vertex(Direction.IN); }
@Override default JanusGraphVertex outVertex() { return vertex(Direction.OUT); }
@Override public boolean evaluate(E relation) { return relation.isEdge() && ((JanusGraphEdge) relation).vertex(direction).equals(otherVertex); }
@Override public boolean evaluate(E element) { if (direction==Direction.BOTH) return true; if (element instanceof CacheEdge) { return direction==((CacheEdge)element).getVertexCentricDirection(); } else if (element instanceof JanusGraphEdge) { return ((JanusGraphEdge)element).vertex(direction).equals(baseVertex); } else if (element instanceof JanusGraphVertexProperty) { return direction==Direction.OUT; } return false; }
private Edge findNext() { JanusGraphEdge rel = null; while (rel == null) { if (currentEdges.hasNext()) { rel = (JanusGraphEdge)currentEdges.next(); if (vertices != null && !vertices.contains(rel.vertex(Direction.IN))) rel = null; } else { if (vertexIterator.hasNext()) { Vertex nextVertex = vertexIterator.next(); currentEdges = nextVertex.edges(Direction.OUT); } else break; } } return rel; }
@Override public Iterable<JanusGraphEdge> getEdges(final Vertex vertex, final Change change, final Direction dir, final String... labels) { final Set<String> stypes = toSet(labels); return (Iterable)getRelations(change, janusgraphRelation -> janusgraphRelation.isEdge() && janusgraphRelation.isIncidentOn(vertex) && (dir==Direction.BOTH || ((JanusGraphEdge)janusgraphRelation).vertex(dir).equals(vertex)) && (stypes.isEmpty() || stypes.contains(janusgraphRelation.getType().name()))); }
private void setStatusEdges(JanusGraphSchemaVertex vertex, SchemaStatus status, Set<PropertyKeyVertex> keys) { Preconditions.checkArgument(vertex.asIndexType().isMixedIndex()); for (JanusGraphEdge edge : vertex.getEdges(TypeDefinitionCategory.INDEX_FIELD, Direction.OUT)) { if (!keys.contains(edge.vertex(Direction.IN))) continue; //Only address edges with matching keys TypeDefinitionDescription desc = edge.valueOrNull(BaseKey.SchemaDefinitionDesc); assert desc.getCategory() == TypeDefinitionCategory.INDEX_FIELD; Parameter[] parameters = (Parameter[]) desc.getModifier(); assert parameters[parameters.length - 1].key().equals(ParameterType.STATUS.getName()); if (parameters[parameters.length - 1].value().equals(status)) continue; Parameter[] paraCopy = Arrays.copyOf(parameters, parameters.length); paraCopy[parameters.length - 1] = ParameterType.STATUS.getParameter(status); edge.remove(); addSchemaEdge(vertex, edge.vertex(Direction.IN), TypeDefinitionCategory.INDEX_FIELD, paraCopy); } for (PropertyKeyVertex prop : keys) prop.resetCache(); }
JanusGraphSchemaVertex v = (JanusGraphSchemaVertex) e.vertex(Direction.IN);
@Override protected void doRun() { JanusGraphVertex v = Iterables.getOnlyElement(tx.query().has(idKey, vertexId).vertices()); for (int i = 0; i < nodeTraversalCount; i++) { assertCount(expectedEdges, v.query().labels(label2Traverse).direction(Direction.BOTH).edges()); for (Object r : v.query().direction(Direction.OUT).labels(label2Traverse).edges()) { v = ((JanusGraphEdge) r).vertex(Direction.IN); } } } }
for (Object o : n.query().direction(Direction.OUT).labels("knows").edges()) { JanusGraphEdge r = (JanusGraphEdge) o; JanusGraphVertex n2 = r.vertex(Direction.IN); int idSum = ((Number) n.value("uid")).intValue() + ((Number) n2.value("uid")).intValue(); assertEquals(idSum, ((Number) r.value("uid")).intValue());
= Iterables.getOnlyElement(changes.getEdges(v, Change.REMOVED, Direction.OUT, "knows")); assertFalse(e1.property("weight").isPresent()); assertEquals(v, e1.vertex(Direction.IN)); e1 = Iterables.getOnlyElement(changes.getEdges(v, Change.ADDED, Direction.OUT, "knows")); assertEquals(44.4, e1.<Float>value("weight").doubleValue(), 0.01); assertEquals(v, e1.vertex(Direction.IN));
JanusGraphVertex oth = edge.vertex(dir.opposite()); assert oth instanceof JanusGraphSchemaVertex; TypeDefinitionDescription desc = edge.valueOrNull(BaseKey.SchemaDefinitionDesc);