xiangfu0 commented on code in PR #18872:
URL: https://github.com/apache/pinot/pull/18872#discussion_r3706897655
##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CastTransformFunction.java:
##########
@@ -300,13 +310,76 @@ public String[] transformToStringValuesSV(ValueBlock
valueBlock) {
byte[][] bytesValues = transformToBytesValuesSV(valueBlock);
ArrayCopyUtils.copy(bytesValues, _stringValuesSV, length);
break;
+ case UUID:
+ ArrayCopyUtils.copyFromUuid(transformToBytesValuesSV(valueBlock),
_stringValuesSV, length);
+ break;
default:
throw new IllegalStateException(String.format("Cannot cast from SV
%s to STRING", resultDataType));
}
}
return _stringValuesSV;
}
+ @Override
+ public byte[][] transformToBytesValuesSV(ValueBlock valueBlock) {
+ DataType resultDataType = _resultMetadata.getDataType();
+ if (resultDataType != DataType.UUID) {
Review Comment:
Done — `transformToBytesValuesSV` now switches on
`_resultMetadata.getDataType()` and delegates to a private
`transformToUuidValuesSV`, matching the `transformToIntValuesSV` /
`transformToBooleanValuesSV` pair. Same for the MV path.
##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CastTransformFunction.java:
##########
@@ -300,13 +310,76 @@ public String[] transformToStringValuesSV(ValueBlock
valueBlock) {
byte[][] bytesValues = transformToBytesValuesSV(valueBlock);
ArrayCopyUtils.copy(bytesValues, _stringValuesSV, length);
break;
+ case UUID:
+ ArrayCopyUtils.copyFromUuid(transformToBytesValuesSV(valueBlock),
_stringValuesSV, length);
+ break;
default:
throw new IllegalStateException(String.format("Cannot cast from SV
%s to STRING", resultDataType));
}
}
return _stringValuesSV;
}
+ @Override
+ public byte[][] transformToBytesValuesSV(ValueBlock valueBlock) {
+ DataType resultDataType = _resultMetadata.getDataType();
+ if (resultDataType != DataType.UUID) {
+ if (resultDataType.getStoredType() == DataType.BYTES) {
+ return _transformFunction.transformToBytesValuesSV(valueBlock);
+ }
+ return super.transformToBytesValuesSV(valueBlock);
+ }
+
+ int length = valueBlock.getNumDocs();
+ initBytesValuesSV(length);
+ switch (_sourceDataType.getStoredType()) {
+ case STRING:
+
ArrayCopyUtils.copyToUuid(_transformFunction.transformToStringValuesSV(valueBlock),
_bytesValuesSV, length);
+ return _bytesValuesSV;
+ case BYTES:
+ byte[][] bytesValues =
_transformFunction.transformToBytesValuesSV(valueBlock);
+ for (int i = 0; i < length; i++) {
+ _bytesValuesSV[i] = UuidUtils.toBytes(bytesValues[i]);
Review Comment:
Added — `ArrayCopyUtils.copyToUuid(byte[][] src, byte[][] dest, int length)`
and the MV `copyToUuid(byte[][][], byte[][][], int)`. Both
`CastTransformFunction` branches now call `ArrayCopyUtils` with no inline loops
left.
##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/ArrayCopyUtils.java:
##########
@@ -228,6 +228,22 @@ public static void copyFromTimestamp(long[] src, String[]
dest, int length) {
}
}
+ /// Renders UUID values, stored as 16 raw bytes, into their canonical dashed
form. Mirrors
+ /// [#copyFromTimestamp(long[], String[], int)], which likewise renders a
logical type from its stored form.
+ public static void copyFromUuid(byte[][] src, String[] dest, int length) {
Review Comment:
Moved — the four UUID helpers now sit with their src/dest neighbours rather
than after `copyFromTimestamp`:
- `copyToUuid(String[], byte[][])` after `copy(String[], byte[][])`
- `copyFromUuid(byte[][], String[])` and `copyToUuid(byte[][], byte[][])`
after `copy(byte[][], String[])`
- the MV variants after `copy(String[][], byte[][][])`
--
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]