nishantmonu51 commented on a change in pull request #5957: Renamed 'Generic
Column' -> 'Numeric Column'; Fixed a few resource leaks in processing; Fixed a
bug in SingleStringInputDimensionSelector; misc refinements
URL: https://github.com/apache/incubator-druid/pull/5957#discussion_r208028537
##########
File path:
processing/src/main/java/io/druid/query/aggregation/JavaScriptAggregatorFactory.java
##########
@@ -339,11 +340,11 @@ public double aggregate(final double current, final
BaseObjectColumnValueSelecto
if (arg != null && arg.getClass().isArray()) {
// Context.javaToJS on an array sort of works, although it
returns false for Array.isArray(...) and
// may have other issues too. Let's just copy the array and wrap
that.
- final Object[] arrayAsObjectArray = new
Object[Array.getLength(arg)];
- for (int j = 0; j < Array.getLength(arg); j++) {
- arrayAsObjectArray[j] = Array.get(arg, j);
- }
- args[i + 1] = cx.newArray(scope, arrayAsObjectArray);
+ args[i + 1] = cx.newArray(scope, arrayToObjectArray(arg));
+ } else if (arg instanceof List) {
+ // Using toArray(Object[]), instead of just toArray(), because
Arrays.asList()'s impl and similar List
+ // impls could clone the underlying array in toArray(), that
could be not Object[], but e. g. String[].
+ args[i + 1] = cx.newArray(scope, ((List)
arg).toArray(ObjectArrays.EMPTY_ARRAY));
Review comment:
do we have a test case for this ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]