Thanks for the architecture clarification! That helps a lot.

I read somewhere that it's suppose to be easy to switch between binary
encoding and json encoding for application testing and debugging. I also
read that schemas were always added to the data output so the schema file
itself is not required on the reader side. But after playing around with the
code, I only figured out how save the schema with the data in binary
(DataFileWriter method) or without the schema in json (Encoder method).
That's when I became confused as to which method to use and if its possible
to save data in json with a schema.
On Jul 13, 2011 2:45 PM, "Doug Cutting" <[email protected]> wrote:
> On 07/13/2011 12:15 PM, Wei Yang wrote:
>
>> So my questions are: 1.) Is there a way to encode the schema into the
>> output using the Encoder/Decoder method? 2.) Is there a way to encode
>> the schema into an Json output?
>
> One can encode the schema as a string. What is the use case you have in
> mind?
>
>> 3.) How does the DataFileWrite/Reader,
>> GenericDatumWriter/Reader and Encoder/Decoder all fit together
>> architecturally?
>
> Encoder and Decoder are the lowest level APIs. They primarily encode
> and decode primitive values. These are not generally used directly by
> applications, although an application might use them as a event-oriented
> API, akin to XML's SAX.
>
> DatumReader and DatumWriter are mid-level APIs. They serialize and
> de-serialize Java objects using an Encoder or Decoder. Different
> versions are used for different Java representations of a Schema. These
> are used by folks implementing Avro data containers, like data files or
RPC.
>
> DataFileReader and DataFileWriter are the application-level APIs. They
> permit one to read and write objects from files.
>
> Doug

Reply via email to