[
https://issues.apache.org/jira/browse/HIVE-25609?focusedWorklogId=684519&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-684519
]
ASF GitHub Bot logged work on HIVE-25609:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 22/Nov/21 05:28
Start Date: 22/Nov/21 05:28
Worklog Time Spent: 10m
Work Description: ayushtkn commented on a change in pull request #2793:
URL: https://github.com/apache/hive/pull/2793#discussion_r753953113
##########
File path: common/src/java/org/apache/hadoop/hive/common/FileUtils.java
##########
@@ -661,11 +663,50 @@ static boolean copy(FileSystem srcFS, Path src,
// is tried and it fails. We depend upon that behaviour in cases like
replication,
// wherein if distcp fails, there is good reason to not plod along with
a trivial
// implementation, and fail instead.
+ boolean shouldPreserveXAttrs = shouldPreserveXAttrs(conf, srcFS, dstFS);
+ Map<Path, Map<String, byte[]>> XAttrsToDestMapping = null;
+ if (shouldPreserveXAttrs) {
+ XAttrsToDestMapping = new HashMap<>();
+ fetchXAttrs(XAttrsToDestMapping, srcFS, srcFS.getFileStatus(src), dst);
+ }
copied = FileUtil.copy(srcFS, src, dstFS, dst, deleteSource, overwrite,
conf);
+ if (copied && shouldPreserveXAttrs) {
+ for (Map.Entry<Path, Map<String, byte[]>> xAttrs :
XAttrsToDestMapping.entrySet()) {
+ for (Map.Entry<String, byte[]> val : xAttrs.getValue().entrySet()) {
+ dstFS.setXAttr(xAttrs.getKey(), val.getKey(), val.getValue());
+ }
+ }
+ }
}
return copied;
}
+ public static void fetchXAttrs(Map<Path, Map<String, byte[]>> xAttrs,
FileSystem srcFS, FileStatus srcStatus, Path dst) throws IOException {
+ Path src = srcStatus.getPath();
+ Path dstFile = new Path(dst, src.getName());
Review comment:
Check the path resolution, It won't work in couple of cases like if src
is a file & /dst doesn't exist.
Can extract the logic for FileUtils.copy from hadoop & have a preserveXAttr
flag additional
--
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 684519)
Time Spent: 0.5h (was: 20m)
> Preserve XAttrs in normal file copy case.
> -----------------------------------------
>
> Key: HIVE-25609
> URL: https://issues.apache.org/jira/browse/HIVE-25609
> Project: Hive
> Issue Type: Improvement
> Reporter: Haymant Mangla
> Assignee: Haymant Mangla
> Priority: Major
> Labels: pull-request-available
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)