lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r1591800 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/handler/component/StatsValuesFactory.java core/src/test/org/apache/solr/TestDistributedSearch.java
Date Fri, 02 May 2014 00:33:29 GMT
Author: hossman
Date: Fri May  2 00:33:28 2014
New Revision: 1591800

URL: http://svn.apache.org/r1591800
Log:
SOLR-6037: Fixed incorrect max/sum/stddev for Date fields in StatsComponent

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/StatsValuesFactory.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1591800&r1=1591799&r2=1591800&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Fri May  2 00:33:28 2014
@@ -126,6 +126,9 @@ Bug Fixes
 * SOLR-6030: Use System.nanoTime() instead of currentTimeInMills() in LRUCache.warm.
   (Tomás Fernández Löbbe via shalin)
 
+* SOLR-6037: Fixed incorrect max/sum/stddev for Date fields in StatsComponent
+  (Brett Lucey, hossman)
+
 Other Changes
 ---------------------
 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/StatsValuesFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/StatsValuesFactory.java?rev=1591800&r1=1591799&r2=1591800&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/StatsValuesFactory.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/StatsValuesFactory.java
Fri May  2 00:33:28 2014
@@ -390,7 +390,7 @@ class EnumStatsValues extends AbstractSt
  */
 class DateStatsValues extends AbstractStatsValues<Date> {
 
-  private long sum = -1;
+  private long sum = 0;
   double sumOfSquares = 0;
 
   public DateStatsValues(SchemaField sf, boolean calcDistinct) {
@@ -433,10 +433,10 @@ class DateStatsValues extends AbstractSt
    */
   @Override
   protected void updateMinMax(Date min, Date max) {
-    if(this.min==null || this.min.after(min)) {
+    if(null != min && (this.min==null || this.min.after(min))) {
       this.min = min;
     }
-    if(this.max==null || this.max.before(min)) {
+    if(null != max && (this.max==null || this.max.before(max))) {
       this.max = max;
     }
   }

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java?rev=1591800&r1=1591799&r2=1591800&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java Fri May
 2 00:33:28 2014
@@ -264,7 +264,17 @@ public class TestDistributedSearch exten
     // test field that is valid in schema and missing in some shards
     query("q","*:*", "rows",100, "facet","true", "facet.field",oddField, "facet.mincount",2);
 
+    query("q","*:*", "sort",i1+" desc", "stats", "true", "stats.field", "stats_dt");
     query("q","*:*", "sort",i1+" desc", "stats", "true", "stats.field", i1);
+    query("q","*:*", "sort",i1+" desc", "stats", "true", "stats.field", tdate_a);
+    query("q","*:*", "sort",i1+" desc", "stats", "true", "stats.field", tdate_b);
+
+    handle.put("stats_fields", UNORDERED);
+    query("q","*:*", "sort",i1+" desc", "stats", "true", 
+          "stats.field", "stats_dt", 
+          "stats.field", i1, 
+          "stats.field", tdate_a, 
+          "stats.field", tdate_b);
 
     /*** TODO: the failure may come back in "exception"
     try {
@@ -417,7 +427,12 @@ public class TestDistributedSearch exten
     del("*:*"); // delete all docs and test stats request
     commit();
     try {
-      query("q", "*:*", "stats", "true", "stats.field", "stats_dt", "stats.calcdistinct",
"true");
+      query("q", "*:*", "stats", "true", 
+            "stats.field", "stats_dt", 
+            "stats.field", i1, 
+            "stats.field", tdate_a, 
+            "stats.field", tdate_b,
+            "stats.calcdistinct", "true");
     } catch (Exception e) {
       log.error("Exception on distrib stats request on empty index", e);
       fail("NullPointerException with stats request on empty index");



Mime
View raw message