Package org.apache.avro.hadoop.io
Class AvroKeyValue<K,V>
java.lang.Object
org.apache.avro.hadoop.io.AvroKeyValue<K,V>
- Type Parameters:
K
- The java type for the key.V
- The java type for the value.
A helper object for working with the Avro generic records that are used to
store key/value pairs in an Avro container file.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A wrapper for iterators over GenericRecords that are known to be KeyValue records. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name of the generic record field containing the key.static final String
The name of the key value pair generic record.static final String
The namespace of the key value pair generic record.static final String
The name of the generic record field containing the value. -
Constructor Summary
ConstructorDescriptionAvroKeyValue
(GenericRecord keyValueRecord) Wraps a GenericRecord that is a key value pair. -
Method Summary
-
Field Details
-
KEY_VALUE_PAIR_RECORD_NAME
The name of the key value pair generic record.- See Also:
-
KEY_VALUE_PAIR_RECORD_NAMESPACE
The namespace of the key value pair generic record.- See Also:
-
KEY_FIELD
The name of the generic record field containing the key.- See Also:
-
VALUE_FIELD
The name of the generic record field containing the value.- See Also:
-
-
Constructor Details
-
AvroKeyValue
Wraps a GenericRecord that is a key value pair.
-
-
Method Details
-
get
Gets the wrapped key/value GenericRecord.- Returns:
- The key/value Avro generic record.
-
getKey
Read the key.- Returns:
- The key from the key/value generic record.
-
getValue
Read the value.- Returns:
- The value from the key/value generic record.
-
setKey
Sets the key.- Parameters:
key
- The key.
-
setValue
Sets the value.- Parameters:
value
- The value.
-
getSchema
Creates a KeyValuePair generic record schema.- Returns:
- A schema for a generic record with two fields: 'key' and 'value'.
-