use of com.alibaba.datax.common.element.DateColumn in project DataX by alibaba.
the class UnstructuredStorageWriterUtil method transportOneRecord.
/**
* 异常表示脏数据
* */
public static void transportOneRecord(Record record, String nullFormat, DateFormat dateParse, TaskPluginCollector taskPluginCollector, UnstructuredWriter unstructuredWriter) {
// warn: default is null
if (null == nullFormat) {
nullFormat = "null";
}
try {
List<String> splitedRows = new ArrayList<String>();
int recordLength = record.getColumnNumber();
if (0 != recordLength) {
Column column;
for (int i = 0; i < recordLength; i++) {
column = record.getColumn(i);
if (null != column.getRawData()) {
boolean isDateColumn = column instanceof DateColumn;
if (!isDateColumn) {
splitedRows.add(column.asString());
} else {
if (null != dateParse) {
splitedRows.add(dateParse.format(column.asDate()));
} else {
splitedRows.add(column.asString());
}
}
} else {
// warn: it's all ok if nullFormat is null
splitedRows.add(nullFormat);
}
}
}
unstructuredWriter.writeOneRecord(splitedRows);
} catch (Exception e) {
// warn: dirty data
taskPluginCollector.collectDirtyRecord(record, e);
}
}
Aggregations