Avro
  1. Avro
  2. AVRO-155

Make avro.io.DataFileReader iterable

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3.0
    • Component/s: python
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      When reading records out of a file object container using the Python bindings, it would be great to be able to say:

      for record in dfr:
        <do something with record>
      

      There's already a "next()" method defined on the DataFileReader, but the _iter_ method is not defined and we "return None" instead of "raise StopIteration" when out of records.

      1. AVRO-155.patch
        0.7 kB
        Jeff Hammerbacher
      2. AVRO-155_with_test.patch
        1 kB
        Sharad Agarwal

        Activity

        Hide
        Jeff Hammerbacher added a comment -

        Make DataFileReader iterable. Note that I didn't run the tests because I only have Java 5 on my box (thanks, Apple). If you have Java 6 and can check that tests pass, that would be great. If folks rely on next() returning "None" in a test, then some things will break.

        Show
        Jeff Hammerbacher added a comment - Make DataFileReader iterable. Note that I didn't run the tests because I only have Java 5 on my box (thanks, Apple). If you have Java 6 and can check that tests pass, that would be great. If folks rely on next() returning "None" in a test, then some things will break.
        Hide
        Sharad Agarwal added a comment -

        ant test worked fine with the patch.

        Show
        Sharad Agarwal added a comment - ant test worked fine with the patch.
        Hide
        Sharad Agarwal added a comment -

        Added the test case.

        Show
        Sharad Agarwal added a comment - Added the test case.
        Hide
        Jeff Hammerbacher added a comment -

        Thanks Sharad! Feel free to commit or ignore as you see fit.

        Show
        Jeff Hammerbacher added a comment - Thanks Sharad! Feel free to commit or ignore as you see fit.
        Hide
        Sharad Agarwal added a comment -

        I just committed this. Thanks Jeff.

        Show
        Sharad Agarwal added a comment - I just committed this. Thanks Jeff.

          People

          • Assignee:
            Jeff Hammerbacher
            Reporter:
            Jeff Hammerbacher
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development