Hi there, What is the primary effects of this bug?
Floyd 2009/5/30 Franklin Simmons <[email protected]> > 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 > > > >
