public class ChunkReader
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE |
Constructor and Description |
---|
ChunkReader(java.io.InputStream in)
Constructs a ChunkReader instance
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying stream.
|
int |
readChunk(org.apache.hadoop.io.Writable str,
int maxBytesToConsume)
Reads data in chunks of DEFAULT_CHUNK_SIZE, until we reach
maxBytesToConsume.
|
int |
readLine(org.apache.hadoop.io.Writable str,
int maxBytesToConsume)
Reads a line terminated by LF.
|
public static final int DEFAULT_BUFFER_SIZE
public ChunkReader(java.io.InputStream in)
in
- input streampublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public int readChunk(org.apache.hadoop.io.Writable str, int maxBytesToConsume) throws java.io.IOException
str
- - output parameter, will contain the read chunk byte arraymaxBytesToConsume
- - requested chunk sizejava.io.IOException
- if the first byte cannot be read for any reason
other than the end of the file, if the input stream has been closed,
or if some other I/O error occurs.public int readLine(org.apache.hadoop.io.Writable str, int maxBytesToConsume) throws java.io.IOException
str
- - output parameter, will contain the read recordmaxBytesToConsume
- - the line mustn't exceed this valuejava.io.IOException
- if the first byte cannot be read for any reason
other than the end of the file, if the input stream has been closed,
or if some other I/O error occurs.