@Override public boolean evaluate(E relation) { return relation.isEdge() && ((TitanEdge) relation).getVertex(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 TitanEdge) { return ((TitanEdge)element).getVertex(direction).equals(baseVertex); } else if (element instanceof TitanProperty) { return direction==Direction.OUT; } return false; }
@Override public boolean apply(@Nullable TitanRelation titanRelation) { return titanRelation.isEdge() && titanRelation.isIncidentOn(vertex) && (dir==Direction.BOTH || ((TitanEdge)titanRelation).getVertex(dir).equals(vertex)) && (stypes.isEmpty() || stypes.contains(titanRelation.getType())); } });
@Override public boolean apply(@Nullable TitanRelation titanRelation) { return titanRelation.isEdge() && titanRelation.isIncidentOn(vertex) && (dir==Direction.BOTH || ((TitanEdge)titanRelation).getVertex(dir).equals(vertex)) && (stypes.isEmpty() || stypes.contains(titanRelation.getType().getName())); } });
@Override protected void doRun() throws Exception { TitanVertex n = Iterables.getOnlyElement(tx.getVertices(id, nodeid)); for (int i = 0; i < nodeTraversalCount; i++) { assertEquals("On vertex: " + n.getID(), expectedEdges, Iterables.size(n.getTitanEdges(Direction.BOTH, relTypeToTraverse))); for (TitanEdge r : n.getTitanEdges(Direction.OUT, relTypeToTraverse)) { n = r.getVertex(Direction.IN); } } } }
@Override protected void doRun() throws Exception { TitanVertex n = Iterables.getOnlyElement(tx.getVertices(id, nodeid)); for (int i = 0; i < nodeTraversalCount; i++) { assertEquals("On vertex: " + n.getLongId(), expectedEdges, Iterables.size(n.getTitanEdges(Direction.BOTH, relTypeToTraverse))); for (TitanEdge r : n.getTitanEdges(Direction.OUT, relTypeToTraverse)) { n = r.getVertex(Direction.IN); } } } }
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.getVertex(Direction.IN))) continue; //Only address edges with matching keys TypeDefinitionDescription desc = edge.getProperty(BaseKey.SchemaDefinitionDesc); assert desc.getCategory()==TypeDefinitionCategory.INDEX_FIELD; Parameter[] parameters = (Parameter[])desc.getModifier(); assert parameters[parameters.length-1].getKey().equals(ParameterType.STATUS.getName()); if (parameters[parameters.length-1].getValue().equals(status)) continue; Parameter[] paraCopy = Arrays.copyOf(parameters,parameters.length); paraCopy[parameters.length-1]=ParameterType.STATUS.getParameter(status); edge.remove(); addSchemaEdge(vertex,edge.getVertex(Direction.IN),TypeDefinitionCategory.INDEX_FIELD,paraCopy); } for (PropertyKeyVertex prop : keys) prop.resetCache(); }
@Override public void run() { while (true) { // Make or break relType between two (possibly same) random nodes // TitanVertex source = tx.getVertex(idProp, RandomGenerator.randomInt(0, nodeCount)); // TitanVertex sink = tx.getVertex(idProp, RandomGenerator.randomInt(0, nodeCount)); TitanVertex source = Iterables.getOnlyElement(tx.getVertices(idProp, 0)); TitanVertex sink = Iterables.getOnlyElement(tx.getVertices(idProp, 1)); for (TitanEdge r : source.getTitanEdges(Direction.OUT, relType)) { if (r.getVertex(Direction.IN).getID() == sink.getID()) { r.remove(); continue; } } source.addEdge(relType, sink); if (Thread.interrupted()) break; } }
@Override public void run() { while (true) { // Make or break relType between two (possibly same) random nodes // TitanVertex source = tx.getVertex(idProp, RandomGenerator.randomInt(0, nodeCount)); // TitanVertex sink = tx.getVertex(idProp, RandomGenerator.randomInt(0, nodeCount)); TitanVertex source = Iterables.getOnlyElement(tx.getVertices(idProp, 0)); TitanVertex sink = Iterables.getOnlyElement(tx.getVertices(idProp, 1)); for (TitanEdge r : source.getTitanEdges(Direction.OUT, relType)) { if (r.getVertex(Direction.IN).getLongId() == sink.getLongId()) { r.remove(); continue; } } source.addEdge(relType, sink); if (Thread.interrupted()) break; } }
TitanSchemaVertex v = (TitanSchemaVertex) e.getVertex(Direction.IN);
TitanEdge e = n1.addEdge(connect, n2); assertNotNull(e.toString()); assertEquals(n1, e.getVertex(OUT)); assertEquals(n2, e.getVertex(IN)); e = n2.addEdge(knows, n3); e.setProperty(weight, 3.0); e = Iterables.getOnlyElement(n2.getTitanEdges(BOTH, connect)); assertNotNull(e.toString()); n1 = e.getVertex(OUT); log.debug("Retrieved node!"); assertEquals(n1, e.getVertex(OUT)); assertEquals(n2, e.getVertex(IN)); assertEquals(3.0, e.getProperty(weight)); assertEquals("HasProperties TitanRelation", e.getProperty(name)); n3 = e.getVertex(IN);
TitanEdge e = n1.addEdge(connect, n2); assertNotNull(e.toString()); assertEquals(n1, e.getVertex(OUT)); assertEquals(n2, e.getVertex(IN)); e = n2.addEdge(knows, n3); e.setProperty("weight", 3.0); e = Iterables.getOnlyElement(n2.getTitanEdges(BOTH, connect)); assertNotNull(e.toString()); n1 = e.getVertex(OUT); log.debug("Retrieved node!"); assertEquals(n1, e.getVertex(OUT)); assertEquals(n2, e.getVertex(IN)); assertTrue(e.getProperty(weight).equals(3.0)); assertEquals("HasProperties TitanRelation", e.getProperty(name)); n3 = e.getVertex(IN);
TitanEdge e = Iterables.getOnlyElement(changes.getEdges(v,Change.REMOVED,Direction.OUT,"knows")); assertNull(e.getProperty("weight")); assertEquals(v,e.getVertex(Direction.IN)); e = Iterables.getOnlyElement(changes.getEdges(v,Change.ADDED,Direction.OUT,"knows")); assertEquals(44.4,e.<Decimal>getProperty("weight").doubleValue(),0.0); assertEquals(v,e.getVertex(Direction.IN));
TitanVertex oth = edge.getVertex(dir.opposite()); assert oth instanceof TitanSchemaVertex; TypeDefinitionDescription desc = edge.getProperty(BaseKey.SchemaDefinitionDesc);