You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "Franklin Simmons (JIRA)" <ji...@apache.org> on 2009/06/01 16:11:07 UTC

[jira] Created: (LUCENENET-183) SegmentTermVector IndexOf method always fails

SegmentTermVector IndexOf method always fails
---------------------------------------------

                 Key: LUCENENET-183
                 URL: https://issues.apache.org/jira/browse/LUCENENET-183
             Project: Lucene.Net
          Issue Type: Bug
            Reporter: Franklin Simmons


At index time term vectors are sorted using String.CompareOrdinal. However method IndexOf of class SegmentTermVector invokes System.Array.BinarySearch, which is using String.Compare.

{noformat}public virtual int IndexOf(System.String termText)
{
	if (terms == null)
		return - 1;
    int res = System.Array.BinarySearch(terms, termText);
	return res >= 0 ? res : - 1;
}
{noformat}

The effect is that the IndexOf method always returns a negative number (no match) because the sort order is incompatible with the default comparer.

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


[jira] Issue Comment Edited: (LUCENENET-183) SegmentTermVector IndexOf method always fails

Posted by "Franklin Simmons (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENENET-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12715270#action_12715270 ] 

Franklin Simmons edited comment on LUCENENET-183 at 6/1/09 2:30 PM:
--------------------------------------------------------------------

Since QueryTermVector#ProcessTerms invokes System.Array.Sort and System.Array.BinarySearch with the default comparer (String) it is not subject to the bug.

      was (Author: franklin):
    Since QueryTermVector#ProcessTerms invokes System.Array.Sort and BinarySearch with the default comparer (String) it is not subject to the bug.
  
> SegmentTermVector IndexOf method always fails
> ---------------------------------------------
>
>                 Key: LUCENENET-183
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-183
>             Project: Lucene.Net
>          Issue Type: Bug
>            Reporter: Franklin Simmons
>         Attachments: SegmentTermVector-2.patch, SegmentTermVector.patch
>
>
> At index time term vectors are sorted using String.CompareOrdinal. However method IndexOf of class SegmentTermVector invokes System.Array.BinarySearch, which is using String.Compare.
> {noformat}public virtual int IndexOf(System.String termText)
> {
> 	if (terms == null)
> 		return - 1;
>     int res = System.Array.BinarySearch(terms, termText);
> 	return res >= 0 ? res : - 1;
> }
> {noformat}
> The effect is that the IndexOf method always returns a negative number (no match) because the sort order is incompatible with the default comparer.

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


[jira] Commented: (LUCENENET-183) SegmentTermVector IndexOf method always fails

Posted by "Franklin Simmons (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENENET-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12715270#action_12715270 ] 

Franklin Simmons commented on LUCENENET-183:
--------------------------------------------

Since QueryTermVector#ProcessTerms invokes System.Array.Sort and BinarySearch with the default comparer (String) it is not subject to the bug.

> SegmentTermVector IndexOf method always fails
> ---------------------------------------------
>
>                 Key: LUCENENET-183
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-183
>             Project: Lucene.Net
>          Issue Type: Bug
>            Reporter: Franklin Simmons
>         Attachments: SegmentTermVector-2.patch, SegmentTermVector.patch
>
>
> At index time term vectors are sorted using String.CompareOrdinal. However method IndexOf of class SegmentTermVector invokes System.Array.BinarySearch, which is using String.Compare.
> {noformat}public virtual int IndexOf(System.String termText)
> {
> 	if (terms == null)
> 		return - 1;
>     int res = System.Array.BinarySearch(terms, termText);
> 	return res >= 0 ? res : - 1;
> }
> {noformat}
> The effect is that the IndexOf method always returns a negative number (no match) because the sort order is incompatible with the default comparer.

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


[jira] Commented: (LUCENENET-183) SegmentTermVector IndexOf method always fails

Posted by "Digy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENENET-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12715244#action_12715244 ] 

