mosche commented on pull request #16947:
URL: https://github.com/apache/beam/pull/16947#issuecomment-1057255231


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


-- 
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]


Reply via email to