Bug 175275 - facilitate case-insensitive search of b-tree indices
Summary: facilitate case-insensitive search of b-tree indices
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 4.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 4.0 M6   Edit
Assignee: Andrew Ferguson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 109724 175151
  Show dependency tree
 
Reported: 2007-02-23 09:07 EST by Andrew Ferguson CLA
Modified: 2014-01-29 17:02 EST (History)
2 users (show)

See Also:


Attachments
proposed patch (47.37 KB, patch)
2007-02-23 10:27 EST, Andrew Ferguson CLA
no flags Details | Diff
patch applied to HEAD (48.31 KB, patch)
2007-02-23 12:09 EST, Andrew Ferguson CLA
cdtdoug: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Ferguson CLA 2007-02-23 09:07:48 EST
for OpenTypeDialog and ContentAssist, it would be good if we could search for bindings case-insensitively.

To achieve this I'd like to order bindings case-insensitively, and then within a case-insensitive equivalence group, order case-sensitively. i.e. for Java Strings this would be:

Comparator<String> c = new Comparator<String>() {
	public int compare(String o1, String o2) {
		String s1 = (String) o1;
		String s2 = (String) o2;
		int cmp= s1.compareToIgnoreCase(s2);
		if(cmp==0) {
			cmp= s1.compareTo(s2);
		}
		return cmp;
	}
};

This way we retain the ability to look-up bindings case-sensitively, but also gain the ability to look-up case-insensitively when needed.

For now, I'd only propose changing the IIndex.findBindingsForPrefix method to be optionally case-insensitive
Comment 1 Markus Schorn CLA 2007-02-23 09:33:42 EST
(In reply to comment #0)
Yes, that's the way to organize the BTree, although its probably worth to make the comparison more efficient, we'll see. 

We also had a discussion on this in bug 169860.
Comment 2 Andrew Ferguson CLA 2007-02-23 10:27:14 EST
Created attachment 59661 [details]
proposed patch

this patch implements the above approach.

Some more notes
 * PDOMFile comparison is unaffected (still case-sensitive)
 * The case-sensitivity comparison is done at the db level in ShortString. It only remaps a-z and A-Z on to each other. 
 * I re-ordered a pair of expected results in a test (ContentAssistTests.testBug72824) to make it pass again under the new scheme.

I'd like to commit this today if no-one objects
Comment 3 Andrew Ferguson CLA 2007-02-23 12:09:13 EST
Created attachment 59681 [details]
patch applied to HEAD

this is the same as the previous patch, but reattaches DBTest to the test suite as it was missing
Comment 4 Andrew Ferguson CLA 2007-02-23 12:09:31 EST
marking as FIXED
Comment 5 Bryan Wilkinson CLA 2007-02-23 12:21:27 EST
Oops looks like I was too slow typing in this comment and the bug has been fixed  in the process...

Anyway,

I just had one concern regarding PDOMCPPNamespace.find(String name, boolean prefixLookup).  The visitor created in this method is set to always be case sensitive.  For content assist at least, case-sensitivity would need to depend on whether or not it is a prefix lookup.  So passing '!prefixLookup' instead of 'true' to the visitor's contructor would work for content assist, or else another boolean parameter for the find(...) method would be needed.

In fact, are there any situations in which we need to control case-sensitivity independently of whether or not a prefix lookup is taking place?  If this is the case then it might be wise to remove any 'caseSensitive' booleans and simply make case-sensitivity depend on the 'prefixLookup' booleans which already existed.
Comment 6 Andrew Ferguson CLA 2007-02-23 12:48:25 EST
hi Bryan,

 sorry - I'm beginning to feel the heat a little and needed to move onwards ;)

I'll re-open 109724 as that bug tracks content assist specifically.

thanks,
Andrew