zhangyue19921010 commented on a change in pull request #4078:
URL: https://github.com/apache/hudi/pull/4078#discussion_r787287103
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/util/FileIOUtils.java
##########
@@ -160,4 +160,33 @@ public static void closeQuietly(Closeable closeable) {
LOG.warn("IOException during close", e);
}
}
+
+ public static void createFileInPath(FileSystem fileSystem,
org.apache.hadoop.fs.Path fullPath, Option<byte[]> content) {
Review comment:
Sure. Changed.
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/util/FileIOUtils.java
##########
@@ -160,4 +160,33 @@ public static void closeQuietly(Closeable closeable) {
LOG.warn("IOException during close", e);
}
}
+
+ public static void createFileInPath(FileSystem fileSystem,
org.apache.hadoop.fs.Path fullPath, Option<byte[]> content) {
+ try {
+ // If the path does not exist, create it first
+ if (!fileSystem.exists(fullPath)) {
+ if (fileSystem.createNewFile(fullPath)) {
+ LOG.info("Created a new file in meta path: " + fullPath);
+ } else {
+ throw new HoodieIOException("Failed to create file " + fullPath);
+ }
+ }
+
+ if (content.isPresent()) {
+ FSDataOutputStream fsout = fileSystem.create(fullPath, true);
+ fsout.write(content.get());
+ fsout.close();
+ }
+ } catch (IOException e) {
+ throw new HoodieIOException("Failed to create file " + fullPath, e);
+ }
+ }
+
+ public static Option<byte[]> readDataFromPath(FileSystem fileSystem,
org.apache.hadoop.fs.Path detailPath) {
Review comment:
Changed.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]