Modifier and Type | Field and Description |
---|---|
private boolean |
checkTypes |
private boolean |
dropUnknownFields |
private Set<RecordField> |
inactiveFields |
private RecordSchema |
schema |
private Optional<SerializedForm> |
serializedForm |
private Map<String,Object> |
values |
Constructor and Description |
---|
MapRecord(RecordSchema schema,
Map<String,Object> values) |
MapRecord(RecordSchema schema,
Map<String,Object> values,
boolean checkTypes,
boolean dropUnknownFields) |
MapRecord(RecordSchema schema,
Map<String,Object> values,
SerializedForm serializedForm) |
MapRecord(RecordSchema schema,
Map<String,Object> values,
SerializedForm serializedForm,
boolean checkTypes,
boolean dropUnknownFields) |
Modifier and Type | Method and Description |
---|---|
private Map<String,Object> |
checkTypes(Map<String,Object> values,
RecordSchema schema) |
private String |
convertToString(Object value,
String format) |
boolean |
equals(Object obj) |
Object[] |
getAsArray(String fieldName) |
Boolean |
getAsBoolean(String fieldName) |
Date |
getAsDate(String fieldName,
String format) |
Double |
getAsDouble(String fieldName) |
Float |
getAsFloat(String fieldName) |
Integer |
getAsInt(String fieldName) |
Long |
getAsLong(String fieldName) |
Record |
getAsRecord(String fieldName,
RecordSchema schema) |
String |
getAsString(RecordField field,
String format) |
String |
getAsString(String fieldName) |
String |
getAsString(String fieldName,
String format) |
private Object |
getExplicitValue(RecordField field) |
private Object |
getExplicitValue(RecordField field,
Map<String,Object> values) |
Set<String> |
getRawFieldNames()
Returns a Set that contains the names of all of the fields that are present in the Record, regardless of
whether or not those fields are contained in the schema.
|
RecordSchema |
getSchema() |
Optional<SerializedForm> |
getSerializedForm() |
private RecordField |
getUpdatedRecordField(RecordField field) |
Object |
getValue(RecordField field) |
Object |
getValue(String fieldName) |
Object[] |
getValues()
Returns a view of the the values of the fields in this Record.
|
int |
hashCode() |
void |
incorporateInactiveFields()
Updates the Record's schema to incorporate all of the fields that were added via the
Record.setValue(RecordField, Object)
method that did not exist in the schema. |
void |
incorporateSchema(RecordSchema other)
Updates the Record's schema to to incorporate all of the fields in the given schema.
|
boolean |
isDropUnknownFields()
If
true , any field that is added to the record will be drop unless the field is known by the schema |
private boolean |
isSimpleType(RecordFieldType fieldType) |
boolean |
isTypeChecked()
Indicates whether or not field values for this record are expected to be coerced into the type designated by the schema.
|
private Optional<RecordField> |
resolveField(RecordField field) |
void |
setArrayValue(String fieldName,
int arrayIndex,
Object value)
Updates the value of a the specified index of a field.
|
void |
setMapValue(String fieldName,
String mapKey,
Object value)
Updates the value of a the specified key in a Map field.
|
void |
setValue(RecordField field,
Object value)
Updates the value of the given field to the given value.
|
void |
setValue(String fieldName,
Object value)
Updates the value of the field with the given name to the given value.
|
private Optional<RecordField> |
setValueAndGetField(String fieldName,
Object value) |
Map<String,Object> |
toMap()
Converts the Record into a Map whose keys are the same as the Record's field names and the values are the field values
|
String |
toString() |
private RecordSchema schema
private Optional<SerializedForm> serializedForm
private final boolean checkTypes
private final boolean dropUnknownFields
private Set<RecordField> inactiveFields
public MapRecord(RecordSchema schema, Map<String,Object> values)
public MapRecord(RecordSchema schema, Map<String,Object> values, boolean checkTypes, boolean dropUnknownFields)
public MapRecord(RecordSchema schema, Map<String,Object> values, SerializedForm serializedForm)
public MapRecord(RecordSchema schema, Map<String,Object> values, SerializedForm serializedForm, boolean checkTypes, boolean dropUnknownFields)
public boolean isDropUnknownFields()
Record
true
, any field that is added to the record will be drop unless the field is known by the schemaisDropUnknownFields
in interface Record
true
if fields that are unknown to the schema will be dropped, false
if all field values are retained.public boolean isTypeChecked()
Record
true
, then it is safe to assume that calling Record.getValue(RecordField)
will return an Object of the appropriate
type according to the schema, or an object that can be coerced into the appropriate type. If type checking
is not enabled, then calling Record.getValue(RecordField)
can return an object of any type.isTypeChecked
in interface Record
true
if type checking is enabled, false
otherwise.public RecordSchema getSchema()
public Object[] getValues()
Record
Returns a view of the the values of the fields in this Record. Note that this method returns values only for those entries in the Record's schema. This allows the Record to guarantee that it will return the values in the order dictated by the schema.
NOTE: The array that is returned may be an underlying array that is backing the contents of the Record. As such, modifying the array in any way may result in modifying the record.public Object getValue(RecordField field)
private Optional<RecordField> resolveField(RecordField field)
private Object getExplicitValue(RecordField field)
private Object getExplicitValue(RecordField field, Map<String,Object> values)
public String getAsString(String fieldName)
getAsString
in interface Record
public String getAsString(String fieldName, String format)
getAsString
in interface Record
public String getAsString(RecordField field, String format)
getAsString
in interface Record
public Double getAsDouble(String fieldName)
getAsDouble
in interface Record
public Float getAsFloat(String fieldName)
getAsFloat
in interface Record
public Record getAsRecord(String fieldName, RecordSchema schema)
getAsRecord
in interface Record
public Boolean getAsBoolean(String fieldName)
getAsBoolean
in interface Record
public Object[] getAsArray(String fieldName)
getAsArray
in interface Record
public Optional<SerializedForm> getSerializedForm()
getSerializedForm
in interface Record
public Map<String,Object> toMap()
Record
public void setValue(RecordField field, Object value)
Record
Record.incorporateInactiveFields()
method. This method should not be called after each invocation of Record.setValue(RecordField, Object)
but rather should be called only once all updates to the Record have completed, in order to optimize performance.
If this method changes any value in the Record, any SerializedForm
that was provided will be removed (i.e., any
subsequent call to Record.getSerializedForm()
} will return an empty Optional).public void setValue(String fieldName, Object value)
Record
SerializedForm
that was provided will be removed (i.e., any
subsequent call to Record.getSerializedForm()
will return an empty Optional).private Optional<RecordField> setValueAndGetField(String fieldName, Object value)
public void setArrayValue(String fieldName, int arrayIndex, Object value)
Record
SerializedForm
that was provided will be removed (i.e., any
subsequent call to Record.getSerializedForm()
will return an empty Optional).setArrayValue
in interface Record
fieldName
- the name of the field to updatearrayIndex
- the 0-based index into the array that should be updated. If this value is larger than the
number of elements in the array, or if the array is null, this method will do nothing.value
- the new value to setpublic void setMapValue(String fieldName, String mapKey, Object value)
Record
SerializedForm
that was provided will be removed (i.e., any
subsequent call to Record.getSerializedForm()
will return an empty Optional).setMapValue
in interface Record
fieldName
- the name of the field to updatemapKey
- the key in the map of the entry to updatevalue
- the new value to setpublic void incorporateSchema(RecordSchema other)
Record
RecordFieldType.CHOICE
field with both types as choices. If two fields have the same name but different
default values, then the default value that is already in place will remain the default value, unless the current
default value is null
. Note that all values for this Record will still be valid according
to this Record's Schema after this operation completes, as no type will be changed except to become more
lenient. However, if incorporating the other schema does modify this schema, then the schema text
returned by getSchemaText()
, the schema format returned by getSchemaFormat()
, and
the SchemaIdentifier returned by getIdentifier()
for this record's schema may all become Empty.incorporateSchema
in interface Record
other
- the other schema to incorporate into this Record's schemapublic void incorporateInactiveFields()
Record
Record.setValue(RecordField, Object)
method that did not exist in the schema.incorporateInactiveFields
in interface Record
private RecordField getUpdatedRecordField(RecordField field)
private boolean isSimpleType(RecordFieldType fieldType)
public Set<String> getRawFieldNames()
Record
Record.getSchema()
.getFieldNames()
instead.getRawFieldNames
in interface Record
Copyright © 2021 Apache NiFi Project. All rights reserved.