public class AvroSequenceFile extends Object
SequenceFile
that also
supports reading and writing Avro data.
The vanilla Hadoop SequenceFile
contains a header
followed by a sequence of records. A record consists of a
key and a value. The key and value must either:
Writable
interface, orSerialization
registered with the
SerializationFactory
.
Since Avro data are Plain Old Java Objects (e.g., Integer
for
data with schema "int"), they do not implement Writable.
Furthermore, a Serialization
implementation cannot determine whether an object instance of type
CharSequence
that also implements Writable
should
be serialized using Avro or WritableSerialization.
The solution implemented in AvroSequenceFile
is to:
AvroKey
object,AvroValue
object,AvroSerialization
with the
SerializationFactory
, which will accept only objects that are
instances of either AvroKey
or AvroValue
, andModifier and Type | Class and Description |
---|---|
static class |
AvroSequenceFile.Reader
A reader for SequenceFiles that may contain Avro data.
|
static class |
AvroSequenceFile.Writer
A writer for an uncompressed SequenceFile that supports Avro data.
|
Modifier and Type | Field and Description |
---|---|
static Text |
METADATA_FIELD_KEY_SCHEMA
The SequenceFile.Metadata field for the Avro key writer schema.
|
static Text |
METADATA_FIELD_VALUE_SCHEMA
The SequenceFile.Metadata field for the Avro value writer schema.
|
Modifier and Type | Method and Description |
---|---|
static SequenceFile.Writer |
createWriter(AvroSequenceFile.Writer.Options options)
Creates a writer from a set of options.
|
public static final Text METADATA_FIELD_KEY_SCHEMA
public static final Text METADATA_FIELD_VALUE_SCHEMA
public static SequenceFile.Writer createWriter(AvroSequenceFile.Writer.Options options) throws IOException
Since there are different implementations of Writer
depending on
the compression type, this method constructs the appropriate subclass
depending on the compression type given in the options
.
options
- The options for the writer.IOException
- If the writer cannot be created.Copyright © 2009–2022 The Apache Software Foundation. All rights reserved.