Commit 84611f1f authored by 丁强's avatar 丁强

textfilewriter修复数据换行bug--换行符替换为空格

parent f9885979
......@@ -41,7 +41,7 @@ public class UnstructuredStorageWriterUtil {
/**
* check parameter: writeMode, encoding, compress, filedDelimiter
* */
*/
public static void validateParameter(Configuration writerConfiguration) {
// writeMode check
String writeMode = writerConfiguration.getNecessaryValue(
......@@ -124,7 +124,7 @@ public class UnstructuredStorageWriterUtil {
}
public static List<Configuration> split(Configuration writerSliceConfig,
Set<String> originAllFileExists, int mandatoryNumber) {
Set<String> originAllFileExists, int mandatoryNumber) {
LOG.info("begin do split...");
Set<String> allFileExists = new HashSet<String>();
allFileExists.addAll(originAllFileExists);
......@@ -153,19 +153,19 @@ public class UnstructuredStorageWriterUtil {
}
public static String buildFilePath(String path, String fileName,
String suffix) {
String suffix) {
boolean isEndWithSeparator = false;
switch (IOUtils.DIR_SEPARATOR) {
case IOUtils.DIR_SEPARATOR_UNIX:
isEndWithSeparator = path.endsWith(String
.valueOf(IOUtils.DIR_SEPARATOR));
break;
case IOUtils.DIR_SEPARATOR_WINDOWS:
isEndWithSeparator = path.endsWith(String
.valueOf(IOUtils.DIR_SEPARATOR_WINDOWS));
break;
default:
break;
case IOUtils.DIR_SEPARATOR_UNIX:
isEndWithSeparator = path.endsWith(String
.valueOf(IOUtils.DIR_SEPARATOR));
break;
case IOUtils.DIR_SEPARATOR_WINDOWS:
isEndWithSeparator = path.endsWith(String
.valueOf(IOUtils.DIR_SEPARATOR_WINDOWS));
break;
default:
break;
}
if (!isEndWithSeparator) {
path = path + IOUtils.DIR_SEPARATOR;
......@@ -179,8 +179,8 @@ public class UnstructuredStorageWriterUtil {
}
public static void writeToStream(RecordReceiver lineReceiver,
OutputStream outputStream, Configuration config, String context,
TaskPluginCollector taskPluginCollector) {
OutputStream outputStream, Configuration config, String context,
TaskPluginCollector taskPluginCollector) {
String encoding = config.getString(Key.ENCODING,
Constant.DEFAULT_ENCODING);
// handle blank encoding
......@@ -239,8 +239,8 @@ public class UnstructuredStorageWriterUtil {
}
private static void doWriteToStream(RecordReceiver lineReceiver,
BufferedWriter writer, String contex, Configuration config,
TaskPluginCollector taskPluginCollector) throws IOException {
BufferedWriter writer, String contex, Configuration config,
TaskPluginCollector taskPluginCollector) throws IOException {
String nullFormat = config.getString(Key.NULL_FORMAT);
......@@ -291,10 +291,10 @@ public class UnstructuredStorageWriterUtil {
/**
* 异常表示脏数据
* */
*/
public static void transportOneRecord(Record record, String nullFormat,
DateFormat dateParse, TaskPluginCollector taskPluginCollector,
UnstructuredWriter unstructuredWriter) {
DateFormat dateParse, TaskPluginCollector taskPluginCollector,
UnstructuredWriter unstructuredWriter) {
// warn: default is null
if (null == nullFormat) {
nullFormat = "null";
......@@ -332,6 +332,7 @@ public class UnstructuredStorageWriterUtil {
unstructuredWriter.writeOneRecord(splitedRows);
} catch (Exception e) {
// warn: dirty data
LOG.info("transportOneRecord 发生异常:", e);
taskPluginCollector.collectDirtyRecord(record, e);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment