Skip to content

Commit

Permalink
Renamed PageHandle to PageManager
Browse files Browse the repository at this point in the history
  • Loading branch information
fickludd committed Jun 25, 2017
1 parent c25528a commit eee7a40
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
Expand Up @@ -24,7 +24,7 @@
abstract class MemoryAccess abstract class MemoryAccess
{ {
long virtualAddress; long virtualAddress;
PageHandle page; PageManager pageman;
long pageId; long pageId;
long base; long base;
int offset; int offset;
Expand All @@ -34,30 +34,30 @@ abstract class MemoryAccess


final void closeAccess() final void closeAccess()
{ {
if ( page != null ) if ( pageman != null )
{ {
try try
{ {
page.releasePage( pageId, base, offset, lockToken ); pageman.releasePage( pageId, base, offset, lockToken );
} }
finally finally
{ {
page = null; pageman = null;
} }
} }
} }


public final boolean hasPageReference() public final boolean hasPageReference()
{ {
return page != null; return pageman != null;
} }


final void access( long virtualAddress, PageHandle page, long pageId, long base, int offset ) final void access( long virtualAddress, PageManager pageman, long pageId, long base, int offset )
{ {
// TODO: this method is too large to inline... // TODO: this method is too large to inline...
if ( this.page != null ) if ( this.pageman != null )
{ {
if ( this.page != page || this.pageId != pageId ) if ( this.pageman != pageman || this.pageId != pageId )
{ {
closeAccess(); closeAccess();
} }
Expand All @@ -67,31 +67,31 @@ final void access( long virtualAddress, PageHandle page, long pageId, long base,
} }
} }
this.virtualAddress = virtualAddress; this.virtualAddress = virtualAddress;
this.page = page; this.pageman = pageman;
this.pageId = pageId; this.pageId = pageId;
this.base = base; this.base = base;
this.offset = offset; this.offset = offset;
} }


final void lockShared() final void lockShared()
{ {
lockToken = page.sharedLock( pageId, base, offset ); lockToken = pageman.sharedLock( pageId, base, offset );
} }


final void lockExclusive() final void lockExclusive()
{ {
lockToken = page.exclusiveLock( pageId, base, offset ); lockToken = pageman.exclusiveLock( pageId, base, offset );
} }


final void lockRelease() final void lockRelease()
{ {
page.releaseLock( pageId, base, offset, lockToken ); pageman.releaseLock( pageId, base, offset, lockToken );
lockToken = 0; lockToken = 0;
} }


final long address( int offset, int size ) final long address( int offset, int size )
{ {
if ( page == null ) if ( pageman == null )
{ {
throw new IllegalStateException( "Cursor has not been initialized." ); throw new IllegalStateException( "Cursor has not been initialized." );
} }
Expand Down
Expand Up @@ -21,7 +21,7 @@


public abstract class MemoryManager public abstract class MemoryManager
{ {
protected static void setup( ReadCursor cursor, long virtualAddress, PageHandle page, long pageId, long base, protected static void setup( ReadCursor cursor, long virtualAddress, PageManager page, long pageId, long base,
int offset ) int offset )
{ {
cursor.access( virtualAddress, page, pageId, base, offset ); cursor.access( virtualAddress, page, pageId, base, offset );
Expand All @@ -30,7 +30,7 @@ protected static void setup( ReadCursor cursor, long virtualAddress, PageHandle
protected static void read( protected static void read(
ReadCursor cursor, ReadCursor cursor,
long virtualAddress, long virtualAddress,
PageHandle page, PageManager page,
long pageId, long pageId,
long base, long base,
int offset, int offset,
Expand All @@ -43,7 +43,7 @@ protected static void read(


protected static void move( ReadCursor cursor, long virtualAddress, int offset, int bound ) protected static void move( ReadCursor cursor, long virtualAddress, int offset, int bound )
{ {
PageHandle page = cursor.page; PageManager page = cursor.pageman;
long pageId = cursor.pageId; long pageId = cursor.pageId;
long base = cursor.base; long base = cursor.base;
page.assertValidOffset( pageId, base, offset, bound ); page.assertValidOffset( pageId, base, offset, bound );
Expand All @@ -54,7 +54,7 @@ protected static void move( ReadCursor cursor, long virtualAddress, int offset,
protected static void write( protected static void write(
Writer writer, Writer writer,
long virtualAddress, long virtualAddress,
PageHandle page, PageManager page,
long pageId, long pageId,
long base, long base,
int offset, int offset,
Expand Down
Expand Up @@ -19,7 +19,7 @@
*/ */
package org.neo4j.impl.store.cursors; package org.neo4j.impl.store.cursors;


public abstract class PageHandle extends MemoryManager public abstract class PageManager extends MemoryManager
{ {
protected abstract void releasePage( long pageId, long base, int offset, long lockToken ); protected abstract void releasePage( long pageId, long base, int offset, long lockToken );


Expand Down
Expand Up @@ -23,7 +23,7 @@ public abstract class ReadCursor extends MemoryAccess implements AutoCloseable
{ {
public final boolean shouldRetry() public final boolean shouldRetry()
{ {
long token = page.refreshLockToken( pageId, base, offset, lockToken ); long token = pageman.refreshLockToken( pageId, base, offset, lockToken );
if ( token != lockToken ) if ( token != lockToken )
{ {
lockToken = token; lockToken = token;
Expand All @@ -35,7 +35,7 @@ public final boolean shouldRetry()
} }
} }


protected final void prepareReadCursor( long virtualAddress, PageHandle page, long pageId, long base ) protected final void prepareReadCursor( long virtualAddress, PageManager page, long pageId, long base )
{ {
access( virtualAddress, page, pageId, base, 0 ); access( virtualAddress, page, pageId, base, 0 );
} }
Expand All @@ -51,11 +51,11 @@ protected final long virtualAddress()
*/ */
protected final boolean gotoVirtualAddress( long virtualAddress ) protected final boolean gotoVirtualAddress( long virtualAddress )
{ {
if ( page == null ) if ( pageman == null )
{ {
throw new IllegalStateException( "Cursor has not been initialized." ); throw new IllegalStateException( "Cursor has not been initialized." );
} }
return page.gotoVirtualAddress( virtualAddress, this, pageId, base, offset, lockToken ); return pageman.gotoVirtualAddress( virtualAddress, this, pageId, base, offset, lockToken );
} }


protected boolean scanNextByVirtualAddress( long maxAddress ) protected boolean scanNextByVirtualAddress( long maxAddress )
Expand Down
Expand Up @@ -31,15 +31,15 @@
import java.nio.MappedByteBuffer; import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;


import org.neo4j.impl.store.cursors.PageHandle; import org.neo4j.impl.store.cursors.PageManager;
import org.neo4j.impl.store.cursors.ReadCursor; import org.neo4j.impl.store.cursors.ReadCursor;


import static java.lang.Math.max; import static java.lang.Math.max;
import static java.nio.channels.FileChannel.MapMode.READ_ONLY; import static java.nio.channels.FileChannel.MapMode.READ_ONLY;
import static org.neo4j.impl.store.prototype.neole.ReadStore.lcm; import static org.neo4j.impl.store.prototype.neole.ReadStore.lcm;
import static org.neo4j.impl.store.prototype.neole.ReadStore.nextPowerOfTwo; import static org.neo4j.impl.store.prototype.neole.ReadStore.nextPowerOfTwo;


abstract class StoreFile extends PageHandle implements Closeable abstract class StoreFile extends PageManager implements Closeable
{ {
static StoreFile fixedSizeRecordFile( File file, int recordSize ) throws IOException static StoreFile fixedSizeRecordFile( File file, int recordSize ) throws IOException
{ {
Expand Down

0 comments on commit eee7a40

Please sign in to comment.