Avro
  1. Avro
  2. AVRO-1137

Could we have a folder with examples/samples in the source code

    Details

    • Type: Improvement Improvement
    • Status: Patch Available
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      all

      Description

      I don't know if there are a collection of examples of usages of Avro anywhere (something like jfreechart has). I've recently posted on stack overflow an example of a problem I ran into:
      http://stackoverflow.com/questions/11866466/using-apache-avro-reflect

        Activity

        Ajo Fod created issue -
        Hide
        Ajo Fod added a comment -

        I am a java user, so I can't speak for the rest, but it would be useful to have a simple example of how to use at least the following features:

        • Read/Write into a file with Reflect Specific and Generic API
        • Use null/union/array/map and any other data structures in each of reflect/specific/generic for read and write.
        • I'm not yet using RPC, but I'm sure people may appreciate examples of that as well.
        Show
        Ajo Fod added a comment - I am a java user, so I can't speak for the rest, but it would be useful to have a simple example of how to use at least the following features: Read/Write into a file with Reflect Specific and Generic API Use null/union/array/map and any other data structures in each of reflect/specific/generic for read and write. I'm not yet using RPC, but I'm sure people may appreciate examples of that as well.
        Hide
        Doug Cutting added a comment -

        I added an answer to your stack overflow question.

        There are lots of examples in unit tests, but they're perhaps they're too complex.

        So probably we should add some examples.

        Should we add these to the javadoc? The above might be added to the page:

        http://avro.apache.org/docs/current/api/java/org/apache/avro/reflect/package-summary.html

        We might add similar examples for generic and specific.

        Show
        Doug Cutting added a comment - I added an answer to your stack overflow question. There are lots of examples in unit tests, but they're perhaps they're too complex. So probably we should add some examples. Should we add these to the javadoc? The above might be added to the page: http://avro.apache.org/docs/current/api/java/org/apache/avro/reflect/package-summary.html We might add similar examples for generic and specific.
        Hide
        Ajo Fod added a comment -

        I went through some of the tests. I find those examples hard to use in simple examples. I feel they are geared towards testing out the codebase.

        For samples, I'd recommend a new package that have a classes with a main method and help on how to invoke them with different CLI options (e.g: switch between Reflect/Specific/Generic API where appropriate).

        https://github.com/wpm/AvroExample/blob/master/src/main/java/wpmcn/AvroExample.java
        The above is a simple example of code that switches between Generic and Specific API. It would be useful if examples such as these lived in package called samples (... or something). They would then be updated with changes to the codebase.

        When I write code for my projects I keep examples such as those around in a separate package to help me get my bearings. I find the ability to play with examples very useful when one has to deal with multiple packages.

        I spent some time with tests and you are right they were a bit too complicated and also hard to play with i.e. manipulate slightly to see the effects of a small change.

        P.S.
        One example to add to the Reflect API would be the inheritance/interfaces to imply unions (my interpretation of what is happening in one of the tests).

        Show
        Ajo Fod added a comment - I went through some of the tests. I find those examples hard to use in simple examples. I feel they are geared towards testing out the codebase. For samples, I'd recommend a new package that have a classes with a main method and help on how to invoke them with different CLI options (e.g: switch between Reflect/Specific/Generic API where appropriate). https://github.com/wpm/AvroExample/blob/master/src/main/java/wpmcn/AvroExample.java The above is a simple example of code that switches between Generic and Specific API. It would be useful if examples such as these lived in package called samples (... or something). They would then be updated with changes to the codebase. When I write code for my projects I keep examples such as those around in a separate package to help me get my bearings. I find the ability to play with examples very useful when one has to deal with multiple packages. I spent some time with tests and you are right they were a bit too complicated and also hard to play with i.e. manipulate slightly to see the effects of a small change. P.S. One example to add to the Reflect API would be the inheritance/interfaces to imply unions (my interpretation of what is happening in one of the tests).
        Ajo Fod made changes -
        Field Original Value New Value
        Status Open [ 1 ] Patch Available [ 10002 ]
        Hide
        Ajo Fod added a comment -

        A couple of examples included here. Hopefully this will go into the codebase.

        Show
        Ajo Fod added a comment - A couple of examples included here. Hopefully this will go into the codebase.
        Ajo Fod made changes -
        Attachment avro.helloworld.zip [ 12541076 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Patch Available Patch Available
        7d 1h 12m 1 Ajo Fod 15/Aug/12 16:46

          People

          • Assignee:
            Unassigned
            Reporter:
            Ajo Fod
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development