Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug](branch-20) fix udf return array_string type has error in branch-20 #41004

Merged
merged 1 commit into from
Sep 19, 2024
Merged
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 @@ -1292,7 +1292,8 @@ public static long copyBatchArrayStringResult(long hasPutElementNum, boolean isN
int num = data.size();
int[] offsets = new int[num];
byte[][] byteRes = new byte[num][];
int offset = 0;
int oldOffsetNum = UdfUtils.UNSAFE.getInt(null, strOffsetAddr + ((hasPutElementNum - 1) * 4L));
int offset = oldOffsetNum;
for (int i = 0; i < num; ++i) {
String value = data.get(i);
if (value == null) {
Expand All @@ -1304,23 +1305,22 @@ public static long copyBatchArrayStringResult(long hasPutElementNum, boolean isN
offset += byteRes[i].length;
offsets[i] = offset;
}
int oldOffsetNum = UdfUtils.UNSAFE.getInt(null, strOffsetAddr + ((hasPutElementNum - 1) * 4L));
int oldSzie = 0;
if (num > 0) {
oldSzie = offsets[num - 1];
}
byte[] bytes = new byte[oldSzie];
long bytesAddr = JNINativeMethod.resizeStringColumn(dataAddr, oldOffsetNum + oldSzie);
long bytesAddr = JNINativeMethod.resizeStringColumn(dataAddr, oldSzie);
int dst = 0;
for (int i = 0; i < num; i++) {
for (int j = 0; j < byteRes[i].length; j++) {
bytes[dst++] = byteRes[i][j];
}
}
UdfUtils.copyMemory(offsets, UdfUtils.INT_ARRAY_OFFSET, null, strOffsetAddr + (4L * oldOffsetNum),
UdfUtils.copyMemory(offsets, UdfUtils.INT_ARRAY_OFFSET, null, strOffsetAddr + (4L * hasPutElementNum),
num * 4L);
UdfUtils.copyMemory(bytes, UdfUtils.BYTE_ARRAY_OFFSET, null, bytesAddr + oldOffsetNum,
oldSzie);
oldSzie - oldOffsetNum);
hasPutElementNum = hasPutElementNum + num;
}
UdfUtils.UNSAFE.putLong(null, offsetsAddr + 8L * row, hasPutElementNum);
Expand Down
Loading