This is an automated email from the ASF dual-hosted git repository.
zuston pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git
The following commit(s) were added to refs/heads/master by this push:
new 0b043aa1 [Minor][Improvement] Introduce FileWriter interface for
Localfile/HDFS file writer (#444)
0b043aa1 is described below
commit 0b043aa1f011d716e9b2bfa37b2ec7c96a9de482
Author: Junfan Zhang <[email protected]>
AuthorDate: Wed Dec 21 16:34:30 2022 +0800
[Minor][Improvement] Introduce FileWriter interface for Localfile/HDFS file
writer (#444)
### What changes were proposed in this pull request?
[Minor][Improvement] Introduce FileWriter interface for Localfile/HDFS file
writer
### Why are the changes needed?
1. To keep consistent with the interface of `FileReader` for Localfile/HDFS
file reader.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Don't need
---
.../org/apache/uniffle/storage/api/FileWriter.java | 29 ++++++++++++++++++++++
.../storage/handler/impl/HdfsFileWriter.java | 3 ++-
.../storage/handler/impl/LocalFileWriter.java | 3 ++-
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git
a/storage/src/main/java/org/apache/uniffle/storage/api/FileWriter.java
b/storage/src/main/java/org/apache/uniffle/storage/api/FileWriter.java
new file mode 100644
index 00000000..d61b756d
--- /dev/null
+++ b/storage/src/main/java/org/apache/uniffle/storage/api/FileWriter.java
@@ -0,0 +1,29 @@
+/*
+ * 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.uniffle.storage.api;
+
+import java.io.IOException;
+
+import org.apache.uniffle.storage.common.FileBasedShuffleSegment;
+
+public interface FileWriter {
+
+ void writeData(byte[] data) throws IOException;
+
+ void writeIndex(FileBasedShuffleSegment segment) throws IOException;
+}
diff --git
a/storage/src/main/java/org/apache/uniffle/storage/handler/impl/HdfsFileWriter.java
b/storage/src/main/java/org/apache/uniffle/storage/handler/impl/HdfsFileWriter.java
index 92c04208..6b899aef 100644
---
a/storage/src/main/java/org/apache/uniffle/storage/handler/impl/HdfsFileWriter.java
+++
b/storage/src/main/java/org/apache/uniffle/storage/handler/impl/HdfsFileWriter.java
@@ -32,10 +32,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.uniffle.common.util.ChecksumUtils;
+import org.apache.uniffle.storage.api.FileWriter;
import org.apache.uniffle.storage.common.FileBasedShuffleSegment;
import org.apache.uniffle.storage.util.ShuffleStorageUtils;
-public class HdfsFileWriter implements Closeable {
+public class HdfsFileWriter implements FileWriter, Closeable {
private static final Logger LOG =
LoggerFactory.getLogger(HdfsFileWriter.class);
diff --git
a/storage/src/main/java/org/apache/uniffle/storage/handler/impl/LocalFileWriter.java
b/storage/src/main/java/org/apache/uniffle/storage/handler/impl/LocalFileWriter.java
index 8c3e99e2..01c188f3 100644
---
a/storage/src/main/java/org/apache/uniffle/storage/handler/impl/LocalFileWriter.java
+++
b/storage/src/main/java/org/apache/uniffle/storage/handler/impl/LocalFileWriter.java
@@ -24,9 +24,10 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import org.apache.uniffle.storage.api.FileWriter;
import org.apache.uniffle.storage.common.FileBasedShuffleSegment;
-public class LocalFileWriter implements Closeable {
+public class LocalFileWriter implements FileWriter, Closeable {
private DataOutputStream dataOutputStream;
private FileOutputStream fileOutputStream;