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 2019/11/21 06:27:20 UTC

[GitHub] [flink] QiLuo-BD commented on a change in pull request #9864: [FLINK-14254][table] Introduce FileSystemOutputFormat for batch

QiLuo-BD commented on a change in pull request #9864: [FLINK-14254][table] Introduce FileSystemOutputFormat for batch
URL: https://github.com/apache/flink/pull/9864#discussion_r348913374
 
 

 ##########
 File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/FileSystemOutputFormat.java
 ##########
 @@ -0,0 +1,223 @@
+/*
+ * 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.table.filesystem;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.common.io.FinalizeOnMaster;
+import org.apache.flink.api.common.io.OutputFormat;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.types.Row;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.LinkedHashMap;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * File system {@link OutputFormat} for batch job. It commit in {@link #finalizeGlobal(int)}.
+ *
+ * @param <T> The type of the consumed records.
+ */
+@Internal
+public class FileSystemOutputFormat<T> implements OutputFormat<T>, FinalizeOnMaster, Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	private static final long CHECKPOINT_ID = 0;
+
+	private final PartitionComputer<T> computer;
+	private final PartitionWriterFactory<T> partitionWriterFactory;
+	private final OutputFormatFactory<T> formatFactory;
+	private final FileSystemCommitter committer;
+
+	private transient PartitionWriter<T> writer;
+	private transient Configuration parameters;
+
+	FileSystemOutputFormat(
+			OutputFormatFactory<T> formatFactory,
+			PartitionComputer<T> computer,
+			PartitionWriterFactory<T> partitionWriterFactory,
+			FileSystemCommitter committer) {
+		this.computer = computer;
+		this.partitionWriterFactory = partitionWriterFactory;
+		this.formatFactory = formatFactory;
+		this.committer = committer;
+	}
+
+	@Override
+	public void finalizeGlobal(int parallelism) throws IOException {
+		try {
+			committer.commitUpToCheckpoint(CHECKPOINT_ID);
 
 Review comment:
   Nope, `finalizeGlobal` is only called in JM once when a batch job finishes.

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


With regards,
Apache Git Services