You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Itamar Syn-Hershko (JIRA)" <ji...@apache.org> on 2008/05/22 20:23:56 UTC

[jira] Created: (LUCENE-1293) Tweaks to PhraseQuery.explain()

Tweaks to PhraseQuery.explain()
-------------------------------

                 Key: LUCENE-1293
                 URL: https://issues.apache.org/jira/browse/LUCENE-1293
             Project: Lucene - Java
          Issue Type: Improvement
          Components: Search
    Affects Versions: 2.3.1, 2.3, 2.2, 2.1, 2.0.0, 1.9, 2.3.2, 2.4
            Reporter: Itamar Syn-Hershko
            Priority: Minor
             Fix For: 2.3.2, 2.4


The explain() function in PhraseQuery.java is very clumzy and could use many optimizations. Perhaps it is only because it is intended to use while debugging?

Here's an example:

{noformat}
      result.addDetail(fieldExpl);

      // combine them
      result.setValue(queryExpl.getValue() * fieldExpl.getValue());

      if (queryExpl.getValue() == 1.0f)
        return fieldExpl;

      return result;
   }
{noformat}

Can easily be tweaked and become:

{noformat}
      if (queryExpl.getValue() == 1.0f) {
        return fieldExpl;
      }

      result.addDetail(fieldExpl);

      // combine them
      result.setValue(queryExpl.getValue() * fieldExpl.getValue());

      return result;
  }
{noformat}

And thats really just for a start...

Itamar.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (LUCENE-1293) Tweaks to PhraseQuery.explain()

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1293?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless resolved LUCENE-1293.
----------------------------------------

       Resolution: Incomplete
    Fix Version/s:     (was: 2.4)

I think the explain method is primarily used for debugging, and so performance is not really important.  It's also complex enough as is, and probably not well covered by unit tests, that I'm nervous about just tweaking it.  I'm resolving this as INCOMPLETE.  Itamar, if you want to see this resolved, can you post a full patch and we can reconsider it?  Thanks.

> Tweaks to PhraseQuery.explain()
> -------------------------------
>
>                 Key: LUCENE-1293
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1293
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4
>            Reporter: Itamar Syn-Hershko
>            Priority: Minor
>
> The explain() function in PhraseQuery.java is very clumzy and could use many optimizations. Perhaps it is only because it is intended to use while debugging?
> Here's an example:
> {noformat}
>       result.addDetail(fieldExpl);
>       // combine them
>       result.setValue(queryExpl.getValue() * fieldExpl.getValue());
>       if (queryExpl.getValue() == 1.0f)
>         return fieldExpl;
>       return result;
>    }
> {noformat}
> Can easily be tweaked and become:
> {noformat}
>       if (queryExpl.getValue() == 1.0f) {
>         return fieldExpl;
>       }
>       result.addDetail(fieldExpl);
>       // combine them
>       result.setValue(queryExpl.getValue() * fieldExpl.getValue());
>       return result;
>   }
> {noformat}
> And thats really just for a start...
> Itamar.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1293) Tweaks to PhraseQuery.explain()

Posted by "Itamar Syn-Hershko (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12600737#action_12600737 ] 

Itamar Syn-Hershko commented on LUCENE-1293:
--------------------------------------------

The specific change above prevents explain() from performing unnecessary actions and return earlier when Value == 1.0f. It could be done better, but will require one to dive really deep into it.

However, this report is of PhraseQuery.explain() being very clumzy - the above is just a small example of that. It really should be redesigned - unless, again, it is only intended for use in debug environments, so the Lucene dev team prefer easier to write code than smarter and robuster code...

> Tweaks to PhraseQuery.explain()
> -------------------------------
>
>                 Key: LUCENE-1293
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1293
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4
>            Reporter: Itamar Syn-Hershko
>            Priority: Minor
>             Fix For: 2.4
>
>
> The explain() function in PhraseQuery.java is very clumzy and could use many optimizations. Perhaps it is only because it is intended to use while debugging?
> Here's an example:
> {noformat}
>       result.addDetail(fieldExpl);
>       // combine them
>       result.setValue(queryExpl.getValue() * fieldExpl.getValue());
>       if (queryExpl.getValue() == 1.0f)
>         return fieldExpl;
>       return result;
>    }
> {noformat}
> Can easily be tweaked and become:
> {noformat}
>       if (queryExpl.getValue() == 1.0f) {
>         return fieldExpl;
>       }
>       result.addDetail(fieldExpl);
>       // combine them
>       result.setValue(queryExpl.getValue() * fieldExpl.getValue());
>       return result;
>   }
> {noformat}
> And thats really just for a start...
> Itamar.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1293) Tweaks to PhraseQuery.explain()

