Skip to content

Commit

Permalink
Fix: Store copy decorator printing negative sizes.
Browse files Browse the repository at this point in the history
The implementation kept the totalWritten in an int instead of a long.
This had no functional impact, since only the decorator ever used
the number.
  • Loading branch information
martinfurmanski committed Jan 16, 2015
1 parent da47a39 commit 5466956
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Expand Up @@ -230,11 +230,11 @@ private StoreWriter decorateWithProgressIndicator( final StoreWriter actual )
private int totalFiles; private int totalFiles;


@Override @Override
public int write( String path, ReadableByteChannel data, ByteBuffer temporaryBuffer, public long write( String path, ReadableByteChannel data, ByteBuffer temporaryBuffer,
boolean hasData ) throws IOException boolean hasData ) throws IOException
{ {
console.log( "Copying " + path ); console.log( "Copying " + path );
int written = actual.write( path, data, temporaryBuffer, hasData ); long written = actual.write( path, data, temporaryBuffer, hasData );
console.log( "Copied " + path + " " + bytes( written ) ); console.log( "Copied " + path + " " + bytes( written ) );
totalFiles++; totalFiles++;
return written; return written;
Expand Down
Expand Up @@ -29,7 +29,7 @@ public interface StoreWriter extends Closeable
// "hasData" is an effect of the block format not supporting a zero length block // "hasData" is an effect of the block format not supporting a zero length block
// whereas a neostore file may actually be 0 bytes we'll have to keep track // whereas a neostore file may actually be 0 bytes we'll have to keep track
// of that special case. // of that special case.
int write( String path, ReadableByteChannel data, ByteBuffer temporaryBuffer, boolean hasData ) long write( String path, ReadableByteChannel data, ByteBuffer temporaryBuffer, boolean hasData )
throws IOException; throws IOException;


@Override @Override
Expand Down
Expand Up @@ -36,7 +36,7 @@ public ToFileStoreWriter( File graphDbStoreDir )
} }


@Override @Override
public int write( String path, ReadableByteChannel data, ByteBuffer temporaryBuffer, public long write( String path, ReadableByteChannel data, ByteBuffer temporaryBuffer,
boolean hasData ) throws IOException boolean hasData ) throws IOException
{ {
try try
Expand All @@ -47,7 +47,7 @@ public int write( String path, ReadableByteChannel data, ByteBuffer temporaryBuf
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
try ( RandomAccessFile randomAccessFile = new RandomAccessFile( file, "rw" ) ) try ( RandomAccessFile randomAccessFile = new RandomAccessFile( file, "rw" ) )
{ {
int totalWritten = 0; long totalWritten = 0;
if ( hasData ) if ( hasData )
{ {
FileChannel channel = randomAccessFile.getChannel(); FileChannel channel = randomAccessFile.getChannel();
Expand Down
Expand Up @@ -42,7 +42,7 @@ public ToNetworkStoreWriter( ChannelBuffer targetBuffer, Monitors monitors )
} }


@Override @Override
public int write( String path, ReadableByteChannel data, ByteBuffer temporaryBuffer, public long write( String path, ReadableByteChannel data, ByteBuffer temporaryBuffer,
boolean hasData ) throws IOException boolean hasData ) throws IOException
{ {
char[] chars = path.toCharArray(); char[] chars = path.toCharArray();
Expand All @@ -51,7 +51,7 @@ public int write( String path, ReadableByteChannel data, ByteBuffer temporaryBuf
targetBuffer.writeByte( hasData ? 1 : 0 ); targetBuffer.writeByte( hasData ? 1 : 0 );
// TODO Make use of temporaryBuffer? // TODO Make use of temporaryBuffer?
BlockLogBuffer buffer = new BlockLogBuffer( targetBuffer, bufferMonitor ); BlockLogBuffer buffer = new BlockLogBuffer( targetBuffer, bufferMonitor );
int totalWritten = 2 + chars.length*2 + 1; long totalWritten = 2 + chars.length*2 + 1;
if ( hasData ) if ( hasData )
{ {
totalWritten += buffer.write( data ); totalWritten += buffer.write( data );
Expand Down

0 comments on commit 5466956

Please sign in to comment.