You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Moti Nisenson (JIRA)" <ji...@apache.org> on 2009/04/02 15:08:12 UTC

[jira] Created: (LUCENE-1583) SpanOrQuery skipTo() doesn't always move forwards

SpanOrQuery skipTo() doesn't always move forwards
-------------------------------------------------

                 Key: LUCENE-1583
                 URL: https://issues.apache.org/jira/browse/LUCENE-1583
             Project: Lucene - Java
          Issue Type: Bug
          Components: Search
    Affects Versions: 2.4.1, 2.4, 2.3.2, 2.3.1, 2.3, 2.2, 2.1, 2.0.0, 1.9
            Reporter: Moti Nisenson
            Priority: Minor


In SpanOrQuery the skipTo() method is improperly implemented if the target doc is less than or equal to the current doc, since skipTo() may not be called for any of the clauses' spans:

    public boolean skipTo(int target) throws IOException {
          if (queue == null) {
            return initSpanQueue(target);
          }

          while (queue.size() != 0 && top().doc() < target) {
            if (top().skipTo(target)) {
              queue.adjustTop();
            } else {
              queue.pop();
            }
          }
          
        	return queue.size() != 0;
        }

This violates the correct behavior (as described in the Spans interface documentation), that skipTo() should always move forwards, in other words the correct implementation would be:

    public boolean skipTo(int target) throws IOException {
          if (queue == null) {
            return initSpanQueue(target);
          }

          boolean skipCalled = false;
          while (queue.size() != 0 && top().doc() < target) {
            if (top().skipTo(target)) {
              queue.adjustTop();
            } else {
              queue.pop();
            }
            skipCalled = true;
          }
          
          if (skipCalled) {
        	return queue.size() != 0;
          }
          return next();
        }

-- 
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] Assigned: (LUCENE-1583) SpanOrQuery skipTo() doesn't always move forwards

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

Mark Miller reassigned LUCENE-1583:
-----------------------------------

    Assignee: Mark Miller

I guess I'll do this one.

You out there reading Paul Elschot? This look right to you? Any issues it might cause?

Else I guess I'll have to put on my thinking cap and figure it myself.

> SpanOrQuery skipTo() doesn't always move forwards
> -------------------------------------------------
>
>                 Key: LUCENE-1583
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1583
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4, 2.4.1
>            Reporter: Moti Nisenson
>            Assignee: Mark Miller
>            Priority: Minor
>             Fix For: 2.9
>
>         Attachments: LUCENE-1583.patch
>
>
> In SpanOrQuery the skipTo() method is improperly implemented if the target doc is less than or equal to the current doc, since skipTo() may not be called for any of the clauses' spans:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>           }
>           
>         	return queue.size() != 0;
>         }
> This violates the correct behavior (as described in the Spans interface documentation), that skipTo() should always move forwards, in other words the correct implementation would be:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           boolean skipCalled = false;
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>             skipCalled = true;
>           }
>           
>           if (skipCalled) {
>         	return queue.size() != 0;
>           }
>           return next();
>         }

-- 
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-1583) SpanOrQuery skipTo() doesn't always move forwards

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

Mark Miller updated LUCENE-1583:
--------------------------------

    Attachment: LUCENE-1583.patch

Adds a Unit test and Changes entry

> SpanOrQuery skipTo() doesn't always move forwards
> -------------------------------------------------
>
>                 Key: LUCENE-1583
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1583
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4, 2.4.1
>            Reporter: Moti Nisenson
>            Assignee: Mark Miller
>            Priority: Minor
>             Fix For: 2.9
>
>         Attachments: LUCENE-1583.patch, LUCENE-1583.patch
>
>
> In SpanOrQuery the skipTo() method is improperly implemented if the target doc is less than or equal to the current doc, since skipTo() may not be called for any of the clauses' spans:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>           }
>           
>         	return queue.size() != 0;
>         }
> This violates the correct behavior (as described in the Spans interface documentation), that skipTo() should always move forwards, in other words the correct implementation would be:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           boolean skipCalled = false;
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>             skipCalled = true;
>           }
>           
>           if (skipCalled) {
>         	return queue.size() != 0;
>           }
>           return next();
>         }

