Skip to content

Replace Class with TypeDescriptor in SchemaProvider implementations#31785

Merged
chamikaramj merged 11 commits intoapache:masterfrom
tilgalas:replace-class-with-typedescriptor
Jul 31, 2024
Merged

Replace Class with TypeDescriptor in SchemaProvider implementations#31785
chamikaramj merged 11 commits intoapache:masterfrom
tilgalas:replace-class-with-typedescriptor

Conversation

@tilgalas
Copy link
Copy Markdown
Contributor

@tilgalas tilgalas commented Jul 5, 2024

This is the first part of a series of PRs which when brought together are equivalent to the change previously proposed in #31648 - the code of this PR doesn't introduce or remove any features from the schema inference mechanisms existing already, it merely prepares the ground for doing that in the subsequent PRs. It does so by passing on down the call hierarchy the TypeDescriptors where previously the code worked with bare Classes. This way the full information carried by TypeDescriptors regarding the type signatures is not lost, and the schema inference, as well as, on the fly bytecode generation facilities will be able to use it to infer beam schemas for generic java types.

Adding the support for schema inference of generic types was proposed in a section of this design doc.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 5, 2024

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

@tilgalas
Copy link
Copy Markdown
Contributor Author

tilgalas commented Jul 5, 2024

Run Java PreCommit

@tilgalas
Copy link
Copy Markdown
Contributor Author

tilgalas commented Jul 8, 2024

assign set of reviewers

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 8, 2024

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @m-trieu for label java.
R: @chamikaramj for label io.

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).

@github-actions
Copy link
Copy Markdown
Contributor

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

@github-actions
Copy link
Copy Markdown
Contributor

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: @damondouglas for label java.
R: @ahmedabu98 for label io.

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)

Copy link
Copy Markdown
Contributor

@m-trieu m-trieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for java, i would get an LGTM from someone more familiar with IOs as well.

Copy link
Copy Markdown
Contributor

@chamikaramj chamikaramj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about the delay.

LGTM for I/O updates other than one comment. Thanks.

@SuppressWarnings("rawtypes")
@Override
public List<FieldValueGetter> fieldValueGetters(Class<?> clazz, Schema schema) {
public List<FieldValueGetter> fieldValueGetters(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed that we break backwards compatibility of public fields here but probably this is OK since these are expected be util classes intended only internal usage ?

Copy link
Copy Markdown
Contributor Author

@tilgalas tilgalas Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point - this is the consequence of changing the methods' signatures in the GetterBasedSchemaProvider - it's not annotated with @Internal so maybe we should actually remain careful with that interface - maybe I'll add some default implementations of the backward compatible methods to that class

@tilgalas
Copy link
Copy Markdown
Contributor Author

Sorry about the delay.

LGTM for I/O updates other than one comment. Thanks.

Restored and deprecated the old GetterBasedSchemaProvider so that if anyone depends on it, it should still work, and changed the base class of known subclasses of this class to the newer "V2" version that uses TypeDescriptors

@tilgalas
Copy link
Copy Markdown
Contributor Author

Run Java_GCP_IO_Direct PreCommit

@tilgalas
Copy link
Copy Markdown
Contributor Author

Run Java PreCommit

@chamikaramj
Copy link
Copy Markdown
Contributor

+1 for deprecating the old public class instead of just changing the signature.

LGTM

@chamikaramj chamikaramj merged commit 835630b into apache:master Jul 31, 2024
@tilgalas tilgalas deleted the replace-class-with-typedescriptor branch August 1, 2024 13:42
reeba212 pushed a commit to reeba212/beam that referenced this pull request Dec 4, 2024
…pache#31785)

* refactor GetterBasedSchemaProvider's methods' signatures

* update StaticSchemaInference's methods' signatures

* update invocations of schemaFromClass

* update FieldValueTypeSupplier's methods' signatures

* replace ClassWithSchema with TypeDescriptorWithSchema as caching key

* remove the stopgap default method in Factory interface

* use TypeDescriptors in AutoValueUtils' methods

* convert the class to generic type descriptor in DefaultSchema

* deprecate GetterBasedSchemaProvider

* update GetterBasedSchemaProviderV2 javadoc

* delegate the deprecated methods instead of throwing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants