avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tl ...@rat.io>
Subject Re: Json.ObjectWriter - "Not the Json schema"
Date Wed, 24 Feb 2016 12:46:01 GMT
Hi again,

I still haven’t found a solution to this problem. Does this look like some beginners Java
mistake (because that may well be…)? Is it okay to ask the same question on stackoverflow
or would that count as crossposting/spamming?

Cheers,
Thomas


> On 23.02.2016, at 02:22, tl <tl@rat.io> wrote:
> 
> Hi,
> 
> 
> I want to convert incoming data to Avro and JSON (and later Parquet). Avro conversion
is working okay, but JSON conversion throws the following error that I don’t understand:
> 
> Exception in thread "main" java.lang.RuntimeException: Not the Json schema: {"type":"record","name":"Torperf","namespace":"converTor.torperf","fields":[{"name":"descriptor_type","type":"string","default":"torperf
1.0"},
> [ … omitted for brevity …]
> {"name":"circ_id","type":["null","int"],"doc":"metrics-lib/TorperfResult: int getCircId()"},{"name":"used_by","type":["null","int"],"doc":"metrics-lib/TorperfResult:
int getUsedBy()"}],"aliases":["torperfResult"]}
> 	at org.apache.avro.data.Json$ObjectWriter.setSchema(Json.java:117)
> 	at converTor.WriterObject.<init>(WriterObject.java:116)
> 	at converTor.TypeWriter.get(TypeWriter.java:31)
> 	at converTor.ConverTor.main(ConverTor.java:249)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:606)
> 	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
> 
> … but that schema is indeed the schema that I want to use.
> 
> 
> This is a snippet of my code:
> 
> File schemaFile = new File("schema/jsonSchema.avsc");
> Schema.Parser parser = new Schema.Parser();
> Schema mySchema = parser.parse(schemaFile) ;
> 
> Json.ObjectWriter jsonDatumWriter = new Json.ObjectWriter();
> jsonDatumWriter.setSchema(mySchema);
> OutputStream out = new FileOutputStream(outputFile);
> Encoder encoder = EncoderFactory.get().jsonEncoder(mySchema, out);
> 
> 
> Can somebody give me a hint?
> 
> 
> Thanks,
> Thomas





Mime
View raw message