Thrift
  1. Thrift
  2. THRIFT-589

Add Field Name to Field ID Mapping

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.2
    • Fix Version/s: 0.2
    • Component/s: Java - Compiler
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      The reflection stuff in java thrift is quite useful, but to use it you must know the field id (not the name) of the field you are working with.
      Given a field name, you can obtain the corresponding ID by iterating through the metaDataMap, but it's not ideal.

      1. thrift589-3.patch
        3 kB
        Cyrus Katrak
      2. thrift589-2.patch
        3 kB
        Cyrus Katrak
      3. thrift589.patch
        2 kB
        Cyrus Katrak

        Activity

        Hide
        Cyrus Katrak added a comment -

        Patch taken against r817892

        Show
        Cyrus Katrak added a comment - Patch taken against r817892
        Hide
        Cyrus Katrak added a comment -

        Newest patch adds tests.

        compile:
        [javac] Compiling 54 source files to /home/yellowcake/co/thrift/lib/java/build
        [javac] Note: Some input files use unchecked or unsafe operations.
        [javac] Note: Recompile with -Xlint:unchecked for details.

        dist:
        [mkdir] Created dir: /home/yellowcake/co/thrift/lib/java/build/META-INF
        [copy] Copying 1 file to /home/yellowcake/co/thrift/lib/java/build/META-INF
        [copy] Copying 1 file to /home/yellowcake/co/thrift/lib/java/build/META-INF
        [jar] Building jar: /home/yellowcake/co/thrift/lib/java/libthrift.jar

        compile-test:
        [javac] Compiling 45 source files to /home/yellowcake/co/thrift/lib/java/build/test
        [javac] Note: Some input files use unchecked or unsafe operations.
        [javac] Note: Recompile with -Xlint:unchecked for details.
        [javac] Compiling 1 source file to /home/yellowcake/co/thrift/lib/java/build/test
        [javac] Note: /home/yellowcake/co/thrift/lib/java/gen-javabean/thrift/test/OneOfEachBeans.java uses unchecked or unsafe operations.
        [javac] Note: Recompile with -Xlint:unchecked for details.
        [javac] Compiling 17 source files to /home/yellowcake/co/thrift/lib/java/build/test

        test:
        [java] In JSON Proto test
        [java] Writing ooe
        [java] Reading ooe
        [java] Comparing ooe
        [java] Writing hm
        [java] Reading hm
        [java] Comparing hm
        [java] Writing base
        [java] Reading base
        [java] Comparing base
        [java] Size in compact protocol: 116
        [java] Size in compact protocol: 145
        [java] Size in compact protocol: 331
        [java] Size in compact protocol: 625
        [java] <TestUnion i32_field:25>

        BUILD SUCCESSFUL

        Show
        Cyrus Katrak added a comment - Newest patch adds tests. compile: [javac] Compiling 54 source files to /home/yellowcake/co/thrift/lib/java/build [javac] Note: Some input files use unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. dist: [mkdir] Created dir: /home/yellowcake/co/thrift/lib/java/build/META-INF [copy] Copying 1 file to /home/yellowcake/co/thrift/lib/java/build/META-INF [copy] Copying 1 file to /home/yellowcake/co/thrift/lib/java/build/META-INF [jar] Building jar: /home/yellowcake/co/thrift/lib/java/libthrift.jar compile-test: [javac] Compiling 45 source files to /home/yellowcake/co/thrift/lib/java/build/test [javac] Note: Some input files use unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. [javac] Compiling 1 source file to /home/yellowcake/co/thrift/lib/java/build/test [javac] Note: /home/yellowcake/co/thrift/lib/java/gen-javabean/thrift/test/OneOfEachBeans.java uses unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. [javac] Compiling 17 source files to /home/yellowcake/co/thrift/lib/java/build/test test: [java] In JSON Proto test [java] Writing ooe [java] Reading ooe [java] Comparing ooe [java] Writing hm [java] Reading hm [java] Comparing hm [java] Writing base [java] Reading base [java] Comparing base [java] Size in compact protocol: 116 [java] Size in compact protocol: 145 [java] Size in compact protocol: 331 [java] Size in compact protocol: 625 [java] <TestUnion i32_field:25> BUILD SUCCESSFUL
        Hide
        Bryan Duxbury added a comment -

        This generally looks pretty good. I would like to see you generate the map with the FIELD_NAME constants instead of the ids directly, though.

        Show
        Bryan Duxbury added a comment - This generally looks pretty good. I would like to see you generate the map with the FIELD_NAME constants instead of the ids directly, though.
        Hide
        Cyrus Katrak added a comment -

        Changes made, now using the FIELD_NAME constants

        test:
        [java] In JSON Proto test
        [java] Writing ooe
        [java] Reading ooe
        [java] Comparing ooe
        [java] Writing hm
        [java] Reading hm
        [java] Comparing hm
        [java] Writing base
        [java] Reading base
        [java] Comparing base
        [java] Size in compact protocol: 116
        [java] Size in compact protocol: 145
        [java] Size in compact protocol: 331
        [java] Size in compact protocol: 625
        [java] <TestUnion i32_field:25>

        BUILD SUCCESSFUL

        Show
        Cyrus Katrak added a comment - Changes made, now using the FIELD_NAME constants test: [java] In JSON Proto test [java] Writing ooe [java] Reading ooe [java] Comparing ooe [java] Writing hm [java] Reading hm [java] Comparing hm [java] Writing base [java] Reading base [java] Comparing base [java] Size in compact protocol: 116 [java] Size in compact protocol: 145 [java] Size in compact protocol: 331 [java] Size in compact protocol: 625 [java] <TestUnion i32_field:25> BUILD SUCCESSFUL
        Hide
        Bryan Duxbury added a comment -

        I just committed this. Thanks for the patch, Cyrus!

        Show
        Bryan Duxbury added a comment - I just committed this. Thanks for the patch, Cyrus!

          People

          • Assignee:
            Cyrus Katrak
            Reporter:
            Cyrus Katrak
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development