From: Wolfgang M. M. <wol...@us...> - 2004-11-28 13:48:49
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31759/src/org/exist/xquery Modified Files: GeneralComparison.java Log Message: Various fixes. Index: GeneralComparison.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/GeneralComparison.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** GeneralComparison.java 22 Nov 2004 22:26:43 -0000 1.24 --- GeneralComparison.java 28 Nov 2004 13:48:35 -0000 1.25 *************** *** 298,301 **** --- 298,302 ---- } else if (relation == Constants.EQ && nodes.hasTextIndex()) { + // we can use the fulltext index String cmp = getComparisonString(rightSeq); *************** *** 303,312 **** nodes = useFulltextIndex(cmp, nodes, docs); // now compare the input node set to the search expression - Collator collator = getCollator(contextSequence); result = ! context.getBroker().getNodesEqualTo(nodes, docs, relation, cmp, collator); } else { ! // no usable index found. Fall back to nodeSetCompare() return nodeSetCompare(nodes, contextSequence); } --- 304,319 ---- nodes = useFulltextIndex(cmp, nodes, docs); // now compare the input node set to the search expression result = ! context.getBroker().getNodesEqualTo(nodes, docs, relation, cmp, getCollator(contextSequence)); ! } else if(Type.subTypeOf(rightSeq.getItemType(), Type.STRING) || ! rightSeq.getItemType() == Type.ATOMIC) { ! ! // no usable index found. Fall back to a sequential scan of the nodes ! result = ! context.getBroker().getNodesEqualTo(nodes, docs, relation, getComparisonString(rightSeq), ! getCollator(contextSequence)); } else { ! // no usable index found. Fall back to nodeSetCompare return nodeSetCompare(nodes, contextSequence); } *************** *** 405,408 **** --- 412,417 ---- if (ltype == Type.ITEM || ltype == Type.ATOMIC) { if (Type.subTypeOf(rtype, Type.NUMBER)) { + if(isEmptyString(lv)) + return false; lv = lv.convertTo(Type.DOUBLE); } else if (rtype == Type.ITEM || rtype == Type.ATOMIC) { *************** *** 413,416 **** --- 422,427 ---- } else if (rtype == Type.ITEM || rtype == Type.ATOMIC) { if (Type.subTypeOf(ltype, Type.NUMBER)) { + if(isEmptyString(lv)) + return false; rv = rv.convertTo(Type.DOUBLE); } else if (rtype == Type.ITEM || rtype == Type.ATOMIC) { *************** *** 443,447 **** } ! private boolean checkArgumentTypes(XQueryContext context, DocumentSet docs) throws XPathException { Configuration config = context.getBroker().getConfiguration(); --- 454,472 ---- } ! /** ! * @param lv ! * @return ! * @throws XPathException ! */ ! private static boolean isEmptyString(AtomicValue lv) throws XPathException { ! if(Type.subTypeOf(lv.getType(), Type.STRING) || lv.getType() == Type.ATOMIC) { ! String str = lv.getStringValue(); ! if(str.length() == 0) ! return true; ! } ! return false; ! } ! ! private boolean checkArgumentTypes(XQueryContext context, DocumentSet docs) throws XPathException { Configuration config = context.getBroker().getConfiguration(); |