You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So with the un-deprecation of the Traversal Framework for Neo4j 5.x there were some changes. One of them causes an issue that I can't resolve without using the undocumented internal APIs.
In Neo4j 4.x the following expand method would have worked. I want to filter the relationships that are returned from the expand. This is a simplified version of my actual method but shows the same problem. In reality I'm doing more complex filtering and ordering of the expanded relationships that are returned from this method.
@Override
public ResourceIterable<Relationship> expand(Path path, BranchState<TraverseState> bState)
{
TraverseState state = state.getState();
assert path.endNode().hasLabel(Labels.Undefined);
var concludes = path.endNode().getRelationships(Direction.OUTGOING, RelationshipTypes.CONCLUDES);
var expansion = new HashSet<Relationship>();
for(Relationship rel : concludes)
{
if(!state.traverseOnce.contains(rel))
{
expansion.add(rel);
state.traverseOnce.add(rel);
}
}
if(expansion.size() > 0)
return expansion;
return Collections.emptyList();
}
For this code I get errors for both return statements because they're returning Iterables. If I try casting them, then I get runtime errors as the cast fails.
The only way I have gotten this to work is to use org.neo4j.internal.helpers.collection.Iterables, so the return statements become:
return Iterables.asResourceIterable(expansion);
return Iterables.emptyResourceIterable();
Now I don't want to have to use this internal API, as it's not supported but I can't find another way with the support API.
I think these static methods should be part of the public API, or another alternative should be made available. Currently there's no way to create a ResourceIterable directly, that I have found.
The text was updated successfully, but these errors were encountered:
Another related item that someone just pointed out on the forums, the documentation of the Traversal Framework API documentation is also incorrect.
The code examples for creating a PathExpander show a very similar example to my use case but the code has the incorrect return type Iterable<Relationship> and wouldn't compile/work because of this. I can't find a way of implementing the example in the documentation without using the internal class/methods mentioned in the initial ticket.
I originally outlined the issue here https://community.neo4j.com/t/traversal-framework-working-with-resourceiterables/60963
So with the un-deprecation of the Traversal Framework for Neo4j 5.x there were some changes. One of them causes an issue that I can't resolve without using the undocumented internal APIs.
In Neo4j 4.x the following expand method would have worked. I want to filter the relationships that are returned from the expand. This is a simplified version of my actual method but shows the same problem. In reality I'm doing more complex filtering and ordering of the expanded relationships that are returned from this method.
For this code I get errors for both return statements because they're returning Iterables. If I try casting them, then I get runtime errors as the cast fails.
The only way I have gotten this to work is to use
org.neo4j.internal.helpers.collection.Iterables
, so the return statements become:return Iterables.asResourceIterable(expansion);
return Iterables.emptyResourceIterable();
Now I don't want to have to use this internal API, as it's not supported but I can't find another way with the support API.
I think these static methods should be part of the public API, or another alternative should be made available. Currently there's no way to create a ResourceIterable directly, that I have found.
The text was updated successfully, but these errors were encountered: