From 461e6de663d74345fac74809ddf0d63e6b2d77e3 Mon Sep 17 00:00:00 2001 From: Mikhaylo Demianenko Date: Thu, 1 Sep 2016 01:20:05 +0200 Subject: [PATCH] Remove homegrown Mutable* --- .../full/FullCheckIntegrationTest.java | 29 ++++---- .../neo4j/graphalgo/impl/path/Dijkstra.java | 12 ++-- .../impl/path/DijkstraBidirectional.java | 12 ++-- .../graphalgo/impl/path/ShortestPath.java | 72 ++++++++++--------- .../util/DijkstraBranchCollisionDetector.java | 11 +-- .../graphalgo/impl/path/TestShortestPath.java | 12 ++-- .../kernel/impl/util/MutableBoolean.java | 25 ------- .../neo4j/kernel/impl/util/MutableDouble.java | 30 -------- .../kernel/impl/util/MutableInteger.java | 30 -------- 9 files changed, 78 insertions(+), 155 deletions(-) delete mode 100644 community/kernel/src/main/java/org/neo4j/kernel/impl/util/MutableBoolean.java delete mode 100644 community/kernel/src/main/java/org/neo4j/kernel/impl/util/MutableDouble.java delete mode 100644 community/kernel/src/main/java/org/neo4j/kernel/impl/util/MutableInteger.java diff --git a/community/consistency-check/src/test/java/org/neo4j/consistency/checking/full/FullCheckIntegrationTest.java b/community/consistency-check/src/test/java/org/neo4j/consistency/checking/full/FullCheckIntegrationTest.java index bd05625e99944..60c042e62e0cf 100644 --- a/community/consistency-check/src/test/java/org/neo4j/consistency/checking/full/FullCheckIntegrationTest.java +++ b/community/consistency-check/src/test/java/org/neo4j/consistency/checking/full/FullCheckIntegrationTest.java @@ -20,6 +20,7 @@ package org.neo4j.consistency.checking.full; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.mutable.MutableInt; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Ignore; @@ -83,12 +84,12 @@ import org.neo4j.kernel.impl.core.ThreadToStatementContextBridge; import org.neo4j.kernel.impl.store.AbstractDynamicStore; import org.neo4j.kernel.impl.store.NodeLabelsField; -import org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator; import org.neo4j.kernel.impl.store.PropertyType; import org.neo4j.kernel.impl.store.RecordStore; import org.neo4j.kernel.impl.store.SchemaStorage; import org.neo4j.kernel.impl.store.SchemaStore; import org.neo4j.kernel.impl.store.StoreAccess; +import org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator; import org.neo4j.kernel.impl.store.record.AbstractSchemaRule; import org.neo4j.kernel.impl.store.record.DynamicRecord; import org.neo4j.kernel.impl.store.record.IndexRule; @@ -103,7 +104,6 @@ import org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord; import org.neo4j.kernel.impl.store.record.UniquePropertyConstraintRule; import org.neo4j.kernel.impl.util.Bits; -import org.neo4j.kernel.impl.util.MutableInteger; import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.logging.FormattedLog; import org.neo4j.storageengine.api.schema.SchemaRule; @@ -123,7 +123,6 @@ import static org.neo4j.graphdb.Label.label; import static org.neo4j.graphdb.RelationshipType.withName; import static org.neo4j.helpers.collection.Iterables.asIterable; -import static org.neo4j.helpers.collection.Iterators.iterator; import static org.neo4j.helpers.collection.MapUtil.stringMap; import static org.neo4j.kernel.api.ReadOperations.ANY_LABEL; import static org.neo4j.kernel.api.ReadOperations.ANY_RELATIONSHIP_TYPE; @@ -134,13 +133,15 @@ import static org.neo4j.kernel.impl.store.DynamicNodeLabels.dynamicPointer; import static org.neo4j.kernel.impl.store.LabelIdArray.prependNodeId; import static org.neo4j.kernel.impl.store.PropertyType.ARRAY; -import static org.neo4j.kernel.impl.store.record.NodePropertyExistenceConstraintRule.nodePropertyExistenceConstraintRule; +import static org.neo4j.kernel.impl.store.record.NodePropertyExistenceConstraintRule + .nodePropertyExistenceConstraintRule; import static org.neo4j.kernel.impl.store.record.Record.NO_LABELS_FIELD; import static org.neo4j.kernel.impl.store.record.Record.NO_NEXT_PROPERTY; import static org.neo4j.kernel.impl.store.record.Record.NO_NEXT_RELATIONSHIP; import static org.neo4j.kernel.impl.store.record.Record.NO_PREV_RELATIONSHIP; import static org.neo4j.kernel.impl.store.record.RecordLoad.FORCE; -import static org.neo4j.kernel.impl.store.record.RelationshipPropertyExistenceConstraintRule.relPropertyExistenceConstraintRule; +import static org.neo4j.kernel.impl.store.record.RelationshipPropertyExistenceConstraintRule + .relPropertyExistenceConstraintRule; import static org.neo4j.kernel.impl.util.Bits.bits; import static org.neo4j.test.Property.property; import static org.neo4j.test.Property.set; @@ -2055,7 +2056,7 @@ protected String getRecordFormatName() private int createLabel() throws Exception { - final MutableInteger id = new MutableInteger( -1 ); + final MutableInt id = new MutableInt( -1 ); fixture.apply( new GraphStoreFixture.Transaction() { @@ -2065,16 +2066,16 @@ protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx, { int labelId = next.label(); tx.nodeLabel( labelId, "label" ); - id.value = labelId; + id.setValue( labelId ); } } ); - return id.value; + return id.intValue(); } private int createPropertyKey() throws Exception { - final MutableInteger id = new MutableInteger( -1 ); + final MutableInt id = new MutableInt( -1 ); fixture.apply( new GraphStoreFixture.Transaction() { @@ -2084,16 +2085,16 @@ protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx, { int propertyKeyId = next.propertyKey(); tx.propertyKey( propertyKeyId, "property" ); - id.value = propertyKeyId; + id.setValue( propertyKeyId ); } } ); - return id.value; + return id.intValue(); } private int createRelType() throws Exception { - final MutableInteger id = new MutableInteger( -1 ); + final MutableInt id = new MutableInt( -1 ); fixture.apply( new GraphStoreFixture.Transaction() { @@ -2103,11 +2104,11 @@ protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx, { int relTypeId = next.relationshipType(); tx.relationshipType( relTypeId, "relType" ); - id.value = relTypeId; + id.setValue( relTypeId ); } } ); - return id.value; + return id.intValue(); } private void createIndexRule( final int labelId, final int propertyKeyId ) throws Exception diff --git a/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/Dijkstra.java b/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/Dijkstra.java index 7d0424bd10a93..9f2171e1316e2 100644 --- a/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/Dijkstra.java +++ b/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/Dijkstra.java @@ -19,6 +19,8 @@ */ package org.neo4j.graphalgo.impl.path; +import org.apache.commons.lang3.mutable.MutableDouble; + import java.util.Collections; import java.util.Iterator; @@ -42,7 +44,6 @@ import org.neo4j.graphdb.traversal.Traverser; import org.neo4j.graphdb.traversal.Uniqueness; import org.neo4j.kernel.impl.traversal.MonoDirectionalTraversalDescription; -import org.neo4j.kernel.impl.util.MutableDouble; import org.neo4j.kernel.impl.util.NoneStrictMath; import static org.neo4j.graphalgo.impl.util.PathInterestFactory.single; @@ -185,7 +186,8 @@ private Traverser traverser( Node start, final Node end, PathInterest in } else { - MutableDouble shortestSoFar = new MutableDouble( Double.MAX_VALUE ); + org.apache.commons.lang3.mutable.MutableDouble + shortestSoFar = new org.apache.commons.lang3.mutable.MutableDouble( Double.MAX_VALUE ); dijkstraExpander = new DijkstraPathExpander( expander, shortestSoFar, epsilon, interest.stopAfterLowestCost() ); dijkstraEvaluator = new DijkstraEvaluator( shortestSoFar, end, costEvaluator ); @@ -218,7 +220,7 @@ private static class DijkstraPathExpander implements PathExpander protected final boolean stopAfterLowestCost; DijkstraPathExpander( final PathExpander source, - MutableDouble shortestSoFar, double epsilon, boolean stopAfterLowestCost ) + org.apache.commons.lang3.mutable.MutableDouble shortestSoFar, double epsilon, boolean stopAfterLowestCost ) { this.source = source; this.shortestSoFar = shortestSoFar; @@ -229,7 +231,7 @@ private static class DijkstraPathExpander implements PathExpander @Override public Iterable expand( Path path, BranchState state ) { - if ( NoneStrictMath.compare( state.getState(), shortestSoFar.value, epsilon ) > 0 && stopAfterLowestCost ) + if ( NoneStrictMath.compare( state.getState(), shortestSoFar.doubleValue(), epsilon ) > 0 && stopAfterLowestCost ) { return Collections.emptyList(); } @@ -266,7 +268,7 @@ public Evaluation evaluate( Path path, BranchState state ) } if ( path.endNode().equals( endNode ) ) { - shortestSoFar.value = Math.min( shortestSoFar.value, nextState ); + shortestSoFar.setValue( Math.min( shortestSoFar.doubleValue(), nextState ) ); return Evaluation.INCLUDE_AND_PRUNE; } return Evaluation.EXCLUDE_AND_CONTINUE; diff --git a/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/DijkstraBidirectional.java b/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/DijkstraBidirectional.java index 022fcc4ee914a..6c83b4f44a513 100644 --- a/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/DijkstraBidirectional.java +++ b/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/DijkstraBidirectional.java @@ -19,6 +19,8 @@ */ package org.neo4j.graphalgo.impl.path; +import org.apache.commons.lang3.mutable.MutableDouble; + import java.util.Collections; import java.util.function.Predicate; @@ -48,7 +50,6 @@ import org.neo4j.graphdb.traversal.TraversalMetadata; import org.neo4j.graphdb.traversal.Traverser; import org.neo4j.graphdb.traversal.Uniqueness; -import org.neo4j.kernel.impl.util.MutableDouble; import org.neo4j.kernel.impl.util.NoneStrictMath; import static org.neo4j.graphdb.Direction.OUTGOING; @@ -108,7 +109,8 @@ public Iterable findAllPaths( Node start, final Node end ) private Traverser traverser( Node start, final Node end, PathInterest interest ) { final MutableDouble shortestSoFar = new MutableDouble( Double.MAX_VALUE ); - final MutableDouble startSideShortest = new MutableDouble( 0 ); + final org.apache.commons.lang3.mutable.MutableDouble + startSideShortest = new org.apache.commons.lang3.mutable.MutableDouble( 0 ); final MutableDouble endSideShortest = new MutableDouble( 0 ); PathExpander dijkstraExpander = new DijkstraBidirectionalPathExpander( expander, shortestSoFar, true, startSideShortest, endSideShortest, epsilon); @@ -164,7 +166,7 @@ private static class DijkstraBidirectionalPathExpander implements PathExpander expand( Path path, BranchState state ) { double thisState = state.getState(); - thisSideShortest.value = thisState; - if ( NoneStrictMath.compare( thisState + otherSideShortest.value, shortestSoFar.value, epsilon ) > 0 && + thisSideShortest.setValue( thisState ); + if ( NoneStrictMath.compare( thisState + otherSideShortest.doubleValue(), shortestSoFar.doubleValue(), epsilon ) > 0 && stopAfterLowestCost ) { return Collections.emptyList(); diff --git a/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/ShortestPath.java b/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/ShortestPath.java index 03291b0ca37b1..46995daa69cfc 100644 --- a/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/ShortestPath.java +++ b/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/ShortestPath.java @@ -19,6 +19,9 @@ */ package org.neo4j.graphalgo.impl.path; +import org.apache.commons.lang3.mutable.MutableBoolean; +import org.apache.commons.lang3.mutable.MutableInt; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -46,8 +49,6 @@ import org.neo4j.helpers.collection.NestingIterator; import org.neo4j.helpers.collection.PrefetchingIterator; import org.neo4j.kernel.impl.factory.GraphDatabaseFacade; -import org.neo4j.kernel.impl.util.MutableBoolean; -import org.neo4j.kernel.impl.util.MutableInteger; import org.neo4j.kernel.monitoring.Monitors; /** @@ -79,7 +80,7 @@ public interface ShortestPathPredicate { * Constructs a new shortest path algorithm. * @param maxDepth the maximum depth for the traversal. Returned paths * will never have a greater {@link Path#length()} than {@code maxDepth}. - * @param expander the {@link RelationshipExpander} to use for deciding + * @param expander the {@link PathExpander} to use for deciding * which relationships to expand for each {@link Node}. */ public ShortestPath( int maxDepth, PathExpander expander ) @@ -143,10 +144,10 @@ private Iterable internalPaths( Node start, Node end, boolean stopAsap ) return filterPaths(Collections.singletonList( PathImpl.singular( start ) )); } Hits hits = new Hits(); - Collection sharedVisitedRels = new HashSet(); - MutableInteger sharedFrozenDepth = new MutableInteger( NULL ); // ShortestPathLengthSoFar + Collection sharedVisitedRels = new HashSet<>(); + MutableInt sharedFrozenDepth = new MutableInt( NULL ); // ShortestPathLengthSoFar MutableBoolean sharedStop = new MutableBoolean(); - MutableInteger sharedCurrentDepth = new MutableInteger( 0 ); + MutableInt sharedCurrentDepth = new MutableInt( 0 ); final DirectionData startData = new DirectionData( start, sharedVisitedRels, sharedFrozenDepth, sharedStop, sharedCurrentDepth, expander ); @@ -212,16 +213,16 @@ private void goOneStep( DirectionData directionData, DirectionData otherSide, Hi // This is a hit int depth = directionData.currentDepth + otherSideHit.depth; - if ( directionData.sharedFrozenDepth.value == NULL ) + if ( directionData.sharedFrozenDepth.intValue() == NULL ) { - directionData.sharedFrozenDepth.value = depth; + directionData.sharedFrozenDepth.setValue( depth ); } - if ( depth <= directionData.sharedFrozenDepth.value ) + if ( depth <= directionData.sharedFrozenDepth.intValue() ) { directionData.haveFoundSomething = true; - if ( depth < directionData.sharedFrozenDepth.value ) + if ( depth < directionData.sharedFrozenDepth.intValue() ) { - directionData.sharedFrozenDepth.value = depth; + directionData.sharedFrozenDepth.setValue( depth ); // TODO Is it really ok to just stop the other side here? // I'm basing that decision on that it was the other side // which found the deeper paths (correct assumption?) @@ -256,7 +257,7 @@ else if ( stopAsap ) else { directionData.haveFoundSomething = false; - directionData.sharedFrozenDepth.value = NULL; + directionData.sharedFrozenDepth.setValue( NULL ); otherSide.stop = false; } } @@ -306,19 +307,19 @@ private class DirectionData extends PrefetchingIterator private final Node startNode; private int currentDepth; private Iterator nextRelationships; - private final Collection nextNodes = new ArrayList(); - private final Map visitedNodes = new HashMap(); + private final Collection nextNodes = new ArrayList<>(); + private final Map visitedNodes = new HashMap<>(); private final Collection sharedVisitedRels; private final DirectionDataPath lastPath; - private final MutableInteger sharedFrozenDepth; + private final MutableInt sharedFrozenDepth; private final MutableBoolean sharedStop; - private final MutableInteger sharedCurrentDepth; + private final MutableInt sharedCurrentDepth; private boolean haveFoundSomething; private boolean stop; private final PathExpander expander; - DirectionData( Node startNode, Collection sharedVisitedRels, MutableInteger sharedFrozenDepth, - MutableBoolean sharedStop, MutableInteger sharedCurrentDepth, PathExpander expander ) + DirectionData( Node startNode, Collection sharedVisitedRels, MutableInt sharedFrozenDepth, + MutableBoolean sharedStop, MutableInt sharedCurrentDepth, PathExpander expander ) { this.startNode = startNode; this.visitedNodes.put( startNode, new LevelData( null, 0 ) ); @@ -329,7 +330,7 @@ private class DirectionData extends PrefetchingIterator this.expander = expander; this.sharedVisitedRels = sharedVisitedRels; this.lastPath = new DirectionDataPath( startNode ); - if ( sharedCurrentDepth.value < maxDepth ) + if ( sharedCurrentDepth.intValue() < maxDepth ) { prepareNextLevel(); } @@ -354,7 +355,7 @@ protected Iterator createNestedIterator( Node node ) } }; this.currentDepth++; - this.sharedCurrentDepth.value++; + this.sharedCurrentDepth.increment(); } @Override @@ -392,18 +393,19 @@ else if ( this.currentDepth == levelData.depth ) private boolean canGoDeeper() { - return this.sharedFrozenDepth.value == NULL && this.sharedCurrentDepth.value < maxDepth && !finishCurrentLayerThenStop; + return (this.sharedFrozenDepth.intValue() == NULL) && (this.sharedCurrentDepth.intValue() < maxDepth) && + !finishCurrentLayerThenStop; } private Relationship fetchNextRelOrNull() { - if ( this.stop || this.sharedStop.value ) + if ( this.stop || this.sharedStop.booleanValue() ) { return null; } - boolean hasComeTooFarEmptyHanded = - this.sharedFrozenDepth.value != NULL - && this.sharedCurrentDepth.value > this.sharedFrozenDepth.value && !this.haveFoundSomething; + boolean hasComeTooFarEmptyHanded = (this.sharedFrozenDepth.intValue() != NULL) && + (this.sharedCurrentDepth.intValue() > this.sharedFrozenDepth.intValue()) && + !this.haveFoundSomething; if ( hasComeTooFarEmptyHanded ) { return null; @@ -540,7 +542,7 @@ void addRel( Relationship rel ) // One long lived instance private static class Hits { - private final Map> hits = new HashMap>(); + private final Map> hits = new HashMap<>(); private int lowestDepth; private int totalHitCount; @@ -549,7 +551,7 @@ int add( Hit hit, int atDepth ) Collection depthHits = hits.get( atDepth ); if ( depthHits == null ) { - depthHits = new HashSet(); + depthHits = new HashSet<>(); hits.put( atDepth, depthHits ); } if ( depthHits.add( hit ) ) @@ -586,7 +588,7 @@ private static class PathData private static Collection hitsToPaths( Collection depthHits, Node start, Node end, boolean stopAsap ) { - LinkedHashMap paths = new LinkedHashMap(); + LinkedHashMap paths = new LinkedHashMap<>(); for ( Hit hit : depthHits ) { for ( Path path : hitToPaths( hit, start, end, stopAsap ) ) @@ -599,7 +601,7 @@ private static Collection hitsToPaths( Collection depthHits, Node sta private static Collection hitToPaths( Hit hit, Node start, Node end, boolean stopAsap ) { - Collection paths = new ArrayList(); + Collection paths = new ArrayList<>(); Iterable> startPaths = getPaths( hit.connectingNode, hit.start, stopAsap ); Iterable> endPaths = getPaths( hit.connectingNode, hit.end, stopAsap ); for ( LinkedList startPath : startPaths ) @@ -621,15 +623,15 @@ private static Iterable> getPaths( Node connectingNode, LevelData levelData = data.visitedNodes.get( connectingNode ); if ( levelData.depth == 0 ) { - Collection> result = new ArrayList>(); - result.add( new LinkedList() ); + Collection> result = new ArrayList<>(); + result.add( new LinkedList<>() ); return result; } - Collection set = new ArrayList(); + Collection set = new ArrayList<>(); GraphDatabaseService graphDb = data.startNode.getGraphDatabase(); for ( long rel : levelData.relsToHere ) { - set.add( new PathData( connectingNode, new LinkedList( Arrays.asList( graphDb + set.add( new PathData( connectingNode, new LinkedList<>( Arrays.asList( graphDb .getRelationshipById( rel ) ) ) ) ); if ( stopAsap ) break; @@ -637,7 +639,7 @@ private static Iterable> getPaths( Node connectingNode, for ( int i = 0; i < levelData.depth - 1; i++ ) { // One level - Collection nextSet = new ArrayList(); + Collection nextSet = new ArrayList<>(); for ( PathData entry : set ) { // One path... @@ -651,7 +653,7 @@ private static Iterable> getPaths( Node connectingNode, // This is a little optimization which reduces number of // lists being copied entry.rels - : new LinkedList( entry.rels ); + : new LinkedList<>( entry.rels ); rels.addFirst( graphDb.getRelationshipById( rel ) ); nextSet.add( new PathData( otherNode, rels ) ); if ( stopAsap ) diff --git a/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/util/DijkstraBranchCollisionDetector.java b/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/util/DijkstraBranchCollisionDetector.java index 499a3251c31fb..06f8838a44143 100644 --- a/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/util/DijkstraBranchCollisionDetector.java +++ b/community/graph-algo/src/main/java/org/neo4j/graphalgo/impl/util/DijkstraBranchCollisionDetector.java @@ -19,6 +19,8 @@ */ package org.neo4j.graphalgo.impl.util; +import org.apache.commons.lang3.mutable.MutableDouble; + import java.util.function.Predicate; import org.neo4j.graphalgo.CostEvaluator; @@ -26,7 +28,6 @@ import org.neo4j.graphdb.impl.traversal.StandardBranchCollisionDetector; import org.neo4j.graphdb.traversal.Evaluator; import org.neo4j.graphdb.traversal.TraversalBranch; -import org.neo4j.kernel.impl.util.MutableDouble; import org.neo4j.kernel.impl.util.NoneStrictMath; /** @@ -40,7 +41,7 @@ public class DijkstraBranchCollisionDetector extends StandardBranchCollisionDete public DijkstraBranchCollisionDetector( Evaluator evaluator, CostEvaluator costEvaluator, - MutableDouble shortestSoFar, double epsilon, Predicate pathPredicate ) + org.apache.commons.lang3.mutable.MutableDouble shortestSoFar, double epsilon, Predicate pathPredicate ) { super( evaluator, pathPredicate ); this.costEvaluator = costEvaluator; @@ -86,11 +87,11 @@ protected boolean includePath( Path path, TraversalBranch startBranch, Traversal double cost = new WeightedPathImpl( costEvaluator, path ).weight(); - if ( cost < shortestSoFar.value ) + if ( cost < shortestSoFar.doubleValue() ) { - shortestSoFar.value = cost; + shortestSoFar.setValue( cost ); } - if ( NoneStrictMath.compare( cost, shortestSoFar.value, epsilon ) <= 0 ) + if ( NoneStrictMath.compare( cost, shortestSoFar.doubleValue(), epsilon ) <= 0 ) { return true; } diff --git a/community/graph-algo/src/test/java/org/neo4j/graphalgo/impl/path/TestShortestPath.java b/community/graph-algo/src/test/java/org/neo4j/graphalgo/impl/path/TestShortestPath.java index 7228aad3d7953..2dee6277a655d 100644 --- a/community/graph-algo/src/test/java/org/neo4j/graphalgo/impl/path/TestShortestPath.java +++ b/community/graph-algo/src/test/java/org/neo4j/graphalgo/impl/path/TestShortestPath.java @@ -20,6 +20,7 @@ package org.neo4j.graphalgo.impl.path; import common.Neo4jAlgoTestCase; +import org.apache.commons.lang3.mutable.MutableInt; import org.junit.Test; import java.util.ArrayList; @@ -43,7 +44,6 @@ import org.neo4j.graphdb.impl.StandardExpander; import org.neo4j.graphdb.traversal.BranchState; import org.neo4j.helpers.collection.Iterables; -import org.neo4j.kernel.impl.util.MutableInteger; import static common.Neo4jAlgoTestCase.MyRelTypes.R1; import static java.util.Arrays.asList; @@ -96,7 +96,7 @@ public void shouldAbortAsSoonAsPossible() assertEquals( "There are 625 different end nodes. The algorithm should start one traversal for each such node. " + "That is 625*2 visited nodes if traversal is interrupted correctly.", 1250, - countingPathExpander.nodesVisited.value ); + countingPathExpander.nodesVisited.intValue() ); } private void recursiveSnowFlake( Node parent, int level, final int desiredLevel, final int branchingFactor, @@ -478,16 +478,16 @@ public PathExpander reverse() // Used to count how many nodes are visited private class CountingPathExpander implements PathExpander { - private MutableInteger nodesVisited; + private MutableInt nodesVisited; private final PathExpander delegate; public CountingPathExpander( PathExpander delegate ) { - nodesVisited = new MutableInteger( 0 ); + nodesVisited = new MutableInt( 0 ); this.delegate = delegate; } - public CountingPathExpander( PathExpander delegate, MutableInteger nodesVisited ) + public CountingPathExpander( PathExpander delegate, MutableInt nodesVisited ) { this( delegate ); this.nodesVisited = nodesVisited; @@ -496,7 +496,7 @@ public CountingPathExpander( PathExpander delegate, MutableInteger nodesVisited @Override public Iterable expand( Path path, BranchState state ) { - nodesVisited.value++; + nodesVisited.increment(); return delegate.expand( path, state ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/util/MutableBoolean.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/util/MutableBoolean.java deleted file mode 100644 index fc749018df53a..0000000000000 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/util/MutableBoolean.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2002-2016 "Neo Technology," - * Network Engine for Objects in Lund AB [http://neotechnology.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.kernel.impl.util; - -public class MutableBoolean -{ - public boolean value; -} diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/util/MutableDouble.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/util/MutableDouble.java deleted file mode 100644 index 402b319236feb..0000000000000 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/util/MutableDouble.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2002-2016 "Neo Technology," - * Network Engine for Objects in Lund AB [http://neotechnology.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.kernel.impl.util; - -public class MutableDouble -{ - public double value; - - public MutableDouble( double initialValue ) - { - this.value = initialValue; - } -} diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/util/MutableInteger.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/util/MutableInteger.java deleted file mode 100644 index a5d34192c08b4..0000000000000 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/util/MutableInteger.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2002-2016 "Neo Technology," - * Network Engine for Objects in Lund AB [http://neotechnology.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.kernel.impl.util; - -public class MutableInteger -{ - public int value; - - public MutableInteger( int initialValue ) - { - this.value = initialValue; - } -}