lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject lucene-solr:branch_6x: SOLR-9066: Make CountMetric return long instead of double
Date Wed, 04 May 2016 16:08:40 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 451feb0f8 -> eb1da08d5


SOLR-9066: Make CountMetric return long instead of double


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/eb1da08d
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/eb1da08d
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/eb1da08d

Branch: refs/heads/branch_6x
Commit: eb1da08d543e87cb8de2291551398db701790176
Parents: 451feb0
Author: Kevin Risden <krisden@apache.org>
Authored: Wed May 4 08:36:43 2016 -0500
Committer: Kevin Risden <krisden@apache.org>
Committed: Wed May 4 11:08:18 2016 -0500

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  2 ++
 .../client/solrj/io/stream/metrics/Bucket.java  |  8 +-------
 .../solrj/io/stream/metrics/CountMetric.java    |  9 +++------
 .../solrj/io/stream/metrics/MaxMetric.java      | 15 +++++---------
 .../solrj/io/stream/metrics/MeanMetric.java     | 21 ++++++++------------
 .../client/solrj/io/stream/metrics/Metric.java  | 16 ++++++---------
 .../solrj/io/stream/metrics/MinMetric.java      |  9 +++------
 .../solrj/io/stream/metrics/SumMetric.java      | 18 +++++++----------
 8 files changed, 35 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb1da08d/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index aa90094..b14f9ae 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -209,6 +209,8 @@ Other Changes
 
 * SOLR-9053: Upgrade commons-fileupload to 1.3.1, fixing a potential vulnerability (Jeff
Field, janhoy)
 
+* SOLR-9066 Make CountMetric return long instead of double (Kevin Risden)
+
 ==================  6.0.0 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb1da08d/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/Bucket.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/Bucket.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/Bucket.java
index 8e2293c..54907ac 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/Bucket.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/Bucket.java
@@ -16,20 +16,14 @@
  */
 package org.apache.solr.client.solrj.io.stream.metrics;
 
-import java.io.Serializable;
 import org.apache.solr.client.solrj.io.Tuple;
 
