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/07/02 21:15:00 UTC

[jira] [Work logged] (BEAM-4451) SchemaRegistry should support a ServiceLoader interface

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

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

                Author: ASF GitHub Bot
            Created on: 02/Jul/18 21:14
            Start Date: 02/Jul/18 21:14
    Worklog Time Spent: 10m 
      Work Description: apilloud commented on a change in pull request #5840: [BEAM-4451] Schemas default provider and serviceloader
URL: https://github.com/apache/beam/pull/5840#discussion_r199620580
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/DefaultSchema.java
 ##########
 @@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.beam.sdk.schemas;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.annotations.Experimental.Kind;
+import org.apache.beam.sdk.transforms.SerializableFunction;
+import org.apache.beam.sdk.values.Row;
+import org.apache.beam.sdk.values.TypeDescriptor;
+
+/**
+ * The {@link DefaultSchema} annotation specifies a {@link SchemaProvider} class to handle obtaining
+ * a schema and row for the specified class.
+ *
+ * <p>For example, if your class is JavaBean, the JavaBeanSchema provider class knows how to vend
+ * schemas for this class. You can annotate it as follows:
+ *
+ * <pre><code>
+ *   {@literal @}DefaultSchema(JavaBeanSchema.class)
+ *   class MyClass {
+ *     public String getFoo();
+ *     void setFoo(String foo);
+ *           ....
+ *   }
+ * </code></pre>
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@SuppressWarnings("rawtypes")
+@Experimental(Kind.SCHEMAS)
+public @interface DefaultSchema {
+  @CheckForNull
+  Class<? extends SchemaProvider> value();
+
+  /**
+   * {@link SchemaProvider} for default schemas. Looks up the provider annotated for a type, and
+   * delegates to that provider.
+   */
+  class DefaultSchemaProvider extends SchemaProvider {
+    Map<TypeDescriptor, SchemaProvider> cachedProviders = Maps.newConcurrentMap();
 
 Review comment:
   Should this be `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: 118400)
    Time Spent: 0.5h  (was: 20m)

> SchemaRegistry should support a ServiceLoader interface
> -------------------------------------------------------
>
>                 Key: BEAM-4451
>                 URL: https://issues.apache.org/jira/browse/BEAM-4451
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-java-core
>            Reporter: Reuven Lax
>            Assignee: Reuven Lax
>            Priority: Major
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> This will allow JARs to register schemas only when they are linked in.



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