@Override public default TitanVertex outVertex() { return vertex(Direction.OUT); }
@Override public default TitanVertex inVertex() { return vertex(Direction.IN); }
@Override public default Iterator<Vertex> vertices(Direction direction) { List<Vertex> vertices; if (direction==Direction.BOTH) { vertices = ImmutableList.of((Vertex) vertex(Direction.OUT), vertex(Direction.IN)); } else { vertices = ImmutableList.of((Vertex) vertex(direction)); } return vertices.iterator(); }
@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 TitanEdge) { return ((TitanEdge)element).vertex(direction).equals(baseVertex); } else if (element instanceof TitanVertexProperty) { return direction==Direction.OUT; } return false; }
@Override public boolean evaluate(E relation) { return relation.isEdge() && ((TitanEdge) relation).vertex(direction).equals(otherVertex); }
private Edge findNext() { TitanEdge rel = null; while (rel == null) { if (currentEdges.hasNext()) { rel = (TitanEdge)currentEdges.next(); if (vertices != null && !vertices.contains(rel.vertex(Direction.IN))) rel = null; } else { if (vertexIter.hasNext()) { Vertex nextVertex = vertexIter.next(); currentEdges = nextVertex.edges(Direction.OUT); } else break; } } return rel; }
@Override public boolean apply(@Nullable TitanRelation titanRelation) { return titanRelation.isEdge() && titanRelation.isIncidentOn(vertex) && (dir==Direction.BOTH || ((TitanEdge)titanRelation).vertex(dir).equals(vertex)) && (stypes.isEmpty() || stypes.contains(titanRelation.getType().name())); } });
private void setStatusEdges(TitanSchemaVertex vertex, SchemaStatus status, Set<PropertyKeyVertex> keys) { Preconditions.checkArgument(vertex.asIndexType().isMixedIndex()); for (TitanEdge 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(); }
TitanSchemaVertex v = (TitanSchemaVertex) e.vertex(Direction.IN);
@Override protected void doRun() throws Exception { TitanVertex v = Iterables.<TitanVertex>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 (TitanEdge r : v.query().direction(Direction.OUT).labels(label2Traverse).edges()) { v = r.vertex(Direction.IN); } } } }
TitanEdge e = Iterables.getOnlyElement(changes.getEdges(v, Change.REMOVED, Direction.OUT, "knows")); assertFalse(e.property("weight").isPresent()); assertEquals(v, e.vertex(Direction.IN)); e = Iterables.getOnlyElement(changes.getEdges(v, Change.ADDED, Direction.OUT, "knows")); assertEquals(44.4, e.<Float>value("weight").doubleValue(), 0.01); assertEquals(v, e.vertex(Direction.IN));
TitanVertex oth = edge.vertex(dir.opposite()); assert oth instanceof TitanSchemaVertex; TypeDefinitionDescription desc = edge.valueOrNull(BaseKey.SchemaDefinitionDesc);
assertCount(2, n.properties()); for (TitanEdge r : n.query().direction(Direction.OUT).labels("knows").edges()) { TitanVertex n2 = r.vertex(Direction.IN); int idsum = ((Number) n.value("uid")).intValue() + ((Number) n2.value("uid")).intValue(); assertEquals(idsum, ((Number) r.value("uid")).intValue());
@Override public default TitanVertex outVertex() { return vertex(Direction.OUT); }
@Override public default TitanVertex inVertex() { return vertex(Direction.IN); }
@Override public default Iterator<Vertex> vertices(Direction direction) { List<Vertex> vertices; if (direction==Direction.BOTH) { vertices = ImmutableList.of((Vertex) vertex(Direction.OUT), vertex(Direction.IN)); } else { vertices = ImmutableList.of((Vertex) vertex(direction)); } return vertices.iterator(); }
@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 TitanEdge) { return ((TitanEdge)element).vertex(direction).equals(baseVertex); } else if (element instanceof TitanVertexProperty) { return direction==Direction.OUT; } return false; }
@Override public boolean evaluate(E relation) { return relation.isEdge() && ((TitanEdge) relation).vertex(direction).equals(otherVertex); }
private Edge findNext() { TitanEdge rel = null; while (rel == null) { if (currentEdges.hasNext()) { rel = (TitanEdge)currentEdges.next(); if (vertices != null && !vertices.contains(rel.vertex(Direction.IN))) rel = null; } else { if (vertexIter.hasNext()) { Vertex nextVertex = vertexIter.next(); currentEdges = nextVertex.edges(Direction.OUT); } else break; } } return rel; }
@Override public boolean apply(@Nullable TitanRelation titanRelation) { return titanRelation.isEdge() && titanRelation.isIncidentOn(vertex) && (dir==Direction.BOTH || ((TitanEdge)titanRelation).vertex(dir).equals(vertex)) && (stypes.isEmpty() || stypes.contains(titanRelation.getType().name())); } });