-- 
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-1583) SpanOrQuery skipTo() doesn't always move forwards

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

Michael McCandless updated LUCENE-1583:
---------------------------------------

    Fix Version/s: 2.9

LUCENE-1327 was a similar issue.

> SpanOrQuery skipTo() doesn't always move forwards
> -------------------------------------------------
>
>                 Key: LUCENE-1583
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1583
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4, 2.4.1
>            Reporter: Moti Nisenson
>            Priority: Minor
>             Fix For: 2.9
>
>
> In SpanOrQuery the skipTo() method is improperly implemented if the target doc is less than or equal to the current doc, since skipTo() may not be called for any of the clauses' spans:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>           }
>           
>         	return queue.size() != 0;
>         }
> This violates the correct behavior (as described in the Spans interface documentation), that skipTo() should always move forwards, in other words the correct implementation would be:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           boolean skipCalled = false;
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>             skipCalled = true;
>           }
>           
>           if (skipCalled) {
>         	return queue.size() != 0;
>           }
>           return next();
>         }

-- 
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-1583) SpanOrQuery skipTo() doesn't always move forwards

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

Mark Miller updated LUCENE-1583:
--------------------------------

    Attachment: LUCENE-1583.patch

I havn't looked closely at it yet, but tests appear to pass (unknown if tests actually hit skipto on SpanOrQuery though)

> SpanOrQuery skipTo() doesn't always move forwards
> -------------------------------------------------
>
>                 Key: LUCENE-1583
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1583
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4, 2.4.1
>            Reporter: Moti Nisenson
>            Priority: Minor
>             Fix For: 2.9
>
>         Attachments: LUCENE-1583.patch
>
>
> In SpanOrQuery the skipTo() method is improperly implemented if the target doc is less than or equal to the current doc, since skipTo() may not be called for any of the clauses' spans:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>           }
>           
>         	return queue.size() != 0;
>         }
> This violates the correct behavior (as described in the Spans interface documentation), that skipTo() should always move forwards, in other words the correct implementation would be:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           boolean skipCalled = false;
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>             skipCalled = true;
>           }
>           
>           if (skipCalled) {
>         	return queue.size() != 0;
>           }
>           return next();
>         }

-- 
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-1583) SpanOrQuery skipTo() doesn't always move forwards

Posted by "Mark Miller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12721858#action_12721858 ] 

Mark Miller commented on LUCENE-1583:
-------------------------------------

That change would always call next once before skipping though right? And the way the patch is, you would only call next if no skipping occurred? I know its semantically the same, and I guess the clarity is probably worth any (probably extremely minor) slowdown?

> SpanOrQuery skipTo() doesn't always move forwards
> -------------------------------------------------
>
>                 Key: LUCENE-1583
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1583
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4, 2.4.1
>            Reporter: Moti Nisenson
>            Assignee: Mark Miller
>            Priority: Minor
>             Fix For: 2.9
>
>         Attachments: LUCENE-1583.patch
>
>
> In SpanOrQuery the skipTo() method is improperly implemented if the target doc is less than or equal to the current doc, since skipTo() may not be called for any of the clauses' spans:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>           }
>           
>         	return queue.size() != 0;
>         }
> This violates the correct behavior (as described in the Spans interface documentation), that skipTo() should always move forwards, in other words the correct implementation would be:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           boolean skipCalled = false;
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>             skipCalled = true;
>           }
>           
>           if (skipCalled) {
>         	return queue.size() != 0;
>           }
>           return next();
>         }

-- 
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-1583) SpanOrQuery skipTo() doesn't always move forwards

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

