use of org.neo4j.util.CalledFromGeneratedCode in project neo4j by neo4j.
the class PathValueBuilder method addMultipleOutgoing.
/**
* Adds multiple outgoing relationships to the path
*
* @param relationships the outgoing relationships to add
* @param target the final target node of the path
*/
@CalledFromGeneratedCode
public void addMultipleOutgoing(ListValue relationships, NodeValue target) {
if (relationships.isEmpty()) {
// nothing to do here
return;
}
int i;
for (i = 0; i < relationships.size() - 1; i++) {
AnyValue value = relationships.value(i);
if (notNoValue(value)) {
// we know these relationships have already loaded start and end relationship
// so we should not use CypherFunctions::[start,end]Node to look them up
RelationshipValue relationship = (RelationshipValue) value;
nodes.add(relationship.endNode());
rels.add(relationship);
}
}
AnyValue last = relationships.value(i);
if (notNoValue(last)) {
rels.add((RelationshipValue) last);
nodes.add(target);
}
}
use of org.neo4j.util.CalledFromGeneratedCode in project neo4j by neo4j.
the class PathValueBuilder method addMultipleUndirected.
/**
* Adds multiple undirected relationships to the path
*
* @param relationships the undirected relationships to add
* @param target the final target node of the path
*/
@CalledFromGeneratedCode
public void addMultipleUndirected(ListValue relationships, NodeValue target) {
if (relationships.isEmpty()) {
// nothing to add
return;
}
long previous = nodes.get(nodes.size() - 1).id();
RelationshipValue first = (RelationshipValue) relationships.head();
boolean correctDirection = startNode(first, dbAccess, cursor).id() == previous || endNode(first, dbAccess, cursor).id() == previous;
int i;
if (correctDirection) {
for (i = 0; i < relationships.size() - 1; i++) {
AnyValue value = relationships.value(i);
if (notNoValue(value)) {
// we know these relationships have already loaded start and end relationship
// so we should not use CypherFunctions::[start,end]Node to look them up
addUndirectedWhenRelationshipsAreFullyLoaded((RelationshipValue) value);
}
}
} else {
for (i = relationships.size() - 1; i > 0; i--) {
AnyValue value = relationships.value(i);
if (notNoValue(value)) {
// we know these relationships have already loaded start and end relationship
// so we should not use CypherFunctions::[start,end]Node to look them up
addUndirectedWhenRelationshipsAreFullyLoaded((RelationshipValue) relationships.value(i));
}
}
}
AnyValue last = relationships.value(i);
if (notNoValue(last)) {
rels.add((RelationshipValue) last);
nodes.add(target);
}
}
use of org.neo4j.util.CalledFromGeneratedCode in project neo4j by neo4j.
the class PathValueBuilder method addMultipleUndirected.
/**
* Adds multiple undirected relationships to the path
*
* @param relationships the undirected relationships to add
*/
@CalledFromGeneratedCode
public void addMultipleUndirected(ListValue relationships) {
if (relationships.isEmpty()) {
// nothing to add
return;
}
long previous = nodes.get(nodes.size() - 1).id();
RelationshipValue first = (RelationshipValue) relationships.head();
boolean correctDirection = startNode(first, dbAccess, cursor).id() == previous || endNode(first, dbAccess, cursor).id() == previous;
if (correctDirection) {
for (AnyValue value : relationships) {
if (notNoValue(value)) {
addUndirectedWhenRelationshipsAreFullyLoaded((RelationshipValue) value);
}
}
} else {
ListValue reversed = relationships.reverse();
for (AnyValue rel : reversed) {
if (notNoValue(rel)) {
addUndirectedWhenRelationshipsAreFullyLoaded((RelationshipValue) rel);
}
}
}
}
Aggregations