@ Override public synchronized int read ( ) throws IOException { long startTime = System . nanoTime ( ) ; // TODO(user): Wrap this in a while-loop if we ever introduce a non-blocking mode for the // underlying channel. int numRead = channel . read ( ByteBuffer . wrap ( singleReadBuf ) ) ; if ( numRead == - 1 ) { return - 1 ; } if ( numRead != 1 ) { throw new IOException ( String . format ( "Somehow read %d bytes using single-byte buffer for path %s ending in position %d!" , numRead , gcsPath , channel . position ( ) ) ) ; } byte b = singleReadBuf [ 0 ] ; totalBytesRead ++ ; statistics . incrementBytesRead ( 1 ) ; long duration = System . nanoTime ( ) - startTime ; ghfs . increment ( GoogleHadoopFileSystemBase . Counter . READ1 ) ; ghfs . increment ( GoogleHadoopFileSystemBase . Counter . READ1_TIME , duration ) ; return ( b & 0xff ) ; }
Reads a single byte from the underlying store .