use of org.neo4j.kernel.impl.api.store.RelationshipIterator in project neo4j by neo4j.
the class CompiledExpandUtils method connectingRelationships.
public static RelationshipIterator connectingRelationships(ReadOperations readOperations, long fromNode, Direction direction, long toNode) throws EntityNotFoundException {
int fromDegree = readOperations.nodeGetDegree(fromNode, direction);
if (fromDegree == 0) {
return RelationshipIterator.EMPTY;
}
int toDegree = readOperations.nodeGetDegree(toNode, direction.reverse());
if (toDegree == 0) {
return RelationshipIterator.EMPTY;
}
long startNode;
long endNode;
Direction relDirection;
if (fromDegree < toDegree) {
startNode = fromNode;
endNode = toNode;
relDirection = direction;
} else {
startNode = toNode;
endNode = fromNode;
relDirection = direction.reverse();
}
RelationshipIterator allRelationships = readOperations.nodeGetRelationships(startNode, relDirection);
return connectingRelationshipsIterator(allRelationships, startNode, endNode);
}
use of org.neo4j.kernel.impl.api.store.RelationshipIterator in project neo4j by neo4j.
the class RelationshipChangesForNodeTest method testIncomingRelsWithTypeAndLoop.
@Test
public void testIncomingRelsWithTypeAndLoop() throws Exception {
RelationshipChangesForNode changes = new RelationshipChangesForNode(RelationshipChangesForNode.DiffStrategy.ADD, mock(RelationshipVisitor.Home.class));
changes.addRelationship(REL_0, TYPE_SELF, Direction.BOTH);
changes.addRelationship(REL_1, TYPE_DIR, INCOMING);
RelationshipIterator iterator = changes.augmentRelationships(INCOMING, new int[] { TYPE_DIR }, EMPTY);
assertEquals(true, iterator.hasNext());
assertEquals(REL_1, iterator.next());
assertEquals("should have no next relationships but has ", false, iterator.hasNext());
}
use of org.neo4j.kernel.impl.api.store.RelationshipIterator in project neo4j by neo4j.
the class CompiledExpandUtils method connectingRelationships.
public static RelationshipIterator connectingRelationships(ReadOperations readOperations, long fromNode, Direction direction, long toNode, int[] relTypes) throws EntityNotFoundException {
int fromDegree = calculateTotalDegree(readOperations, fromNode, direction, relTypes);
if (fromDegree == 0) {
return RelationshipIterator.EMPTY;
}
int toDegree = calculateTotalDegree(readOperations, toNode, direction.reverse(), relTypes);
if (toDegree == 0) {
return RelationshipIterator.EMPTY;
}
long startNode;
long endNode;
Direction relDirection;
if (fromDegree < toDegree) {
startNode = fromNode;
endNode = toNode;
relDirection = direction;
} else {
startNode = toNode;
endNode = fromNode;
relDirection = direction.reverse();
}
RelationshipIterator allRelationships = readOperations.nodeGetRelationships(startNode, relDirection, relTypes);
return connectingRelationshipsIterator(allRelationships, startNode, endNode);
}
use of org.neo4j.kernel.impl.api.store.RelationshipIterator in project neo4j by neo4j.
the class RelationshipChangesForNodeTest method testOutgoingRelsWithTypeAndLoop.
@Test
public void testOutgoingRelsWithTypeAndLoop() throws Exception {
RelationshipChangesForNode changes = new RelationshipChangesForNode(RelationshipChangesForNode.DiffStrategy.ADD, mock(RelationshipVisitor.Home.class));
changes.addRelationship(REL_0, TYPE_SELF, Direction.BOTH);
changes.addRelationship(REL_1, TYPE_DIR, OUTGOING);
RelationshipIterator iterator = changes.augmentRelationships(OUTGOING, new int[] { TYPE_DIR }, EMPTY);
assertEquals(true, iterator.hasNext());
assertEquals(REL_1, iterator.next());
assertEquals("should have no next relationships but has ", false, iterator.hasNext());
}
Aggregations