Package org.apache.druid.data.input
Class TextReader<T>
java.lang.Object
org.apache.druid.data.input.IntermediateRowParsingReader<T>
org.apache.druid.data.input.TextReader<T>
- All Implemented Interfaces:
InputEntityReader
- Direct Known Subclasses:
TextReader.Bytes,TextReader.Strings
Abstract
InputEntityReader for text format readers such as CSV or JSON.-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTextReader(InputRowSchema inputRowSchema, InputEntity source) -
Method Summary
Modifier and TypeMethodDescriptionstatic RowSignaturefindOrCreateInputRowSignature(List<String> parsedLine) abstract intReturns the number of header lines to skip.Same asintermediateRowIterator, but it also contains the metadata such as the line number to generate more informativeParseException.protected abstract CloseableIterator<T>abstract booleanReturns true if the file format needs to process a header line.parseInputRows(T intermediateRow) Parses the given line into a list ofInputRows.abstract voidprocessHeaderLine(T line) Processes a header line.protected InputEntitysource()Methods inherited from class org.apache.druid.data.input.IntermediateRowParsingReader
intermediateRowAsString, intermediateRowIterator, read, sample, toMap
-
Constructor Details
-
TextReader
-
-
Method Details
-
getInputRowSchema
-
intermediateRowIteratorWithMetadata
Description copied from class:IntermediateRowParsingReaderSame asintermediateRowIterator, but it also contains the metadata such as the line number to generate more informativeParseException.- Overrides:
intermediateRowIteratorWithMetadatain classIntermediateRowParsingReader<T>- Throws:
IOException
-
source
- Overrides:
sourcein classIntermediateRowParsingReader<T>- Returns:
- InputEntity which the implementation is reading from. Useful in generating informative
ParseExceptions. For example, in case ofFileEntity, file name containing erroneous records or in case ofHttpEntity, the endpoint containing the erroneous data can be attached to the error message
-
parseInputRows
Parses the given line into a list ofInputRows. Note that some file formats can explode a single line of input into multiple inputRows. This method will be called aftergetNumHeaderLinesToSkip()andprocessHeaderLine(T).- Specified by:
parseInputRowsin classIntermediateRowParsingReader<T>- Throws:
ParseException- if it cannot parse the given intermediateRow properlyIOException
-
getNumHeaderLinesToSkip
public abstract int getNumHeaderLinesToSkip()Returns the number of header lines to skip.processHeaderLine(T)will be called as many times as the returned number. -
needsToProcessHeaderLine
public abstract boolean needsToProcessHeaderLine()Returns true if the file format needs to process a header line. This method will be called after skipping lines as many asgetNumHeaderLinesToSkip(). -
processHeaderLine
Processes a header line. This will be called ifneedsToProcessHeaderLine()= true.- Throws:
IOException
-
makeSourceIterator
-
findOrCreateInputRowSignature
-