Package org.apache.druid.data.input
Class IntermediateRowParsingReader<T>
java.lang.Object
org.apache.druid.data.input.IntermediateRowParsingReader<T>
- Type Parameters:
T- type of intermediate row. For example, it can beStringfor text formats.
- All Implemented Interfaces:
InputEntityReader
- Direct Known Subclasses:
JsonNodeReader,JsonReader,TextReader
InputEntityReader that parses bytes into some intermediate rows first, and then into InputRows.
For example, DelimitedValueReader parses bytes into string lines, and then parses
those lines into InputRows.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringintermediateRowAsString(T row) String representation of an intermediate row.protected CloseableIterator<T> Creates an iterator of intermediate rows.protected CloseableIteratorWithMetadata<T> Same asintermediateRowIterator, but it also contains the metadata such as the line number to generate more informativeParseException.parseInputRows(T intermediateRow) Parses the given intermediate row into a list ofInputRows.read()sample()protected InputEntitysource()Converts the given intermediate row into aMap.
-
Constructor Details
-
IntermediateRowParsingReader
public IntermediateRowParsingReader()
-
-
Method Details
-
read
- Specified by:
readin interfaceInputEntityReader- Throws:
IOException
-
sample
- Specified by:
samplein interfaceInputEntityReader- Throws:
IOException
-
intermediateRowIterator
Creates an iterator of intermediate rows. The returned rows will be consumed byparseInputRows(T)andtoMap(T). Either this orintermediateRowIteratorWithMetadata()should be implemented- Throws:
IOException
-
intermediateRowIteratorWithMetadata
Same asintermediateRowIterator, but it also contains the metadata such as the line number to generate more informativeParseException.- Throws:
IOException
-
intermediateRowAsString
String representation of an intermediate row. Used for error messages. -
source
- 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
protected abstract List<InputRow> parseInputRows(T intermediateRow) throws IOException, ParseException Parses the given intermediate row into a list ofInputRows. This should return a non-empty list.- Throws:
ParseException- if it cannot parse the given intermediateRow properlyIOException
-
toMap
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 byparseInputRows(T)or the returned objects will be discarded- Throws:
IOException
-