org.apache.hadoop.hdfs
Interface BlockReader

All Superinterfaces:
org.apache.hadoop.fs.ByteBufferReadable

public interface BlockReader
extends org.apache.hadoop.fs.ByteBufferReadable

A BlockReader is responsible for reading a single block from a single datanode.


Method Summary
 int available()
          Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without performing network I/O.
 void close()
          Close the block reader.
 org.apache.hadoop.hdfs.client.ClientMmap getClientMmap(EnumSet<org.apache.hadoop.fs.ReadOption> opts)
          Get a ClientMmap object for this BlockReader.
 boolean isLocal()
           
 boolean isShortCircuit()
           
 int read(byte[] buf, int off, int len)
           
 int readAll(byte[] buf, int offset, int len)
          Similar to readFully(byte[], int, int) except that it will not throw an exception on EOF.
 void readFully(byte[] buf, int readOffset, int amtToRead)
          Read exactly the given amount of data, throwing an exception if EOF is reached before that amount
 long skip(long n)
          Skip the given number of bytes
 
Methods inherited from interface org.apache.hadoop.fs.ByteBufferReadable
read
 

Method Detail

read

int read(byte[] buf,
         int off,
         int len)
         throws IOException
Throws:
IOException

skip

long skip(long n)
          throws IOException
Skip the given number of bytes

Throws:
IOException

available

int available()
              throws IOException
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without performing network I/O.

Throws:
IOException

close

void close()
           throws IOException
Close the block reader.

Throws:
IOException

readFully

void readFully(byte[] buf,
               int readOffset,
               int amtToRead)
               throws IOException
Read exactly the given amount of data, throwing an exception if EOF is reached before that amount

Throws:
IOException

readAll

int readAll(byte[] buf,
            int offset,
            int len)
            throws IOException
Similar to readFully(byte[], int, int) except that it will not throw an exception on EOF. However, it differs from the simple read(byte[], int, int) call in that it is guaranteed to read the data if it is available. In other words, if this call does not throw an exception, then either the buffer has been filled or the next call will return EOF.

Throws:
IOException

isLocal

boolean isLocal()
Returns:
true only if this is a local read.

isShortCircuit

boolean isShortCircuit()
Returns:
true only if this is a short-circuit read. All short-circuit reads are also local.

getClientMmap

org.apache.hadoop.hdfs.client.ClientMmap getClientMmap(EnumSet<org.apache.hadoop.fs.ReadOption> opts)
Get a ClientMmap object for this BlockReader.

Parameters:
opts - The read options to use.
Returns:
The ClientMmap object, or null if mmap is not supported.


Copyright © 2014 Apache Software Foundation. All Rights Reserved.