Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -119,6 +118,12 @@ protected void checkOutputDir() {
}
}

/** 文件分隔符(File.separatorChar)在windows为\,而在linux中为/,在hadoop中路径需要固定为/, */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you comment in English?

protected char getHdfsPathChar() {
// hadoop 文件系统固定为/,避免路径不对,文件写入错误及移动失败

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

return '/';
}

@Override
protected void deleteDataDir() {
deleteDirectory(outputFilePath);
Expand Down Expand Up @@ -160,7 +165,7 @@ public String getExtension() {

@Override
protected long getCurrentFileSize() {
String path = tmpPath + File.separatorChar + currentFileName;
String path = tmpPath + getHdfsPathChar() + currentFileName;
try {
if (hdfsConf.getMaxFileSize() > ConstantValue.STORE_SIZE_G) {
return fs.getFileStatus(new Path(path)).getLen();
Expand Down Expand Up @@ -203,7 +208,7 @@ protected void deleteDataFiles(List<String> preCommitFilePathList, String path)
String currentFilePath = "";
try {
for (String fileName : this.preCommitFilePathList) {
currentFilePath = path + File.separatorChar + fileName;
currentFilePath = path + getHdfsPathChar() + fileName;
Path commitFilePath = new Path(currentFilePath);
fs.delete(commitFilePath, true);
LOG.info("delete file:{}", currentFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.apache.hadoop.mapred.RecordWriter;
import org.apache.hadoop.mapred.Reporter;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
Expand Down Expand Up @@ -163,7 +162,7 @@ protected void nextBlock() {
}

try {
String currentBlockTmpPath = tmpPath + File.separatorChar + currentFileName;
String currentBlockTmpPath = tmpPath + getHdfsPathChar() + currentFileName;
recordWriter =
outputFormat.getRecordWriter(null, jobConf, currentBlockTmpPath, Reporter.NULL);
currentFileIndex++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.apache.parquet.schema.PrimitiveType;
import org.apache.parquet.schema.Types;

import java.io.File;
import java.io.IOException;
import java.security.PrivilegedAction;
import java.util.HashMap;
Expand Down Expand Up @@ -95,7 +94,7 @@ protected void nextBlock() {
}

try {
String currentBlockTmpPath = tmpPath + File.separatorChar + currentFileName;
String currentBlockTmpPath = tmpPath + getHdfsPathChar() + currentFileName;
Path writePath = new Path(currentBlockTmpPath);

// Compatible with old code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import org.apache.hadoop.fs.Path;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

Expand All @@ -55,7 +54,7 @@ protected void nextBlock() {
}

try {
String currentBlockTmpPath = tmpPath + File.separatorChar + currentFileName;
String currentBlockTmpPath = tmpPath + getHdfsPathChar() + currentFileName;
Path p = new Path(currentBlockTmpPath);

if (CompressType.TEXT_NONE.equals(compressType)) {
Expand Down