Skip to content

Commit

Permalink
Moves store cursors to the the recordstorage package
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint committed Jun 11, 2018
1 parent 4023dc1 commit 25d0ca9
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 54 deletions.
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.kernel.impl.newapi; package org.neo4j.kernel.impl.storageengine.impl.recordstorage;


import static org.neo4j.kernel.impl.store.record.AbstractBaseRecord.NO_ID; import static org.neo4j.kernel.impl.store.record.AbstractBaseRecord.NO_ID;


Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.kernel.impl.newapi; package org.neo4j.kernel.impl.storageengine.impl.recordstorage;


import java.util.function.LongPredicate; import java.util.function.LongPredicate;


Expand All @@ -30,7 +30,7 @@
import org.neo4j.kernel.impl.store.record.RecordLoad; import org.neo4j.kernel.impl.store.record.RecordLoad;
import org.neo4j.storageengine.api.StorageNodeCursor; import org.neo4j.storageengine.api.StorageNodeCursor;


public class StoreNodeCursor extends NodeRecord implements StorageNodeCursor class RecordNodeCursor extends NodeRecord implements StorageNodeCursor
{ {
private NodeStore read; private NodeStore read;
private RecordCursor<DynamicRecord> labelCursor; private RecordCursor<DynamicRecord> labelCursor;
Expand All @@ -40,7 +40,7 @@ public class StoreNodeCursor extends NodeRecord implements StorageNodeCursor
private long nextStoreReference; private long nextStoreReference;
private boolean open; private boolean open;


public StoreNodeCursor( NodeStore read ) RecordNodeCursor( NodeStore read )
{ {
super( NO_ID ); super( NO_ID );
this.read = read; this.read = read;
Expand Down Expand Up @@ -230,11 +230,11 @@ public String toString()
{ {
if ( !open ) if ( !open )
{ {
return "StoreNodeCursor[closed state]"; return "RecordNodeCursor[closed state]";
} }
else else
{ {
return "StoreNodeCursor[id=" + getId() + return "RecordNodeCursor[id=" + getId() +
", open state with: highMark=" + highMark + ", open state with: highMark=" + highMark +
", next=" + next + ", next=" + next +
", underlying record=" + super.toString() + " ]"; ", underlying record=" + super.toString() + " ]";
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.kernel.impl.newapi; package org.neo4j.kernel.impl.storageengine.impl.recordstorage;


import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.function.IntPredicate; import java.util.function.IntPredicate;
Expand Down Expand Up @@ -48,7 +48,7 @@
import org.neo4j.values.storable.ValueGroup; import org.neo4j.values.storable.ValueGroup;
import org.neo4j.values.storable.Values; import org.neo4j.values.storable.Values;


public class StorePropertyCursor extends PropertyRecord implements StoragePropertyCursor class RecordPropertyCursor extends PropertyRecord implements StoragePropertyCursor
{ {
private static final int MAX_BYTES_IN_SHORT_STRING_OR_SHORT_ARRAY = 32; private static final int MAX_BYTES_IN_SHORT_STRING_OR_SHORT_ARRAY = 32;
private static final int INITIAL_POSITION = -1; private static final int INITIAL_POSITION = -1;
Expand All @@ -62,7 +62,7 @@ public class StorePropertyCursor extends PropertyRecord implements StorageProper
private PageCursor arrayPage; private PageCursor arrayPage;
private boolean open; private boolean open;


public StorePropertyCursor( PropertyStore read ) RecordPropertyCursor( PropertyStore read )
{ {
super( NO_ID ); super( NO_ID );
this.read = read; this.read = read;
Expand Down Expand Up @@ -392,14 +392,14 @@ private void property( PropertyRecord record, long reference, PageCursor pageCur
read.getRecordByCursor( reference, record, RecordLoad.FORCE, pageCursor ); read.getRecordByCursor( reference, record, RecordLoad.FORCE, pageCursor );
} }


private TextValue string( org.neo4j.kernel.impl.newapi.StorePropertyCursor cursor, long reference, PageCursor page ) private TextValue string( RecordPropertyCursor cursor, long reference, PageCursor page )
{ {
ByteBuffer buffer = cursor.buffer = read.loadString( reference, cursor.buffer, page ); ByteBuffer buffer = cursor.buffer = read.loadString( reference, cursor.buffer, page );
buffer.flip(); buffer.flip();
return Values.stringValue( UTF8.decode( buffer.array(), 0, buffer.limit() ) ); return Values.stringValue( UTF8.decode( buffer.array(), 0, buffer.limit() ) );
} }


private ArrayValue array( org.neo4j.kernel.impl.newapi.StorePropertyCursor cursor, long reference, PageCursor page ) private ArrayValue array( RecordPropertyCursor cursor, long reference, PageCursor page )
{ {
ByteBuffer buffer = cursor.buffer = read.loadArray( reference, cursor.buffer, page ); ByteBuffer buffer = cursor.buffer = read.loadArray( reference, cursor.buffer, page );
buffer.flip(); buffer.flip();
Expand Down
Expand Up @@ -17,25 +17,22 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.kernel.impl.newapi; package org.neo4j.kernel.impl.storageengine.impl.recordstorage;


import org.neo4j.internal.kernel.api.NodeCursor;
import org.neo4j.internal.kernel.api.PropertyCursor;
import org.neo4j.io.pagecache.PageCursor; import org.neo4j.io.pagecache.PageCursor;
import org.neo4j.kernel.impl.api.RelationshipVisitor; import org.neo4j.kernel.impl.api.RelationshipVisitor;
import org.neo4j.kernel.impl.store.RelationshipGroupStore; import org.neo4j.kernel.impl.store.RelationshipGroupStore;
import org.neo4j.kernel.impl.store.RelationshipStore; import org.neo4j.kernel.impl.store.RelationshipStore;
import org.neo4j.kernel.impl.store.record.RecordLoad; import org.neo4j.kernel.impl.store.record.RecordLoad;
import org.neo4j.kernel.impl.store.record.RelationshipGroupRecord;
import org.neo4j.kernel.impl.store.record.RelationshipRecord; import org.neo4j.kernel.impl.store.record.RelationshipRecord;
import org.neo4j.storageengine.api.StorageRelationshipCursor; import org.neo4j.storageengine.api.StorageRelationshipCursor;


abstract class StoreRelationshipCursor extends RelationshipRecord implements RelationshipVisitor<RuntimeException>, StorageRelationshipCursor abstract class RecordRelationshipCursor extends RelationshipRecord implements RelationshipVisitor<RuntimeException>, StorageRelationshipCursor
{ {
final RelationshipStore relationshipStore; final RelationshipStore relationshipStore;
final RelationshipGroupStore groupStore; final RelationshipGroupStore groupStore;


StoreRelationshipCursor( RelationshipStore relationshipStore, RelationshipGroupStore groupStore ) RecordRelationshipCursor( RelationshipStore relationshipStore, RelationshipGroupStore groupStore )
{ {
super( NO_ID ); super( NO_ID );
this.relationshipStore = relationshipStore; this.relationshipStore = relationshipStore;
Expand Down
Expand Up @@ -17,24 +17,24 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.kernel.impl.newapi; package org.neo4j.kernel.impl.storageengine.impl.recordstorage;


import org.eclipse.collections.api.map.primitive.MutableIntObjectMap; import org.eclipse.collections.api.map.primitive.MutableIntObjectMap;
import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap;


import org.neo4j.io.pagecache.PageCursor; import org.neo4j.io.pagecache.PageCursor;
import org.neo4j.kernel.impl.newapi.StoreRelationshipTraversalCursor.Record; import org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordRelationshipTraversalCursor.Record;
import org.neo4j.kernel.impl.store.RelationshipGroupStore; import org.neo4j.kernel.impl.store.RelationshipGroupStore;
import org.neo4j.kernel.impl.store.RelationshipStore; import org.neo4j.kernel.impl.store.RelationshipStore;
import org.neo4j.kernel.impl.store.record.RecordLoad; import org.neo4j.kernel.impl.store.record.RecordLoad;
import org.neo4j.kernel.impl.store.record.RelationshipGroupRecord; import org.neo4j.kernel.impl.store.record.RelationshipGroupRecord;
import org.neo4j.kernel.impl.store.record.RelationshipRecord; import org.neo4j.kernel.impl.store.record.RelationshipRecord;
import org.neo4j.storageengine.api.StorageRelationshipGroupCursor; import org.neo4j.storageengine.api.StorageRelationshipGroupCursor;


import static org.neo4j.kernel.impl.newapi.GroupReferenceEncoding.isRelationship; import static org.neo4j.kernel.impl.storageengine.impl.recordstorage.GroupReferenceEncoding.isRelationship;
import static org.neo4j.kernel.impl.newapi.References.clearEncoding; import static org.neo4j.kernel.impl.storageengine.impl.recordstorage.References.clearEncoding;


public class StoreRelationshipGroupCursor extends RelationshipGroupRecord implements StorageRelationshipGroupCursor class RecordRelationshipGroupCursor extends RelationshipGroupRecord implements StorageRelationshipGroupCursor
{ {
private final RelationshipStore relationshipStore; private final RelationshipStore relationshipStore;
private final RelationshipGroupStore groupStore; private final RelationshipGroupStore groupStore;
Expand All @@ -45,7 +45,7 @@ public class StoreRelationshipGroupCursor extends RelationshipGroupRecord implem
private PageCursor edgePage; private PageCursor edgePage;
private boolean open; private boolean open;


public StoreRelationshipGroupCursor( RelationshipStore relationshipStore, RelationshipGroupStore groupStore ) RecordRelationshipGroupCursor( RelationshipStore relationshipStore, RelationshipGroupStore groupStore )
{ {
super( NO_ID ); super( NO_ID );
this.relationshipStore = relationshipStore; this.relationshipStore = relationshipStore;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.kernel.impl.newapi; package org.neo4j.kernel.impl.storageengine.impl.recordstorage;


import java.util.function.LongPredicate; import java.util.function.LongPredicate;


Expand All @@ -28,7 +28,7 @@
import org.neo4j.kernel.impl.store.record.RelationshipRecord; import org.neo4j.kernel.impl.store.record.RelationshipRecord;
import org.neo4j.storageengine.api.StorageRelationshipScanCursor; import org.neo4j.storageengine.api.StorageRelationshipScanCursor;


public class StoreRelationshipScanCursor extends StoreRelationshipCursor implements StorageRelationshipScanCursor class RecordRelationshipScanCursor extends RecordRelationshipCursor implements StorageRelationshipScanCursor
{ {
private int type; private int type;
private long next; private long next;
Expand All @@ -37,7 +37,7 @@ public class StoreRelationshipScanCursor extends StoreRelationshipCursor impleme
private PageCursor pageCursor; private PageCursor pageCursor;
private boolean open; private boolean open;


public StoreRelationshipScanCursor( RelationshipStore relationshipStore, RelationshipGroupStore groupStore ) RecordRelationshipScanCursor( RelationshipStore relationshipStore, RelationshipGroupStore groupStore )
{ {
super( relationshipStore, groupStore ); super( relationshipStore, groupStore );
} }
Expand Down
Expand Up @@ -17,19 +17,20 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.kernel.impl.newapi; package org.neo4j.kernel.impl.storageengine.impl.recordstorage;


import java.util.function.LongPredicate; import java.util.function.LongPredicate;


import org.neo4j.io.pagecache.PageCursor; import org.neo4j.io.pagecache.PageCursor;
import org.neo4j.kernel.impl.newapi.RelationshipDirection;
import org.neo4j.kernel.impl.store.RelationshipGroupStore; import org.neo4j.kernel.impl.store.RelationshipGroupStore;
import org.neo4j.kernel.impl.store.RelationshipStore; import org.neo4j.kernel.impl.store.RelationshipStore;
import org.neo4j.kernel.impl.store.record.RelationshipRecord; import org.neo4j.kernel.impl.store.record.RelationshipRecord;
import org.neo4j.storageengine.api.StorageRelationshipTraversalCursor; import org.neo4j.storageengine.api.StorageRelationshipTraversalCursor;


import static org.neo4j.kernel.impl.newapi.References.clearEncoding; import static org.neo4j.kernel.impl.storageengine.impl.recordstorage.References.clearEncoding;


public class StoreRelationshipTraversalCursor extends StoreRelationshipCursor implements StorageRelationshipTraversalCursor class RecordRelationshipTraversalCursor extends RecordRelationshipCursor implements StorageRelationshipTraversalCursor
{ {
private enum GroupState private enum GroupState
{ {
Expand All @@ -43,14 +44,14 @@ private enum GroupState
private long next; private long next;
private Record buffer; private Record buffer;
private PageCursor pageCursor; private PageCursor pageCursor;
private final StoreRelationshipGroupCursor group; private final RecordRelationshipGroupCursor group;
private GroupState groupState; private GroupState groupState;
private boolean open; private boolean open;


public StoreRelationshipTraversalCursor( RelationshipStore relationshipStore, RelationshipGroupStore groupStore ) RecordRelationshipTraversalCursor( RelationshipStore relationshipStore, RelationshipGroupStore groupStore )
{ {
super( relationshipStore, groupStore ); super( relationshipStore, groupStore );
this.group = new StoreRelationshipGroupCursor( relationshipStore, groupStore ); this.group = new RecordRelationshipGroupCursor( relationshipStore, groupStore );
} }


@Override @Override
Expand Down
Expand Up @@ -64,10 +64,6 @@
import org.neo4j.kernel.impl.core.TokenNotFoundException; import org.neo4j.kernel.impl.core.TokenNotFoundException;
import org.neo4j.kernel.impl.locking.Lock; import org.neo4j.kernel.impl.locking.Lock;
import org.neo4j.kernel.impl.locking.LockService; import org.neo4j.kernel.impl.locking.LockService;
import org.neo4j.kernel.impl.newapi.StoreNodeCursor;
import org.neo4j.kernel.impl.newapi.StoreRelationshipGroupCursor;
import org.neo4j.kernel.impl.newapi.StoreRelationshipScanCursor;
import org.neo4j.kernel.impl.newapi.StoreRelationshipTraversalCursor;
import org.neo4j.kernel.impl.store.InvalidRecordException; import org.neo4j.kernel.impl.store.InvalidRecordException;
import org.neo4j.kernel.impl.store.NeoStores; import org.neo4j.kernel.impl.store.NeoStores;
import org.neo4j.kernel.impl.store.NodeStore; import org.neo4j.kernel.impl.store.NodeStore;
Expand Down Expand Up @@ -946,30 +942,30 @@ public long getGraphPropertyReference()
@Override @Override
public StorageNodeCursor allocateNodeCursor() public StorageNodeCursor allocateNodeCursor()
{ {
return new StoreNodeCursor( nodeStore ); return new RecordNodeCursor( nodeStore );
} }


@Override @Override
public StorageRelationshipGroupCursor allocateRelationshipGroupCursor() public StorageRelationshipGroupCursor allocateRelationshipGroupCursor()
{ {
return new StoreRelationshipGroupCursor( relationshipStore, relationshipGroupStore ); return new RecordRelationshipGroupCursor( relationshipStore, relationshipGroupStore );
} }


@Override @Override
public StorageRelationshipTraversalCursor allocateRelationshipTraversalCursor() public StorageRelationshipTraversalCursor allocateRelationshipTraversalCursor()
{ {
return new StoreRelationshipTraversalCursor( relationshipStore, relationshipGroupStore ); return new RecordRelationshipTraversalCursor( relationshipStore, relationshipGroupStore );
} }


@Override @Override
public StorageRelationshipScanCursor allocateRelationshipScanCursor() public StorageRelationshipScanCursor allocateRelationshipScanCursor()
{ {
return new StoreRelationshipScanCursor( relationshipStore, relationshipGroupStore ); return new RecordRelationshipScanCursor( relationshipStore, relationshipGroupStore );
} }


@Override @Override
public StoragePropertyCursor allocatePropertyCursor() public StoragePropertyCursor allocatePropertyCursor()
{ {
return new org.neo4j.kernel.impl.newapi.StorePropertyCursor( propertyStore ); return new RecordPropertyCursor( propertyStore );
} }
} }
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.kernel.impl.newapi; package org.neo4j.kernel.impl.storageengine.impl.recordstorage;


import org.neo4j.kernel.impl.store.record.AbstractBaseRecord; import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;


Expand All @@ -33,10 +33,6 @@
* to silently detect that we have a group reference, parse the groups, and setup the cursor to serve relationship * to silently detect that we have a group reference, parse the groups, and setup the cursor to serve relationship
* via this mode instead. * via this mode instead.
* *
* The opposite problem also appears when the user acquires a relationship group reference from a non-dense node. See
* {@link org.neo4j.kernel.impl.newapi.Read#relationships(long, long,
* org.neo4j.internal.kernel.api.RelationshipTraversalCursor)} for more details.
*
* Node that {@code -1} is used to encode {@link AbstractBaseRecord#NO_ID that a reference is invalid}. In terms of * Node that {@code -1} is used to encode {@link AbstractBaseRecord#NO_ID that a reference is invalid}. In terms of
* encoding {@code -1} is considered to have all flags, to setting one will not change {@code -1}. This however also * encoding {@code -1} is considered to have all flags, to setting one will not change {@code -1}. This however also
* means that calling code must check for {@code -1} references before checking flags existence. * means that calling code must check for {@code -1} references before checking flags existence.
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.kernel.impl.newapi; package org.neo4j.kernel.impl.storageengine.impl.recordstorage;


import static org.neo4j.kernel.impl.store.record.AbstractBaseRecord.NO_ID; import static org.neo4j.kernel.impl.store.record.AbstractBaseRecord.NO_ID;


Expand Down
Expand Up @@ -46,7 +46,7 @@ public class PropertyRecord extends AbstractBaseRecord implements Iterable<Prope
private long nextProp; private long nextProp;
private long prevProp; private long prevProp;
// Holds the purely physical representation of the loaded properties in this record. This is so that // Holds the purely physical representation of the loaded properties in this record. This is so that
// StorePropertyCursor is able to use this raw data without the rather heavy and bloated data structures // RecordPropertyCursor is able to use this raw data without the rather heavy and bloated data structures
// of PropertyBlock and thereabouts. So when a property record is loaded only these blocks are read, // of PropertyBlock and thereabouts. So when a property record is loaded only these blocks are read,
// the construction of all PropertyBlock instances are loaded lazily when they are first needed, loaded // the construction of all PropertyBlock instances are loaded lazily when they are first needed, loaded
// by ensureBlocksLoaded(). // by ensureBlocksLoaded().
Expand Down
Expand Up @@ -83,7 +83,7 @@
import static org.neo4j.kernel.impl.store.record.RecordLoad.NORMAL; import static org.neo4j.kernel.impl.store.record.RecordLoad.NORMAL;


@RunWith( Enclosed.class ) @RunWith( Enclosed.class )
public class StorePropertyCursorTest public class RecordPropertyCursorTest
{ {
private static final List<Object[]> PARAMETERS = asList( private static final List<Object[]> PARAMETERS = asList(
new Object[]{false, PropertyType.BOOL}, new Object[]{false, PropertyType.BOOL},
Expand Down Expand Up @@ -206,7 +206,7 @@ public class StorePropertyCursorTest
PropertyType.STRING} PropertyType.STRING}
); );


private StorePropertyCursorTest() private RecordPropertyCursorTest()
{ {
} }


Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.kernel.impl.newapi; package org.neo4j.kernel.impl.storageengine.impl.recordstorage;


import org.junit.Test; import org.junit.Test;


Expand All @@ -29,9 +29,9 @@
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.neo4j.kernel.impl.newapi.References.clearEncoding; import static org.neo4j.kernel.impl.storageengine.impl.recordstorage.References.clearEncoding;
import static org.neo4j.kernel.impl.newapi.RelationshipReferenceEncoding.GROUP; import static org.neo4j.kernel.impl.storageengine.impl.recordstorage.RelationshipReferenceEncoding.GROUP;
import static org.neo4j.kernel.impl.newapi.RelationshipReferenceEncoding.parseEncoding; import static org.neo4j.kernel.impl.storageengine.impl.recordstorage.RelationshipReferenceEncoding.parseEncoding;
import static org.neo4j.kernel.impl.store.record.AbstractBaseRecord.NO_ID; import static org.neo4j.kernel.impl.store.record.AbstractBaseRecord.NO_ID;


public class ReferencesTest public class ReferencesTest
Expand Down

0 comments on commit 25d0ca9

Please sign in to comment.