You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Luca Cavanna (Created) (JIRA)" <ji...@apache.org> on 2012/02/24 10:55:48 UTC

[jira] [Created] (SOLR-3160) Division by zero in StatsComponent with date field always missing

Division by zero in StatsComponent with date field always missing
-----------------------------------------------------------------

                 Key: SOLR-3160
                 URL: https://issues.apache.org/jira/browse/SOLR-3160
             Project: Solr
          Issue Type: Bug
    Affects Versions: 3.5
            Reporter: Luca Cavanna
            Assignee: Luca Cavanna
            Priority: Minor
             Fix For: 3.6, 4.0


Using the StatsComponent with a date field that never has a value you'll get 
{code}
java.lang.ArithmeticException: / by zero at org.apache.solr.handler.component.DateStatsValues.addTypeSpecificStats (StatsValuesFactory.java:384)
{code}

The problem is in this line of DateStatsValues:
{code}
res.add("mean", new Date(sum / count));
{code}

If count is 0 the division throws ArithmeticException because sum is long here. This doesn't happen with NumericStatsValues because sum is double there and the division result is Nan.
By the way, the result of those divisions is not even included in the output when count is 0 because of this condition in SimpleStats#getStatsFields:
{code}
if (isShard == true || (Long) stv.get("count") > 0) {
    res.add(f, stv);
} else {
    res.add(f, null);
}
{code}

Therefore, it should never throw an exception!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Updated] (SOLR-3160) Division by zero in StatsComponent with date field always missing

Posted by "Luca Cavanna (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SOLR-3160?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luca Cavanna updated SOLR-3160:
-------------------------------

    Attachment: SOLR-3160.patch

Attached patch containing some new test methods and a fix within DateStatsvalues.
StatsComponentTest tests now the same situation (count=0) for string, date and numeric field, and the result is the same.

                
> Division by zero in StatsComponent with date field always missing
> -----------------------------------------------------------------
>
>                 Key: SOLR-3160
>                 URL: https://issues.apache.org/jira/browse/SOLR-3160
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: 3.5
>            Reporter: Luca Cavanna
>            Assignee: Luca Cavanna
>            Priority: Minor
>             Fix For: 3.6, 4.0
>
>         Attachments: SOLR-3160.patch
>
>
> Using the StatsComponent with a date field that never has a value you'll get 
> {code}
> java.lang.ArithmeticException: / by zero at org.apache.solr.handler.component.DateStatsValues.addTypeSpecificStats (StatsValuesFactory.java:384)
> {code}
> The problem is in this line of DateStatsValues:
> {code}
> res.add("mean", new Date(sum / count));
> {code}
> If count is 0 the division throws ArithmeticException because sum is long here. This doesn't happen with NumericStatsValues because sum is double there and the division result is Nan.
> By the way, the result of those divisions is not even included in the output when count is 0 because of this condition in SimpleStats#getStatsFields:
> {code}
> if (isShard == true || (Long) stv.get("count") > 0) {
>     res.add(f, stv);
> } else {
>     res.add(f, null);
> }
> {code}
> Therefore, it should never throw an exception!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Resolved] (SOLR-3160) Division by zero in StatsComponent with date field always missing

Posted by "Erick Erickson (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SOLR-3160?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Erick Erickson resolved SOLR-3160.
----------------------------------

    Resolution: Fixed

Trunk: r1293270
3x:    1293272

Thanks Luca!
                
> Division by zero in StatsComponent with date field always missing
> -----------------------------------------------------------------
>
>                 Key: SOLR-3160
>                 URL: https://issues.apache.org/jira/browse/SOLR-3160
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: 3.5
>            Reporter: Luca Cavanna
>            Assignee: Erick Erickson
>            Priority: Minor
>             Fix For: 3.6, 4.0
>
>         Attachments: SOLR-3160.patch
>
>
> Using the StatsComponent with a date field that never has a value you'll get 
> {code}
> java.lang.ArithmeticException: / by zero at org.apache.solr.handler.component.DateStatsValues.addTypeSpecificStats (StatsValuesFactory.java:384)
> {code}
> The problem is in this line of DateStatsValues:
> {code}
> res.add("mean", new Date(sum / count));
> {code}
> If count is 0 the division throws ArithmeticException because sum is long here. This doesn't happen with NumericStatsValues because sum is double there and the division result is Nan.
> By the way, the result of those divisions is not even included in the output when count is 0 because of this condition in SimpleStats#getStatsFields:
> {code}
> if (isShard == true || (Long) stv.get("count") > 0) {
>     res.add(f, stv);
> } else {
>     res.add(f, null);
> }
> {code}
> Therefore, it should never throw an exception!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Commented] (SOLR-3160) Division by zero in StatsComponent with date field always missing

