Apache Avro – Example(Serialization and Deserialization)

I have used Protocol Buffer and just want to learn Avro. Here are few points from my learning.

Avro is extensively used in the Hadoop ecosystem. The schema should be defined in .avsc file. Please refer the below example schema file


{
	"namespace": "com.avro.entity",
	"type": "record",
	"name": "User",
	"fields": [
		{"name": "id",  "type": ["int", "null"]},
		{"name": "fName", "type": "string"},
                {"name": "lName", "type": "string"}
	 ]
}

Once define the schema file, then java classes needs to be generated for that schema file. Then the same java classes needs to be used in the applications.

We can either create the java classes with that schema or we can use the schema file directly in the application.

Please refer the below Github repo to know the serialization and deserialization of avro content.

https://github.com/dkbalachandar/avro-example

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s