Skip to content

Commit

Permalink
[BIRT-859] Fix bugs when write data out.
Browse files Browse the repository at this point in the history
Two issue there:
1. FolderArchiveEntry didn't get flushed, when flushbuffer() is called.
2. Buffer mechnism error in RAStreamBufferMgr, leading to flush header
buffer every time, even in reader stream!

Signed-off-by: xinzhao-acutate <xzhao@actuate.com>
  • Loading branch information
xinzhao-actuate authored and greatyan committed Sep 21, 2015
1 parent 53bc39e commit 7cfa1fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public void write( long pos, byte[] b, int off, int len )
{
out.seek( pos );
out.write( b, off, len );
out.flush( );
}

public void close( ) throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public RAStreamBufferMgr( RandomAccessFile randomFile ) throws IOException
this.randomFile = randomFile;
this.length = randomFile.length( );
this.totalBuffer = 0;
this.currentBuffer = getBuffer( 0 );
this.currentBuffer = null;
}

/*
* The file pointer in the underlying file if no buffer is used.
*/
public long getFilePointer( )
{
return currentBuffer.getOffset() + currentBuffer.getBufCur();
return currentBuffer == null ? 0 : currentBuffer.getOffset() + currentBuffer.getBufCur();
}

/*
Expand All @@ -65,6 +65,9 @@ public long getFilePointer( )
*/
public void write (byte b[], int off, int len ) throws IOException
{
if ( currentBuffer == null ) {
currentBuffer = getBuffer( 0 );
}
while ( len > 0 )
{
int ret = currentBuffer.write( b, off, len );
Expand All @@ -88,7 +91,7 @@ public void seek( long localPos ) throws IOException
{
long offset = ( localPos / IOUtil.RA_STREAM_BUFFER_LENGTH )
* IOUtil.RA_STREAM_BUFFER_LENGTH;
if ( currentBuffer.getOffset() != offset )
if ( currentBuffer == null || currentBuffer.getOffset() != offset )
currentBuffer = getBuffer( offset );
currentBuffer.setBufCur( (int)(localPos - offset) );
if ( localPos > length )
Expand Down

0 comments on commit 7cfa1fb

Please sign in to comment.