public abstract class AbstractJsonRowRecordReader extends Object implements RecordReader
| Modifier and Type | Field and Description |
|---|---|
private Map<String,String> |
capturedFields |
private BiPredicate<String,String> |
captureFieldPredicate |
private static com.fasterxml.jackson.databind.ObjectMapper |
codec |
private com.fasterxml.jackson.databind.JsonNode |
firstJsonNode |
private boolean |
firstObjectConsumed |
private static com.fasterxml.jackson.core.JsonFactory |
jsonFactory |
private com.fasterxml.jackson.core.JsonParser |
jsonParser |
private Supplier<DateFormat> |
LAZY_DATE_FORMAT |
private Supplier<DateFormat> |
LAZY_TIME_FORMAT |
private Supplier<DateFormat> |
LAZY_TIMESTAMP_FORMAT |
private org.apache.nifi.logging.ComponentLog |
logger |
private StartingFieldStrategy |
strategy |
| Modifier | Constructor and Description |
|---|---|
private |
AbstractJsonRowRecordReader(org.apache.nifi.logging.ComponentLog logger,
String dateFormat,
String timeFormat,
String timestampFormat) |
protected |
AbstractJsonRowRecordReader(InputStream in,
org.apache.nifi.logging.ComponentLog logger,
String dateFormat,
String timeFormat,
String timestampFormat) |
protected |
AbstractJsonRowRecordReader(InputStream in,
org.apache.nifi.logging.ComponentLog logger,
String dateFormat,
String timeFormat,
String timestampFormat,
StartingFieldStrategy strategy,
String nestedFieldName,
BiPredicate<String,String> captureFieldPredicate)
Constructor with initial logic for JSON to NiFi record parsing.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
captureCurrentField(BiPredicate<String,String> captureFieldPredicate) |
void |
close() |
protected abstract Record |
convertJsonNodeToRecord(com.fasterxml.jackson.databind.JsonNode nextNode,
RecordSchema schema,
boolean coerceTypes,
boolean dropUnknownFields) |
private Record |
createOptionalRecord(com.fasterxml.jackson.databind.JsonNode fieldNode,
DataType dataType,
boolean strict) |
private Record |
createRecordFromRawValue(com.fasterxml.jackson.databind.JsonNode fieldNode,
RecordSchema childSchema) |
Map<String,String> |
getCapturedFields() |
private com.fasterxml.jackson.databind.JsonNode |
getJsonNode() |
private com.fasterxml.jackson.databind.JsonNode |
getJsonNodeWithNestedNodeStrategy() |
protected Supplier<DateFormat> |
getLazyDateFormat() |
protected Supplier<DateFormat> |
getLazyTimeFormat() |
protected Supplier<DateFormat> |
getLazyTimestampFormat() |
private Map<String,Object> |
getMapFromRawValue(com.fasterxml.jackson.databind.JsonNode fieldNode,
DataType dataType,
String fieldName) |
protected com.fasterxml.jackson.databind.JsonNode |
getNextJsonNode() |
protected Object |
getRawNodeValue(com.fasterxml.jackson.databind.JsonNode fieldNode,
DataType dataType,
String fieldName) |
protected Object |
getRawNodeValue(com.fasterxml.jackson.databind.JsonNode fieldNode,
String fieldName) |
private Record |
getRecordFromRawValue(com.fasterxml.jackson.databind.JsonNode fieldNode,
DataType dataType) |
Record |
nextRecord(boolean coerceTypes,
boolean dropUnknownFields) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateRecordSet, getSchema, nextRecordprivate final org.apache.nifi.logging.ComponentLog logger
private final Supplier<DateFormat> LAZY_DATE_FORMAT
private final Supplier<DateFormat> LAZY_TIME_FORMAT
private final Supplier<DateFormat> LAZY_TIMESTAMP_FORMAT
private boolean firstObjectConsumed
private static final com.fasterxml.jackson.core.JsonFactory jsonFactory
private static final com.fasterxml.jackson.databind.ObjectMapper codec
private com.fasterxml.jackson.core.JsonParser jsonParser
private com.fasterxml.jackson.databind.JsonNode firstJsonNode
private StartingFieldStrategy strategy
private BiPredicate<String,String> captureFieldPredicate
private AbstractJsonRowRecordReader(org.apache.nifi.logging.ComponentLog logger, String dateFormat, String timeFormat, String timestampFormat)
protected AbstractJsonRowRecordReader(InputStream in, org.apache.nifi.logging.ComponentLog logger, String dateFormat, String timeFormat, String timestampFormat) throws IOException, MalformedRecordException
IOExceptionMalformedRecordExceptionprotected AbstractJsonRowRecordReader(InputStream in, org.apache.nifi.logging.ComponentLog logger, String dateFormat, String timeFormat, String timestampFormat, StartingFieldStrategy strategy, String nestedFieldName, BiPredicate<String,String> captureFieldPredicate) throws IOException, MalformedRecordException
in - the input stream to parselogger - ComponentLogdateFormat - format for parsing date fieldstimeFormat - format for parsing time fieldstimestampFormat - format for parsing timestamp fieldsstrategy - whether to start processing from a specific fieldnestedFieldName - the name of the field to start the processing fromcaptureFieldPredicate - predicate that takes a JSON fieldName and fieldValue to capture top-level non-processed fields which can
be accessed by calling getCapturedFields()IOException - in case of JSON stream processing failureMalformedRecordException - in case of malformed JSON inputprotected Supplier<DateFormat> getLazyDateFormat()
protected Supplier<DateFormat> getLazyTimeFormat()
protected Supplier<DateFormat> getLazyTimestampFormat()
public Record nextRecord(boolean coerceTypes, boolean dropUnknownFields) throws IOException, MalformedRecordException
nextRecord in interface RecordReaderIOExceptionMalformedRecordExceptionprotected Object getRawNodeValue(com.fasterxml.jackson.databind.JsonNode fieldNode, String fieldName) throws IOException
IOExceptionprotected Object getRawNodeValue(com.fasterxml.jackson.databind.JsonNode fieldNode, DataType dataType, String fieldName) throws IOException
IOExceptionprivate void captureCurrentField(BiPredicate<String,String> captureFieldPredicate) throws IOException
IOExceptionprivate Map<String,Object> getMapFromRawValue(com.fasterxml.jackson.databind.JsonNode fieldNode, DataType dataType, String fieldName) throws IOException
IOExceptionprivate Record getRecordFromRawValue(com.fasterxml.jackson.databind.JsonNode fieldNode, DataType dataType) throws IOException
IOExceptionprivate Record createOptionalRecord(com.fasterxml.jackson.databind.JsonNode fieldNode, DataType dataType, boolean strict) throws IOException
IOExceptionprivate Record createRecordFromRawValue(com.fasterxml.jackson.databind.JsonNode fieldNode, RecordSchema childSchema) throws IOException
IOExceptionprotected com.fasterxml.jackson.databind.JsonNode getNextJsonNode()
throws IOException,
MalformedRecordException
IOExceptionMalformedRecordExceptionprivate com.fasterxml.jackson.databind.JsonNode getJsonNodeWithNestedNodeStrategy()
throws IOException,
MalformedRecordException
IOExceptionMalformedRecordExceptionprivate com.fasterxml.jackson.databind.JsonNode getJsonNode()
throws IOException,
MalformedRecordException
IOExceptionMalformedRecordExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionprotected abstract Record convertJsonNodeToRecord(com.fasterxml.jackson.databind.JsonNode nextNode, RecordSchema schema, boolean coerceTypes, boolean dropUnknownFields) throws IOException, MalformedRecordException
IOExceptionMalformedRecordExceptionCopyright © 2023 Apache NiFi Project. All rights reserved.