public class JsonRowDeserializationSchema extends Object implements DeserializationSchema<Row>
Row
.
Deserializes the byte[]
messages as a JSON object and reads
the specified fields.
Failure during deserialization are forwarded as wrapped IOExceptions.
Constructor and Description |
---|
JsonRowDeserializationSchema(String[] fieldNames,
Class<?>[] fieldTypes)
Creates a JSON deserializtion schema for the given fields and type classes.
|
JsonRowDeserializationSchema(String[] fieldNames,
TypeInformation<?>[] fieldTypes)
Creates a JSON deserializtion schema for the given fields and types.
|
Modifier and Type | Method and Description |
---|---|
Row |
deserialize(byte[] message)
Deserializes the byte message.
|
TypeInformation<Row> |
getProducedType()
Gets the data type (as a
TypeInformation ) produced by this function or input format. |
boolean |
isEndOfStream(Row nextElement)
Method to decide whether the element signals the end of the stream.
|
void |
setFailOnMissingField(boolean failOnMissingField)
Configures the failure behaviour if a JSON field is missing.
|
public JsonRowDeserializationSchema(String[] fieldNames, Class<?>[] fieldTypes)
fieldNames
- Names of JSON fields to parse.fieldTypes
- Type classes to parse JSON fields as.public JsonRowDeserializationSchema(String[] fieldNames, TypeInformation<?>[] fieldTypes)
fieldNames
- Names of JSON fields to parse.fieldTypes
- Types to parse JSON fields as.public Row deserialize(byte[] message) throws IOException
DeserializationSchema
deserialize
in interface DeserializationSchema<Row>
message
- The message, as a byte array.IOException
public boolean isEndOfStream(Row nextElement)
DeserializationSchema
isEndOfStream
in interface DeserializationSchema<Row>
nextElement
- The element to test for the end-of-stream signal.public TypeInformation<Row> getProducedType()
ResultTypeQueryable
TypeInformation
) produced by this function or input format.getProducedType
in interface ResultTypeQueryable<Row>
public void setFailOnMissingField(boolean failOnMissingField)
By default, a missing field is ignored and the field is set to null.
failOnMissingField
- Flag indicating whether to fail or not on a missing field.Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.