Skip to content

Commit

Permalink
Revert closing of paths and branches in graph algo module
Browse files Browse the repository at this point in the history
ignore,
disable open statement check in graph algo module
  • Loading branch information
MishaDemianenko committed Aug 22, 2017
1 parent b85f304 commit 40e037f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 50 deletions.
3 changes: 3 additions & 0 deletions community/graph-algo/pom.xml
Expand Up @@ -13,6 +13,9 @@
<bundle.namespace>org.neo4j.graphalgo</bundle.namespace>
<license-text.header>GPL-3-header.txt</license-text.header>
<licensing.prepend.text>notice-gpl-prefix.txt</licensing.prepend.text>
<test.runner.jvm.settings.additional>
-Dorg.neo4j.kernel.impl.api.KernelStatement.trackStatements=false
</test.runner.jvm.settings.additional>
</properties>

<modelVersion>4.0.0</modelVersion>
Expand Down
Expand Up @@ -109,9 +109,4 @@ public Iterator<PropertyContainer> iterator()
return path.iterator();
}

@Override
public void close()
{
path.close();
}
}
Expand Up @@ -19,6 +19,7 @@
*/
package org.neo4j.graphalgo.path;

import common.Neo4jAlgoTestCase;
import org.junit.Test;

import org.neo4j.graphalgo.GraphAlgoFactory;
Expand All @@ -29,7 +30,7 @@
import org.neo4j.graphdb.Path;
import org.neo4j.graphdb.PathExpander;
import org.neo4j.graphdb.PathExpanders;
import common.Neo4jAlgoTestCase;

import static org.junit.Assert.assertNotNull;

public class TestExactDepthPathFinder extends Neo4jAlgoTestCase
Expand Down Expand Up @@ -64,9 +65,11 @@ public void testSingle()
{
createGraph();
PathFinder<Path> finder = newFinder();
Path path = finder.findSinglePath( graph.getNode( "SOURCE" ), graph.getNode( "TARGET" ) );
assertNotNull( path );
assertPathDef( path, "SOURCE", "z", "9", "0", "TARGET" );
try ( Path path = finder.findSinglePath( graph.getNode( "SOURCE" ), graph.getNode( "TARGET" ) ) )
{
assertNotNull( path );
assertPathDef( path, "SOURCE", "z", "9", "0", "TARGET" );
}
}

@Test
Expand Down
Expand Up @@ -76,15 +76,13 @@ public TraversalBranch next( TraversalContext metadata )
TraversalBranch otherBranch = otherState.branch;
if ( otherBranch != null )
{
closeBranch( branch );
otherState.branch = null;
return otherBranch;
}

otherBranch = otherSelector.next( metadata );
if ( otherBranch != null )
{
closeBranch( branch );
return otherBranch;
}
else
Expand All @@ -93,14 +91,6 @@ public TraversalBranch next( TraversalContext metadata )
}
}

private void closeBranch( TraversalBranch branch )
{
if ( branch != null )
{
branch.close();
}
}

static class Entry
{
private final AtomicInteger depth = new AtomicInteger();
Expand Down
Expand Up @@ -161,19 +161,8 @@ protected Path fetchNextOrNull()
if ( foundPaths.hasNext() )
{
numberOfPathsReturned++;
// not sure we need to close result here
result.close();
Path next = foundPaths.next();
return next;
return foundPaths.next();
}
else
{
result.close();
}
}
else
{
result.close();
}
}
}
Expand Down
Expand Up @@ -73,10 +73,6 @@ protected Path fetchNextOrNull()
numberOfPathsReturned++;
return result;
}
else
{
result.close();
}
}
}

Expand Down
Expand Up @@ -88,8 +88,7 @@ protected void expandRelationships( PathExpander expander )
}
else
{
closeRelationships();
relationships = Iterators.emptyResourceIterator();
resetRelationships();
}
}

Expand Down Expand Up @@ -144,8 +143,7 @@ public TraversalBranch next( PathExpander expander, TraversalContext context )
context.unnecessaryRelationshipTraversed();
}
}
relationships.close();
relationships = Iterators.emptyResourceIterator();
resetRelationships();
return null;
}

Expand All @@ -157,24 +155,16 @@ protected TraversalBranch newNextBranch( Node node, Relationship relationship )
@Override
public void prune()
{
closeRelationships();
relationships = Iterators.emptyResourceIterator();
resetRelationships();
}

@Override
public void close()
{
//TODO: not sure its a right place to close parent
parent.close();
closeRelationships();
}

private void closeRelationships()
private void resetRelationships()
{
if ( relationships != null )
{
relationships.close();
}
relationships = Iterators.emptyResourceIterator();
}

@Override
Expand Down

0 comments on commit 40e037f

Please sign in to comment.