public interface Record
Modifier and Type | Method and Description |
---|---|
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) |
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() |
Object |
getValue(RecordField field) |
Object |
getValue(String fieldName) |
Object[] |
getValues()
Returns a view of the the values of the fields in this Record.
|
void |
incorporateInactiveFields()
Updates the Record's schema to incorporate all of the fields that were added via the
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 |
boolean |
isTypeChecked()
Indicates whether or not field values for this record are expected to be coerced into the type designated by the schema.
|
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.
|
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
|
RecordSchema getSchema()
boolean isTypeChecked()
true
, then it is safe to assume that calling 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 getValue(RecordField)
can return an object of any type.true
if type checking is enabled, false
otherwise.boolean isDropUnknownFields()
true
, any field that is added to the record will be drop unless the field is known by the schematrue
if fields that are unknown to the schema will be dropped, false
if all field values are retained.void incorporateSchema(RecordSchema other)
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.other
- the other schema to incorporate into this Record's schemaUnsupportedOperationException
- if this record does not support incorporating other schemasvoid incorporateInactiveFields()
setValue(RecordField, Object)
method that did not exist in the schema.UnsupportedOperationException
- if this record does not support incorporating other fieldsObject[] getValues()
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.Object getValue(RecordField field)
String getAsString(RecordField field, String format)
Record getAsRecord(String fieldName, RecordSchema schema)
Optional<SerializedForm> getSerializedForm()
void setValue(String fieldName, Object value)
SerializedForm
that was provided will be removed (i.e., any
subsequent call to getSerializedForm()
will return an empty Optional).fieldName
- the name of the field to updatevalue
- the new value to setIllegalTypeConversionException
- if the value is not of the correct type, as defined
by the schema, and cannot be coerced into the correct type.void setValue(RecordField field, Object value)
incorporateInactiveFields()
method. This method should not be called after each invocation of 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 getSerializedForm()
} will return an empty Optional).field
- the field to updatevalue
- the value to setvoid setArrayValue(String fieldName, int arrayIndex, Object value)
SerializedForm
that was provided will be removed (i.e., any
subsequent call to getSerializedForm()
will return an empty Optional).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 setIllegalTypeConversionException
- if the value is not of the correct type, as defined
by the schema, and cannot be coerced into the correct type; or if the field with the given
name is not an ArrayIllegalArgumentException
- if the arrayIndex is less than 0.void setMapValue(String fieldName, String mapKey, Object value)
SerializedForm
that was provided will be removed (i.e., any
subsequent call to getSerializedForm()
will return an empty Optional).fieldName
- the name of the field to updatemapKey
- the key in the map of the entry to updatevalue
- the new value to setIllegalTypeConversionException
- if the value is not of the correct type, as defined
by the schema, and cannot be coerced into the correct type; or if the field with the given
name is not a MapSet<String> getRawFieldNames()
getSchema()
.getFieldNames()
instead.Copyright © 2021 Apache NiFi Project. All rights reserved.