@Test public void readWithInvalidArgument() throws Exception { mThrown.expect(IllegalArgumentException.class); mThrown.expectMessage("exceeding fileSize"); mReader.read(TEST_BLOCK_SIZE - 1, 2); }
@Override public ByteBuffer read(long offset, long length) throws IOException { Preconditions.checkArgument(offset + length <= mFileSize, "offset=%s, length=%s, exceeding fileSize=%s", offset, length, mFileSize); if (length == -1L) { length = mFileSize - offset; } return mLocalFileChannel.map(FileChannel.MapMode.READ_ONLY, offset, length); }
LocalFileBlockReader extends BlockReader { @Override public ByteBuffer read(long offset, long length) throws IOException { Preconditions.checkArgument(offset + length <= mFileSize, "offset=%s, length=%s, exceeding fileSize=%s", offset, length, mFileSize); if (length == -1L) { length = mFileSize - offset; } return mLocalFileChannel.map(FileChannel.MapMode.READ_ONLY, offset, length); } }
LocalFileBlockReader extends BlockReader { @Override public ByteBuffer read(long offset, long length) throws IOException { Preconditions.checkArgument(offset + length <= mFileSize, "offset=%s, length=%s, exceeding fileSize=%s", offset, length, mFileSize); if (length == -1L) { length = mFileSize - offset; } return mLocalFileChannel.map(FileChannel.MapMode.READ_ONLY, offset, length); } LocalFileBlockReader(String path); }
LocalFileBlockReader extends BlockReader { @Override public ByteBuffer read(long offset, long length) throws IOException { Preconditions.checkArgument(offset + length <= mFileSize, "offset=%s, length=%s, exceeding fileSize=%s", offset, length, mFileSize); if (length == -1L) { length = mFileSize - offset; } return mLocalFileChannel.map(FileChannel.MapMode.READ_ONLY, offset, length); } LocalFileBlockReader(String path); @Override ReadableByteChannel getChannel(); @Override long getLength(); void increaseUsageCount(); void decreaseUsageCount(); int getUsageCount(); String getFilePath(); @Override ByteBuffer read(long offset, long length); @Override int transferTo(ByteBuf buf); @Override void close(); @Override boolean isClosed(); }
LocalFileBlockReader extends BlockReader { @Override public ByteBuffer read(long offset, long length) throws IOException { Preconditions.checkArgument(offset + length <= mFileSize, "offset=%s, length=%s, exceeding fileSize=%s", offset, length, mFileSize); if (length == -1L) { length = mFileSize - offset; } return mLocalFileChannel.map(FileChannel.MapMode.READ_ONLY, offset, length); } LocalFileBlockReader(String path); @Override ReadableByteChannel getChannel(); @Override long getLength(); void increaseUsageCount(); void decreaseUsageCount(); int getUsageCount(); String getFilePath(); @Override ByteBuffer read(long offset, long length); @Override int transferTo(ByteBuf buf); @Override void close(); @Override boolean isClosed();  }