public static class StructuredRecord.Builder extends Object
StructuredRecord.
TODO: enforce schema correctness?| Modifier and Type | Method and Description |
|---|---|
StructuredRecord |
build()
Build a
StructuredRecord with the fields set by this builder. |
StructuredRecord.Builder |
convertAndSet(String fieldName,
Date date)
Convert the given date into the type of the given field, and set the value for that field.
|
StructuredRecord.Builder |
convertAndSet(String fieldName,
Date date,
DateFormat dateFormat)
Convert the given date into the type of the given field, and set the value for that field.
|
StructuredRecord.Builder |
convertAndSet(String fieldName,
String strVal)
Convert the given string into the type of the given field, and set the value for that field.
|
StructuredRecord.Builder |
set(String fieldName,
Object value)
Set the field to the given value.
|
public StructuredRecord.Builder set(String fieldName, @Nullable Object value)
fieldName - Name of the field to setvalue - Value for the fieldUnexpectedFormatException - if the field is not in the schema, or the field is not nullable but a null
value is givenpublic StructuredRecord.Builder convertAndSet(String fieldName, @Nullable Date date) throws UnexpectedFormatException
fieldName - Name of the field to setdate - Date value for the fieldUnexpectedFormatException - if the field is not in the schema, or the field is not nullable but a null
value is given, or the date cannot be converted to the type for the fieldpublic StructuredRecord.Builder convertAndSet(String fieldName, @Nullable Date date, @Nullable DateFormat dateFormat) throws UnexpectedFormatException
fieldName - Name of the field to setdate - Date value for the fielddateFormat - Format for the date if it is a string. If null, the default format of
"YYYY-MM-DD'T'HH:mm:ss z" will be usedUnexpectedFormatException - if the field is not in the schema, or the field is not nullable but a null
value is given, or the date cannot be converted to the type for the fieldpublic StructuredRecord.Builder convertAndSet(String fieldName, @Nullable String strVal) throws UnexpectedFormatException
fieldName - Name of the field to setstrVal - String value for the fieldUnexpectedFormatException - if the field is not in the schema, or the field is not nullable but a null
value is given, or the string cannot be converted to the type for the fieldpublic StructuredRecord build() throws UnexpectedFormatException
StructuredRecord with the fields set by this builder.StructuredRecord with the fields set by this builderUnexpectedFormatException - if there is at least one non-nullable field without a valueCopyright © 2018 Cask Data, Inc. Licensed under the Apache License, Version 2.0.