Skip to end of metadata
Go to start of metadata


From Thrift

Avro's specific implementation can be very similar to thrift's IDL / generation paradigm. For an example of project that simultaneously supports both Java and Thrift, see Flume which has both Avro and Thrift Sources.

Source files

Here we see an avro IDL file and a thrift source file that represent the same RPC service.


Two key differences are that fields are not numbered in Avro in the same way they are numbered in Thrift and that maps are only allowed to have String keys, so they just require one parameter when defined.

Building clients and servers

On the client side, Avro generates a client class against which you can make RPC calls. This example shows how to instantiate a client that request over HTTP transport.

This is a similar, but not exactly equivalent thrift code segment:

On the server side, Avro creates an interface (similar to Thrift) that your server must implement. This will contain the method signatures from your IDL file.

In thrift we have:

Nonstandard data types

Avro has some quirky data-types that will cause hiccups if directly copying your thrift code.

Utf8 In older versions of Avro's (1.3.3 and earlier), function signatures that involve strings use Utf8() not String(). Your client and server implementations will expect to pass and receive Utf8() instances, so you will need to translate this type to and from String on your own.

Arrays If your function accepts or returns an Array type, you cannot simply pass a Java array. Instead, it will expect an implementing class of Avro's own GenericArray. To create an array of Strings, for example, use

  • No labels