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

Scott Carey edited comment on AVRO-853 at 7/7/11 6:22 PM:
----------------------------------------------------------

{quote}
I think we have two consistent choices:

* Schemas are equal only if all aliases, props, and doc fields match exactly – 
in other words if toString() prints the same result.
* Schemas are equal based on name, type, and structure alone. In other words, 
they can exchange serialized data without type promotion.
{quote}

I want to discuss this point a bit more.  These in my mind are the two 
fundamental use cases for equivalence of schemas:

*  Does a set of equivalent schemas contain the same information in their JSON 
form?  (requires equivalent props, aliases, and doc)
or
*  Can a set of equivalent schemas participate in mutial exchange of serialized 
information according to the Avro spec? (requires ignoring props, aliases, and 
doc)

Type promotion in schema resolution cannot be part of equals() because it is 
asymmetric.  {"int"} promotesTo {"long"} but not vice-versa.
Alias translation cannot be part of equals() because it is not transitive (but 
it is pair-symmetric).
These are separate questions, not one of equivalence.

There are more equivalence classes that may be useful too, such as:
*  Can a set of equivalent schemas participate in mutial exchange of serialized 
information without losing data, ignoring the Avro spec (do not need to match 
names, just structure and types)






      was (Author: scott_carey):
    {quote}
I think we have two consistent choices:

* Schemas are equal only if all aliases, props, and doc fields match exactly – 
in other words if toString() prints the same result.
* Schemas are equal based on name, type, and structure alone. In other words, 
they can exchange serialized data without type promotion.
{quote}

I want to discuss this point a bit more.  These in my mind are the two 
fundamental use cases for equivalence of schemas:

*  In their JSON form, do they contain the same information?  (requires 
checking props, aliases, and doc)
or
*  Can these two schemas participate in a bi-directional exchange of serialized 
information according to the Avro spec? (requires ignoring props, aliases, and 
doc)

Type promotion in schema resolution cannot be part of equals() because it is 
asymmmetric.  {"int"} promotesTo {"long"} but not vice-versa.  Like alias 
translation, this is a separate question and not one of equivalence.  Type 
promotion is one-way, alias translation is two-way but not transitive.




  
> Cache hash codes in Schema and Field
> ------------------------------------
>
>                 Key: AVRO-853
>                 URL: https://issues.apache.org/jira/browse/AVRO-853
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.5.1
>            Reporter: Douglas Kaminsky
>         Attachments: AVRO-853-approach2.patch, AVRO-853.patch
>
>
> We are experiencing a serious performance degradation when trying to 
> store/retrieve fields and schemas in hash-based data structures (eg. 
> HashMap). Since all fields and schemas are immutable (with the exception of 
> RecordSchema allowing deferred setting of Fields) it makes sense to cache the 
> hash code on the object instead of recalculating every time the hashCode 
> method gets called. 
> (Are there other mutable Schema sub-types that I'm not thinking about?)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to