Skip to content

Commit

Permalink
Small cleanups, variable name change and remove unused field
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Feb 18, 2019
1 parent 32eba2f commit 230ff34
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
Expand Up @@ -231,10 +231,10 @@ private int performSingleMerge( int mergeFactor, BlockReader<KEY,VALUE> reader,
} }
} }


private void writeBlock( StoreChannel targetChannel, BlockEntryCursor<KEY,VALUE> merger, long blockSize, long entryCount ) throws IOException private void writeBlock( StoreChannel targetChannel, BlockEntryCursor<KEY,VALUE> blockEntryCursor, long blockSize, long entryCount ) throws IOException
{ {
writeHeader( byteBuffer, blockSize, entryCount ); writeHeader( byteBuffer, blockSize, entryCount );
long actualDataSize = writeMergedBlock( targetChannel, byteBuffer, layout, merger ); long actualDataSize = writeEntries( targetChannel, byteBuffer, layout, blockEntryCursor );
writeLastEntriesWithPadding( targetChannel, byteBuffer, blockSize - actualDataSize ); writeLastEntriesWithPadding( targetChannel, byteBuffer, blockSize - actualDataSize );
} }


Expand All @@ -244,16 +244,16 @@ private static void writeHeader( ByteBuffer byteBuffer, long blockSize, long ent
byteBuffer.putLong( entryCount ); byteBuffer.putLong( entryCount );
} }


private static <KEY, VALUE> long writeMergedBlock( StoreChannel targetChannel, ByteBuffer byteBuffer, Layout<KEY,VALUE> layout, private static <KEY, VALUE> long writeEntries( StoreChannel targetChannel, ByteBuffer byteBuffer, Layout<KEY,VALUE> layout,
BlockEntryCursor<KEY,VALUE> merger ) throws IOException BlockEntryCursor<KEY,VALUE> blockEntryCursor ) throws IOException
{ {
// Loop over block entries // Loop over block entries
long actualDataSize = BLOCK_HEADER_SIZE; long actualDataSize = BLOCK_HEADER_SIZE;
ByteArrayPageCursor pageCursor = new ByteArrayPageCursor( byteBuffer ); ByteArrayPageCursor pageCursor = new ByteArrayPageCursor( byteBuffer );
while ( merger.next() ) while ( blockEntryCursor.next() )
{ {
KEY key = merger.key(); KEY key = blockEntryCursor.key();
VALUE value = merger.value(); VALUE value = blockEntryCursor.value();
int entrySize = BlockEntry.entrySize( layout, key, value ); int entrySize = BlockEntry.entrySize( layout, key, value );
actualDataSize += entrySize; actualDataSize += entrySize;


Expand Down
Expand Up @@ -24,7 +24,6 @@
import org.neo4j.index.internal.gbptree.Layout; import org.neo4j.index.internal.gbptree.Layout;
import org.neo4j.io.pagecache.PageCursor; import org.neo4j.io.pagecache.PageCursor;
import org.neo4j.kernel.impl.api.index.UpdateMode; import org.neo4j.kernel.impl.api.index.UpdateMode;
import org.neo4j.kernel.impl.transaction.log.ReadAheadChannel;


import static org.neo4j.kernel.impl.index.schema.IndexUpdateStorage.STOP_TYPE; import static org.neo4j.kernel.impl.index.schema.IndexUpdateStorage.STOP_TYPE;


Expand All @@ -34,7 +33,6 @@
*/ */
public class IndexUpdateCursor<KEY, VALUE> implements BlockEntryCursor<KEY,VALUE> public class IndexUpdateCursor<KEY, VALUE> implements BlockEntryCursor<KEY,VALUE>
{ {
private final ReadAheadChannel channel;
private final PageCursor cursor; private final PageCursor cursor;
private final Layout<KEY,VALUE> layout; private final Layout<KEY,VALUE> layout;


Expand All @@ -44,9 +42,8 @@ public class IndexUpdateCursor<KEY, VALUE> implements BlockEntryCursor<KEY,VALUE
private KEY key2; private KEY key2;
private VALUE value; private VALUE value;


public IndexUpdateCursor( ReadAheadChannel channel, PageCursor cursor, Layout<KEY,VALUE> layout ) IndexUpdateCursor( PageCursor cursor, Layout<KEY,VALUE> layout )
{ {
this.channel = channel;
this.cursor = cursor; this.cursor = cursor;
this.layout = layout; this.layout = layout;
this.key1 = layout.newKey(); this.key1 = layout.newKey();
Expand Down
Expand Up @@ -100,7 +100,7 @@ public void add( IndexEntryUpdate<?> update ) throws IOException
IndexUpdateEntry.write( pageCursor, layout, updateMode, key1, key2, value ); IndexUpdateEntry.write( pageCursor, layout, updateMode, key1, key2, value );
} }


public void doneAdding() throws IOException void doneAdding() throws IOException
{ {
if ( buffer.remaining() < TYPE_SIZE ) if ( buffer.remaining() < TYPE_SIZE )
{ {
Expand All @@ -114,7 +114,7 @@ public IndexUpdateCursor<KEY,VALUE> reader() throws IOException
{ {
ReadAheadChannel<StoreChannel> channel = new ReadAheadChannel<>( fs.open( file, OpenMode.READ ) ); ReadAheadChannel<StoreChannel> channel = new ReadAheadChannel<>( fs.open( file, OpenMode.READ ) );
PageCursor pageCursor = new ReadableChannelPageCursor( channel ); PageCursor pageCursor = new ReadableChannelPageCursor( channel );
return new IndexUpdateCursor<>( channel, pageCursor, layout ); return new IndexUpdateCursor<>( pageCursor, layout );
} }


private void flush() throws IOException private void flush() throws IOException
Expand Down

0 comments on commit 230ff34

Please sign in to comment.