public class CSVRecordReader extends LineRecordReader
| Modifier and Type | Field and Description |
|---|---|
static char |
DEFAULT_DELIMITER |
static char |
DEFAULT_QUOTE |
static String |
DELIMITER |
static String |
QUOTE |
static String |
SKIP_NUM_LINES |
protected int |
skipNumLines |
charset, conf, initialized, lineIndex, locations, splitIndexinputSplit, listeners, streamCreatorFnAPPEND_LABEL, LABELS, NAME_SPACE| Constructor and Description |
|---|
CSVRecordReader() |
CSVRecordReader(char delimiter)
Create a CSVRecordReader with the specified delimiter
|
CSVRecordReader(int skipNumLines)
Skip first n lines
|
CSVRecordReader(int skipNumLines,
char delimiter)
Skip lines and use delimiter
|
CSVRecordReader(int skipNumLines,
char delimiter,
char quote)
Skip lines, use delimiter, and strip quotes
|
CSVRecordReader(int skipNumLines,
String delimiter)
Deprecated.
This constructor is deprecated; use
CSVRecordReader(int, char) or
CSVRecordReader(int, char, char) |
CSVRecordReader(int skipNumLines,
String delimiter,
String quote)
Deprecated.
This constructor is deprecated; use
CSVRecordReader(int, char) or
CSVRecordReader(int, char, char) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
batchesSupported()
This method returns true, if next(int) signature is supported by this RecordReader implementation.
|
boolean |
hasNext()
Whether there are anymore records
|
void |
initialize(Configuration conf,
InputSplit split)
Called once at initialization.
|
List<Record> |
loadFromMetaData(List<RecordMetaData> recordMetaDatas)
Load multiple records from the given a list of
RecordMetaData instances |
Record |
loadFromMetaData(RecordMetaData recordMetaData)
Load a single record from the given
RecordMetaData instanceNote: that for data that isn't splittable (i.e., text data that needs to be scanned/split), it is more efficient to load multiple records at once using RecordReader.loadFromMetaData(List) |
List<Writable> |
next()
Get the next record
|
List<List<Writable>> |
next(int num)
This method will be used, if batchesSupported() returns true.
|
Record |
nextRecord()
Similar to
RecordReader.next(), but returns a Record object, that may include metadata such as the source
of the data |
protected void |
onLocationOpen(URI location) |
protected List<Writable> |
parseLine(String line) |
protected String |
readStringLine() |
List<Writable> |
record(URI uri,
DataInputStream dataInputStream)
Load the record from the given DataInputStream
Unlike
RecordReader.next() the internal state of the RecordReader is not modified
Implementations of this method should not close the DataInputStream |
void |
reset()
Reset record reader iterator
|
close, closeIfRequired, getConf, getIterator, getLabels, initialize, resetSupported, setConfgetListeners, invokeListeners, setListeners, setListenersprotected int skipNumLines
public static final char DEFAULT_DELIMITER
public static final char DEFAULT_QUOTE
public static final String SKIP_NUM_LINES
public static final String DELIMITER
public static final String QUOTE
public CSVRecordReader(int skipNumLines)
skipNumLines - the number of lines to skippublic CSVRecordReader(char delimiter)
delimiter - Delimiter character for CSVpublic CSVRecordReader(int skipNumLines,
char delimiter)
skipNumLines - the number of lines to skipdelimiter - the delimiter@Deprecated public CSVRecordReader(int skipNumLines, String delimiter)
CSVRecordReader(int, char) or
CSVRecordReader(int, char, char)skipNumLines - Number of lines to skipdelimiter - Delimiter to usepublic CSVRecordReader(int skipNumLines,
char delimiter,
char quote)
skipNumLines - the number of lines to skipdelimiter - the delimiterquote - the quote to strip@Deprecated public CSVRecordReader(int skipNumLines, String delimiter, String quote)
CSVRecordReader(int, char) or
CSVRecordReader(int, char, char)skipNumLines - the number of lines to skipdelimiter - the delimiterquote - the quote to strippublic CSVRecordReader()
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException
RecordReaderinitialize in interface RecordReaderinitialize in class LineRecordReaderconf - a configuration for initializationsplit - the split that defines the range of records to readIOExceptionInterruptedExceptionpublic boolean batchesSupported()
RecordReaderbatchesSupported in interface RecordReaderbatchesSupported in class BaseRecordReaderpublic boolean hasNext()
RecordReaderhasNext in interface RecordReaderhasNext in class LineRecordReaderpublic List<List<Writable>> next(int num)
RecordReadernext in interface RecordReadernext in class BaseRecordReaderpublic List<Writable> next()
RecordReadernext in interface RecordReadernext in class LineRecordReaderprotected String readStringLine()
public Record nextRecord()
RecordReaderRecordReader.next(), but returns a Record object, that may include metadata such as the source
of the datanextRecord in interface RecordReadernextRecord in class LineRecordReaderpublic Record loadFromMetaData(RecordMetaData recordMetaData) throws IOException
RecordReaderRecordMetaData instanceRecordReader.loadFromMetaData(List)loadFromMetaData in interface RecordReaderloadFromMetaData in class LineRecordReaderrecordMetaData - Metadata for the record that we want to load fromIOException - If I/O error occurs during loadingpublic List<Record> loadFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException
RecordReaderRecordMetaData instancesloadFromMetaData in interface RecordReaderloadFromMetaData in class LineRecordReaderrecordMetaDatas - Metadata for the records that we want to load fromIOException - If I/O error occurs during loadingpublic List<Writable> record(URI uri, DataInputStream dataInputStream) throws IOException
RecordReaderRecordReader.next() the internal state of the RecordReader is not modified
Implementations of this method should not close the DataInputStreamrecord in interface RecordReaderrecord in class LineRecordReaderIOException - if error occurs during reading from the input streampublic void reset()
RecordReaderreset in interface RecordReaderreset in class LineRecordReaderprotected void onLocationOpen(URI location)
onLocationOpen in class LineRecordReaderCopyright © 2019. All rights reserved.