mikhailnik-db commented on code in PR #48748:
URL: https://github.com/apache/spark/pull/48748#discussion_r1858392537
##########
common/unsafe/src/main/java/org/apache/spark/unsafe/types/ByteArray.java:
##########
@@ -160,6 +160,39 @@ public static byte[] concat(byte[]... inputs) {
return result;
}
+ public static byte[] concatWS(byte[] delimiter, byte[]... inputs) {
+ // Compute the total length of the result
+ long totalLength = 0;
+ for (byte[] input : inputs) {
+ if (input != null) {
+ totalLength += input.length + delimiter.length;
+ } else {
+ return null;
+ }
+ }
+ if (totalLength > 0) totalLength -= delimiter.length;
+ // Allocate a new byte array, and copy the inputs one by one into it
+ final byte[] result = new byte[Ints.checkedCast(totalLength)];
+ int offset = 0;
+ for (int i = 0; i < inputs.length; i++) {
+ byte[] input = inputs[i];
+ int len = input.length;
+ Platform.copyMemory(
Review Comment:
I didn't want to accidentally change existing behavior or performance so I
thought a little copy-paste was justified in this isolated code. But I probably
concern too much)
Removed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]