@Override public synchronized int read(byte buf[], int off, int len) throws IOException { if (closed) { throw new IOException("Stream closed"); } int result = wrappedStream.read(buf, off, len); if (result > 0) { pos += result; } if (stats != null && result > 0) { stats.incrementBytesRead(result); } return result; }
@Override public synchronized int read() throws IOException { if (closed) { throw new IOException(E_STREAM_CLOSED); } int byteRead = wrappedStream.read(); if (byteRead >= 0) { pos++; } if (stats != null & byteRead >= 0) { stats.incrementBytesRead(1); } return byteRead; }
@Override public synchronized int read() throws IOException { if (closed) { throw new IOException("Stream closed"); } int byteRead = wrappedStream.read(); if (byteRead >= 0) { pos++; } if (stats != null && byteRead >= 0) { stats.incrementBytesRead(1); } return byteRead; }
public synchronized int read(byte buf[], int off, int len) throws IOException { if (closed) { throw new IOException("Stream closed"); } int result = wrappedStream.read(buf, off, len); if (result > 0) { pos += result; } if (stats != null & result > 0) { stats.incrementBytesRead(result); } return result; }
@Override public int read() throws IOException { try { int value = fis.read(); if (value >= 0) { this.position++; statistics.incrementBytesRead(1); } return value; } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
public int read(byte[] data) throws IOException { int result = super.read(data); if (result != -1) { statistics.incrementBytesRead(result); } return result; }
@Override public synchronized int read() throws IOException { int ch = in.read(); if (stat != null && ch != -1) { stat.incrementBytesRead(1); } return ch; }
void updateFileSystemReadStats(int distance, int nRead) { if (stats != null) { stats.incrementBytesRead(nRead); stats.incrementBytesReadByDistance(distance, nRead); } }
/** * Increment the bytes read counter if there is a stats instance * and the number of bytes read is more than zero. * @param bytesRead number of bytes read */ private void incrementBytesRead(long bytesRead) { if (stats != null && bytesRead > 0) { stats.incrementBytesRead(bytesRead); } }
public int read() throws IOException { int result = super.read(); if (result != -1) { statistics.incrementBytesRead(1); } return result; }
public int read() throws IOException { int result = super.read(); if (result != -1) { statistics.incrementBytesRead(1); } return result; }
@Override public int read(byte[] buffer, int offset, int length) throws IOException { if (mClosed) { throw new IOException(ExceptionMessage.READ_CLOSED_STREAM.getMessage()); } int bytesRead = mInputStream.read(buffer, offset, length); if (bytesRead != -1 && mStatistics != null) { mStatistics.incrementBytesRead(bytesRead); } return bytesRead; }
@Override public int read(long position, byte[] b, int off, int len) throws IOException { // parameter check validatePositionedReadArgs(position, b, off, len); if (len == 0) { return 0; } ByteBuffer bb = ByteBuffer.wrap(b, off, len); try { int value = fis.getChannel().read(bb, position); if (value > 0) { statistics.incrementBytesRead(value); } return value; } catch (IOException e) { throw new FSError(e); } }
@Override public int read(byte[] b, int off, int len) throws IOException { // parameter check validatePositionedReadArgs(position, b, off, len); try { int value = fis.read(b, off, len); if (value > 0) { this.position += value; statistics.incrementBytesRead(value); } return value; } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
public synchronized int read(byte[] buf, int off, int len) throws IOException { if (closed) { throw new IOException(E_STREAM_CLOSED); } int result = wrappedStream.read(buf, off, len); if (result > 0) { pos += result; } if (stats != null & result > 0) { stats.incrementBytesRead(result); } return result; }
@Override public int read() throws IOException { try { int value = fis.read(); if (value >= 0) { this.position++; statistics.incrementBytesRead(1); } return value; } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
private static FileSystem.Statistics combineFileSystemStatistics(final FileSystem.Statistics s1, final FileSystem.Statistics s2) { FileSystem.Statistics result = new FileSystem.Statistics(s1); result.incrementReadOps(s2.getReadOps()); result.incrementLargeReadOps(s2.getLargeReadOps()); result.incrementWriteOps(s2.getWriteOps()); result.incrementBytesRead(s2.getBytesRead()); result.incrementBytesWritten(s2.getBytesWritten()); return result; }
@Override public int read(long position, byte[] buffer, int offset, int length) throws IOException { if (mClosed) { throw new IOException(ExceptionMessage.READ_CLOSED_STREAM.getMessage()); } int bytesRead = mInputStream.positionedRead(position, buffer, offset, length); if (bytesRead != -1 && mStatistics != null) { mStatistics.incrementBytesRead(bytesRead); } return bytesRead; }
@Override public int read(byte[] buffer, int offset, int length) throws IOException { if (mClosed) { throw new IOException(ExceptionMessage.READ_CLOSED_STREAM.getMessage()); } int bytesRead = mInputStream.read(buffer, offset, length); if (bytesRead != -1 && mStatistics != null) { mStatistics.incrementBytesRead(bytesRead); } return bytesRead; }
@Override public int read() throws IOException { if (mClosed) { throw new IOException(ExceptionMessage.READ_CLOSED_STREAM.getMessage()); } int data = mInputStream.read(); if (data != -1 && mStatistics != null) { mStatistics.incrementBytesRead(1); } return data; }