You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/10/10 01:52:16 UTC

[GitHub] [flink] stevenzwu commented on a change in pull request #13576: [FLINK-19512] Introduce the new sink API

stevenzwu commented on a change in pull request #13576:
URL: https://github.com/apache/flink/pull/13576#discussion_r502731108



##########
File path: flink-core/src/main/java/org/apache/flink/api/connector/sink/Sink.java
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.flink.api.connector.sink;
+
+import org.apache.flink.annotation.Experimental;
+import org.apache.flink.core.io.SimpleVersionedSerializer;
+import org.apache.flink.metrics.MetricGroup;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * This interface lets the sink developer build a simple sink topology, which could guarantee the exactly once
+ * semantics in both batch and stream execution mode if there is a {@link Committer} or {@link GlobalCommitter}.
+ * 1. The {@link Writer} is responsible for producing the committable.
+ * 2. The {@link Committer} is responsible for committing a single committable.
+ * 3. The {@link GlobalCommitter} is responsible for committing an aggregated committable, which we called the global
+ *    committable. There is only one instance of the {@link GlobalCommitter}.
+ * Note: Developers need to ensure the idempotence of {@link Committer} and {@link GlobalCommitter}.
+ *
+ * @param <InputT>        The type of the sink's input
+ * @param <CommT>         The type of the committable data
+ * @param <GlobalCommT>   The type of the aggregated committable
+ * @param <WriterStateT>  The type of the writer's state
+ */
+@Experimental
+public interface Sink<InputT, CommT, GlobalCommT, WriterStateT> {
+
+	/**
+	 * Create a {@link Writer}.
+	 * @param context the runtime context.
+	 * @param states the writer's state.
+	 * @return A sink writer.
+	 */
+	Writer<InputT, CommT, WriterStateT> createWriter(InitContext context, List<WriterStateT> states);

Review comment:
       curious about the `List<WriterStateT> states`. is it similar to union state? each writer subtask should choose the `WriteStateT` applicable to itself?




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

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