reuvenlax commented on pull request #16947:
URL: https://github.com/apache/beam/pull/16947#issuecomment-1057270723
Unfortunately if you truly need recursive or mutually-recursive types, Beam
Schemas won't work today. We supported nested types, but not true recursion.
On Wed, Mar 2, 2022 at 10:40 AM Reuven Lax ***@***.***> wrote:
> Do you mean mutually recursive? We considered supporting this with schema,
> but the complexity was high and there didn't seem to be many good use
cases.
>
> On Wed, Mar 2, 2022 at 10:37 AM Moritz Mack ***@***.***>
> wrote:
>
>> But the getter methods are public, right?
>>
>> There's public getters of course, but not following the "getX" naming
>> convention.
>>
>> I've also looked briefly at just extending GetterBasedSchemaProvider,
>> that works really well actually. The read part is rather trivial. The
field
>> metadata of each SDK model provides an easy way to read fields (without
any
>> reflection involved).
>>
>> static class SdkFieldValueGetter<ObjectT, ValueT> implements
FieldValueGetter<ObjectT, ValueT> {
>> private final SdkField<ValueT> field;
>>
>> public SdkFieldValueGetter(SdkField<ValueT> field) {
>> this.field = field;
>> }
>>
>> @Override
>> @Nullable
>> public ValueT get(ObjectT object) {
>> return field.getValueOrDefault(object);
>> }
>>
>> @Override
>> public String name() {
>> return field.memberName();
>> }
>> }
>>
>> Recursive type hierarchies are also definitely support.
>>
>> Problem with recursive types is the immutable Schema. I'm not aware of
>> any way to generate such a schema for a recursive hierarchy ... same
>> problem exists for FieldValueTypeInformation.
>> Just verified it quickly, I get a stackoverflow as expected ... so
>> recursive types are definitely not supported.
>>
>> —
>> Reply to this email directly, view it on GitHub
>> <https://github.com/apache/beam/pull/16947#issuecomment-1057255231>, or
>> unsubscribe
>>
<https://github.com/notifications/unsubscribe-auth/AFAYJVIAMSNFPACIJDYOFVDU56YODANCNFSM5PKC75YA>
>> .
>> Triage notifications on the go with GitHub Mobile for iOS
>>
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
>> or Android
>>
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>>
>> You are receiving this because you were mentioned.Message ID:
>> ***@***.***>
>>
>
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]