Package org.apache.druid.data.input.impl
Class DelimitedValueReader
- java.lang.Object
-
- org.apache.druid.data.input.IntermediateRowParsingReader<T>
-
- org.apache.druid.data.input.TextReader<byte[]>
-
- org.apache.druid.data.input.TextReader.Bytes
-
- org.apache.druid.data.input.impl.DelimitedValueReader
-
- All Implemented Interfaces:
InputEntityReader
public class DelimitedValueReader extends TextReader.Bytes
DelimitedValueReader is the reader for Delimitor Separate Value format input data(CSV/TSV).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.druid.data.input.TextReader
TextReader.Bytes, TextReader.Strings
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getNumHeaderLinesToSkip()
Returns the number of header lines to skip.boolean
needsToProcessHeaderLine()
Returns true if the file format needs to process a header line.List<InputRow>
parseInputRows(byte[] line)
Parses the given line into a list ofInputRow
s.void
processHeaderLine(byte[] line)
Processes a header line.List<Map<String,Object>>
toMap(byte[] intermediateRow)
Converts the given intermediate row into aMap
.-
Methods inherited from class org.apache.druid.data.input.TextReader.Bytes
intermediateRowAsString, makeSourceIterator
-
Methods inherited from class org.apache.druid.data.input.TextReader
findOrCreateInputRowSignature, getInputRowSchema, intermediateRowIteratorWithMetadata, source
-
Methods inherited from class org.apache.druid.data.input.IntermediateRowParsingReader
intermediateRowIterator, read, sample
-
-
-
-
Method Detail
-
parseInputRows
public List<InputRow> parseInputRows(byte[] line) throws IOException, ParseException
Description copied from class:TextReader
Parses the given line into a list ofInputRow
s. Note that some file formats can explode a single line of input into multiple inputRows. This method will be called afterTextReader.getNumHeaderLinesToSkip()
andTextReader.processHeaderLine(T)
.- Specified by:
parseInputRows
in classTextReader<byte[]>
- Throws:
ParseException
- if it cannot parse the given intermediateRow properlyIOException
-
toMap
public List<Map<String,Object>> toMap(byte[] intermediateRow) throws IOException
Description copied from class:IntermediateRowParsingReader
Converts the given intermediate row into aMap
. The returned JSON will be used by InputSourceSampler. Implementations can use any method to convert the given row into a Map. This should return a non-empty list with the same size of the list returned byIntermediateRowParsingReader.parseInputRows(T)
or the returned objects will be discarded- Specified by:
toMap
in classIntermediateRowParsingReader<byte[]>
- Throws:
IOException
-
getNumHeaderLinesToSkip
public int getNumHeaderLinesToSkip()
Description copied from class:TextReader
Returns the number of header lines to skip.TextReader.processHeaderLine(T)
will be called as many times as the returned number.- Specified by:
getNumHeaderLinesToSkip
in classTextReader<byte[]>
-
needsToProcessHeaderLine
public boolean needsToProcessHeaderLine()
Description copied from class:TextReader
Returns true if the file format needs to process a header line. This method will be called after skipping lines as many asTextReader.getNumHeaderLinesToSkip()
.- Specified by:
needsToProcessHeaderLine
in classTextReader<byte[]>
-
processHeaderLine
public void processHeaderLine(byte[] line) throws IOException
Description copied from class:TextReader
Processes a header line. This will be called ifTextReader.needsToProcessHeaderLine()
= true.- Specified by:
processHeaderLine
in classTextReader<byte[]>
- Throws:
IOException
-
-