HappenLee commented on code in PR #16841:
URL: https://github.com/apache/doris/pull/16841#discussion_r1108531267
##########
fe/java-udf/src/main/java/org/apache/doris/udf/BaseExecutor.java:
##########
@@ -206,25 +220,299 @@ protected Object[] allocateInputObjects(long row, int
argClassOffset) throws Udf
case STRING: {
long offset =
Integer.toUnsignedLong(UdfUtils.UNSAFE.getInt(null,
UdfUtils.UNSAFE.getLong(null,
UdfUtils.getAddressAtOffset(inputOffsetsPtrs, i))
+ 4L * row));
- long numBytes = row == 0 ? offset : offset -
Integer.toUnsignedLong(UdfUtils.UNSAFE.getInt(null,
- UdfUtils.UNSAFE.getLong(null,
-
UdfUtils.getAddressAtOffset(inputOffsetsPtrs, i)) + 4L * (row - 1)));
- long base =
- row == 0 ? UdfUtils.UNSAFE.getLong(null,
UdfUtils.getAddressAtOffset(inputBufferPtrs, i)) :
- UdfUtils.UNSAFE.getLong(null,
UdfUtils.getAddressAtOffset(inputBufferPtrs, i))
- + offset - numBytes;
+ long numBytes = row == 0 ? offset
+ : offset -
Integer.toUnsignedLong(UdfUtils.UNSAFE.getInt(null,
+ UdfUtils.UNSAFE.getLong(null,
+
UdfUtils.getAddressAtOffset(inputOffsetsPtrs, i)) + 4L * (row - 1)));
+ long base = row == 0
+ ? UdfUtils.UNSAFE.getLong(null,
UdfUtils.getAddressAtOffset(inputBufferPtrs, i))
+ : UdfUtils.UNSAFE.getLong(null,
UdfUtils.getAddressAtOffset(inputBufferPtrs, i))
+ + offset - numBytes;
byte[] bytes = new byte[(int) numBytes];
UdfUtils.copyMemory(null, base, bytes,
UdfUtils.BYTE_ARRAY_OFFSET, numBytes);
inputObjects[i] = new String(bytes,
StandardCharsets.UTF_8);
break;
}
+ case ARRAY_TYPE: {
+ Type type = argTypes[i].getItemType();
+ inputObjects[i] = arrayTypeInputData(type, i, row);
+ break;
+ }
default:
throw new UdfRuntimeException("Unsupported argument type:
" + argTypes[i]);
}
}
return inputObjects;
}
+ public ArrayList<?> arrayTypeInputData(Type type, int argIdx, long row)
+ throws UdfRuntimeException {
+ long offsetStart = (row == 0) ? 0
+ : Integer.toUnsignedLong(UdfUtils.UNSAFE.getInt(null,
UdfUtils.UNSAFE.getLong(null,
+ UdfUtils.getAddressAtOffset(inputOffsetsPtrs, argIdx))
+ 8L * (row - 1)));
+ long offsetEnd = Integer.toUnsignedLong(UdfUtils.UNSAFE.getInt(null,
UdfUtils.UNSAFE.getLong(null,
+ UdfUtils.getAddressAtOffset(inputOffsetsPtrs, argIdx)) + 8L *
row));
+
+ switch (type.getPrimitiveType()) {
+ case BOOLEAN: {
+ ArrayList<Boolean> data = new ArrayList<>();
+ for (long offsetRow = offsetStart; offsetRow < offsetEnd;
++offsetRow) {
+ if ((UdfUtils.UNSAFE.getByte(null,
UdfUtils.UNSAFE.getLong(null,
+ UdfUtils.getAddressAtOffset(inputArrayNullsPtrs,
argIdx)) + offsetRow) == 1)) {
Review Comment:
should only call `UdfUtils.UNSAFE.getLong(null,
UdfUtils.getAddressAtOffset(inputArrayNullsPtrs,
argIdx))` one time
--
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]