Uploaded image for project: 'CarbonData'
  1. CarbonData
  2. CARBONDATA-2627

remove dependecy of tech.allegro.schema.json2avro

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 1.4.1
    • None
    • None

    Description

      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() }

      }
      }
      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Bjangir Babulal
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h 40m
                  2h 40m