You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/15 11:28:26 UTC

[GitHub] [beam] Amar3tto commented on a diff in pull request #21765: [BEAM-14073] [CdapIO] CDAP IO for batch plugins: Read, Write. Unit tests included

Amar3tto commented on code in PR #21765:
URL: https://github.com/apache/beam/pull/21765#discussion_r897862777


##########
sdks/java/io/cdap/src/main/java/org/apache/beam/sdk/io/cdap/CdapIO.java:
##########
@@ -0,0 +1,235 @@
+/*
+ * 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.io.cdap;
+
+import static org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkArgument;
+
+import com.google.auto.value.AutoValue;
+import io.cdap.cdap.api.plugin.PluginConfig;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.io.hadoop.format.HDFSSynchronization;
+import org.apache.beam.sdk.io.hadoop.format.HadoopFormatIO;
+import org.apache.beam.sdk.transforms.PTransform;
+import org.apache.beam.sdk.values.KV;
+import org.apache.beam.sdk.values.PBegin;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.PDone;
+import org.apache.hadoop.conf.Configuration;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * An unbounded/bounded sources and sinks from <a
+ * href="https://github.com/data-integrations">CDAP</a> plugins.
+ */
+@SuppressWarnings({
+  "argument.type.incompatible",
+  "return.type.incompatible",
+  "dereference.of.nullable",
+  "UnnecessaryParentheses"
+})
+public class CdapIO {
+
+  public static <K, V> Read<K, V> read() {
+    return new AutoValue_CdapIO_Read.Builder<K, V>().build();
+  }
+
+  public static <K, V> Write<K, V> write() {
+    return new AutoValue_CdapIO_Write.Builder<K, V>().build();
+  }
+
+  /** A {@link PTransform} to read from CDAP source. */
+  @AutoValue
+  @AutoValue.CopyAnnotations
+  public abstract static class Read<K, V> extends PTransform<PBegin, PCollection<KV<K, V>>> {
+
+    abstract @Nullable PluginConfig getPluginConfig();
+
+    abstract @Nullable Plugin getCdapPlugin();
+
+    abstract @Nullable Class<K> getKeyClass();
+
+    abstract @Nullable Class<V> getValueClass();
+
+    abstract Builder<K, V> toBuilder();
+
+    @Experimental(Experimental.Kind.PORTABILITY)
+    @AutoValue.Builder
+    abstract static class Builder<K, V> {
+
+      abstract Builder<K, V> setPluginConfig(PluginConfig config);
+
+      abstract Builder<K, V> setCdapPlugin(Plugin plugin);
+
+      abstract Builder<K, V> setKeyClass(Class<K> keyClass);
+
+      abstract Builder<K, V> setValueClass(Class<V> valueClass);
+
+      abstract Read<K, V> build();
+    }
+
+    public Read<K, V> withCdapPlugin(Plugin plugin) {
+      checkArgument(plugin != null, "Cdap plugin can not be null");

Review Comment:
   This was written the same way as in HadoopFormatIO, JdbcIO and other IOs.
   Do you think we should change it everywhere or only here or leave it as it is?



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org