avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lan Jiang <ljia...@gmail.com>
Subject Converting Protobuf object to Avro
Date Mon, 24 Aug 2015 19:54:56 GMT
Hi, there

I am trying to convert a protobuf object to Avro. I am using 	

//myProto object is deserialized using google protobuf API
ProtobufDatumWriter<MyProto> pbWriter = new ProtobufDatumWriter<MyProto>(MyProto.class);
FileOutputStream fo = new FileOutputStream(args[0]);
Encoder e = EncoderFactory.get().binaryEncoder(fo, null);
pbWriter.write(myProto, e);
fo.flush();

The avro file was created successfully. If I cat the file, I can see the data in the file.
However, when I tried to use avro-tools to get schema or meta info about the saved avro file,
it says

Exception in thread "main" java.io.IOException: Not a data file.
	at org.apache.avro.file.DataFileStream.initialize(DataFileStream.java:105)
	at org.apache.avro.file.DataFileReader.<init>(DataFileReader.java:97)
	at org.apache.avro.tool.DataFileGetSchemaTool.run(DataFileGetSchemaTool.java:47)

Look at the Avro source code, the error means it does not have the first 4 bytes matching
the MAGIC first 4 bytes. I am trying to see if I have done anything wrong. 

Appreciate any help you can give me.

Lan
Mime
View raw message