lmccay4 commented on a change in pull request #163: KNOX-2052 - KnoxShellTable 
mean, median, and mode methods
URL: https://github.com/apache/knox/pull/163#discussion_r332292265
 
 

 ##########
 File path: 
gateway-shell/src/main/java/org/apache/knox/gateway/shell/table/KnoxShellTable.java
 ##########
 @@ -76,6 +80,98 @@ public KnoxShellTable value(Comparable<? extends Object> 
value) {
     return col;
   }
 
+  public double[] toDoubleArray(String colName) throws 
IllegalArgumentException {
+    List<Comparable<? extends Object>> col = values(colName);
+    double[] colArray = new double[col.size()];
+    int conversionMethod = 0;
+    for (int i = 0; i < col.size(); i++) {
+      if (i == 0) {
+        if (col.get(i) instanceof Integer) {
+          conversionMethod = INTEGER_CONVERSION_METHOD;
 
 Review comment:
   The check is needed as `valueOf` can't be called on a Comparable. You would 
need to convert to something like string before doing that. I had something 
similar to this originally (my comment on the jira) where it was 
`Double.parseDouble(col.get(i).toString());`, which is not efficient. With this 
though we're just going from whichever underlying datatype it happens to be out 
to double.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to