java.io.Closeable, java.lang.AutoCloseable, IOStatisticsSource@LimitedPrivate("MapReduce")
@Unstable
public class LineReader
extends java.lang.Object
implements java.io.Closeable, IOStatisticsSource
| Constructor | Description |
|---|---|
LineReader(java.io.InputStream in) |
Create a line reader that reads from the given stream using the
default buffer-size (64k).
|
LineReader(java.io.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(java.io.InputStream in,
int bufferSize) |
Create a line reader that reads from the given stream using the
given buffer-size.
|
LineReader(java.io.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.
|
LineReader(java.io.InputStream in,
Configuration conf) |
Create a line reader that reads from the given stream using the
io.file.buffer.size specified in the given
Configuration. |
LineReader(java.io.InputStream in,
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. |
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
Close the underlying stream.
|
protected int |
fillBuffer(java.io.InputStream in,
byte[] buffer,
boolean inDelimiter) |
|
protected int |
getBufferPosn() |
|
protected int |
getBufferSize() |
|
IOStatistics |
getIOStatistics() |
Return any IOStatistics provided by the source.
|
int |
readLine(Text str) |
Read from the InputStream into the given Text.
|
int |
readLine(Text str,
int maxLineLength) |
Read from the InputStream into the given Text.
|
int |
readLine(Text str,
int maxLineLength,
int maxBytesToConsume) |
Read one line from the InputStream into the given Text.
|
protected void |
unsetNeedAdditionalRecordAfterSplit() |
public LineReader(java.io.InputStream in)
in - The input streampublic LineReader(java.io.InputStream in,
int bufferSize)
in - The input streambufferSize - Size of the read bufferpublic LineReader(java.io.InputStream in,
Configuration conf)
throws java.io.IOException
io.file.buffer.size specified in the given
Configuration.in - input streamconf - configurationjava.io.IOException - raised on errors performing I/O.public LineReader(java.io.InputStream in,
byte[] recordDelimiterBytes)
in - The input streamrecordDelimiterBytes - The delimiterpublic LineReader(java.io.InputStream in,
int bufferSize,
byte[] recordDelimiterBytes)
in - The input streambufferSize - Size of the read bufferrecordDelimiterBytes - The delimiterpublic LineReader(java.io.InputStream in,
Configuration conf,
byte[] recordDelimiterBytes)
throws java.io.IOException
io.file.buffer.size specified in the given
Configuration, and using a custom delimiter of array of
bytes.in - input streamconf - configurationrecordDelimiterBytes - The delimiterjava.io.IOException - raised on errors performing I/O.public void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeablejava.io.IOException - raised on errors performing I/O.public IOStatistics getIOStatistics()
getIOStatistics in interface IOStatisticsSourcepublic int readLine(Text str, int maxLineLength, int maxBytesToConsume) throws java.io.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.java.io.IOException - if the underlying stream throwsprotected int fillBuffer(java.io.InputStream in,
byte[] buffer,
boolean inDelimiter)
throws java.io.IOException
java.io.IOExceptionpublic int readLine(Text str, int maxLineLength) throws java.io.IOException
str - the object to store the given linemaxLineLength - the maximum number of bytes to store into str.java.io.IOException - if the underlying stream throwspublic int readLine(Text str) throws java.io.IOException
str - the object to store the given linejava.io.IOException - if the underlying stream throwsprotected int getBufferPosn()
protected int getBufferSize()
protected void unsetNeedAdditionalRecordAfterSplit()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.