You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "tilgalas (via GitHub)" <gi...@apache.org> on 2025/10/21 16:00:42 UTC

[PR] make use of generic type info in *Utils classes [beam]

tilgalas opened a new pull request, #36581:
URL: https://github.com/apache/beam/pull/36581

   This is a 4th PR in the series of PRs (based on the now closed https://github.com/apache/beam/pull/31648) whose ultimate goal is to add support for generic classes to schema providers.
   
   This PR replaces the uses of incomplete type information carried in `TypeDescriptor.of` invocations in the various *Utils classes with the full type signature stored in the `FieldValueTypeInformation` objects
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "tilgalas (via GitHub)" <gi...@apache.org>.
tilgalas commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3503656349

   Run Java PreCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "tilgalas (via GitHub)" <gi...@apache.org>.
tilgalas commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3431593678

   Run Java PreCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "tilgalas (via GitHub)" <gi...@apache.org>.
tilgalas commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3431599167

   Run Java_Amazon-Web-Services2_IO_Direct PreCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3480233628

   Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment `assign to next reviewer`:
   
   R: @kennknowles for label java.
   
   Available commands:
   - `stop reviewer notifications` - opt out of the automated review tooling
   - `remind me after tests pass` - tag the comment author after tests pass
   - `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3427417524

   ## Summary of Changes
   
   Hello @tilgalas, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
   
   This pull request is the fourth in a series aimed at enabling full support for generic classes within Beam's schema providers. It focuses on refining how type information is accessed and utilized across various utility classes responsible for schema-related operations. By transitioning from potentially incomplete `TypeDescriptor` invocations to the more robust `FieldValueTypeInformation`, the changes ensure that type conversions, field access, and bytecode generation are performed with accurate and complete generic type signatures, laying essential groundwork for future generic class support.
   
   ### Highlights
   
   * **Enhanced Type Information Usage**: The pull request updates several `*Utils` classes (`AutoValueUtils`, `ByteBuddyUtils`, `JavaBeanUtils`, `POJOUtils`) to utilize the comprehensive generic type information provided by `FieldValueTypeInformation` objects. This replaces previous reliance on `TypeDescriptor.of` which could provide incomplete type signatures, especially for generic types.
   * **Refactoring of Setter Generation in POJOUtils**: The logic for generating `FieldValueSetter` instances has been removed from `POJOUtils.java`, along with associated caching mechanisms and test cases. This indicates a significant refactoring or relocation of setter creation responsibilities.
   * **Improved Type Conversion and Casting**: New type casting logic has been introduced in `JavaBeanUtils.java` and `POJOUtils.java` for getter implementations, ensuring correct type handling during bytecode generation. Additionally, `ByteBuddyUtils.java` now includes a `primitiveToWrapper` helper for more robust type conversions in collections and iterables.
   * **Streamlined API for Getter/Setter Implementations**: Methods like `implementGetterMethods` in `JavaBeanUtils.java` and `POJOUtils.java`, and `SetFieldCreateInstruction` in `POJOUtils.java`, have been refactored to directly accept `FieldValueTypeInformation` lists or objects, simplifying their interfaces and promoting consistent type handling.
   
   
   
   
   
   
   
   <details>
   <summary><b>Using Gemini Code Assist</b></summary>
   <br>
   
   The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.
   
   <b>Invoking Gemini</b>
   
   You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page.
   
   Feature | Command | Description
   --- | --- | ---
   Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
   Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
   Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments.
   Help | `/gemini help` | Displays a list of available commands.
   
   <b>Customization</b>
   
   To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
   
   <b>Limitations & Feedback</b>
   
   Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
   
   <b>You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the [Gemini Code Assist IDE Extension](https://cloud.google.com/products/gemini/code-assist).</b>
   </details>
   
   
   
   
   [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3428786019

   Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "tilgalas (via GitHub)" <gi...@apache.org>.
tilgalas commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3431603408

   Run Java_IOs_Direct PreCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3428584329

   ## [Codecov](https://app.codecov.io/gh/apache/beam/pull/36581?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 56.93%. Comparing base ([`d0d0cd8`](https://app.codecov.io/gh/apache/beam/commit/d0d0cd8c2f1f40d22a3e5c73c6606761eea98999?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`9eebd65`](https://app.codecov.io/gh/apache/beam/commit/9eebd65cbac5071191fda1dc929a0b76393a2b35?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 9 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff            @@
   ##             master   #36581   +/-   ##
   =========================================
     Coverage     56.93%   56.93%           
   - Complexity     3393     3395    +2     
   =========================================
     Files          1222     1222           
     Lines        186813   186817    +4     
     Branches       3543     3545    +2     
   =========================================
   + Hits         106362   106373   +11     
   + Misses        77079    77073    -6     
   + Partials       3372     3371    -1     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/beam/pull/36581/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [java](https://app.codecov.io/gh/apache/beam/pull/36581/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.34% <ø> (+0.02%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/beam/pull/36581?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3431839891

   Assigning reviewers:
   
   R: @chamikaramj for label java.
   
   
   Note: If you would like to opt out of this review, comment `assign to next reviewer`.
   
   Available commands:
   - `stop reviewer notifications` - opt out of the automated review tooling
   - `remind me after tests pass` - tag the comment author after tests pass
   - `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
   
   The PR bot will only process comments in the main thread (not review comments).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "tilgalas (via GitHub)" <gi...@apache.org>.
tilgalas commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3490843125

   > This mostly seems fine, I'm just still catching up on the design doc and everything and the new FieldValueTypeInformation vs TypeDescriptor. So I still have more like high level curiosity.
   
   sure, thanks so much!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "tilgalas (via GitHub)" <gi...@apache.org>.
tilgalas commented on code in PR #36581:
URL: https://github.com/apache/beam/pull/36581#discussion_r2503908620


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JavaBeanUtils.java:
##########
@@ -439,6 +441,13 @@ public ByteCodeAppender appender(final Target implementationTarget) {
       return (methodVisitor, implementationContext, instrumentedMethod) -> {
         // this + method parameters.
         int numLocals = 1 + instrumentedMethod.getParameters().size();
+        StackManipulation cast =
+            typeInformation
+                    .getRawType()
+                    .isAssignableFrom(
+                        Preconditions.checkNotNull(typeInformation.getMethod()).getReturnType())

Review Comment:
   pushed an update - I had to change some additional lines containing the old-style `checkNotNull` invocations which made the PR somewhat larger- hopefully it's still relatively easy to scan those changes while doing the review   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "tilgalas (via GitHub)" <gi...@apache.org>.
tilgalas commented on code in PR #36581:
URL: https://github.com/apache/beam/pull/36581#discussion_r2494178445


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JavaBeanUtils.java:
##########
@@ -439,6 +441,13 @@ public ByteCodeAppender appender(final Target implementationTarget) {
       return (methodVisitor, implementationContext, instrumentedMethod) -> {
         // this + method parameters.
         int numLocals = 1 + instrumentedMethod.getParameters().size();
+        StackManipulation cast =
+            typeInformation
+                    .getRawType()
+                    .isAssignableFrom(
+                        Preconditions.checkNotNull(typeInformation.getMethod()).getReturnType())

Review Comment:
   got it, will fix



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "kennknowles (via GitHub)" <gi...@apache.org>.
kennknowles commented on code in PR #36581:
URL: https://github.com/apache/beam/pull/36581#discussion_r2486625022


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JavaBeanUtils.java:
##########
@@ -439,6 +441,13 @@ public ByteCodeAppender appender(final Target implementationTarget) {
       return (methodVisitor, implementationContext, instrumentedMethod) -> {
         // this + method parameters.
         int numLocals = 1 + instrumentedMethod.getParameters().size();
+        StackManipulation cast =
+            typeInformation
+                    .getRawType()
+                    .isAssignableFrom(
+                        Preconditions.checkNotNull(typeInformation.getMethod()).getReturnType())

Review Comment:
   Please avoid `Preconditions.checkNotNull` - we've made better versions. Please use `checkArgumentNotNull` if the null error should be blamed on the caller, or `checkStateNotNull` if the null error should be blamed on this class.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "tilgalas (via GitHub)" <gi...@apache.org>.
tilgalas commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3503373170

   Run Java PreCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3461212182

   Reminder, please take a look at this pr: @chamikaramj 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #36581:
URL: https://github.com/apache/beam/pull/36581#issuecomment-3536434756

   Reminder, please take a look at this pr: @kennknowles 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] make use of generic type info in *Utils classes [beam]

Posted by "kennknowles (via GitHub)" <gi...@apache.org>.
kennknowles merged PR #36581:
URL: https://github.com/apache/beam/pull/36581


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org