[
https://issues.apache.org/jira/browse/CARBONDATA-2627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ravindra Pesala resolved CARBONDATA-2627.
-----------------------------------------
Resolution: Fixed
Fix Version/s: 1.4.1
> remove dependecy of tech.allegro.schema.json2avro
> -------------------------------------------------
>
> Key: CARBONDATA-2627
> URL:
https://issues.apache.org/jira/browse/CARBONDATA-2627> Project: CarbonData
> Issue Type: Bug
> Reporter: Babulal
> Priority: Minor
> Fix For: 1.4.1
>
> Time Spent: 2h 40m
> Remaining Estimate: 0h
>
> currently tech.allegro.schema.json2avro is used for json to avro converter but it is not formally supported by AVRO and may feature does not work in converter like byte data type.
> Below code can be used instead of
>
> def jsonToAvro( json:String, schemaStr:String) :GenericRecord= {
> var input :InputStream= null;
> var writer :DataFileWriter[GenericRecord] = null;
> var encoder :Encoder= null;
> var output :ByteArrayOutputStream= null;
> try {
> val schema = new org.apache.avro.Schema.Parser().parse(schemaStr);
> val reader = new GenericDatumReader[GenericRecord](schema);
> input = new ByteArrayInputStream(json.getBytes());
> output = new ByteArrayOutputStream();
> val din = new DataInputStream(input);
> writer = new DataFileWriter[GenericRecord](new GenericDatumWriter[GenericRecord]());
> writer.create(schema, output);
> val decoder = DecoderFactory.get().jsonDecoder(schema, din);
> var datum :GenericRecord=null;
> datum = reader.read(null, decoder);
> return datum;
> } finally {
> try {
> input.close();
> writer.close();
> } catch {
> case e:Exception => {
> e.printStackTrace()
> }
> }
> }
> }
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)