Posted by "Luca Cavanna (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-3160?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13215589#comment-13215589 ] 

Luca Cavanna commented on SOLR-3160:
------------------------------------

Thanks Erick! 
Catch is not mine, it comes from this [StackOverflow question|http://stackoverflow.com/q/9368926/633239], I just reported the error and worked on the patch.
                
> Division by zero in StatsComponent with date field always missing
> -----------------------------------------------------------------
>
>                 Key: SOLR-3160
>                 URL: https://issues.apache.org/jira/browse/SOLR-3160
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: 3.5
>            Reporter: Luca Cavanna
>            Assignee: Erick Erickson
>            Priority: Minor
>             Fix For: 3.6, 4.0
>
>         Attachments: SOLR-3160.patch
>
>
> Using the StatsComponent with a date field that never has a value you'll get 
> {code}
> java.lang.ArithmeticException: / by zero at org.apache.solr.handler.component.DateStatsValues.addTypeSpecificStats (StatsValuesFactory.java:384)
> {code}
> The problem is in this line of DateStatsValues:
> {code}
> res.add("mean", new Date(sum / count));
> {code}
> If count is 0 the division throws ArithmeticException because sum is long here. This doesn't happen with NumericStatsValues because sum is double there and the division result is Nan.
> By the way, the result of those divisions is not even included in the output when count is 0 because of this condition in SimpleStats#getStatsFields:
> {code}
> if (isShard == true || (Long) stv.get("count") > 0) {
>     res.add(f, stv);
> } else {
>     res.add(f, null);
> }
> {code}
> Therefore, it should never throw an exception!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Assigned] (SOLR-3160) Division by zero in StatsComponent with date field always missing

Posted by "Erick Erickson (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SOLR-3160?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Erick Erickson reassigned SOLR-3160:
------------------------------------

    Assignee: Erick Erickson  (was: Luca Cavanna)
    
> Division by zero in StatsComponent with date field always missing
> -----------------------------------------------------------------
>
>                 Key: SOLR-3160
>                 URL: https://issues.apache.org/jira/browse/SOLR-3160
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: 3.5
>            Reporter: Luca Cavanna
>            Assignee: Erick Erickson
>            Priority: Minor
>             Fix For: 3.6, 4.0
>
>         Attachments: SOLR-3160.patch
>
>
> Using the StatsComponent with a date field that never has a value you'll get 
> {code}
> java.lang.ArithmeticException: / by zero at org.apache.solr.handler.component.DateStatsValues.addTypeSpecificStats (StatsValuesFactory.java:384)
> {code}
> The problem is in this line of DateStatsValues:
> {code}
> res.add("mean", new Date(sum / count));
> {code}
> If count is 0 the division throws ArithmeticException because sum is long here. This doesn't happen with NumericStatsValues because sum is double there and the division result is Nan.
> By the way, the result of those divisions is not even included in the output when count is 0 because of this condition in SimpleStats#getStatsFields:
> {code}
> if (isShard == true || (Long) stv.get("count") > 0) {
>     res.add(f, stv);
> } else {
>     res.add(f, null);
> }
> {code}
> Therefore, it should never throw an exception!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Commented] (SOLR-3160) Division by zero in StatsComponent with date field always missing

Posted by "Erick Erickson (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-3160?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13215577#comment-13215577 ] 

Erick Erickson commented on SOLR-3160:
--------------------------------------

Luca:

Good catch. I'll assign it to myself (that way I won't forget!) and check it in later today. Thanks!
                
> Division by zero in StatsComponent with date field always missing
> -----------------------------------------------------------------
>
>                 Key: SOLR-3160
>                 URL: https://issues.apache.org/jira/browse/SOLR-3160
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: 3.5
>            Reporter: Luca Cavanna
>            Assignee: Luca Cavanna
>            Priority: Minor
>             Fix For: 3.6, 4.0
>
>         Attachments: SOLR-3160.patch
>
>
> Using the StatsComponent with a date field that never has a value you'll get 
> {code}
> java.lang.ArithmeticException: / by zero at org.apache.solr.handler.component.DateStatsValues.addTypeSpecificStats (StatsValuesFactory.java:384)
> {code}
> The problem is in this line of DateStatsValues:
> {code}
> res.add("mean", new Date(sum / count));
> {code}
> If count is 0 the division throws ArithmeticException because sum is long here. This doesn't happen with NumericStatsValues because sum is double there and the division result is Nan.
> By the way, the result of those divisions is not even included in the output when count is 0 because of this condition in SimpleStats#getStatsFields:
> {code}
> if (isShard == true || (Long) stv.get("count") > 0) {
>     res.add(f, stv);
> } else {
>     res.add(f, null);
> }
> {code}
> Therefore, it should never throw an exception!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org