SabrinaZhaozyf commented on code in PR #9296: URL: https://github.com/apache/pinot/pull/9296#discussion_r960068033
########## pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CastTransformFunction.java: ########## @@ -96,6 +109,204 @@ public TransformResultMetadata getResultMetadata() { return _resultMetadata; } + @Override + public double[][] transformToDoubleValuesMV(ProjectionBlock projectionBlock) { + DataType resultStoredType = _resultMetadata.getDataType().getStoredType(); + if (resultStoredType == DataType.DOUBLE) { + return _transformFunction.transformToDoubleValuesMV(projectionBlock); + } else { + int length = projectionBlock.getNumDocs(); + if (_doubleValuesMV == null || _doubleValuesMV.length < length) { + _doubleValuesMV = new double[length][]; + } + switch (resultStoredType) { + case INT: + int[][] intValues = _transformFunction.transformToIntValuesMV(projectionBlock); + ArrayCopyUtils.copy(intValues, _doubleValuesMV, length); + break; + case LONG: + long[][] longValues = _transformFunction.transformToLongValuesMV(projectionBlock); + ArrayCopyUtils.copy(longValues, _doubleValuesMV, length); + break; + case FLOAT: + float[][] floatValues = _transformFunction.transformToFloatValuesMV(projectionBlock); + ArrayCopyUtils.copy(floatValues, _doubleValuesMV, length); + break; + case STRING: + String[][] stringValues = _transformFunction.transformToStringValuesMV(projectionBlock); + ArrayCopyUtils.copy(stringValues, _doubleValuesMV, length); + break; + default: + throw new IllegalStateException(); + } + } + return _doubleValuesMV; + } + + @Override + public String[][] transformToStringValuesMV(ProjectionBlock projectionBlock) { + DataType resultDataType = _resultMetadata.getDataType(); + DataType resultStoredType = resultDataType.getStoredType(); + int length = projectionBlock.getNumDocs(); + if (resultStoredType == DataType.STRING) { + // Specialize BOOLEAN and TIMESTAMP when casting to STRING + DataType inputDataType = _transformFunction.getResultMetadata().getDataType(); + if (inputDataType.getStoredType() != inputDataType) { + if (_stringValuesMV == null || _stringValuesMV.length < length) { + _stringValuesMV = new String[length][]; + } + if (inputDataType == DataType.BOOLEAN) { + int[][] intValues = _transformFunction.transformToIntValuesMV(projectionBlock); + for (int i = 0; i < length; i++) { + int rowLen = intValues[i].length; + for (int j = 0; j < rowLen; j++) { + _stringValuesMV[i][j] = Boolean.toString(intValues[i][j] == 1); + } + } Review Comment: Done - simplified the code for both SV and MV. -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org