Mark Miller resolved LUCENE-1583.
---------------------------------

       Resolution: Fixed
    Lucene Fields: [New, Patch Available]  (was: [New])

Thanks Moti!

> SpanOrQuery skipTo() doesn't always move forwards
> -------------------------------------------------
>
>                 Key: LUCENE-1583
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1583
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4, 2.4.1
>            Reporter: Moti Nisenson
>            Assignee: Mark Miller
>            Priority: Minor
>             Fix For: 2.9
>
>         Attachments: LUCENE-1583.patch, LUCENE-1583.patch
>
>
> In SpanOrQuery the skipTo() method is improperly implemented if the target doc is less than or equal to the current doc, since skipTo() may not be called for any of the clauses' spans:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>           }
>           
>         	return queue.size() != 0;
>         }
> This violates the correct behavior (as described in the Spans interface documentation), that skipTo() should always move forwards, in other words the correct implementation would be:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           boolean skipCalled = false;
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>             skipCalled = true;
>           }
>           
>           if (skipCalled) {
>         	return queue.size() != 0;
>           }
>           return next();
>         }

-- 
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-1583) SpanOrQuery skipTo() doesn't always move forwards

Posted by "Paul Elschot (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12719811#action_12719811 ] 

Paul Elschot commented on LUCENE-1583:
--------------------------------------

Midnight here, still reading :)

The patch looks good. However, it might be easier to understand by starting like this after the queue initialisation:
{code}
if (!next()) return false;
{code}
and leave the rest of the code as it is.

I did not run any tests on this, so a thinking cap might well save time.

> SpanOrQuery skipTo() doesn't always move forwards
> -------------------------------------------------
>
>                 Key: LUCENE-1583
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1583
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4, 2.4.1
>            Reporter: Moti Nisenson
>            Assignee: Mark Miller
>            Priority: Minor
>             Fix For: 2.9
>
>         Attachments: LUCENE-1583.patch
>
>
> In SpanOrQuery the skipTo() method is improperly implemented if the target doc is less than or equal to the current doc, since skipTo() may not be called for any of the clauses' spans:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>           }
>           
>         	return queue.size() != 0;
>         }
> This violates the correct behavior (as described in the Spans interface documentation), that skipTo() should always move forwards, in other words the correct implementation would be:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           boolean skipCalled = false;
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>             skipCalled = true;
>           }
>           
>           if (skipCalled) {
>         	return queue.size() != 0;
>           }
>           return next();
>         }

-- 
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-1583) SpanOrQuery skipTo() doesn't always move forwards

Posted by "Mark Miller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12723587#action_12723587 ] 

Mark Miller commented on LUCENE-1583:
-------------------------------------

I'm going to commit this soon.

> SpanOrQuery skipTo() doesn't always move forwards
> -------------------------------------------------
>
>                 Key: LUCENE-1583
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1583
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4, 2.4.1
>            Reporter: Moti Nisenson
>            Assignee: Mark Miller
>            Priority: Minor
>             Fix For: 2.9
>
>         Attachments: LUCENE-1583.patch
>
>
> In SpanOrQuery the skipTo() method is improperly implemented if the target doc is less than or equal to the current doc, since skipTo() may not be called for any of the clauses' spans:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>           }
>           
>         	return queue.size() != 0;
>         }
> This violates the correct behavior (as described in the Spans interface documentation), that skipTo() should always move forwards, in other words the correct implementation would be:
>     public boolean skipTo(int target) throws IOException {
>           if (queue == null) {
>             return initSpanQueue(target);
>           }
>           boolean skipCalled = false;
>           while (queue.size() != 0 && top().doc() < target) {
>             if (top().skipTo(target)) {
>               queue.adjustTop();
>             } else {
>               queue.pop();
>             }
>             skipCalled = true;
>           }
>           
>           if (skipCalled) {
>         	return queue.size() != 0;
>           }
>           return next();
>         }

-- 
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