Digy commented on LUCENENET-183:
--------------------------------

Shouldn't we also fix QueryTermVector#IndexOf?  Has anyone tested it?

DIGY

> SegmentTermVector IndexOf method always fails
> ---------------------------------------------
>
>                 Key: LUCENENET-183
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-183
>             Project: Lucene.Net
>          Issue Type: Bug
>            Reporter: Franklin Simmons
>         Attachments: SegmentTermVector-2.patch, SegmentTermVector.patch
>
>
> At index time term vectors are sorted using String.CompareOrdinal. However method IndexOf of class SegmentTermVector invokes System.Array.BinarySearch, which is using String.Compare.
> {noformat}public virtual int IndexOf(System.String termText)
> {
> 	if (terms == null)
> 		return - 1;
>     int res = System.Array.BinarySearch(terms, termText);
> 	return res >= 0 ? res : - 1;
> }
> {noformat}
> The effect is that the IndexOf method always returns a negative number (no match) because the sort order is incompatible with the default comparer.

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


[jira] Updated: (LUCENENET-183) SegmentTermVector IndexOf method always fails

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

Franklin Simmons updated LUCENENET-183:
---------------------------------------

    Attachment:     (was: SegmentTermVector.patch)

> SegmentTermVector IndexOf method always fails
> ---------------------------------------------
>
>                 Key: LUCENENET-183
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-183
>             Project: Lucene.Net
>          Issue Type: Bug
>            Reporter: Franklin Simmons
>         Attachments: SegmentTermVector.patch
>
>
> At index time term vectors are sorted using String.CompareOrdinal. However method IndexOf of class SegmentTermVector invokes System.Array.BinarySearch, which is using String.Compare.
> {noformat}public virtual int IndexOf(System.String termText)
> {
> 	if (terms == null)
> 		return - 1;
>     int res = System.Array.BinarySearch(terms, termText);
> 	return res >= 0 ? res : - 1;
> }
> {noformat}
> The effect is that the IndexOf method always returns a negative number (no match) because the sort order is incompatible with the default comparer.

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


[jira] Updated: (LUCENENET-183) SegmentTermVector IndexOf method always fails

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

Franklin Simmons updated LUCENENET-183:
---------------------------------------

    Attachment: SegmentTermVector-2.patch

The intended patch containing the fully qualified object, sorry about the repost.

> SegmentTermVector IndexOf method always fails
> ---------------------------------------------
>
>                 Key: LUCENENET-183
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-183
>             Project: Lucene.Net
>          Issue Type: Bug
>            Reporter: Franklin Simmons
>         Attachments: SegmentTermVector-2.patch, SegmentTermVector.patch
>
>
> At index time term vectors are sorted using String.CompareOrdinal. However method IndexOf of class SegmentTermVector invokes System.Array.BinarySearch, which is using String.Compare.
> {noformat}public virtual int IndexOf(System.String termText)
> {
> 	if (terms == null)
> 		return - 1;
>     int res = System.Array.BinarySearch(terms, termText);
> 	return res >= 0 ? res : - 1;
> }
> {noformat}
> The effect is that the IndexOf method always returns a negative number (no match) because the sort order is incompatible with the default comparer.

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


[jira] Updated: (LUCENENET-183) SegmentTermVector IndexOf method always fails

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

Franklin Simmons updated LUCENENET-183:
---------------------------------------

    Attachment: SegmentTermVector.patch

I've attached the very simple patch.  This best remedy was suggested by Eyal Post.

{noformat}
public virtual int IndexOf(System.String termText)
{
	if (terms == null)
		return - 1;
    int res = System.Array.BinarySearch(terms, termText, StringComparer.Ordinal);
	return res >= 0 ? res : - 1;
}
{noformat}

