In the previous chapter, we described the input type of Avro, i.e., Avro schemas. In this chapter, we will explain the classes and methods used in the serialization and deserialization of Avro schemas.
This class belongs to the package org.apache.avro.specific. It implements the DatumWriter interface which converts Java objects into an in-memory serialized format.
S.No. | Description |
---|---|
1 | SpecificDatumWriter(Schema schema) |
S.No. | Description |
---|---|
1 | SpecificData getSpecificData() Returns the SpecificData implementation used by this writer. |
This class belongs to the package org.apache.avro.specific. It implements the DatumReader interface which reads the data of a schema and determines in-memory data representation. SpecificDatumReader is the class which supports generated java classes.
S.No. | Description |
---|---|
1 | SpecificDatumReader(Schema schema) Construct where the writer's and reader's schemas are the same. |
S.No. | Description |
---|---|
1 | SpecificData getSpecificData() Returns the contained SpecificData. |
2 | void setSchema(Schema actual) This method is used to set the writer's schema. |
Instantiates DataFileWrite for emp class. This class writes a sequence serialized records of data conforming to a schema, along with the schema in a file.
S.No. | Description |
---|---|
1 | DataFileWriter(DatumWriter<D> dout) |
S.No | Description |
---|---|
1 | void append(D datum) Appends a datum to a file. |
2 | DataFileWriter<D> appendTo(File file) This method is used to open a writer appending to an existing file. |
This class provides random access to files written with DataFileWriter. It inherits the class DataFileStream.
S.No. | Description |
---|---|
1 | DataFileReader(File file, DatumReader<D> reader)) |
S.No. | Description |
---|---|
1 | next() Reads the next datum in the file. |
2 | Boolean hasNext() Returns true if more entries remain in this file. |
This class is a parser for JSON-format schemas. It contains methods to parse the schema. It belongs to org.apache.avro package.
S.No. | Description |
---|---|
1 | Schema.Parser() |
S.No. | Description |
---|---|
1 | parse (File file) Parses the schema provided in the given file. |
2 | parse (InputStream in) Parses the schema provided in the given InputStream. |
3 | parse (String s) Parses the schema provided in the given String. |
This interface provides methods to access the fields by name as well as index.
S.No. | Description |
---|---|
1 | Object get(String key) Returns the value of a field given. |
2 | void put(String key, Object v) Sets the value of a field given its name. |
S.No. | Description |
---|---|
1 | GenericData.Record(Schema schema) |
S.No. | Description |
---|---|
1 | Object get(String key) Returns the value of a field of the given name. |
2 | Schema getSchema() Returns the schema of this instance. |
3 | void put(int i, Object v) Sets the value of a field given its position in the schema. |
4 | void put(String key, Object value) Sets the value of a field given its name. |