Skip to content

Commit

Permalink
Remove unused collections factory methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Koval committed Jul 31, 2018
1 parent 07e9b4e commit 907d592
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 80 deletions.
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.collections.api.map.primitive.MutableLongObjectMap;
import org.eclipse.collections.api.map.primitive.MutableObjectLongMap;
import org.eclipse.collections.api.set.primitive.MutableLongSet;
import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap;
import org.eclipse.collections.impl.map.mutable.primitive.ObjectLongHashMap;

import java.util.Collection;
Expand Down Expand Up @@ -207,7 +208,7 @@ private MutableLongDiffSets getOrCreateLabelStateNodeDiffSets( long labelId )
{
if ( labelStatesMap == null )
{
labelStatesMap = collectionsFactory.newLongObjectMap();
labelStatesMap = new LongObjectHashMap<>();
}
return labelStatesMap.getIfAbsentPut( labelId, () -> new MutableLongDiffSetsImpl( collectionsFactory ) );
}
Expand Down Expand Up @@ -433,7 +434,7 @@ public void labelDoCreateForName( String labelName, long id )
{
if ( createdLabelTokens == null )
{
createdLabelTokens = collectionsFactory.newLongObjectMap();
createdLabelTokens = new LongObjectHashMap<>();
}
createdLabelTokens.put( id, labelName );
changed();
Expand All @@ -444,7 +445,7 @@ public void propertyKeyDoCreateForName( String propertyKeyName, int id )
{
if ( createdPropertyKeyTokens == null )
{
createdPropertyKeyTokens = collectionsFactory.newLongObjectMap();
createdPropertyKeyTokens = new LongObjectHashMap<>();
}
createdPropertyKeyTokens.put( id, propertyKeyName );
changed();
Expand All @@ -455,7 +456,7 @@ public void relationshipTypeDoCreateForName( String labelName, int id )
{
if ( createdRelationshipTypeTokens == null )
{
createdRelationshipTypeTokens = collectionsFactory.newLongObjectMap();
createdRelationshipTypeTokens = new LongObjectHashMap<>();
}
createdRelationshipTypeTokens.put( id, labelName );
changed();
Expand Down Expand Up @@ -598,7 +599,7 @@ private NodeStateImpl getOrCreateNodeState( long nodeId )
{
if ( nodeStatesMap == null )
{
nodeStatesMap = collectionsFactory.newLongObjectMap();
nodeStatesMap = new LongObjectHashMap<>();
}
return nodeStatesMap.getIfAbsentPut( nodeId, () -> new NodeStateImpl( nodeId, collectionsFactory ) );
}
Expand All @@ -607,7 +608,7 @@ private RelationshipStateImpl getOrCreateRelationshipState( long relationshipId
{
if ( relationshipStatesMap == null )
{
relationshipStatesMap = collectionsFactory.newLongObjectMap();
relationshipStatesMap = new LongObjectHashMap<>();
}
return relationshipStatesMap.getIfAbsentPut( relationshipId, () -> new RelationshipStateImpl( relationshipId, collectionsFactory ) );
}
Expand Down
Expand Up @@ -19,8 +19,6 @@
*/
package org.neo4j.kernel.impl.util.collection;

import org.eclipse.collections.api.map.primitive.MutableIntObjectMap;
import org.eclipse.collections.api.map.primitive.MutableLongObjectMap;
import org.eclipse.collections.api.set.primitive.MutableLongSet;

import org.neo4j.kernel.impl.api.state.TxState;
Expand All @@ -35,10 +33,6 @@ public interface CollectionsFactory
{
MutableLongSet newLongSet();

<V> MutableLongObjectMap<V> newLongObjectMap();

<V> MutableIntObjectMap<V> newIntObjectMap();

MutableLongDiffSetsImpl newLongDiffSets();

MemoryTracker getMemoryTracker();
Expand Down
Expand Up @@ -19,11 +19,7 @@
*/
package org.neo4j.kernel.impl.util.collection;

import org.eclipse.collections.api.map.primitive.MutableIntObjectMap;
import org.eclipse.collections.api.map.primitive.MutableLongObjectMap;
import org.eclipse.collections.api.set.primitive.MutableLongSet;
import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap;
import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap;

import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -56,18 +52,6 @@ public MutableLongSet newLongSet()
return set;
}

@Override
public <V> MutableLongObjectMap<V> newLongObjectMap()
{
return new LongObjectHashMap<>();
}

@Override
public <V> MutableIntObjectMap<V> newIntObjectMap()
{
return new IntObjectHashMap<>();
}

@Override
public MutableLongDiffSetsImpl newLongDiffSets()
{
Expand Down
Expand Up @@ -19,11 +19,7 @@
*/
package org.neo4j.kernel.impl.util.collection;

import org.eclipse.collections.api.map.primitive.MutableIntObjectMap;
import org.eclipse.collections.api.map.primitive.MutableLongObjectMap;
import org.eclipse.collections.api.set.primitive.MutableLongSet;
import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap;
import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap;
import org.eclipse.collections.impl.set.mutable.primitive.LongHashSet;

import org.neo4j.kernel.impl.util.diffsets.MutableLongDiffSetsImpl;
Expand All @@ -44,18 +40,6 @@ public MutableLongSet newLongSet()
return new LongHashSet();
}

@Override
public <V> MutableLongObjectMap<V> newLongObjectMap()
{
return new LongObjectHashMap<>();
}

@Override
public <V> MutableIntObjectMap<V> newIntObjectMap()
{
return new IntObjectHashMap<>();
}

@Override
public MutableLongDiffSetsImpl newLongDiffSets()
{
Expand Down
Expand Up @@ -19,8 +19,6 @@
*/
package org.neo4j.kernel.impl.api;

import org.eclipse.collections.api.map.primitive.MutableIntObjectMap;
import org.eclipse.collections.api.map.primitive.MutableLongObjectMap;
import org.eclipse.collections.api.set.primitive.MutableLongSet;
import org.junit.Before;
import org.mockito.Mockito;
Expand Down Expand Up @@ -196,18 +194,6 @@ public MutableLongSet newLongSet()
return OnHeapCollectionsFactory.INSTANCE.newLongSet();
}

@Override
public <V> MutableLongObjectMap<V> newLongObjectMap()
{
return OnHeapCollectionsFactory.INSTANCE.newLongObjectMap();
}

@Override
public <V> MutableIntObjectMap<V> newIntObjectMap()
{
return OnHeapCollectionsFactory.INSTANCE.newIntObjectMap();
}

@Override
public MutableLongDiffSetsImpl newLongDiffSets()
{
Expand Down
Expand Up @@ -22,7 +22,6 @@
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.eclipse.collections.api.IntIterable;
import org.eclipse.collections.api.set.primitive.LongSet;
import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
Expand Down Expand Up @@ -80,11 +79,6 @@
import static org.junit.Assert.fail;
import static org.junit.runners.Parameterized.Parameter;
import static org.junit.runners.Parameterized.Parameters;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.neo4j.helpers.collection.Iterators.asSet;
import static org.neo4j.helpers.collection.Pair.of;
import static org.neo4j.values.storable.ValueGroup.TEXT;
Expand Down Expand Up @@ -1492,22 +1486,6 @@ public void visitDeletedNode( long id )
} );
}

@Test
public void useCollectionFactory()
{
final CollectionsFactory collectionsFactory = mock( CollectionsFactory.class );
doAnswer( invocation -> new LongObjectHashMap<>() ).when( collectionsFactory ).newLongObjectMap();

state = new TxState( collectionsFactory );

state.labelDoCreateForName( "foo", 1 );
state.propertyKeyDoCreateForName( "bar", 2 );
state.relationshipTypeDoCreateForName( "baz", 3 );

verify( collectionsFactory, times( 3 ) ).newLongObjectMap();
verifyNoMoreInteractions( collectionsFactory );
}

//endregion

abstract class VisitationOrder extends TxStateVisitor.Adapter
Expand Down

0 comments on commit 907d592

Please sign in to comment.