Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.6.1
    • Fix Version/s: 1.6.2
    • Component/s: java
    • Labels:
      None

      Description

      If i create a copy of a Schema.Field using the constructor i lose the props and aliases. I can find out what the props are and add them back in using Schema.Field.props() but there is no way to find out the aliases. Can we also expose the aliases? Set<String> Schema.Field.aliases()?

      1. AVRO-1016.patch
        2 kB
        Doug Cutting
      2. AVRO-1016.diff
        0.7 kB
        koert kuipers

        Activity

        Hide
        koert kuipers added a comment -

        svn diff done in dir trunk/lang/java/avro

        Show
        koert kuipers added a comment - svn diff done in dir trunk/lang/java/avro
        Hide
        Doug Cutting added a comment -

        Here's a modified version of the patch that:

        • adds some tests; and
        • avoids printing empty alias lists when copying aliases to a new Field instance.
        Show
        Doug Cutting added a comment - Here's a modified version of the patch that: adds some tests; and avoids printing empty alias lists when copying aliases to a new Field instance.
        Hide
        Scott Carey added a comment -

        Should the copy constructor also copy aliases and props? Should we create such a copy constructor or static factory method that creates a new field based on an old one, and retains aliases and/or props? Creating a new one, then filling out the bits one by one seems like a clumsy API. Either way we need the exposed aliases() getter.

        Show
        Scott Carey added a comment - Should the copy constructor also copy aliases and props? Should we create such a copy constructor or static factory method that creates a new field based on an old one, and retains aliases and/or props? Creating a new one, then filling out the bits one by one seems like a clumsy API. Either way we need the exposed aliases() getter.
        Hide
        Doug Cutting added a comment -

        A copy constructor would work if you want an exact copy of the field. I'd not object to adding that. But if you're copying a field and manipulating parts of it then a copy-constructor alone might not be sufficient.

        Ideally we might have a builder API for Field and Schema, where each of these could accept an existing instance as the base. Then you could do something like:

        new Builder(oldField).setName("foo").build();

        But that seems beyond the scope of this issue.

        Show
        Doug Cutting added a comment - A copy constructor would work if you want an exact copy of the field. I'd not object to adding that. But if you're copying a field and manipulating parts of it then a copy-constructor alone might not be sufficient. Ideally we might have a builder API for Field and Schema, where each of these could accept an existing instance as the base. Then you could do something like: new Builder(oldField).setName("foo").build(); But that seems beyond the scope of this issue.
        Hide
        Scott Carey added a comment -

        I agree, it is out of scope to go as far as a builder API. Going half way with many static method signatures complicates the API more than it helps.

        +1 as is.

        Show
        Scott Carey added a comment - I agree, it is out of scope to go as far as a builder API. Going half way with many static method signatures complicates the API more than it helps. +1 as is.
        Hide
        Doug Cutting added a comment -

        I committed this.

        Show
        Doug Cutting added a comment - I committed this.

          People

          • Assignee:
            Doug Cutting
            Reporter:
            koert kuipers
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development