newCursor( RecordS
void node( NodeRecord record, long reference )
{
- throw new UnsupportedOperationException( "not implemented" );
+ stores.getNodeStore().getRecord( reference, record, RecordLoad.CHECK );
}
void relationship( RelationshipRecord record, long reference )
+ {
+ stores.getRelationshipStore().getRecord( reference, record, RecordLoad.CHECK );
+ }
+
+ void property( PropertyRecord record, long reference )
+ {
+ stores.getPropertyStore().getRecord( reference, record, RecordLoad.NORMAL );
+ }
+
+ void group( RelationshipGroupRecord record, long reference )
{
throw new UnsupportedOperationException( "not implemented" );
}
long nodeHighMark()
{
- throw new UnsupportedOperationException( "not implemented" );
+ return stores.getNodeStore().getHighestPossibleIdInUse();
}
long relationshipHighMark()
{
- throw new UnsupportedOperationException( "not implemented" );
+ return stores.getRelationshipStore().getHighestPossibleIdInUse();
+ }
+
+ TextValue string( PropertyCursor cursor, long reference )
+ {
+ ByteBuffer buffer =
+ cursor.buffer = readDynamic( stores.getPropertyStore().getStringStore(), reference, cursor.buffer );
+ buffer.flip();
+ return Values.stringValue( UTF8.decode( buffer.array(), 0, buffer.limit() ) );
+ }
+
+ ArrayValue array( PropertyCursor cursor, long reference )
+ {
+ ByteBuffer buffer =
+ cursor.buffer = readDynamic( stores.getPropertyStore().getArrayStore(), reference, cursor.buffer );
+ buffer.flip();
+ return PropertyUtil.readArrayFromBuffer( buffer );
+ }
+
+ /**
+ * Inverted references are used to signal that the reference is of a special type.
+ *
+ * For example that it is a direct reference to a relationship record rather than a reference to relationship group
+ * record in {@link NodeCursor#relationshipGroupReference()}.
+ *
+ * Since {@code -1} is used to encode {@link AbstractBaseRecord#NO_ID that the reference is invalid}, we reserve
+ * this value from the range by subtracting the reference from {@code -2} when inverting.
+ *
+ * This function is its own inverse function.
+ *
+ * @param reference
+ * the reference to invert.
+ * @return the inverted reference.
+ */
+ static long invertReference( long reference )
+ {
+ return -2 - reference;
+ }
+
+ private static ByteBuffer readDynamic( AbstractDynamicStore store, long reference, ByteBuffer buffer )
+ {
+ if ( buffer == null )
+ {
+ buffer = ByteBuffer.allocate( 512 );
+ }
+ else
+ {
+ buffer.clear();
+ }
+ DynamicRecord record = store.newRecord();
+ do
+ {
+ store.getRecord( reference, record, RecordLoad.NORMAL );
+ reference = record.getNextBlock();
+ byte[] data = record.getData();
+ if ( buffer.remaining() < data.length )
+ {
+ buffer = grow( buffer, data.length );
+ }
+ buffer.put( data, 0, data.length );
+ }
+ while ( reference != NO_ID );
+ return buffer;
+ }
+
+ private static ByteBuffer grow( ByteBuffer buffer, int required )
+ {
+ buffer.flip();
+ int capacity = buffer.capacity();
+ do
+ {
+ capacity *= 2;
+ }
+ while ( capacity - buffer.limit() < required );
+ return ByteBuffer.allocate( capacity ).order( ByteOrder.LITTLE_ENDIAN ).put( buffer );
}
}
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/RelationshipGroupCursor.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/RelationshipGroupCursor.java
index 10e582362347f..3a021ef3ccc3d 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/RelationshipGroupCursor.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/RelationshipGroupCursor.java
@@ -19,14 +19,19 @@
*/
package org.neo4j.kernel.impl.newapi;
-import org.neo4j.internal.kernel.api.RelationshipTraversalCursor;
-import org.neo4j.kernel.impl.store.NeoStores;
+import org.neo4j.collection.primitive.Primitive;
+import org.neo4j.collection.primitive.PrimitiveIntObjectMap;
import org.neo4j.kernel.impl.store.record.RelationshipGroupRecord;
+import org.neo4j.kernel.impl.store.record.RelationshipRecord;
+
+import static org.neo4j.kernel.impl.newapi.Read.invertReference;
class RelationshipGroupCursor extends RelationshipGroupRecord
implements org.neo4j.internal.kernel.api.RelationshipGroupCursor
{
private final Read read;
+ private final RelationshipRecord edge = new RelationshipRecord( NO_ID );
+ private Group current;
RelationshipGroupCursor( Read read )
{
@@ -34,9 +39,57 @@ class RelationshipGroupCursor extends RelationshipGroupRecord
this.read = read;
}
- void init( NeoStores stores, long nodeReference, long reference )
+ void buffer( long nodeReference, long relationshipReference )
{
- throw new UnsupportedOperationException( "not implemented" );
+ setOwningNode( nodeReference );
+ setId( NO_ID );
+ setNext( NO_ID );
+ // TODO: read first record to get the required capacity (from the count value in the prev field)
+ try ( PrimitiveIntObjectMap buffer = Primitive.intObjectMap() )
+ {
+ Group current = null;
+ while ( relationshipReference != NO_ID )
+ {
+ read.relationship( edge, relationshipReference );
+ // find the group
+ Group group = buffer.get( edge.getType() );
+ if ( group == null )
+ {
+ buffer.put( edge.getType(), current = group = new Group( edge, current ) );
+ }
+ // buffer the relationship into the group
+ if ( edge.getFirstNode() == nodeReference ) // outgoing or loop
+ {
+ if ( edge.getSecondNode() == nodeReference ) // loop
+ {
+ group.loop( edge );
+ }
+ else // outgoing
+ {
+ group.outgoing( edge );
+ }
+ relationshipReference = edge.getFirstNextRel();
+ }
+ else if ( edge.getSecondNode() == nodeReference ) // incoming
+ {
+ group.incoming( edge );
+ relationshipReference = edge.getSecondNextRel();
+ }
+ else
+ {
+ throw new IllegalStateException( "not a part of the chain! TODO: better exception" );
+ }
+ }
+ this.current = new Group( edge, current ); // we need a dummy before the first to denote the initial pos
+ }
+ }
+
+ void direct( long nodeReference, long reference )
+ {
+ setOwningNode( nodeReference );
+ current = null;
+ clear();
+ setNext( reference );
}
@Override
@@ -54,7 +107,25 @@ public void resume( Position position )
@Override
public boolean next()
{
- throw new UnsupportedOperationException( "not implemented" );
+ if ( current != null )
+ {
+ current = current.next;
+ if ( current == null )
+ {
+ return false; // we never have both types of traversal, so terminate early
+ }
+ setType( current.label );
+ setFirstOut( current.outgoing() );
+ setFirstIn( current.incoming() );
+ setFirstLoop( current.loops() );
+ return true;
+ }
+ if ( getNext() == NO_ID )
+ {
+ return false;
+ }
+ read.group( this, getNext() );
+ return true;
}
@Override
@@ -66,66 +137,191 @@ public boolean shouldRetry()
@Override
public void close()
{
- throw new UnsupportedOperationException( "not implemented" );
+ current = null;
+ setId( NO_ID );
+ clear();
}
@Override
public int relationshipLabel()
{
- throw new UnsupportedOperationException( "not implemented" );
+ return getType();
}
@Override
public int outgoingCount()
{
- throw new UnsupportedOperationException( "not implemented" );
+ if ( current != null )
+ {
+ return current.outgoingCount;
+ }
+ return count( outgoingReference() );
}
@Override
public int incomingCount()
{
- throw new UnsupportedOperationException( "not implemented" );
+ if ( current != null )
+ {
+ return current.incomingCount;
+ }
+ return count( incomingReference() );
}
@Override
public int loopCount()
{
- throw new UnsupportedOperationException( "not implemented" );
+ if ( current != null )
+ {
+ return current.loopsCount;
+ }
+ return count( loopsReference() );
+ }
+
+ private int count( long reference )
+ {
+ if ( reference == NO_ID )
+ {
+ return 0;
+ }
+ read.relationship( edge, reference );
+ if ( edge.getFirstNode() == getOwningNode() )
+ {
+ return (int) edge.getFirstPrevRel();
+ }
+ else
+ {
+ return (int) edge.getSecondPrevRel();
+ }
}
@Override
- public void outgoing( RelationshipTraversalCursor cursor )
+ public void outgoing( org.neo4j.internal.kernel.api.RelationshipTraversalCursor cursor )
{
- throw new UnsupportedOperationException( "not implemented" );
+ if ( current != null && cursor instanceof RelationshipTraversalCursor )
+ {
+ ((RelationshipTraversalCursor) cursor).buffered( getOwningNode(), current.outgoing );
+ }
+ else
+ {
+ read.relationships( getOwningNode(), outgoingReference(), cursor );
+ }
}
@Override
- public void incoming( RelationshipTraversalCursor cursor )
+ public void incoming( org.neo4j.internal.kernel.api.RelationshipTraversalCursor cursor )
{
- throw new UnsupportedOperationException( "not implemented" );
+ if ( current != null && cursor instanceof RelationshipTraversalCursor )
+ {
+ ((RelationshipTraversalCursor) cursor).buffered( getOwningNode(), current.incoming );
+ }
+ else
+ {
+ read.relationships( getOwningNode(), incomingReference(), cursor );
+ }
}
@Override
- public void loops( RelationshipTraversalCursor cursor )
+ public void loops( org.neo4j.internal.kernel.api.RelationshipTraversalCursor cursor )
{
- throw new UnsupportedOperationException( "not implemented" );
+ if ( current != null && cursor instanceof RelationshipTraversalCursor )
+ {
+ ((RelationshipTraversalCursor) cursor).buffered( getOwningNode(), current.loops );
+ }
+ else
+ {
+ read.relationships( getOwningNode(), loopsReference(), cursor );
+ }
}
@Override
public long outgoingReference()
{
- throw new UnsupportedOperationException( "not implemented" );
+ return getFirstOut();
}
@Override
public long incomingReference()
{
- throw new UnsupportedOperationException( "not implemented" );
+ return getFirstIn();
}
@Override
public long loopsReference()
{
- throw new UnsupportedOperationException( "not implemented" );
+ return getFirstLoop();
+ }
+
+ static class Group
+ {
+ final int label;
+ final Group next;
+ RelationshipTraversalCursor.Record outgoing;
+ RelationshipTraversalCursor.Record incoming;
+ RelationshipTraversalCursor.Record loops;
+ private long firstOut = NO_ID;
+ private long firstIn = NO_ID;
+ private long firstLoop = NO_ID;
+ int outgoingCount;
+ int incomingCount;
+ int loopsCount;
+
+ Group( RelationshipRecord edge, Group next )
+ {
+ this.label = edge.getType();
+ this.next = next;
+ }
+
+ void outgoing( RelationshipRecord edge )
+ {
+ if ( outgoing == null )
+ {
+ firstOut = edge.getId();
+ }
+ outgoing = new RelationshipTraversalCursor.Record( edge, outgoing );
+ outgoingCount++;
+ }
+
+ void incoming( RelationshipRecord edge )
+ {
+ if ( incoming == null )
+ {
+ firstIn = edge.getId();
+ }
+ incoming = new RelationshipTraversalCursor.Record( edge, incoming );
+ incomingCount++;
+ }
+
+ void loop( RelationshipRecord edge )
+ {
+ if ( loops == null )
+ {
+ firstLoop = edge.getId();
+ }
+ loops = new RelationshipTraversalCursor.Record( edge, loops );
+ loopsCount++;
+ }
+
+ long outgoing()
+ {
+ return flaggedAsRequiringFiltering( firstOut );
+ }
+
+ long incoming()
+ {
+ return flaggedAsRequiringFiltering( firstIn );
+ }
+
+ long loops()
+ {
+ return flaggedAsRequiringFiltering( firstLoop );
+ }
+
+ private long flaggedAsRequiringFiltering( long reference )
+ {
+ // set a high order bit as flag noting that "filtering is required"
+ // invert the reference to note that "this reference is special"
+ return invertReference( reference | 0x2000_0000_0000_0000L );
+ }
}
}
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/RelationshipScanCursor.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/RelationshipScanCursor.java
index b9b26e44a3726..a522c286b31f1 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/RelationshipScanCursor.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/RelationshipScanCursor.java
@@ -62,22 +62,28 @@ public boolean next()
close();
return false;
}
- read.relationship( this, next++ );
- if ( next > highMark )
+ do
{
- if ( highMark == NO_ID )
+ read.relationship( this, next++ );
+ if ( next > highMark )
{
- next = NO_ID;
- }
- else
- {
- highMark = read.relationshipHighMark();
- if ( next > highMark )
+ if ( highMark == NO_ID )
{
next = NO_ID;
+ return (label == -1 || label() == label) && inUse();
+ }
+ else
+ {
+ highMark = read.relationshipHighMark();
+ if ( next > highMark )
+ {
+ next = NO_ID;
+ return (label == -1 || label() == label) && inUse();
+ }
}
}
}
+ while ( !inUse() );
}
while ( label != -1 && label() != label );
return true;
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/RelationshipTraversalCursor.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/RelationshipTraversalCursor.java
index ccd117cd9f423..1aa4bdba23d4e 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/RelationshipTraversalCursor.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/RelationshipTraversalCursor.java
@@ -20,6 +20,7 @@
package org.neo4j.kernel.impl.newapi;
import org.neo4j.internal.kernel.api.NodeCursor;
+import org.neo4j.kernel.impl.store.record.RelationshipRecord;
class RelationshipTraversalCursor extends RelationshipCursor
implements org.neo4j.internal.kernel.api.RelationshipTraversalCursor
@@ -32,13 +33,23 @@ class RelationshipTraversalCursor extends RelationshipCursor
super( read );
}
- void init( long nodeReference, long reference )
+ void buffered( long nodeReference, Record record )
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+
+ void chain( long nodeReference, long reference )
{
setId( NO_ID );
originNodeReference = nodeReference;
next = reference;
}
+ void groups( long nodeReference, long reference )
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+
@Override
public Position suspend()
{
@@ -117,4 +128,14 @@ public void close()
{
setId( next = NO_ID );
}
+
+ static class Record
+ {
+ final Record next;
+
+ Record( RelationshipRecord record, Record next )
+ {
+ this.next = next;
+ }
+ }
}
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/TempKernel.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/TempKernel.java
new file mode 100644
index 0000000000000..bd6f1add6f390
--- /dev/null
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/TempKernel.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2002-2017 "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.newapi;
+
+import org.neo4j.internal.kernel.api.CursorFactory;
+import org.neo4j.internal.kernel.api.KernelAPI;
+import org.neo4j.internal.kernel.api.Token;
+import org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine;
+import org.neo4j.kernel.impl.store.NeoStores;
+import org.neo4j.kernel.internal.GraphDatabaseAPI;
+import org.neo4j.values.storable.Value;
+
+class TempKernel implements KernelAPI
+{
+ private final Transaction tx;
+ private final Cursors cursors;
+
+ TempKernel( GraphDatabaseAPI db )
+ {
+ RecordStorageEngine engine = db.getDependencyResolver().resolveDependency( RecordStorageEngine.class );
+ this.tx = new Transaction( engine.testAccessNeoStores() );
+ this.cursors = new Cursors( tx );
+ }
+
+ @Override
+ public Transaction beginTransaction()
+ {
+ return tx;
+ }
+
+ @Override
+ public CursorFactory cursors()
+ {
+ return cursors;
+ }
+
+ @Override
+ public Token token()
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+
+ private static class Transaction extends Read implements org.neo4j.internal.kernel.api.Transaction
+ {
+ Transaction( NeoStores stores )
+ {
+ super( stores );
+ }
+
+ @Override
+ public void success()
+ {
+ }
+
+ @Override
+ public void failure()
+ {
+ }
+
+ @Override
+ public void close() throws Exception
+ {
+ }
+
+ @Override
+ public long nodeCreate()
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+
+ @Override
+ public void nodeDelete( long node )
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+
+ @Override
+ public long relationshipCreate( long sourceNode, int relationshipLabel, long targetNode )
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+
+ @Override
+ public void relationshipDelete( long relationship )
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+
+ @Override
+ public void nodeAddLabel( long node, int nodeLabel )
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+
+ @Override
+ public void nodeRemoveLabel( long node, int nodeLabel )
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+
+ @Override
+ public void nodeSetProperty( long node, int propertyKey, Object value )
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+
+ @Override
+ public void nodeRemoveProperty( long node, int propertyKey )
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+
+ @Override
+ public void relationshipSetProperty( long relationship, int propertyKey, Value value )
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+
+ @Override
+ public void relationshipRemoveProperty( long node, int propertyKey )
+ {
+ throw new UnsupportedOperationException( "not implemented" );
+ }
+ }
+}
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/CommonAbstractStore.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/CommonAbstractStore.java
index 0a3718a704480..515b24972378b 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/CommonAbstractStore.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/CommonAbstractStore.java
@@ -1038,7 +1038,7 @@ public RECORD getRecord( long id, RECORD record, RecordLoad mode )
}
}
- void readIntoRecord( long id, RECORD record, RecordLoad mode, PageCursor cursor ) throws IOException
+ public void readIntoRecord( long id, RECORD record, RecordLoad mode, PageCursor cursor ) throws IOException
{
// Mark the record with this id regardless of whether or not we load the contents of it.
// This is done in this method since there are multiple call sites and they all want the id
diff --git a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/CursorFactoryTestBase.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/NodeCursorTest.java
similarity index 74%
rename from community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/CursorFactoryTestBase.java
rename to community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/NodeCursorTest.java
index 951c50edbba88..371f9e59a85ba 100644
--- a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/CursorFactoryTestBase.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/NodeCursorTest.java
@@ -17,8 +17,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package org.neo4j.internal.kernel.api;
+package org.neo4j.kernel.impl.newapi;
-public class CursorFactoryTestBase
+import org.neo4j.internal.kernel.api.NodeCursorTestBase;
+
+public class NodeCursorTest extends NodeCursorTestBase
{
+ @Override
+ public ReadTestSupport newTestSupport()
+ {
+ return new ReadTestSupport();
+ }
}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/PropertyCursorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/PropertyCursorTest.java
new file mode 100644
index 0000000000000..04c9b40284e21
--- /dev/null
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/PropertyCursorTest.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2002-2017 "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.newapi;
+
+import org.neo4j.internal.kernel.api.PropertyCursorTestBase;
+
+public class PropertyCursorTest extends PropertyCursorTestBase
+{
+ @Override
+ public ReadTestSupport newTestSupport()
+ {
+ return new ReadTestSupport();
+ }
+}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/ReadTestSupport.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/ReadTestSupport.java
new file mode 100644
index 0000000000000..acc2d5bc94d78
--- /dev/null
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/ReadTestSupport.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2002-2017 "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.newapi;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.function.Consumer;
+
+import org.neo4j.graphdb.GraphDatabaseService;
+import org.neo4j.internal.kernel.api.KernelAPI;
+import org.neo4j.internal.kernel.api.KernelAPIReadTestSupport;
+import org.neo4j.kernel.internal.GraphDatabaseAPI;
+import org.neo4j.test.TestGraphDatabaseFactory;
+
+class ReadTestSupport implements KernelAPIReadTestSupport
+{
+ private GraphDatabaseService db;
+
+ @Override
+ public void setup( File storeDir, Consumer create ) throws IOException
+ {
+ db = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder( storeDir ).newGraphDatabase();
+ create.accept( db );
+ }
+
+ @Override
+ public void beforeEachTest()
+ {
+ }
+
+ @Override
+ public KernelAPI kernelToTest()
+ {
+ return new TempKernel( (GraphDatabaseAPI) db );
+ }
+
+ @Override
+ public void tearDown()
+ {
+ db.shutdown();
+ db = null;
+ }
+}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/RelationshipScanCursorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/RelationshipScanCursorTest.java
new file mode 100644
index 0000000000000..aad4f3f06fecf
--- /dev/null
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/RelationshipScanCursorTest.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2002-2017 "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.newapi;
+
+import org.neo4j.internal.kernel.api.RelationshipScanCursorTestBase;
+
+public class RelationshipScanCursorTest extends RelationshipScanCursorTestBase
+{
+ @Override
+ public ReadTestSupport newTestSupport()
+ {
+ return new ReadTestSupport();
+ }
+}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/RelationshipTraversalCursorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/RelationshipTraversalCursorTest.java
new file mode 100644
index 0000000000000..e240d48f4c56d
--- /dev/null
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/RelationshipTraversalCursorTest.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2002-2017 "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.newapi;
+
+import org.neo4j.internal.kernel.api.RelationshipTraversalCursorTestBase;
+
+public class RelationshipTraversalCursorTest extends RelationshipTraversalCursorTestBase
+{
+ @Override
+ public ReadTestSupport newTestSupport()
+ {
+ return new ReadTestSupport();
+ }
+}
diff --git a/community/values/src/main/java/org/neo4j/values/storable/BooleanValue.java b/community/values/src/main/java/org/neo4j/values/storable/BooleanValue.java
index 6e55c40bc0469..b017d3bfe4a12 100644
--- a/community/values/src/main/java/org/neo4j/values/storable/BooleanValue.java
+++ b/community/values/src/main/java/org/neo4j/values/storable/BooleanValue.java
@@ -27,9 +27,11 @@
*/
public final class BooleanValue extends ScalarValue
{
+ static final BooleanValue TRUE = new BooleanValue( true );
+ static final BooleanValue FALSE = new BooleanValue( false );
private final boolean value;
- BooleanValue( boolean value )
+ private BooleanValue( boolean value )
{
this.value = value;
}
diff --git a/community/values/src/main/java/org/neo4j/values/storable/Values.java b/community/values/src/main/java/org/neo4j/values/storable/Values.java
index d510138964a12..d7efae172ae81 100644
--- a/community/values/src/main/java/org/neo4j/values/storable/Values.java
+++ b/community/values/src/main/java/org/neo4j/values/storable/Values.java
@@ -190,7 +190,7 @@ public static ByteValue byteValue( byte value )
public static BooleanValue booleanValue( boolean value )
{
- return new BooleanValue( value );
+ return value ? BooleanValue.TRUE : BooleanValue.FALSE;
}
public static CharValue charValue( char value )