lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Floyd Wu <floyd...@gmail.com>
Subject Re: bug in SegmentTermVector.IndexOf ?
Date Mon, 01 Jun 2009 02:18:01 GMT
Hi there,

What is the primary effects of this bug?

Floyd

2009/5/30 Franklin Simmons <fsimmons@sccmediaserver.com>

> Greetings,
>
>
>
> I hope I have this all wrong;  I haven't seen this issue raised.
>
>
>
> 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:
>
>
>
> public virtual int IndexOf(System.String termText)
>
> {
>
>                                if (terms == null)
>
>                                                return - 1;
>
> int res = System.Array.BinarySearch(terms, termText);
>
> return res >= 0 ? res : - 1;
>
> }
>
>
>
>
>
> As implemented this method always (for me, anyway) returns a negative
> number.  The modification below works, but I need to know if this is
> actually a bug and if so, what is the correct fix.
>
>
>
>
>
> public class SegmentTermVector : TermFreqVector
>
> {
>
>                . . .
>
>
>
> private class TermVectorComparer : System.Collections.IComparer
>
> {
>
> public int Compare(object a, object b)
>
> {
>
> return String.CompareOrdinal((string)a, (string)b);
>
> }
>
> }
>
>
>
> public virtual int IndexOf(System.String termText)
>
> {
>
>                                if (terms == null)
>
>                                                return - 1;
>
> int res = System.Array.BinarySearch(terms, termText, new
> TermVectorComparer());
>
> return res >= 0 ? res : - 1;
>
> }
>
>
>
> . . .
>
> }
>
>
>
>
>
> Franklin Simmons
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message