Bug #3167
closed
Problems with QName hash-codes in trieWithCollation()
Applies to JS Branch:
Trunk
Fix Committed on JS Branch:
Trunk
Description
In cases where the key for a map entry is a QName@, rather than 'string-like', a hash function wasn't being assigned. This requires some careful alterations to the logic in @Compare.js#trieWithCollation()
There are two further problems here:
(a) for non-string keys, we are treating keys as equal if their hash codes are equal.
(b) For QNames, we have a very poor hash function, specifically:
return this.uri.substring(this.uri.length - 3) + ":" + this.local.substring(0, 3);
A better one would be
return this.uri.substring(this.uri.length - 3) + ":" + new XdmString(this.local).hashCode()
Test case: try grouping elements by node-name() where there are elements whose names don't vary in the first four characters.
- Assignee changed from Michael Kay to Debbie Lockett
- Found in version deleted (
1.0.0)
trieWithCollation is new development code since the release of Saxon-JS 1.0.0.
It may be worth testing whether the same bug arises when grouping by element name using Saxon-JS 1.0.0. Or whether it is just now broken in the development version. (For now I'm declassifying this bug from being 'found in version Saxon-JS 1.0.0'.)
- Status changed from New to Resolved
XSLT 3.0 test for-each-group-082 added.
Saxon-JS code fixes:
-
Atomic.XdmQName.hashCode updated as suggested in (b).
-
New method matchKey() added to all classes for primitive types. matchKey() returns a string representation of the value, such that
![]((a.equals(b)) implies (matchKey(a) )
i.e. the matchKey strings are always different for different values. (Note that this condition is not always true for hash codes, so they are not always suitable.)
matchKey() can then be used by matchFn() in Compare.trieWithCollation.
- Applies to branch deleted (
9.8)
- Applies to JS Branch Trunk added
- Fix Committed on JS Branch Trunk added
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in JS Release set to Saxon-JS 1.0.1
Bug fix applied in Saxon-JS 1.0.1 maintenance release.
Please register to edit this issue
Also available in: Atom
PDF
Tracking page