From: Wolfgang M. M. <wol...@us...> - 2004-08-05 09:13:14
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17974/src/org/exist/dom Modified Files: AbstractNodeSet.java ExtArrayNodeSet.java Log Message: Commented out the quickSelectAncestorDescendant method in AbstractNodeSet. This method can't work if the descendant nodes occur on different levels of the DOM tree. Index: AbstractNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/AbstractNodeSet.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** AbstractNodeSet.java 30 Jun 2004 15:56:59 -0000 1.23 --- AbstractNodeSet.java 5 Aug 2004 09:13:05 -0000 1.24 *************** *** 374,379 **** boolean includeSelf, boolean rememberContext) { ! if(!(al instanceof VirtualNodeSet)) ! return quickSelectAncestorDescendant(al, mode, includeSelf, rememberContext); NodeProxy n, p; // long start = System.currentTimeMillis(); --- 374,379 ---- boolean includeSelf, boolean rememberContext) { ! // if(!(al instanceof VirtualNodeSet)) ! // return quickSelectAncestorDescendant(al, mode, includeSelf, rememberContext); NodeProxy n, p; // long start = System.currentTimeMillis(); *************** *** 429,432 **** --- 429,435 ---- /** + * TODO: This method is rubbish. It can't work this way if descendants occur on + * different levels in the dom tree. + * * Fast ancestor descendant join based on two iterators. This method is * selected if the ancestor set is fixed, i.e. the selection step did not contain *************** *** 438,511 **** * @return */ ! private NodeSet quickSelectAncestorDescendant(NodeSet al, int mode, boolean includeSelf, boolean rememberContext) { ! final NodeSet result = new ExtArrayNodeSet(); ! final Iterator ia = al.iterator(); ! final Iterator ib = iterator(); ! // final long start = System.currentTimeMillis(); ! NodeProxy na = (NodeProxy) ia.next(), nb = (NodeProxy) ib.next(); ! // check if one of the node sets is empty ! if(na == null || nb == null) ! return result; ! ! long pa, pb; ! while (true) { ! // first, try to find nodes belonging to the same doc ! if (na.doc.getDocId() < nb.doc.getDocId()) { ! if (ia.hasNext()) ! na = (NodeProxy) ia.next(); ! else ! break; ! } else if (na.doc.getDocId() > nb.doc.getDocId()) { ! if (ib.hasNext()) ! nb = (NodeProxy) ib.next(); ! else ! break; ! } else { ! // same document ! pa = na.gid; ! pb = nb.gid; ! int la = na.doc.getTreeLevel(pa); ! int lb = nb.doc.getTreeLevel(pb); ! boolean foundSelf = la == lb; ! while (la < lb) { ! pb = XMLUtil.getParentId(nb.doc, pb, lb); ! --lb; ! } ! if (pa < pb) { ! if (ia.hasNext()) ! na = (NodeProxy) ia.next(); ! else ! break; ! } else if (pa > pb) { ! if (ib.hasNext()) ! nb = (NodeProxy) ib.next(); ! else ! break; ! } else { ! if(!foundSelf || includeSelf) { ! if(mode == NodeSet.DESCENDANT) { ! if (rememberContext) ! nb.addContextNode(na); ! else ! nb.copyContext(na); ! result.add(nb); ! } else { ! if (rememberContext) ! na.addContextNode(nb); ! else ! na.copyContext(nb); ! result.add(na); ! } ! } ! if (ib.hasNext()) ! nb = (NodeProxy) ib.next(); ! else ! break; ! } ! } ! } ! // LOG.debug("quickSelect took " + (System.currentTimeMillis() - start)); ! return result; ! } private NodeSet quickSelectParentChild(NodeSet al, int mode, boolean rememberContext) { --- 441,518 ---- * @return */ ! // private NodeSet quickSelectAncestorDescendant(NodeSet al, int mode, boolean includeSelf, boolean rememberContext) { ! // final NodeSet result = new ExtArrayNodeSet(); ! // final Iterator ia = al.iterator(); ! // final Iterator ib = iterator(); ! //// final long start = System.currentTimeMillis(); ! // NodeProxy na = (NodeProxy) ia.next(), nb = (NodeProxy) ib.next(); ! // // check if one of the node sets is empty ! // if(na == null || nb == null) ! // return result; ! // ! // long pa, pb; ! // while (true) { ! // // first, try to find nodes belonging to the same doc ! // if (na.doc.getDocId() < nb.doc.getDocId()) { ! // if (ia.hasNext()) ! // na = (NodeProxy) ia.next(); ! // else ! // break; ! // } else if (na.doc.getDocId() > nb.doc.getDocId()) { ! // if (ib.hasNext()) ! // nb = (NodeProxy) ib.next(); ! // else ! // break; ! // } else { ! // // same document ! // pa = na.gid; ! // pb = nb.gid; ! // int la = na.doc.getTreeLevel(pa); ! // int lb = nb.doc.getTreeLevel(pb); ! // boolean foundSelf = la == lb; ! // while (lb> la) { ! // pb = XMLUtil.getParentId(nb.doc, pb, lb--); ! // System.out.println(pb); ! // } ! // System.out.println("Comparing " + pa + " -> " + pb + " (" + nb.gid + ") " + ! // XMLUtil.getParentId(nb.doc, pb)); ! // if (pa < pb) { ! // if (ia.hasNext()) ! // na = (NodeProxy) ia.next(); ! // else ! // break; ! // } else if (pa > pb) { ! // if (ib.hasNext()) ! // nb = (NodeProxy) ib.next(); ! // else if(ia.hasNext()) ! // na = (NodeProxy) ia.next(); ! // else ! // break; ! // } else { ! // if(!foundSelf || includeSelf) { ! // if(mode == NodeSet.DESCENDANT) { ! // if (rememberContext) ! // nb.addContextNode(na); ! // else ! // nb.copyContext(na); ! // result.add(nb); ! // } else { ! // if (rememberContext) ! // na.addContextNode(nb); ! // else ! // na.copyContext(nb); ! // result.add(na); ! // } ! // } ! // if (ib.hasNext()) ! // nb = (NodeProxy) ib.next(); ! // else ! // break; ! // } ! // } ! // } ! //// LOG.debug("quickSelect took " + (System.currentTimeMillis() - start)); ! // return result; ! // } private NodeSet quickSelectParentChild(NodeSet al, int mode, boolean rememberContext) { Index: ExtArrayNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ExtArrayNodeSet.java 8 Jun 2004 08:16:08 -0000 1.21 --- ExtArrayNodeSet.java 5 Aug 2004 09:13:05 -0000 1.22 *************** *** 518,524 **** while (gid > 0) { gid = XMLUtil.getParentId(doc, gid, level); ! if ((temp = get(gid)) != null) return temp; ! else if (directParent) return null; else --- 518,524 ---- while (gid > 0) { gid = XMLUtil.getParentId(doc, gid, level); ! if ((temp = get(gid)) != null) { return temp; ! } else if (directParent) return null; else |