linliu-code commented on code in PR #12866:
URL: https://github.com/apache/hudi/pull/12866#discussion_r1978351104
##########
hudi-hadoop-common/src/main/java/org/apache/hudi/io/hadoop/HoodieHFileUtils.java:
##########
@@ -153,4 +155,57 @@ public void readFully(long position, byte[] buffer, int
offset, int length) thro
read(position, buffer, offset, length);
}
}
+
+ /**
+ * Create the specified file on the filesystem. By default, this will:
+ * <ol>
+ * <li>apply the umask in the configuration (if it is enabled)</li>
+ * <li>use the fs configured buffer size (or 4096 if not set)</li>
+ * <li>use the default replication</li>
+ * <li>use the default block size</li>
+ * <li>not track progress</li>
+ * </ol>
+ * @param fs {@link FileSystem} on which to write the file
+ * @param path {@link Path} to the file to write
+ * @param perm intial permissions
+ * @param overwrite Whether or not the created file should be overwritten.
+ * @return output stream to the created file
+ * @throws IOException if the file cannot be created
+ */
+ public static FSDataOutputStream create(FileSystem fs, Path path,
FsPermission perm,
+ boolean overwrite) throws
IOException {
+ return fs.create(path, perm, overwrite, getDefaultBufferSize(fs),
+ getDefaultReplication(fs, path), getDefaultBlockSize(fs, path), null);
+ }
+
+ /**
+ * Returns the default buffer size to use during writes. The size of the
buffer should probably be
+ * a multiple of hardware page size (4096 on Intel x86), and it determines
how much data is
+ * buffered during read and write operations.
+ * @param fs filesystem object
+ * @return default buffer size to use during writes
+ */
+ public static int getDefaultBufferSize(final FileSystem fs) {
Review Comment:
yes, if hoodiestorage can generate the outputstream, then these utils
functions can be removed.
--
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]