mirror of
https://github.com/alibaba/DataX.git
synced 2025-05-03 06:39:43 +08:00
optimize joinrows function
This commit is contained in:
parent
b936f0562a
commit
0d0dd3b75c
@ -100,10 +100,25 @@ public class DorisStreamLoadVisitor {
|
|||||||
if (null != props && props.containsKey("row_delimiter")) {
|
if (null != props && props.containsKey("row_delimiter")) {
|
||||||
lineDelimiter = DorisDelimiterParser.parse(String.valueOf(props.get("row_delimiter")), "\n");
|
lineDelimiter = DorisDelimiterParser.parse(String.valueOf(props.get("row_delimiter")), "\n");
|
||||||
}
|
}
|
||||||
return (String.join(lineDelimiter, rows) + lineDelimiter).getBytes(StandardCharsets.UTF_8);
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String row : rows) {
|
||||||
|
sb.append(row).append(lineDelimiter);
|
||||||
|
}
|
||||||
|
return sb.toString().getBytes(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
if (DorisWriterOptions.StreamLoadFormat.JSON.equals(writerOptions.getStreamLoadFormat())) {
|
if (DorisWriterOptions.StreamLoadFormat.JSON.equals(writerOptions.getStreamLoadFormat())) {
|
||||||
return new StringBuilder("[").append(String.join(",", rows)).append("]").toString().getBytes(StandardCharsets.UTF_8);
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("[");
|
||||||
|
boolean isFirstElement = true;
|
||||||
|
for (String row : rows) {
|
||||||
|
if (!isFirstElement) {
|
||||||
|
sb.append(",");
|
||||||
|
}
|
||||||
|
sb.append(row);
|
||||||
|
isFirstElement = false;
|
||||||
|
}
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString().getBytes(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
throw new RuntimeException("Failed to join rows data, unsupported `format` from stream load properties:");
|
throw new RuntimeException("Failed to join rows data, unsupported `format` from stream load properties:");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user