Skip to content

Commit

Permalink
Removed Primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Koval committed May 8, 2018
1 parent 815d2cb commit 02e63ba
Show file tree
Hide file tree
Showing 24 changed files with 60 additions and 183 deletions.
Expand Up @@ -19,8 +19,7 @@
*/
package org.neo4j.cypher.internal.runtime.interpreted.pipes

import org.eclipse.collections.api.map.primitive.MutableLongObjectMap
import org.neo4j.collection.primitive.Primitive
import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap
import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext
import org.neo4j.cypher.internal.util.v3_5.InternalException
import org.neo4j.cypher.internal.util.v3_5.attribution.Id
Expand Down Expand Up @@ -84,7 +83,7 @@ case class PruningVarLengthExpandPipe(source: Pipe,
val pathLength: Int,
val queryState: QueryState,
val row: ExecutionContext,
val expandMap: MutableLongObjectMap[NodeState],
val expandMap: LongObjectHashMap[NodeState],
val prevLocalRelIndex: Int,
val prevNodeState: NodeState ) {

Expand Down Expand Up @@ -271,7 +270,7 @@ case class PruningVarLengthExpandPipe(source: Pipe,
case node: VirtualNodeValue =>
push( node = node,
pathLength = 0,
expandMap = Primitive.longObjectMap[NodeState](),
expandMap = new LongObjectHashMap[NodeState](),
prevLocalRelIndex = -1,
prevNodeState = NodeState.NOOP )

Expand All @@ -298,7 +297,7 @@ case class PruningVarLengthExpandPipe(source: Pipe,

def push(node: VirtualNodeValue,
pathLength: Int,
expandMap: MutableLongObjectMap[NodeState],
expandMap: LongObjectHashMap[NodeState],
prevLocalRelIndex: Int,
prevNodeState: NodeState): VirtualNodeValue = {
depth += 1
Expand Down
Expand Up @@ -19,10 +19,9 @@
*/
package org.neo4j.cypher.internal.runtime.interpreted.pipes

import org.eclipse.collections.api.set.primitive.{LongSet, MutableLongSet}
import org.eclipse.collections.impl.set.mutable.primitive.LongHashSet
import org.neo4j.cypher.internal.util.v3_5.CypherTypeException
import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext
import org.neo4j.cypher.internal.util.v3_5.CypherTypeException
import org.neo4j.cypher.internal.util.v3_5.attribution.Id
import org.neo4j.values.storable.Values
import org.neo4j.values.virtual.VirtualNodeValue
Expand All @@ -35,7 +34,7 @@ case class TriadicSelectionPipe(positivePredicate: Boolean, left: Pipe, source:
extends PipeWithSource(left) {

override protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState) = {
var triadicState: LongSet = null
var triadicState: LongHashSet = null
// 1. Build
new LazyGroupingIterator[ExecutionContext](input) {
override def getKey(row: ExecutionContext) = row(source)
Expand All @@ -46,7 +45,7 @@ extends PipeWithSource(left) {
case x => throw new CypherTypeException(s"Expected a node at `$seen` but got $x")
}

override def setState(triadicSet: LongSet) = triadicState = triadicSet
override def setState(triadicSet: LongHashSet) = triadicState = triadicSet

// 2. pass through 'right'
}.flatMap { (outerContext) =>
Expand All @@ -66,7 +65,7 @@ extends PipeWithSource(left) {
}

abstract class LazyGroupingIterator[ROW >: Null <: AnyRef](val input: Iterator[ROW]) extends AbstractIterator[ROW] {
def setState(state: LongSet)
def setState(state: LongHashSet)
def getKey(row: ROW): Any
def getValue(row: ROW): Option[Long]

Expand Down Expand Up @@ -115,7 +114,7 @@ abstract class LazyGroupingIterator[ROW >: Null <: AnyRef](val input: Iterator[R
}
}

def update(triadicSet: MutableLongSet, row: ROW): AnyVal = {
def update(triadicSet: LongHashSet, row: ROW): AnyVal = {
for (value <- getValue(row))
triadicSet.add(value)
}
Expand Down
Expand Up @@ -20,7 +20,7 @@
package org.neo4j.cypher.internal.runtime.interpreted.pipes

import org.eclipse.collections.api.LongIterable
import org.eclipse.collections.api.set.primitive.LongSet
import org.eclipse.collections.impl.set.mutable.primitive.LongHashSet
import org.neo4j.cypher.internal.util.v3_5.test_helpers.CypherFunSuite

class LazyGroupingIteratorTest extends CypherFunSuite {
Expand Down Expand Up @@ -89,9 +89,9 @@ class LazyGroupingIteratorTest extends CypherFunSuite {
}

class LazyGroupingRowIterator(rows: Row*) extends LazyGroupingIterator[Row](rows.iterator) {
var state: LongSet = null
var state: LongHashSet = null

override def setState(state: LongSet) = {
override def setState(state: LongHashSet) = {
this.state = state
}

Expand Down
Expand Up @@ -19,8 +19,7 @@
*/
package org.neo4j.cypher.internal.runtime.interpreted.pipes

import org.eclipse.collections.api.map.primitive.MutableLongObjectMap
import org.neo4j.collection.primitive.Primitive
import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap
import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext
import org.neo4j.cypher.internal.util.v3_5.InternalException
import org.neo4j.cypher.internal.util.v3_5.attribution.Id
Expand Down Expand Up @@ -89,7 +88,7 @@ case class LegacyPruningVarLengthExpandPipe(source: Pipe,
val pathLength: Int,
val state: QueryState,
row: ExecutionContext,
expandMap: MutableLongObjectMap[FullExpandDepths]
expandMap: LongObjectHashMap[FullExpandDepths]
) extends State with Expandable with CheckPath {

private var rels: Iterator[RelationshipValue] = _
Expand Down Expand Up @@ -184,7 +183,7 @@ case class LegacyPruningVarLengthExpandPipe(source: Pipe,
val pathLength: Int,
val state: QueryState,
row: ExecutionContext,
expandMap: MutableLongObjectMap[FullExpandDepths],
expandMap: LongObjectHashMap[FullExpandDepths],
updateMinFullExpandDepth: Int => Unit) extends State with Expandable with CheckPath {

import FullExpandDepths.UNINITIALIZED
Expand Down Expand Up @@ -268,7 +267,7 @@ case class LegacyPruningVarLengthExpandPipe(source: Pipe,
pathLength = 0,
state = state,
row = row,
expandMap = Primitive.longObjectMap[FullExpandDepths]())
expandMap = new LongObjectHashMap[FullExpandDepths]())
nextState.next()
}

Expand Down
Expand Up @@ -39,7 +39,6 @@
import java.util.Map;
import java.util.Set;

import org.neo4j.collection.primitive.Primitive;
import org.neo4j.internal.kernel.api.schema.SchemaDescriptor;

/**
Expand All @@ -58,7 +57,7 @@ public final class IndexMap implements Cloneable

public IndexMap()
{
this( Primitive.longObjectMap(), new HashMap<>(), new ObjectLongHashMap<>() );
this( new LongObjectHashMap<>(), new HashMap<>(), new ObjectLongHashMap<>() );
}

IndexMap( MutableLongObjectMap<IndexProxy> indexesById )
Expand Down
Expand Up @@ -24,19 +24,18 @@
import org.eclipse.collections.api.map.primitive.MutableLongObjectMap;
import org.eclipse.collections.api.set.primitive.LongSet;
import org.eclipse.collections.api.set.primitive.MutableLongSet;
import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap;
import org.eclipse.collections.impl.set.mutable.primitive.LongHashSet;

import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;

import org.neo4j.collection.primitive.Primitive;
import org.neo4j.function.ThrowingConsumer;
import org.neo4j.function.ThrowingFunction;
import org.neo4j.graphdb.ResourceIterator;
Expand Down Expand Up @@ -247,7 +246,7 @@ public void start()
// do it at one point after recovery... i.e. here
indexMapRef.indexMapSnapshot().forEachIndexProxy( indexProxyOperation( "refresh", IndexProxy::refresh ) );

final MutableLongObjectMap<RebuildingIndexDescriptor> rebuildingDescriptors = Primitive.longObjectMap();
final MutableLongObjectMap<RebuildingIndexDescriptor> rebuildingDescriptors = new LongObjectHashMap<>();
indexMapRef.modify( indexMap ->
{
Map<InternalIndexState, List<IndexLogRecord>> indexStates = new EnumMap<>( InternalIndexState.class );
Expand Down
Expand Up @@ -21,6 +21,7 @@

import org.eclipse.collections.api.map.primitive.LongObjectMap;
import org.eclipse.collections.api.map.primitive.MutableLongObjectMap;
import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -32,7 +33,6 @@
import org.neo4j.kernel.impl.transaction.command.Command.PropertyCommand;
import org.neo4j.storageengine.api.CommandsToApply;

import static org.neo4j.collection.primitive.Primitive.longObjectMap;
import static org.neo4j.kernel.impl.store.NodeLabelsField.fieldPointsToDynamicRecordOfLabels;

/**
Expand All @@ -42,8 +42,8 @@
public class NodePropertyCommandsExtractor extends TransactionApplier.Adapter
implements BatchTransactionApplier
{
private final MutableLongObjectMap<NodeCommand> nodeCommandsById = longObjectMap();
private final MutableLongObjectMap<List<PropertyCommand>> propertyCommandsByNodeIds = longObjectMap();
private final MutableLongObjectMap<NodeCommand> nodeCommandsById = new LongObjectHashMap<>();
private final MutableLongObjectMap<List<PropertyCommand>> propertyCommandsByNodeIds = new LongObjectHashMap<>();
private boolean hasUpdates;

@Override
Expand Down
Expand Up @@ -35,7 +35,6 @@
import java.util.concurrent.locks.StampedLock;
import java.util.function.Function;

import org.neo4j.collection.primitive.Primitive;
import org.neo4j.helpers.collection.Iterators;
import org.neo4j.internal.kernel.api.schema.SchemaDescriptor;
import org.neo4j.internal.kernel.api.schema.SchemaDescriptorPredicates;
Expand Down Expand Up @@ -188,8 +187,8 @@ private static class SchemaCacheState
{
this.constraintSemantics = constraintSemantics;
this.constraints = new HashSet<>();
this.indexRuleById = Primitive.longObjectMap();
this.constraintRuleById = Primitive.longObjectMap();
this.indexRuleById = new LongObjectHashMap<>();
this.constraintRuleById = new LongObjectHashMap<>();

this.indexDescriptors = new HashMap<>();
this.indexDescriptorsByLabel = new IntObjectHashMap<>();
Expand Down
Expand Up @@ -20,14 +20,14 @@
package org.neo4j.kernel.impl.coreapi;

import org.eclipse.collections.api.map.primitive.MutableLongObjectMap;
import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;

import org.neo4j.collection.primitive.Primitive;
import org.neo4j.cursor.Cursor;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Node;
Expand Down Expand Up @@ -78,7 +78,7 @@ public class TxStateTransactionDataSnapshot implements TransactionData
private final Collection<PropertyEntry<Node>> removedNodeProperties = new ArrayList<>();
private final Collection<PropertyEntry<Relationship>> removedRelationshipProperties = new ArrayList<>();
private final Collection<LabelEntry> removedLabels = new ArrayList<>();
private final MutableLongObjectMap<RelationshipProxy> relationshipsReadFromStore = Primitive.longObjectMap( 16 );
private final MutableLongObjectMap<RelationshipProxy> relationshipsReadFromStore = new LongObjectHashMap<>( 16 );

public TxStateTransactionDataSnapshot(
ReadableTransactionState state, EmbeddedProxySPI proxySpi,
Expand Down
Expand Up @@ -20,8 +20,8 @@
package org.neo4j.kernel.impl.transaction.state;

import org.eclipse.collections.api.map.primitive.MutableLongObjectMap;
import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap;

import org.neo4j.collection.primitive.Primitive;
import org.neo4j.helpers.collection.Iterables;
import org.neo4j.kernel.impl.util.statistics.IntCounter;
import org.neo4j.kernel.impl.util.statistics.LocalIntCounter;
Expand All @@ -36,7 +36,7 @@
*/
public class RecordChanges<RECORD,ADDITIONAL> implements RecordAccess<RECORD,ADDITIONAL>
{
private MutableLongObjectMap<RecordProxy<RECORD, ADDITIONAL>> recordChanges = Primitive.longObjectMap();
private MutableLongObjectMap<RecordProxy<RECORD, ADDITIONAL>> recordChanges = new LongObjectHashMap<>();
private final Loader<RECORD,ADDITIONAL> loader;
private final IntCounter changeCounter;

Expand Down Expand Up @@ -103,7 +103,7 @@ public void close()
else
{
// Let's not allow the internal maps to grow too big over time.
recordChanges = Primitive.longObjectMap();
recordChanges = new LongObjectHashMap<>();
}
changeCounter.clear();
}
Expand Down
Expand Up @@ -23,8 +23,9 @@
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.collection.primitive.Primitive;
import org.neo4j.kernel.impl.util.diffsets.PrimitiveLongDiffSets;
import org.neo4j.memory.MemoryAllocationTracker;
import org.neo4j.memory.MemoryTracker;
Expand All @@ -43,13 +44,13 @@ class OffHeapCollectionsFactory implements CollectionsFactory
@Override
public MutableLongSet newLongSet()
{
return Primitive.offHeapLongSet( memoryTracker );
return new LongHashSet();
}

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

@Override
Expand Down
Expand Up @@ -24,9 +24,9 @@
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.collection.primitive.Primitive;
import org.neo4j.kernel.impl.util.diffsets.PrimitiveLongDiffSets;
import org.neo4j.memory.MemoryTracker;

Expand All @@ -48,7 +48,7 @@ public MutableLongSet newLongSet()
@Override
public <V> MutableLongObjectMap<V> newLongObjectMap()
{
return Primitive.longObjectMap();
return new LongObjectHashMap<>();
}

@Override
Expand Down
Expand Up @@ -22,11 +22,11 @@
import org.eclipse.collections.api.map.primitive.MutableLongObjectMap;
import org.eclipse.collections.api.set.primitive.IntSet;
import org.eclipse.collections.impl.factory.primitive.IntSets;
import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap;
import org.eclipse.collections.impl.set.mutable.primitive.IntHashSet;
import org.junit.Before;
import org.junit.Test;

import org.neo4j.collection.primitive.Primitive;
import org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor;
import org.neo4j.internal.kernel.api.schema.SchemaDescriptor;
import org.neo4j.kernel.api.schema.SchemaDescriptorFactory;
Expand All @@ -48,7 +48,7 @@ public class IndexMapTest
@Before
public void setup()
{
MutableLongObjectMap<IndexProxy> map = Primitive.longObjectMap();
MutableLongObjectMap<IndexProxy> map = new LongObjectHashMap<>();
map.put( 1L, new TestIndexProxy( schema3_4 ) );
map.put( 2L, new TestIndexProxy( schema5_6_7 ) );
map.put( 3L, new TestIndexProxy( schema5_8 ) );
Expand Down
Expand Up @@ -21,6 +21,7 @@

import org.eclipse.collections.api.map.primitive.LongObjectMap;
import org.eclipse.collections.api.map.primitive.MutableLongObjectMap;
import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
Expand All @@ -31,7 +32,6 @@
import java.util.function.Function;

import org.neo4j.collection.RawIterator;
import org.neo4j.collection.primitive.Primitive;
import org.neo4j.internal.kernel.api.CapableIndexReference;
import org.neo4j.internal.kernel.api.IndexReference;
import org.neo4j.internal.kernel.api.InternalIndexState;
Expand Down Expand Up @@ -527,8 +527,8 @@ public Statement apply( Statement base, Description description )
public void evaluate() throws Throwable
{

MutableLongObjectMap<Node> nodes = Primitive.longObjectMap();
MutableLongObjectMap<Property> properties = Primitive.longObjectMap();
MutableLongObjectMap<Node> nodes = new LongObjectHashMap<>();
MutableLongObjectMap<Property> properties = new LongObjectHashMap<>();

MockStore.this.nodes = nodes;
MockStore.this.properties = properties;
Expand Down

0 comments on commit 02e63ba

Please sign in to comment.