> SegmentTermVector IndexOf method always fails
> ---------------------------------------------
>
>                 Key: LUCENENET-183
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-183
>             Project: Lucene.Net
>          Issue Type: Bug
>            Reporter: Franklin Simmons
>         Attachments: SegmentTermVector.patch
>
>
> At index time term vectors are sorted using String.CompareOrdinal. However method IndexOf of class SegmentTermVector invokes System.Array.BinarySearch, which is using String.Compare.
> {noformat}public virtual int IndexOf(System.String termText)
> {
> 	if (terms == null)
> 		return - 1;
>     int res = System.Array.BinarySearch(terms, termText);
> 	return res >= 0 ? res : - 1;
> }
> {noformat}
> The effect is that the IndexOf method always returns a negative number (no match) because the sort order is incompatible with the default comparer.

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


[jira] Commented: (LUCENENET-183) SegmentTermVector IndexOf method always fails

Posted by "Eyal Post (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENENET-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12715403#action_12715403 ] 

Eyal Post commented on LUCENENET-183:
-------------------------------------

I think it would be nice to also provide a test that fails using the old code and passed after the patch.

> SegmentTermVector IndexOf method always fails
> ---------------------------------------------
>
>                 Key: LUCENENET-183
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-183
>             Project: Lucene.Net
>          Issue Type: Bug
>            Reporter: Franklin Simmons
>         Attachments: SegmentTermVector-2.patch, SegmentTermVector.patch
>
>
> At index time term vectors are sorted using String.CompareOrdinal. However method IndexOf of class SegmentTermVector invokes System.Array.BinarySearch, which is using String.Compare.
> {noformat}public virtual int IndexOf(System.String termText)
> {
> 	if (terms == null)
> 		return - 1;
>     int res = System.Array.BinarySearch(terms, termText);
> 	return res >= 0 ? res : - 1;
> }
> {noformat}
> The effect is that the IndexOf method always returns a negative number (no match) because the sort order is incompatible with the default comparer.

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


[jira] Closed: (LUCENENET-183) SegmentTermVector IndexOf method always fails

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

Digy closed LUCENENET-183.
--------------------------

    Resolution: Fixed

Patch applied.

DIGY

> SegmentTermVector IndexOf method always fails
> ---------------------------------------------
>
>                 Key: LUCENENET-183
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-183
>             Project: Lucene.Net
>          Issue Type: Bug
>            Reporter: Franklin Simmons
>         Attachments: SegmentTermVector-2.patch, SegmentTermVector.patch
>
>
> At index time term vectors are sorted using String.CompareOrdinal. However method IndexOf of class SegmentTermVector invokes System.Array.BinarySearch, which is using String.Compare.
> {noformat}public virtual int IndexOf(System.String termText)
> {
> 	if (terms == null)
> 		return - 1;
>     int res = System.Array.BinarySearch(terms, termText);
> 	return res >= 0 ? res : - 1;
> }
> {noformat}
> The effect is that the IndexOf method always returns a negative number (no match) because the sort order is incompatible with the default comparer.

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


[jira] Updated: (LUCENENET-183) SegmentTermVector IndexOf method always fails

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

Franklin Simmons updated LUCENENET-183:
---------------------------------------

    Attachment: SegmentTermVector.patch

This patch fully qualifies System.StringComparer.Ordinal

> SegmentTermVector IndexOf method always fails
> ---------------------------------------------
>
>                 Key: LUCENENET-183
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-183
>             Project: Lucene.Net
>          Issue Type: Bug
>            Reporter: Franklin Simmons
>         Attachments: SegmentTermVector.patch
>
>
> At index time term vectors are sorted using String.CompareOrdinal. However method IndexOf of class SegmentTermVector invokes System.Array.BinarySearch, which is using String.Compare.
> {noformat}public virtual int IndexOf(System.String termText)
> {
> 	if (terms == null)
> 		return - 1;
>     int res = System.Array.BinarySearch(terms, termText);
> 	return res >= 0 ? res : - 1;
> }
> {noformat}
> The effect is that the IndexOf method always returns a negative number (no match) because the sort order is incompatible with the default comparer.

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