public class LineReader extends Object implements Closeable
Constructor and Description |
---|
LineReader(InputStream in)
Create a line reader that reads from the given stream using the
default buffer-size (64k).
|
LineReader(InputStream in,
byte[] recordDelimiterBytes)
Create a line reader that reads from the given stream using the
default buffer-size, and using a custom delimiter of array of
bytes.
|
LineReader(InputStream in,
org.apache.hadoop.conf.Configuration conf)
Create a line reader that reads from the given stream using the
io.file.buffer.size specified in the given
Configuration . |
LineReader(InputStream in,
org.apache.hadoop.conf.Configuration conf,
byte[] recordDelimiterBytes)
Create a line reader that reads from the given stream using the
io.file.buffer.size specified in the given
Configuration , and using a custom delimiter of array of
bytes. |
LineReader(InputStream in,
int bufferSize)
Create a line reader that reads from the given stream using the
given buffer-size.
|
LineReader(InputStream in,
int bufferSize,
byte[] recordDelimiterBytes)
Create a line reader that reads from the given stream using the
given buffer-size, and using a custom delimiter of array of
bytes.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the underlying stream.
|
protected int |
fillBuffer(InputStream in,
byte[] buffer,
boolean inDelimiter) |
int |
readDefaultLine(NonSyncByteArrayOutputStream str,
ArrayList<Integer> offsets,
int maxLineLength,
int maxBytesToConsume)
Read a line terminated by one of CR, LF, or CRLF.
|
int |
readLine(org.apache.hadoop.io.Text str)
Read from the InputStream into the given Text.
|
int |
readLine(org.apache.hadoop.io.Text str,
int maxLineLength)
Read from the InputStream into the given Text.
|
int |
readLine(org.apache.hadoop.io.Text str,
int maxLineLength,
int maxBytesToConsume)
Read one line from the InputStream into the given Text.
|
void |
reset() |
public LineReader(InputStream in)
in
- The input streamIOException
public LineReader(InputStream in, int bufferSize)
in
- The input streambufferSize
- Size of the read bufferIOException
public LineReader(InputStream in, org.apache.hadoop.conf.Configuration conf) throws IOException
io.file.buffer.size
specified in the given
Configuration
.in
- input streamconf
- configurationIOException
public LineReader(InputStream in, byte[] recordDelimiterBytes)
in
- The input streamrecordDelimiterBytes
- The delimiterpublic LineReader(InputStream in, int bufferSize, byte[] recordDelimiterBytes)
in
- The input streambufferSize
- Size of the read bufferrecordDelimiterBytes
- The delimiterIOException
public LineReader(InputStream in, org.apache.hadoop.conf.Configuration conf, byte[] recordDelimiterBytes) throws IOException
io.file.buffer.size
specified in the given
Configuration
, and using a custom delimiter of array of
bytes.in
- input streamconf
- configurationrecordDelimiterBytes
- The delimiterIOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void reset()
public int readLine(org.apache.hadoop.io.Text str, int maxLineLength, int maxBytesToConsume) throws IOException
str
- the object to store the given line (without newline)maxLineLength
- the maximum number of bytes to store into str;
the rest of the line is silently discarded.maxBytesToConsume
- the maximum number of bytes to consume
in this call. This is only a hint, because if the line cross
this threshold, we allow it to happen. It can overshoot
potentially by as much as one buffer length.IOException
- if the underlying stream throwsprotected int fillBuffer(InputStream in, byte[] buffer, boolean inDelimiter) throws IOException
IOException
public int readDefaultLine(NonSyncByteArrayOutputStream str, ArrayList<Integer> offsets, int maxLineLength, int maxBytesToConsume) throws IOException
IOException
public int readLine(org.apache.hadoop.io.Text str, int maxLineLength) throws IOException
str
- the object to store the given linemaxLineLength
- the maximum number of bytes to store into str.IOException
- if the underlying stream throwspublic int readLine(org.apache.hadoop.io.Text str) throws IOException
str
- the object to store the given lineIOException
- if the underlying stream throwsCopyright © 2014 Apache Software Foundation. All Rights Reserved.