public static long getSumIgnoreNegatives(List<Long> vals) {
    long result = 0;
    for (Long l : vals) {
      if (l > 0) {
        result = safeAdd(result, l);
      }
    }
    return result;
  }
Get sum of all values in the list that are &gt;0
@param vals
         - list of values
@return sum
ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUtils.java