-public class Bucket implements Serializable {
+public class Bucket {
 
-  private static final long serialVersionUID = 1;
   private static final String NULL_VALUE = "NULL";
 
   private String bucketKey;
 
-  public Bucket() {
-
-  }
-
   public Bucket(String bucketKey) {
     this.bucketKey = bucketKey;
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb1da08d/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/CountMetric.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/CountMetric.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/CountMetric.java
index 445b530..0e8cbb0 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/CountMetric.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/CountMetric.java
@@ -16,7 +16,6 @@
  */
 package org.apache.solr.client.solrj.io.stream.metrics;
 import java.io.IOException;
-import java.io.Serializable;
 import java.util.Locale;
 
 import org.apache.solr.client.solrj.io.Tuple;
@@ -24,15 +23,13 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
 import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
 import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
 
-public class CountMetric extends Metric implements Serializable {
-
-  private static final long serialVersionUID = 1;
-
+public class CountMetric extends Metric {
   private long count;
   
   public CountMetric(){
     init("count");
   }
+
   public CountMetric(StreamExpression expression, StreamFactory factory) throws IOException{
     // grab all parameters out
     String functionName = expression.getFunctionName();
@@ -63,7 +60,7 @@ public class CountMetric extends Metric implements Serializable {
     ++count;
   }
 
-  public double getValue() {
+  public Long getValue() {
     return count;
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb1da08d/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MaxMetric.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MaxMetric.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MaxMetric.java
index 0594bf4..c02b327 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MaxMetric.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MaxMetric.java
@@ -17,7 +17,6 @@
 package org.apache.solr.client.solrj.io.stream.metrics;
 
 import java.io.IOException;
-import java.io.Serializable;
 import java.util.Locale;
 
 import org.apache.solr.client.solrj.io.Tuple;
@@ -25,11 +24,7 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
 import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
 import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
 
-public class MaxMetric extends Metric implements Serializable {
-
-  private static final long serialVersionUID = 1;
-
-  public static final String MAX = "max";
+public class MaxMetric extends Metric {
   private long longMax = -Long.MIN_VALUE;
   private double doubleMax = -Double.MAX_VALUE;
   private String columnName;
@@ -37,6 +32,7 @@ public class MaxMetric extends Metric implements Serializable {
   public MaxMetric(String columnName){
     init("max", columnName);
   }
+
   public MaxMetric(StreamExpression expression, StreamFactory factory) throws IOException{
     // grab all parameters out
     String functionName = expression.getFunctionName();
@@ -58,8 +54,8 @@ public class MaxMetric extends Metric implements Serializable {
     setFunctionName(functionName);
     setIdentifier(functionName, "(", columnName, ")");
   }
-  
-  public double getValue() {
+
+  public Number getValue() {
     if(longMax == Long.MIN_VALUE) {
       return doubleMax;
     } else {
@@ -68,8 +64,7 @@ public class MaxMetric extends Metric implements Serializable {
   }
 
   public String[] getColumns() {
-    String[] cols =  {columnName};
-    return cols;
+    return new String[]{columnName};
   }
 
   public void update(Tuple tuple) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb1da08d/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MeanMetric.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MeanMetric.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MeanMetric.java
index 097e04b..03c037a 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MeanMetric.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MeanMetric.java
@@ -17,7 +17,6 @@
 package org.apache.solr.client.solrj.io.stream.metrics;
 
 import java.io.IOException;
-import java.io.Serializable;
 import java.util.Locale;
 
 import org.apache.solr.client.solrj.io.Tuple;
@@ -25,14 +24,12 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
 import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
 import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
 
-public class MeanMetric extends Metric implements Serializable {
+public class MeanMetric extends Metric {
   // How'd the MeanMetric get to be so mean?
   // Maybe it was born with it.
   // Maybe it was mayba-mean.
   //
   // I'll see myself out.
-  
-  private static final long serialVersionUID = 1;
 
   private String columnName;
   private double doubleSum;
@@ -42,6 +39,7 @@ public class MeanMetric extends Metric implements Serializable {
   public MeanMetric(String columnName){
     init("avg", columnName);
   }
+
   public MeanMetric(StreamExpression expression, StreamFactory factory) throws IOException{
     // grab all parameters out
     String functionName = expression.getFunctionName();
@@ -69,10 +67,10 @@ public class MeanMetric extends Metric implements Serializable {
     Object o = tuple.get(columnName);
     if(o instanceof Double) {
       Double d = (Double)tuple.get(columnName);
-      doubleSum += d.doubleValue();
+      doubleSum += d;
     } else {
       Long l = (Long)tuple.get(columnName);
-      longSum += l.doubleValue();
+      longSum += l;
     }
   }
 
@@ -81,19 +79,16 @@ public class MeanMetric extends Metric implements Serializable {
   }
 
   public String[] getColumns() {
-    String[] cols =  {columnName};
-    return cols;
+    return new String[]{columnName};
   }
 
-  public double getValue() {
+  public Double getValue() {
     double dcount = (double)count;
     if(longSum == 0) {
-      double ave = doubleSum/dcount;
-      return ave;
+      return doubleSum/dcount;
 
     } else {
-      double ave = longSum/dcount;
-      return ave;
+      return longSum/dcount;
     }
   }
   

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb1da08d/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/Metric.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/Metric.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/Metric.java
index 4e24854..582b54a 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/Metric.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/Metric.java
@@ -17,7 +17,6 @@
 package org.apache.solr.client.solrj.io.stream.metrics;
 
 import java.io.IOException;
-import java.io.Serializable;
 import java.util.UUID;
 
 import org.apache.solr.client.solrj.io.Tuple;
@@ -26,19 +25,16 @@ import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
 import org.apache.solr.client.solrj.io.stream.expr.Expressible;
 import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
 
-public abstract class Metric implements Serializable, Expressible {
-  
-  private static final long serialVersionUID = 1L;
+public abstract class Metric implements Expressible {
+
   private UUID metricNodeId = UUID.randomUUID();
   private String functionName;
   private String identifier;
-  
-//  @Override
+
   public String getFunctionName(){
     return functionName;
   }
-  
-//  @Override
+
   public void setFunctionName(String functionName){
     this.functionName = functionName;
   }
@@ -59,7 +55,7 @@ public abstract class Metric implements Serializable, Expressible {
   
   @Override
   public Explanation toExplanation(StreamFactory factory) throws IOException {
-    return new Explanation(metricNodeId.toString())
+    return new Explanation(getMetricNodeId().toString())
       .withFunctionName(functionName)
       .withImplementingClass(getClass().getName())
       .withExpression(toExpression(factory).toString())
@@ -70,7 +66,7 @@ public abstract class Metric implements Serializable, Expressible {
     return metricNodeId;
   }
   
-  public abstract double getValue();
+  public abstract Number getValue();
   public abstract void update(Tuple tuple);
   public abstract Metric newInstance();
   public abstract String[] getColumns();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb1da08d/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MinMetric.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MinMetric.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MinMetric.java
index 0a56580..ddccde1 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MinMetric.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/MinMetric.java
@@ -25,8 +25,6 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
 import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
 
 public class MinMetric extends Metric {
-
-  private static final long serialVersionUID = 1L;
   
   private long longMin = Long.MAX_VALUE;
   private double doubleMin = Double.MAX_VALUE;
@@ -35,6 +33,7 @@ public class MinMetric extends Metric {
   public MinMetric(String columnName){
     init("min", columnName);
   }
+
   public MinMetric(StreamExpression expression, StreamFactory factory) throws IOException{
     // grab all parameters out
     String functionName = expression.getFunctionName();
@@ -57,13 +56,11 @@ public class MinMetric extends Metric {
     setIdentifier(functionName, "(", columnName, ")");
   }
 
-
   public String[] getColumns() {
-    String[] cols =  {columnName};
-    return cols;
+    return new String[]{columnName};
   }
 
-  public double getValue() {
+  public Number getValue() {
     if(longMin == Long.MAX_VALUE) {
       return doubleMin;
     } else {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb1da08d/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/SumMetric.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/SumMetric.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/SumMetric.java
index 578dae7..3eaf6d9 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/SumMetric.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/metrics/SumMetric.java
@@ -17,7 +17,6 @@
 package org.apache.solr.client.solrj.io.stream.metrics;
 
 import java.io.IOException;
-import java.io.Serializable;
 import java.util.Locale;
 
 import org.apache.solr.client.solrj.io.Tuple;
@@ -25,10 +24,7 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
 import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
 import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
 
-public class SumMetric extends Metric implements Serializable {
-
-  private static final long serialVersionUID = 1;
-
+public class SumMetric extends Metric {
   private String columnName;
   private double doubleSum;
   private long longSum;
@@ -36,6 +32,7 @@ public class SumMetric extends Metric implements Serializable {
   public SumMetric(String columnName){
     init("sum", columnName);
   }
+
   public SumMetric(StreamExpression expression, StreamFactory factory) throws IOException{
     // grab all parameters out
     String functionName = expression.getFunctionName();
@@ -59,18 +56,17 @@ public class SumMetric extends Metric implements Serializable {
   }
 
   public String[] getColumns() {
-    String[] cols =  {columnName};
-    return cols;
+    return new String[]{columnName};
   }
 
   public void update(Tuple tuple) {
     Object o = tuple.get(columnName);
     if(o instanceof Double) {
       Double d = (Double)o;
-      doubleSum += d.doubleValue();
+      doubleSum += d;
     } else {
       Long l = (Long)o;
-      longSum += l.longValue();
+      longSum += l;
     }
   }
 
@@ -78,11 +74,11 @@ public class SumMetric extends Metric implements Serializable {
     return new SumMetric(columnName);
   }
 
-  public double getValue() {
+  public Number getValue() {
     if(longSum == 0) {
       return doubleSum;
     } else {
-      return (double)longSum;
+      return longSum;
     }
   }
   


Mime
View raw message