Skip to content

Commit

Permalink
migrate GraphDatabaseFacade.getAllRelationships
Browse files Browse the repository at this point in the history
  • Loading branch information
fickludd committed Feb 2, 2018
1 parent c4e96d4 commit 19ffc7c
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.neo4j.internal.kernel.api.NodeLabelIndexCursor;
import org.neo4j.internal.kernel.api.NodeValueIndexCursor;
import org.neo4j.internal.kernel.api.Read;
import org.neo4j.internal.kernel.api.RelationshipScanCursor;
import org.neo4j.internal.kernel.api.TokenRead;
import org.neo4j.internal.kernel.api.Write;
import org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException;
Expand Down Expand Up @@ -463,32 +464,35 @@ public void close()
@Override
public ResourceIterable<Relationship> getAllRelationships()
{
assertTransactionOpen();
KernelTransaction ktx = statementContext.getKernelTransactionBoundToThisThread( true );
assertTransactionOpen( ktx );
return () ->
{
final Statement statement = statementContext.get();
final PrimitiveLongIterator ids = statement.readOperations().relationshipsGetAll();
Statement statement = ktx.acquireStatement();
RelationshipScanCursor cursor = ktx.cursors().allocateRelationshipScanCursor();
ktx.dataRead().allRelationshipsScan( cursor );
return new PrefetchingResourceIterator<Relationship>()
{
@Override
public void close()
{
statement.close();
}

@Override
protected Relationship fetchNextOrNull()
{
if ( ids.hasNext() )
if ( cursor.next() )
{
return newRelationshipProxy( ids.next() );
return newRelationshipProxy( cursor.relationshipReference() );
}
else
{
close();
return null;
}
}

@Override
public void close()
{
cursor.close();
statement.close();
}
};
};
}
Expand Down

0 comments on commit 19ffc7c

Please sign in to comment.