leventov 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_r209113135
 
 

 ##########
 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:
   This change is going to be required in the following PR, where I replace 
some uses of Java arrays with lists. It's going to be tested then.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to