You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Rumeshkrishnan (JIRA)" <ji...@apache.org> on 2019/01/02 10:08:00 UTC

[jira] [Comment Edited] (AVRO-1294) XML Encoder/Decoder implementations?

    [ https://issues.apache.org/jira/browse/AVRO-1294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16731906#comment-16731906 ] 

Rumeshkrishnan edited comment on AVRO-1294 at 1/2/19 10:07 AM:
---------------------------------------------------------------

Hi [~cutting],

I am come up with test schema and sample XML with data. We need to review this structure with our schema. I have provided the *doc* property for the fields which value different from standard way of XSD representation. I hope this is the starting point of our new XML encoder and decoder.

*Avro Schema:* 
{code:java}
{  
  "type" : "record",
  "name" : "TestSimpleSchema",
  "namespace" : "com.sample",
  "fields" : [
  {
   "name" : "field_null",
   "type" : "null",
   "doc"  : "either <field></field> or <field/> way value given in XML."
  },
  { "name" : "field_int", "type" : "int" },
  { "name" : "field_long", "type" : "long" },
  { "name" : "field_float", "type" : "float" },
  { "name" : "field_double", "type" : "double" },
  { "name" : "field_string", "type" : "string" },
  { "name" : "field_boolean", "type" : "boolean" },
  {
    "name" : "field_bytes",
    "type" : "bytes",
    "doc"  : "Base 64 encoded Binary String format in XML"
  },
  {
    "name" : "field_decimal",
    "type" : { "type": "bytes", "logicalType": "decimal", "precision": 4, "scale": 2 },
    "doc": "Base 64 encoded Binary String format in XML"
  },
  { "name" : "field_date", "type" : { "type": "int", "logicalType": "date" }},
  { "name" : "field_time_millis", "type" : { "type": "int", "logicalType": "time-millis" }},
  { "name" : "field_time_micros", "type" : { "type": "long", "logicalType": "time-micros" }},
  { "name" : "field_timestamp_millis", "type" : { "type": "long", "logicalType": "timestamp-millis" }},
  { "name" : "field_timestamp_micros", "type" : { "type": "long", "logicalType": "timestamp-micros" }},
  {
    "name": "field_simple_record",
    "type": {
      "type": "record",
      "name": "innerSchema",
      "fields": [
        { "name" : "field_sr_int", "type" : "int" },
        { "name" : "field_sr_long", "type" : "long" }
      ]
    }
  },
  {
    "name": "field_enum",
    "type": {
      "type": "enum",
      "name": "Suit",
      "symbols" : ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    }
  },
  {
    "name": "field_simple_array",
    "type": { "type": "array", "items": "string" },
    "doc": "value inside <avro:primitive_type></avro:primitive_type> tag for array in XML."
  },
  {
    "name": "field_simple_map",
    "type": { "type": "map", "values": "long"},
    "doc": "value inside <key></key> tag for map in XML."
  },
  {
    "name": "field_simple_union",
    "type": ["long", "double", "null"],
    "doc": "value inside <avro:primitive_type></avro:primitive_type> tag for any one of union type in XML."
  },
  {
    "name": "field_array_of_record",
    "type": {
      "type": "array",
      "items": {
        "type": "record",
        "name": "arrayItemSchema",
        "fields": [
          { "name" : "field_ar_int", "type" : "int" },
          { "name" : "field_ar_long", "type" : "long" }
        ]
      }
    }
  },
  {
    "name": "field_nullable_string_default",
    "type": ["null", "string"],
    "doc" : "if default value given than XML without this field in the sequence is acceptable.",
    "default": null
  }
 ]
}
{code}
*Sample XML:* 
{code:java}
<TestSimpleSchema>
  <field_null></field_null>
  <field_int>10</field_int>
  <field_long>123456</field_long>
  <field_float>123.45</field_float>
  <field_double>123456.43231</field_double>
  <field_string>Hello World.!</field_string>
  <field_boolean>false</field_boolean>
  <field_bytes>DSFFDSG4=</field_bytes>
  <field_decimal>ASDVRTWE=</field_decimal>
  <field_date>17987</field_date>
  <field_time_millis>12345</field_time_millis>
  <field_time_micros>12345678</field_time_micros>
  <field_timestamp_millis>1546420775354</field_timestamp_millis>
  <field_timestamp_micros>1546420775354831</field_timestamp_micros>
  <field_simple_record>
    <field_sr_int>0</field_sr_int>
    <field_sr_long>987511</field_sr_long>
  </field_simple_record>
  <field_enum>SPADES</field_enum>
  <field_simple_array>
    <avro:string>one</avro:string>
    <avro:string>two</avro:string>
  </field_simple_array>
  <field_simple_map>
    <key_one>12345</key_one>
    <key_two>67890</key_two>
  </field_simple_map>
  <field_simple_union>
    <avro:long>23456789</avro.long>
  </field_simple_union>
  <field_array_of_record>
    <arrayItemSchema>
      <field_ar_int>324</field_ar_int>
      <field_ar_long>435132543</field_ar_long>
    </arrayItemSchema>
    <arrayItemSchema>
      <field_ar_int>234</field_ar_int>
      <field_ar_long>3245342643</field_ar_long>
    </arrayItemSchema>
  </field_array_of_record>
</TestSimpleSchema>{code}
Let me know what every one think about this structure. Can any one assign this task to my name ?

 


was (Author: rumeshkrish):
Hi [~cutting],

I am come up with test schema and sample XML with data. We need to review this structure with our schema. I have provided the *doc* property for the fields which value different way of representation from usual XSD. I hope this is the starting point of our new encoder and decoder development.

*Avro Schema:* 
{code:java}
{  
  "type" : "record",
  "name" : "TestSimpleSchema",
  "namespace" : "com.sample",
  "fields" : [
  {
   "name" : "field_null",
   "type" : "null",
   "doc"  : "either <field></field> or <field/> way value given in XML."
  },
  { "name" : "field_int", "type" : "int" },
  { "name" : "field_long", "type" : "long" },
  { "name" : "field_float", "type" : "float" },
  { "name" : "field_double", "type" : "double" },
  { "name" : "field_string", "type" : "string" },
  { "name" : "field_boolean", "type" : "boolean" },
  {
    "name" : "field_bytes",
    "type" : "bytes",
    "doc"  : "Base 64 encoded Binary String format in XML"
  },
  {
    "name" : "field_decimal",
    "type" : { "type": "bytes", "logicalType": "decimal", "precision": 4, "scale": 2 },
    "doc": "Base 64 encoded Binary String format in XML"
  },
  { "name" : "field_date", "type" : { "type": "int", "logicalType": "date" }},
  { "name" : "field_time_millis", "type" : { "type": "int", "logicalType": "time-millis" }},
  { "name" : "field_time_micros", "type" : { "type": "long", "logicalType": "time-micros" }},
  { "name" : "field_timestamp_millis", "type" : { "type": "long", "logicalType": "timestamp-millis" }},
  { "name" : "field_timestamp_micros", "type" : { "type": "long", "logicalType": "timestamp-micros" }},
  {
    "name": "field_simple_record",
    "type": {
      "type": "record",
      "name": "innerSchema",
      "fields": [
        { "name" : "field_sr_int", "type" : "int" },
        { "name" : "field_sr_long", "type" : "long" }
      ]
    }
  },
  {
    "name": "field_enum",
    "type": {
      "type": "enum",
      "name": "Suit",
      "symbols" : ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    }
  },
  {
    "name": "field_simple_array",
    "type": { "type": "array", "items": "string" },
    "doc": "value inside <avro:primitive_type></avro:primitive_type> tag for array in XML."
  },
  {
    "name": "field_simple_map",
    "type": { "type": "map", "values": "long"},
    "doc": "value inside <key></key> tag for map in XML."
  },
  {
    "name": "field_simple_union",
    "type": ["long", "double", "null"],
    "doc": "value inside <avro:primitive_type></avro:primitive_type> tag for any one of union type in XML."
  },
  {
    "name": "field_array_of_record",
    "type": {
      "type": "array",
      "items": {
        "type": "record",
        "name": "arrayItemSchema",
        "fields": [
          { "name" : "field_ar_int", "type" : "int" },
          { "name" : "field_ar_long", "type" : "long" }
        ]
      }
    }
  },
  {
    "name": "field_nullable_string_default",
    "type": ["null", "string"],
    "doc" : "if default value given than XML without this field in the sequence is acceptable.",
    "default": null
  }
 ]
}
{code}
*Sample XML:* 
{code:java}
<TestSimpleSchema>
  <field_null></field_null>
  <field_int>10</field_int>
  <field_long>123456</field_long>
  <field_float>123.45</field_float>
  <field_double>123456.43231</field_double>
  <field_string>Hello World.!</field_string>
  <field_boolean>false</field_boolean>
  <field_bytes>DSFFDSG4=</field_bytes>
  <field_decimal>ASDVRTWE=</field_decimal>
  <field_date>17987</field_date>
  <field_time_millis>12345</field_time_millis>
  <field_time_micros>12345678</field_time_micros>
  <field_timestamp_millis>1546420775354</field_timestamp_millis>
  <field_timestamp_micros>1546420775354831</field_timestamp_micros>
  <field_simple_record>
    <field_sr_int>0</field_sr_int>
    <field_sr_long>987511</field_sr_long>
  </field_simple_record>
  <field_enum>SPADES</field_enum>
  <field_simple_array>
    <avro:string>one</avro:string>
    <avro:string>two</avro:string>
  </field_simple_array>
  <field_simple_map>
    <key_one>12345</key_one>
    <key_two>67890</key_two>
  </field_simple_map>
  <field_simple_union>
    <avro:long>23456789</avro.long>
  </field_simple_union>
  <field_array_of_record>
    <arrayItemSchema>
      <field_ar_int>324</field_ar_int>
      <field_ar_long>435132543</field_ar_long>
    </arrayItemSchema>
    <arrayItemSchema>
      <field_ar_int>234</field_ar_int>
      <field_ar_long>3245342643</field_ar_long>
    </arrayItemSchema>
  </field_array_of_record>
</TestSimpleSchema>{code}
Let me know what every one think about this structure. Can any one assign this task to my name ?

 

> XML Encoder/Decoder implementations?
> ------------------------------------
>
>                 Key: AVRO-1294
>                 URL: https://issues.apache.org/jira/browse/AVRO-1294
>             Project: Apache Avro
>          Issue Type: New Feature
>          Components: java
>            Reporter: Brian Kent
>            Priority: Minor
>
> Are there any plans to support XML Encoder/Decoder implementations?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)