You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/08/01 00:10:00 UTC

[jira] [Work logged] (BEAM-4453) Provide automatic schema registration for POJOs

     [ https://issues.apache.org/jira/browse/BEAM-4453?focusedWorklogId=129547&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-129547 ]

ASF GitHub Bot logged work on BEAM-4453:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 01/Aug/18 00:09
            Start Date: 01/Aug/18 00:09
    Worklog Time Spent: 10m 
      Work Description: apilloud commented on a change in pull request #6114: [BEAM-4453] Add convenience methods for pojo and javabean schema registration.
URL: https://github.com/apache/beam/pull/6114#discussion_r206720953
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaRegistry.java
 ##########
 @@ -67,8 +68,40 @@
   private final Map<TypeDescriptor, SchemaEntry> entries = Maps.newHashMap();
   private final ArrayDeque<SchemaProvider> providers;
 
+  class PerTypeRegisteredProvider implements SchemaProvider {
+    private Map<TypeDescriptor, SchemaProvider> providers = Maps.newHashMap();
+
+    void registerProvider(TypeDescriptor typeDescriptor, SchemaProvider schemaProvider) {
+      providers.put(typeDescriptor, schemaProvider);
+    }
+
+    @Nullable
+    @Override
+    public <T> Schema schemaFor(TypeDescriptor<T> typeDescriptor) {
+      SchemaProvider schemaProvider = providers.get(typeDescriptor);
+      return (schemaProvider != null) ? schemaProvider.schemaFor(typeDescriptor) : null;
+    }
+
+    @Nullable
+    @Override
+    public <T> SerializableFunction<T, Row> toRowFunction(TypeDescriptor<T> typeDescriptor) {
+      SchemaProvider schemaProvider = providers.get(typeDescriptor);
+      return (schemaProvider != null) ? schemaProvider.toRowFunction(typeDescriptor) : null;
+    }
+
+    @Nullable
+    @Override
+    public <T> SerializableFunction<Row, T> fromRowFunction(TypeDescriptor<T> typeDescriptor) {
+      SchemaProvider schemaProvider = providers.get(typeDescriptor);
+      return (schemaProvider != null) ? schemaProvider.fromRowFunction(typeDescriptor) : null;
+    }
+  }
+
+  private PerTypeRegisteredProvider perTypeRegisteredProviders = new PerTypeRegisteredProvider();
 
 Review comment:
   `final`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 129547)
    Time Spent: 10h  (was: 9h 50m)

> Provide automatic schema registration for POJOs
> -----------------------------------------------
>
>                 Key: BEAM-4453
>                 URL: https://issues.apache.org/jira/browse/BEAM-4453
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-java-core
>            Reporter: Reuven Lax
>            Assignee: Reuven Lax
>            Priority: Major
>          Time Spent: 10h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)