avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sachingsachin <...@git.apache.org>
Subject [GitHub] avro pull request: AVRO-695: Support for circular references.
Date Mon, 09 Mar 2015 22:26:35 GMT
GitHub user sachingsachin opened a pull request:

    https://github.com/apache/avro/pull/23

    AVRO-695: Support for circular references.

    All objects are put into a temporary thread-local hash-map whose key is the object and
value is an integer ID.
    If any object is seen again while serializaing, its ID is taken from the hash-map, wrapped
into 'CircularRef' class and the CircularRef wrapper is serialized instead.
    
    On deserializing, if the CircularRef is encountered, we know that it has to be the ID
of a previously seen object.
    And so we restore the same.
    
    On the schema side, we create unions of all classes with CircularRef if the user suspects
circular references in his code. This union makes sure the above writers are able to write
a CircularRef instead of the actual object.
    
    Note that this strategy is perfectly safe in other languages' deserialization of a circularly
referenced data.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/sachingsachin/avro AVRO-695

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/avro/pull/23.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #23
    
----
commit e3f9295474a3f45c022850cb4ac2ba84a8ac31f4
Author: Sachin Goyal <sgoyal@walmart.com>
Date:   2015-03-09T22:18:01Z

    AVRO-695: Support for circular references.
    
    All objects are put into a temporary thread-local hash-map whose key is the object and
value is an integer ID.
    If any object is seen again while serializaing, its ID is taken from the hash-map,
    wrapped into 'CircularRef' class and the CircularRef wrapper is serialized instead.
    On deserializing, if the CircularRef is encountered, we know that it has to be the ID
of a previously seen object.
    And so we restore the same.
    
    On the schema side, we create unions of all classes with CircularRef if the user suspects
circular references in his code.
    This union makes sure the above writers are able to write a CircularRef instead of the
actual object.
    
    Note that this strategy is perfectly safe in other languages' deserialziation of a circularly
referenced data.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message