Posted by "Mike Klaas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12600973#action_12600973 ] 

Mike Klaas commented on LUCENE-1293:
------------------------------------

It is meant for debugging, though I have found it so painfully slow in the past that I have avoided it on occasion.

The main culprit is the looped next() call in PhraseScorer.explain().  Using skipTo() would be faster.

> Tweaks to PhraseQuery.explain()
> -------------------------------
>
>                 Key: LUCENE-1293
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1293
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4
>            Reporter: Itamar Syn-Hershko
>            Priority: Minor
>             Fix For: 2.4
>
>
> The explain() function in PhraseQuery.java is very clumzy and could use many optimizations. Perhaps it is only because it is intended to use while debugging?
> Here's an example:
> {noformat}
>       result.addDetail(fieldExpl);
>       // combine them
>       result.setValue(queryExpl.getValue() * fieldExpl.getValue());
>       if (queryExpl.getValue() == 1.0f)
>         return fieldExpl;
>       return result;
>    }
> {noformat}
> Can easily be tweaked and become:
> {noformat}
>       if (queryExpl.getValue() == 1.0f) {
>         return fieldExpl;
>       }
>       result.addDetail(fieldExpl);
>       // combine them
>       result.setValue(queryExpl.getValue() * fieldExpl.getValue());
>       return result;
>   }
> {noformat}
> And thats really just for a start...
> Itamar.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (LUCENE-1293) Tweaks to PhraseQuery.explain()

Posted by "Michael Busch (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1293?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Busch updated LUCENE-1293:
----------------------------------

    Fix Version/s:     (was: 2.3.2)

> Tweaks to PhraseQuery.explain()
> -------------------------------
>
>                 Key: LUCENE-1293
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1293
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4
>            Reporter: Itamar Syn-Hershko
>            Priority: Minor
>             Fix For: 2.4
>
>
> The explain() function in PhraseQuery.java is very clumzy and could use many optimizations. Perhaps it is only because it is intended to use while debugging?
> Here's an example:
> {noformat}
>       result.addDetail(fieldExpl);
>       // combine them
>       result.setValue(queryExpl.getValue() * fieldExpl.getValue());
>       if (queryExpl.getValue() == 1.0f)
>         return fieldExpl;
>       return result;
>    }
> {noformat}
> Can easily be tweaked and become:
> {noformat}
>       if (queryExpl.getValue() == 1.0f) {
>         return fieldExpl;
>       }
>       result.addDetail(fieldExpl);
>       // combine them
>       result.setValue(queryExpl.getValue() * fieldExpl.getValue());
>       return result;
>   }
> {noformat}
> And thats really just for a start...
> Itamar.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1293) Tweaks to PhraseQuery.explain()

Posted by "Otis Gospodnetic (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12599557#action_12599557 ] 

Otis Gospodnetic commented on LUCENE-1293:
------------------------------------------

Itamar - could you explain, in plain English, why the above is better? (sorry, I'm not terribly familiar with PhraseQuery's explain(), so I can't tell why this reordering makes the explain output better).  Also, if you have more changes to make, please go ahead and put them in a patch.  Thanks!


> Tweaks to PhraseQuery.explain()
> -------------------------------
>
>                 Key: LUCENE-1293
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1293
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4
>            Reporter: Itamar Syn-Hershko
>            Priority: Minor
>             Fix For: 2.3.2, 2.4
>
>
> The explain() function in PhraseQuery.java is very clumzy and could use many optimizations. Perhaps it is only because it is intended to use while debugging?
> Here's an example:
> {noformat}
>       result.addDetail(fieldExpl);
>       // combine them
>       result.setValue(queryExpl.getValue() * fieldExpl.getValue());
>       if (queryExpl.getValue() == 1.0f)
>         return fieldExpl;
>       return result;
>    }
> {noformat}
> Can easily be tweaked and become:
> {noformat}
>       if (queryExpl.getValue() == 1.0f) {
>         return fieldExpl;
>       }
>       result.addDetail(fieldExpl);
>       // combine them
>       result.setValue(queryExpl.getValue() * fieldExpl.getValue());
>       return result;
>   }
> {noformat}
> And thats really just for a start...
> Itamar.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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