Source:
private int applyOperation() throws IOException { if (ClientIOOperation.isRead(mParameters.mOperation)) { if (mInStream == null) { mInStream = mFs.open(mFilePath); } if (mParameters.mReadRandom) { mCurrentOffset = Math.abs(mRandom.nextLong()) % mMaxOffset; if (!ClientIOOperation.isPosRead(mParameters.mOperation)) { mInStream.seek(mCurrentOffset); } } else { mCurrentOffset += mBuffer.length; if (mCurrentOffset > mMaxOffset) { mCurrentOffset = 0; } } } switch (mParameters.mOperation) { case ReadArray: { int bytesRead = mInStream.read(mBuffer); if (bytesRead < 0) { closeInStream(); mInStream = mFs.open(mFilePath); } return bytesRead; } case ReadByteBuffer: { int bytesRead = mInStream.read(mByteBuffer); if (bytesRead < 0) { closeInStream(); mInStream = mFs.open(mFilePath); } return bytesRead; } case ReadFully: { int toRead = Math.min(mBuffer.length, (int) (mFileSize - mInStream.getPos())); mInStream.readFully(mBuffer, 0, toRead); if (mInStream.getPos() == mFileSize) { closeInStream(); mInStream = mFs.open(mFilePath); } return toRead; } case PosRead: { return mInStream.read(mCurrentOffset, mBuffer, 0, mBuffer.length); } case PosReadFully: { mInStream.readFully(mCurrentOffset, mBuffer, 0, mBuffer.length); return mBuffer.length; } case Write: { if (mOutStream == null) { mOutStream = mFs.create(mFilePath, false, mBuffer.length, (short) 1, mBlockSize); } int bytesToWrite = (int) Math.min(mFileSize - mOutStream.getPos(), mBuffer.length); if (bytesToWrite == 0) { mOutStream.close(); return -1; } mOutStream.write(mBuffer, 0, bytesToWrite); return bytesToWrite; } default: throw new IllegalStateException("Unknown operation: " + mParameters.mOperation); } }

Target:
private int applyOperation() throws IOException { if (ClientIOOperation.isRead(mParameters.mOperation)) { if (mInStream == null) { mInStream = mFs.open(mFilePath); } if (mParameters.mReadRandom) { mCurrentOffset = mLongs.next(); if (!ClientIOOperation.isPosRead(mParameters.mOperation)) { mInStream.seek(mCurrentOffset); } } else { mCurrentOffset += mBuffer.length; if (mCurrentOffset > mMaxOffset) { mCurrentOffset = 0; } } } switch (mParameters.mOperation) { case ReadArray: { int bytesRead = mInStream.read(mBuffer); if (bytesRead < 0) { closeInStream(); mInStream = mFs.open(mFilePath); } return bytesRead; } case ReadByteBuffer: { int bytesRead = mInStream.read(mByteBuffer); if (bytesRead < 0) { closeInStream(); mInStream = mFs.open(mFilePath); } return bytesRead; } case ReadFully: { int toRead = Math.min(mBuffer.length, (int) (mFileSize - mInStream.getPos())); mInStream.readFully(mBuffer, 0, toRead); if (mInStream.getPos() == mFileSize) { closeInStream(); mInStream = mFs.open(mFilePath); } return toRead; } case PosRead: { return mInStream.read(mCurrentOffset, mBuffer, 0, mBuffer.length); } case PosReadFully: { mInStream.readFully(mCurrentOffset, mBuffer, 0, mBuffer.length); return mBuffer.length; } case Write: { if (mOutStream == null) { mOutStream = mFs.create(mFilePath, false, mBuffer.length, (short) 1, mBlockSize); } int bytesToWrite = (int) Math.min(mFileSize - mOutStream.getPos(), mBuffer.length); if (bytesToWrite == 0) { mOutStream.close(); return -1; } mOutStream.write(mBuffer, 0, bytesToWrite); return bytesToWrite; } default: throw new IllegalStateException("Unknown operation: " + mParameters.mOperation); } }