mirror of
https://github.com/alibaba/DataX.git
synced 2025-05-02 07:21:48 +08:00
Merge dc3a82f3d9
into 0824b45c5e
This commit is contained in:
commit
e7824688e2
@ -271,21 +271,9 @@ public class HdfsWriter extends Writer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String buildFilePath() {
|
private String buildFilePath() {
|
||||||
boolean isEndWithSeparator = false;
|
boolean isEndWithSeparator = this.path.endsWith(String.valueOf(IOUtils.DIR_SEPARATOR_UNIX));
|
||||||
switch (IOUtils.DIR_SEPARATOR) {
|
|
||||||
case IOUtils.DIR_SEPARATOR_UNIX:
|
|
||||||
isEndWithSeparator = this.path.endsWith(String
|
|
||||||
.valueOf(IOUtils.DIR_SEPARATOR));
|
|
||||||
break;
|
|
||||||
case IOUtils.DIR_SEPARATOR_WINDOWS:
|
|
||||||
isEndWithSeparator = this.path.endsWith(String
|
|
||||||
.valueOf(IOUtils.DIR_SEPARATOR_WINDOWS));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!isEndWithSeparator) {
|
if (!isEndWithSeparator) {
|
||||||
this.path = this.path + IOUtils.DIR_SEPARATOR;
|
this.path = this.path + IOUtils.DIR_SEPARATOR_UNIX;
|
||||||
}
|
}
|
||||||
return this.path;
|
return this.path;
|
||||||
}
|
}
|
||||||
@ -297,38 +285,18 @@ public class HdfsWriter extends Writer {
|
|||||||
*/
|
*/
|
||||||
private String buildTmpFilePath(String userPath) {
|
private String buildTmpFilePath(String userPath) {
|
||||||
String tmpFilePath;
|
String tmpFilePath;
|
||||||
boolean isEndWithSeparator = false;
|
boolean isEndWithSeparator = userPath.endsWith(String.valueOf(IOUtils.DIR_SEPARATOR_UNIX));
|
||||||
switch (IOUtils.DIR_SEPARATOR) {
|
|
||||||
case IOUtils.DIR_SEPARATOR_UNIX:
|
|
||||||
isEndWithSeparator = userPath.endsWith(String
|
|
||||||
.valueOf(IOUtils.DIR_SEPARATOR));
|
|
||||||
break;
|
|
||||||
case IOUtils.DIR_SEPARATOR_WINDOWS:
|
|
||||||
isEndWithSeparator = userPath.endsWith(String
|
|
||||||
.valueOf(IOUtils.DIR_SEPARATOR_WINDOWS));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
String tmpSuffix;
|
String tmpSuffix;
|
||||||
tmpSuffix = UUID.randomUUID().toString().replace('-', '_');
|
do {
|
||||||
if (!isEndWithSeparator) {
|
|
||||||
tmpFilePath = String.format("%s__%s%s", userPath, tmpSuffix, IOUtils.DIR_SEPARATOR);
|
|
||||||
}else if("/".equals(userPath)){
|
|
||||||
tmpFilePath = String.format("%s__%s%s", userPath, tmpSuffix, IOUtils.DIR_SEPARATOR);
|
|
||||||
}else{
|
|
||||||
tmpFilePath = String.format("%s__%s%s", userPath.substring(0,userPath.length()-1), tmpSuffix, IOUtils.DIR_SEPARATOR);
|
|
||||||
}
|
|
||||||
while(hdfsHelper.isPathexists(tmpFilePath)){
|
|
||||||
tmpSuffix = UUID.randomUUID().toString().replace('-', '_');
|
tmpSuffix = UUID.randomUUID().toString().replace('-', '_');
|
||||||
if (!isEndWithSeparator) {
|
if (!isEndWithSeparator || String.valueOf(IOUtils.DIR_SEPARATOR_UNIX).equals(userPath)) {
|
||||||
tmpFilePath = String.format("%s__%s%s", userPath, tmpSuffix, IOUtils.DIR_SEPARATOR);
|
tmpFilePath = String.format("%s__%s%s", userPath, tmpSuffix, IOUtils.DIR_SEPARATOR_UNIX);
|
||||||
}else if("/".equals(userPath)){
|
} else {
|
||||||
tmpFilePath = String.format("%s__%s%s", userPath, tmpSuffix, IOUtils.DIR_SEPARATOR);
|
tmpFilePath = String.format("%s__%s%s", userPath.substring(0,userPath.length()-1), tmpSuffix,
|
||||||
}else{
|
IOUtils.DIR_SEPARATOR_UNIX);
|
||||||
tmpFilePath = String.format("%s__%s%s", userPath.substring(0,userPath.length()-1), tmpSuffix, IOUtils.DIR_SEPARATOR);
|
|
||||||
}
|
}
|
||||||
}
|
} while(hdfsHelper.isPathexists(tmpFilePath));
|
||||||
|
|
||||||
return tmpFilePath;
|
return tmpFilePath;
|
||||||
}
|
}
|
||||||
public void unitizeParquetConfig(Configuration writerSliceConfig) {
|
public void unitizeParquetConfig(Configuration writerSliceConfig) {
|
||||||
|
Loading…
Reference in New Issue
Block a user