risdenk 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_r332278559
##########
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:
Do we need to do this check and then later do a complicated convert to
`double`? Is it possible to just do something like `Double.valueOf(col.get(i))`?
----------------------------------------------------------------
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