nutch-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aaron Scheffel (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (NUTCH-1638) SolrWriter Bad String comparision
Date Tue, 10 Sep 2013 03:15:54 GMT

    [ https://issues.apache.org/jira/browse/NUTCH-1638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13762674#comment-13762674
] 

Aaron Scheffel edited comment on NUTCH-1638 at 9/10/13 3:15 AM:
----------------------------------------------------------------

They are actually not the same objects. You can check with the debugger. Just put a break
there and see if that expression is always true. Even when those strings are equal they are
not equal. Your comparing two string objects, since you serialized one in one map one way
and another a different way the objects are never the same even if their values are. If your
goal is to perform inputDoc.addField(sCopy, val2); every single time then the code is working,
but you should remove the if statement because it isn't needed.
 
Please feel free to try it. 
                
      was (Author: ascheffe):
    They are actually not the same objects. You can check with the debugger. Just put a break
there and see if that expression is always true. Your comparing two string objects since you
serialized one in one map one way and another a different way the objects are not the same.


Please feel free to try it. 
                  
> SolrWriter Bad String comparision
> ---------------------------------
>
>                 Key: NUTCH-1638
>                 URL: https://issues.apache.org/jira/browse/NUTCH-1638
>             Project: Nutch
>          Issue Type: Bug
>          Components: indexer
>    Affects Versions: 1.7, 2.2.1
>            Reporter: Aaron Scheffel
>            Priority: Minor
>              Labels: patch
>         Attachments: NUTCH-1638.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> In version 2.2.1 and 1.7
> Class org.apache.nutch.indexer.solr.SolrWriter
> Line 66
> inputDoc.addField(solrMapping.mapKey(e.getKey()), val2);
> String sCopy = solrMapping.mapCopyKey(e.getKey());
> if (sCopy != e.getKey()) {
> inputDoc.addField(sCopy, val2);
> }
> There is a string comparison "sCopy != e.getKey()" with a != and not an
> equals. It basically never works right. Not sure if someone was trying to
> be clever but even if those strings are the same they happen to be
> different objects. Which I'm assuming is due to how the strings are
> serialized in from the config files.
> Suggest its updated to
> String sCopy = solrMapping.mapCopyKey(e.getKey());
> if (!sCopy.equals(solrMapping.mapKey(e.getKey()))) {
>        inputDoc.addField(sCopy, val2);
> }
> -Aaron

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message