tmf: Fix BufferedRandomAccessFile
authorPatrick Tasse <patrick.tasse@gmail.com>
Fri, 24 Mar 2017 22:08:21 +0000 (18:08 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Wed, 5 Apr 2017 14:58:42 +0000 (10:58 -0400)
commitf698c776e14240cd0508523191c05d46c8f0de76
tree05b88f3d37baf810dadbe79146feb377836174b3
parent567cb91277f6086ed83e52da3dc0aa8985251cca
tmf: Fix BufferedRandomAccessFile

The method read(byte[]) was not overloaded and therefore reading
natively at the real file pointer, which could be different than the
buffered file pointer set at the last seek or read. The method now reads
from the buffer.

The write methods were not overloaded, and had the same issues. The real
file pointer is now synched with the buffered file pointer before the
write, and the buffered file pointer is synched with the real file
pointer after the write.

When repeatedly seeking backwards and reading, the buffer was
invalidated and filled at every iteration. The file will now position
itself to read ahead by half of the buffer size when seeking backwards.
This will improve the chance to benefit from the read buffer.

Unit tests are added.

Change-Id: If9662844818f1500f8d403b1120083892e788188
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/93840
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.core.tests/META-INF/MANIFEST.MF
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/io/BufferedRandomAccessFileTest.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/io/BufferedRandomAccessFile.java
This page took 0.025058 seconds and 5 git commands to generate.