From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:05
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/dom Modified Files: ArraySet.java SortedNodeSet.java SingleNodeSet.java NodeProxy.java EmptyNodeSet.java ExtArrayNodeSet.java AbstractNodeSet.java Match.java AVLTreeNodeSet.java XMLUtil.java VirtualNodeSet.java DocumentImpl.java DocumentOrderComparator.java Added Files: AbstractNodeSetBase.java Removed Files: TextSearchResult.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: AbstractNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/AbstractNodeSet.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** AbstractNodeSet.java 5 Aug 2004 09:13:05 -0000 1.24 --- AbstractNodeSet.java 12 Sep 2004 09:25:20 -0000 1.25 *************** *** 23,27 **** import java.util.Iterator; - import org.apache.log4j.Logger; import org.exist.util.Range; import org.exist.xquery.XPathException; --- 23,26 ---- *************** *** 42,47 **** */ public abstract class AbstractNodeSet extends AbstractSequence implements NodeSet { - - protected final static Logger LOG = Logger.getLogger(AbstractNodeSet.class); protected AbstractNodeSet() { --- 41,44 ---- *************** *** 73,77 **** return Type.NODE; } ! /** * Check if this node set contains a node matching the given --- 70,74 ---- return Type.NODE; } ! /** * Check if this node set contains a node matching the given *************** *** 203,207 **** for(Iterator i = iterator(); i.hasNext(); ) { p = (NodeProxy)i.next(); ! ds.add(p.doc); } return ds; --- 200,204 ---- for(Iterator i = iterator(); i.hasNext(); ) { p = (NodeProxy)i.next(); ! ds.add(p.getDocument()); } return ds; *************** *** 223,228 **** int mode, boolean rememberContext) { ! Range range = XMLUtil.getChildRange(parent.doc, parent.gid); ! return getRange(parent.doc, range.getStart(), range.getEnd()); } --- 220,225 ---- int mode, boolean rememberContext) { ! Range range = XMLUtil.getChildRange(parent.getDocument(), parent.gid); ! return getRange(parent.getDocument(), range.getStart(), range.getEnd()); } *************** *** 275,280 **** for (Iterator i = iterator(); i.hasNext();) { n = (NodeProxy) i.next(); ! if (lastDoc == null || n.doc != lastDoc) { ! lastDoc = n.doc; sizeHint = getSizeHint(lastDoc); } --- 272,277 ---- for (Iterator i = iterator(); i.hasNext();) { n = (NodeProxy) i.next(); ! if (lastDoc == null || n.getDocument() != lastDoc) { ! lastDoc = n.getDocument(); sizeHint = getSizeHint(lastDoc); } *************** *** 292,297 **** for (Iterator i = iterator(); i.hasNext();) { n = (NodeProxy) i.next(); ! if (lastDoc == null || n.doc != lastDoc) { ! lastDoc = n.doc; sizeHint = al.getSizeHint(lastDoc); } --- 289,294 ---- for (Iterator i = iterator(); i.hasNext();) { n = (NodeProxy) i.next(); ! if (lastDoc == null || n.getDocument() != lastDoc) { ! lastDoc = n.getDocument(); sizeHint = al.getSizeHint(lastDoc); } *************** *** 386,394 **** n = (NodeProxy) i.next(); // get a size hint for every new document encountered ! if (lastDoc == null || n.doc != lastDoc) { ! lastDoc = n.doc; sizeHint = getSizeHint(lastDoc); } ! if ((p = al.parentWithChild(n.doc, n.gid, false, includeSelf, -1)) != null) { if (rememberContext) --- 383,391 ---- n = (NodeProxy) i.next(); // get a size hint for every new document encountered ! if (lastDoc == null || n.getDocument() != lastDoc) { ! lastDoc = n.getDocument(); sizeHint = getSizeHint(lastDoc); } ! if ((p = al.parentWithChild(n.getDocument(), n.gid, false, includeSelf, -1)) != null) { if (rememberContext) *************** *** 404,412 **** n = (NodeProxy) i.next(); // get a size hint for every new document encountered ! if (lastDoc == null || n.doc != lastDoc) { ! lastDoc = n.doc; sizeHint = al.getSizeHint(lastDoc); } ! p = al.parentWithChild(n.doc, n.gid, false, includeSelf, -1); if (p != null) { if (rememberContext) --- 401,409 ---- n = (NodeProxy) i.next(); // get a size hint for every new document encountered ! if (lastDoc == null || n.getDocument() != lastDoc) { ! lastDoc = n.getDocument(); sizeHint = al.getSizeHint(lastDoc); } ! p = al.parentWithChild(n.getDocument(), n.gid, false, includeSelf, -1); if (p != null) { if (rememberContext) *************** *** 529,538 **** 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(); --- 526,535 ---- while (true) { // first, try to find nodes belonging to the same doc ! if (na.getDocument().getDocId() < nb.getDocument().getDocId()) { if (ia.hasNext()) na = (NodeProxy) ia.next(); else break; ! } else if (na.getDocument().getDocId() > nb.getDocument().getDocId()) { if (ib.hasNext()) nb = (NodeProxy) ib.next(); *************** *** 544,548 **** pb = nb.gid; // System.out.println(pa + " -> " + pb); ! pb = XMLUtil.getParentId(nb.doc, pb, nb.doc.getTreeLevel(pb)); // System.out.println("comparing " + pa + " -> " + pb); if(pa == pb) { --- 541,545 ---- pb = nb.gid; // System.out.println(pa + " -> " + pb); ! pb = XMLUtil.getParentId(nb.getDocument(), pb, nb.getDocument().getTreeLevel(pb)); // System.out.println("comparing " + pa + " -> " + pb); if(pa == pb) { *************** *** 601,605 **** for (Iterator i = dl.iterator(); i.hasNext();) { n = (NodeProxy) i.next(); ! ancestors = ancestorsForChild(n.doc, n.gid, false, includeSelf, -1); for(Iterator j = ancestors.iterator(); j.hasNext(); ) { p = (NodeProxy) j.next(); --- 598,602 ---- for (Iterator i = dl.iterator(); i.hasNext();) { n = (NodeProxy) i.next(); ! ancestors = ancestorsForChild(n.getDocument(), n.gid, false, includeSelf, -1); for(Iterator j = ancestors.iterator(); j.hasNext(); ) { p = (NodeProxy) j.next(); *************** *** 627,636 **** NodeProxy na = (NodeProxy) ia.next(), nb = (NodeProxy) ib.next(); while(true) { ! 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(); --- 624,633 ---- NodeProxy na = (NodeProxy) ia.next(), nb = (NodeProxy) ib.next(); while(true) { ! if(na.getDocument().getDocId() < nb.getDocument().getDocId()) { if(ia.hasNext()) na = (NodeProxy) ia.next(); else break; ! } else if(na.getDocument().getDocId() > nb.getDocument().getDocId()) { if(ib.hasNext()) nb = (NodeProxy) ib.next(); *************** *** 673,682 **** 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(); --- 670,679 ---- while (true) { // first, try to find nodes belonging to the same doc ! if (na.getDocument().getDocId() < nb.getDocument().getDocId()) { if (ia.hasNext()) na = (NodeProxy) ia.next(); else break; ! } else if (na.getDocument().getDocId() > nb.getDocument().getDocId()) { if (ib.hasNext()) nb = (NodeProxy) ib.next(); *************** *** 685,690 **** } else { // same document: check if the nodes have the same parent ! pa = XMLUtil.getParentId(na.doc, na.gid); ! pb = XMLUtil.getParentId(nb.doc, nb.gid); if (pa < pb) { // wrong parent: proceed --- 682,687 ---- } else { // same document: check if the nodes have the same parent ! pa = XMLUtil.getParentId(na.getDocument(), na.gid); ! pb = XMLUtil.getParentId(nb.getDocument(), nb.gid); if (pa < pb) { // wrong parent: proceed *************** *** 840,844 **** boolean includeSelf, int level) { ! return parentWithChild(proxy.doc, proxy.gid, directParent, includeSelf, level); } --- 837,841 ---- boolean includeSelf, int level) { ! return parentWithChild(proxy.getDocument(), proxy.gid, directParent, includeSelf, level); } *************** *** 882,888 **** p = (NodeProxy) i.next(); // calculate parent's gid ! pid = XMLUtil.getParentId(p.doc, p.gid); if (pid > -1) ! parents.add(new NodeProxy(p.doc, pid, Node.ELEMENT_NODE)); } return parents; --- 879,885 ---- p = (NodeProxy) i.next(); // calculate parent's gid ! pid = XMLUtil.getParentId(p.getDocument(), p.gid); if (pid > -1) ! parents.add(new NodeProxy(p.getDocument(), pid, Node.ELEMENT_NODE)); } return parents; *************** *** 890,907 **** /** - * Returns true if all nodes in this node set are included in - * the fulltext index. - * - * @return - */ - public boolean hasIndex() { - for (Iterator i = iterator(); i.hasNext();) { - if (!((NodeProxy) i.next()).hasIndex()) - return false; - } - return true; - } - - /** * Return a sub-range of this node set containing the range of nodes greater than or including * the lower node and smaller than or including the upper node. --- 887,890 ---- *************** *** 1065,1070 **** if (rememberContext) context.addContextNode(context); ! if(lastDoc != null && lastDoc.getDocId() != context.doc.getDocId()) { ! lastDoc = context.doc; result.add(context, getSizeHint(lastDoc)); } else --- 1048,1053 ---- if (rememberContext) context.addContextNode(context); ! if(lastDoc != null && lastDoc.getDocId() != context.getDocument().getDocId()) { ! lastDoc = context.getDocument(); result.add(context, getSizeHint(lastDoc)); } else Index: DocumentImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/DocumentImpl.java,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** DocumentImpl.java 28 Jul 2004 18:54:57 -0000 1.51 --- DocumentImpl.java 12 Sep 2004 09:25:21 -0000 1.52 *************** *** 260,264 **** if(treeLevelStartPoints[i + 1] > 0x6fffffffffffffffL || treeLevelStartPoints[i + 1] < 0) { ! throw new EXistException("The document is too complex/irregularily structured " + "to be mapped into eXist's numbering scheme. Number of children per level of the " + "tree: " + printTreeLevelOrder()); } --- 260,265 ---- if(treeLevelStartPoints[i + 1] > 0x6fffffffffffffffL || treeLevelStartPoints[i + 1] < 0) { ! throw new EXistException("The document is too complex/irregularily structured " + ! "to be mapped into eXist's numbering scheme. Number of children per level of the " + "tree: " + printTreeLevelOrder()); } Index: Match.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/Match.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Match.java 14 Jul 2004 19:03:24 -0000 1.6 --- Match.java 12 Sep 2004 09:25:20 -0000 1.7 *************** *** 1,9 **** /* ! * Match.java - Mar 20, 2003 * ! * @author wolf */ package org.exist.dom; public class Match implements Comparable { --- 1,44 ---- /* ! * eXist Open Source Native XML Database ! * Copyright (C) 2001-04, Wolfgang M. Meier (wol...@ex...) ! * and others (see http://exist-db.org) * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Library General Public License ! * as published by the Free Software Foundation; either version 2 ! * of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU Library General Public License for more details. ! * ! * You should have received a copy of the GNU Library General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! * $Id$ */ package org.exist.dom; + /** + * Used to track fulltext matches throughout the query. + * + * {@link org.exist.storage.TextSearchEngine} will add a + * match object to every {@link org.exist.dom.NodeProxy} + * that triggered a fulltext match for every term matched. The + * Match object contains the nodeId of the text node that triggered the + * match, the string value of the matching term and a frequency count, + * indicating the frequency of the matching term string within the corresponding + * single text node. + * + * All path operations copy existing match objects, i.e. the match objects + * are copied to the selected descendant or child nodes. This means that + * every NodeProxy being the direct or indirect result of a fulltext + * selection will have one or more match objects, indicating which text nodes + * among its descendant nodes contained a fulltext match. + * + * @author wolf + */ public class Match implements Comparable { *************** *** 62,65 **** return matchTerm.compareTo(other.matchTerm); } - } --- 97,99 ---- --- NEW FILE: AbstractNodeSetBase.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier (wol...@ex...) * and others (see http://exist-db.org) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: AbstractNodeSetBase.java,v 1.1 2004/09/12 09:25:20 wolfgang_m Exp $ */ package org.exist.dom; import java.util.Iterator; import org.apache.log4j.Logger; /** * @author wolf * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public abstract class AbstractNodeSetBase extends AbstractNodeSet { protected final static Logger LOG = Logger.getLogger(AbstractNodeSetBase.class); private final static int UNKNOWN = -1; private final static int NOT_INDEXED = 0; private final static int ALL_NODES_IN_INDEX = 1; // indicates if the nodes in this set and their descendant nodes // have been fulltext indexed private int hasIndex = UNKNOWN; private boolean isCached = false; protected AbstractNodeSetBase() { super(); } public void setIsCached(boolean cached) { isCached = cached; } public boolean isCached() { return isCached; } /** * Returns true if all nodes in this node set and their descendants * are included in the fulltext index. This information is required * to determine if comparison operators can use the * fulltext index to speed up equality comparisons. * * @see org.exist.xquery.GeneralComparison * @see org.exist.xquery.ValueComparison * @return */ public boolean hasIndex() { if(hasIndex == UNKNOWN) { hasIndex = ALL_NODES_IN_INDEX; for (Iterator i = iterator(); i.hasNext();) { if (!((NodeProxy) i.next()).hasIndex()) { hasIndex = NOT_INDEXED; break; } } } return hasIndex == ALL_NODES_IN_INDEX; } } Index: ArraySet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ArraySet.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** ArraySet.java 8 Jun 2004 08:16:08 -0000 1.32 --- ArraySet.java 12 Sep 2004 09:25:20 -0000 1.33 *************** *** 28,32 **** import org.w3c.dom.Node; ! public class ArraySet extends AbstractNodeSet { protected int counter = 0; --- 28,32 ---- import org.w3c.dom.Node; ! public class ArraySet extends AbstractNodeSetBase { protected int counter = 0; *************** *** 121,125 **** while (low <= high) { mid = (low + high) / 2; ! if (items[mid].doc.docId == cmpDoc.docId) { if (items[mid].gid == gid) return mid; --- 121,125 ---- while (low <= high) { mid = (low + high) / 2; ! if (items[mid].getDocument().docId == cmpDoc.docId) { if (items[mid].gid == gid) return mid; *************** *** 128,132 **** else low = mid + 1; ! } else if (items[mid].doc.docId > cmpDoc.docId) high = mid - 1; else --- 128,132 ---- else low = mid + 1; ! } else if (items[mid].getDocument().docId > cmpDoc.docId) high = mid - 1; else *************** *** 614,621 **** DocumentImpl lastDoc = null; for (int i = 0; i < counter; i++) { ! if(lastDoc == null || lastDoc.getDocId() != nodes[i].doc.getDocId()) { ! docs.add(nodes[i].doc, false); } ! lastDoc = nodes[i].doc; } return docs; --- 614,621 ---- DocumentImpl lastDoc = null; for (int i = 0; i < counter; i++) { ! if(lastDoc == null || lastDoc.getDocId() != nodes[i].getDocument().getDocId()) { ! docs.add(nodes[i].getDocument(), false); } ! lastDoc = nodes[i].getDocument(); } return docs; *************** *** 655,659 **** private final static NodeProxy[] copyNodeSet(ArraySet al, ArraySet dl) { int ax = 0, dx = 0; ! int ad = al.nodes[ax].doc.docId, dd = dl.nodes[dx].doc.docId; final int alen = al.counter - 1, dlen = dl.counter - 1; final NodeProxy[] ol = new NodeProxy[dl.counter]; --- 655,659 ---- private final static NodeProxy[] copyNodeSet(ArraySet al, ArraySet dl) { int ax = 0, dx = 0; ! int ad = al.nodes[ax].getDocument().docId, dd = dl.nodes[dx].getDocument().docId; final int alen = al.counter - 1, dlen = dl.counter - 1; final NodeProxy[] ol = new NodeProxy[dl.counter]; *************** *** 662,666 **** if (ax < alen) { ++ax; ! ad = al.nodes[ax].doc.docId; } else break; --- 662,666 ---- if (ax < alen) { ++ax; ! ad = al.nodes[ax].getDocument().docId; } else break; *************** *** 669,673 **** ol[dx] = null; ++dx; ! dd = dl.nodes[dx].doc.docId; } else break; --- 669,673 ---- ol[dx] = null; ++dx; ! dd = dl.nodes[dx].getDocument().docId; } else break; *************** *** 676,680 **** if (dx < dlen) { ++dx; ! dd = dl.nodes[dx].doc.docId; } else break; --- 676,680 ---- if (dx < dlen) { ++dx; ! dd = dl.nodes[dx].getDocument().docId; } else break; *************** *** 686,690 **** private final static void trimNodeSet(ArraySet al, ArraySet dl) { int ax = 0, dx = 0; ! int ad = al.nodes[ax].doc.docId, dd = dl.nodes[dx].doc.docId; int count = 0; final int alen = al.counter - 1, dlen = dl.counter - 1; --- 686,690 ---- private final static void trimNodeSet(ArraySet al, ArraySet dl) { int ax = 0, dx = 0; ! int ad = al.nodes[ax].getDocument().docId, dd = dl.nodes[dx].getDocument().docId; int count = 0; final int alen = al.counter - 1, dlen = dl.counter - 1; *************** *** 693,697 **** if (ax < alen) { ++ax; ! ad = al.nodes[ax].doc.docId; } else break; --- 693,697 ---- if (ax < alen) { ++ax; ! ad = al.nodes[ax].getDocument().docId; } else break; *************** *** 699,703 **** if (dx < dlen) { ++dx; ! dd = dl.nodes[dx].doc.docId; } else break; --- 699,703 ---- if (dx < dlen) { ++dx; ! dd = dl.nodes[dx].getDocument().docId; } else break; *************** *** 706,710 **** ++dx; count++; ! dd = dl.nodes[dx].doc.docId; } else break; --- 706,710 ---- ++dx; count++; ! dd = dl.nodes[dx].getDocument().docId; } else break; *************** *** 751,760 **** public int compare(int a, int b) { NodeProxy anode = nodes[a], bnode = nodes[b]; ! if (anode.doc.docId == bnode.doc.docId) { return anode.gid == bnode.gid ? 0 : (anode.gid < bnode.gid ? -1 : 1); } ! return anode.doc.docId < bnode.doc.docId ? -1 : 1; } --- 751,760 ---- public int compare(int a, int b) { NodeProxy anode = nodes[a], bnode = nodes[b]; ! if (anode.getDocument().docId == bnode.getDocument().docId) { return anode.gid == bnode.gid ? 0 : (anode.gid < bnode.gid ? -1 : 1); } ! return anode.getDocument().docId < bnode.getDocument().docId ? -1 : 1; } Index: VirtualNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/VirtualNodeSet.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** VirtualNodeSet.java 10 May 2004 11:22:39 -0000 1.34 --- VirtualNodeSet.java 12 Sep 2004 09:25:20 -0000 1.35 *************** *** 48,52 **** * @author Timo Boehme */ ! public class VirtualNodeSet extends AbstractNodeSet { protected int axis = -1; --- 48,52 ---- * @author Timo Boehme */ ! public class VirtualNodeSet extends AbstractNodeSetBase { protected int axis = -1; *************** *** 80,84 **** return ( (first != null) ! || (context.get(p.doc, XMLUtil.getParentId(p.doc, p.gid)) != null)); } --- 80,84 ---- return ( (first != null) ! || (context.get(p.getDocument(), XMLUtil.getParentId(p.getDocument(), p.gid)) != null)); } *************** *** 112,116 **** boolean directParent, int recursions) { ! long pid = XMLUtil.getParentId(node.doc, node.gid); NodeProxy parent; // check if the start-node should be included, e.g. to process an --- 112,116 ---- boolean directParent, int recursions) { ! long pid = XMLUtil.getParentId(node.getDocument(), node.gid); NodeProxy parent; // check if the start-node should be included, e.g. to process an *************** *** 120,124 **** // if we're on the child axis, test if // the node is a direct child of the context node ! if ((parent = context.get(new NodeProxy(node.doc, pid))) != null) { node.copyContext(parent); if (useSelfAsContext && inPredicate) { --- 120,124 ---- // if we're on the child axis, test if // the node is a direct child of the context node ! if ((parent = context.get(new NodeProxy(node.getDocument(), pid))) != null) { node.copyContext(parent); if (useSelfAsContext && inPredicate) { *************** *** 139,143 **** return null; } ! first = new NodeProxy(node.doc, pid, Node.ELEMENT_NODE); // Timo Boehme: we need a real parent (child from context) return getFirstParent(first, first, false, directParent, recursions + 1); --- 139,143 ---- return null; } ! first = new NodeProxy(node.getDocument(), pid, Node.ELEMENT_NODE); // Timo Boehme: we need a real parent (child from context) return getFirstParent(first, first, false, directParent, recursions + 1); *************** *** 145,149 **** // is pid member of the context set? ! parent = context.get(node.doc, pid); if (parent != null && test.matches(first)) { --- 145,149 ---- // is pid member of the context set? ! parent = context.get(node.getDocument(), pid); if (parent != null && test.matches(first)) { *************** *** 171,175 **** } else { // continue for expressions like //*/n or /*//n ! parent = new NodeProxy(node.doc, pid, Node.ELEMENT_NODE); return getFirstParent(parent, first, false, directParent, recursions + 1); } --- 171,175 ---- } else { // continue for expressions like //*/n or /*//n ! parent = new NodeProxy(node.getDocument(), pid, Node.ELEMENT_NODE); return getFirstParent(parent, first, false, directParent, recursions + 1); } *************** *** 251,259 **** || axis == Constants.DESCENDANT_SELF_AXIS || axis == Constants.DESCENDANT_ATTRIBUTE_AXIS) { ! domIter = docElemProxy.doc.getBroker().getNodeIterator(docElemProxy); NodeImpl node = (NodeImpl) domIter.next(); ! node.setOwnerDocument(docElemProxy.doc); node.setGID(docElemProxy.gid); ! docElemProxy.match = proxy.match; addChildren(docElemProxy, result, node, domIter, 0); } --- 251,259 ---- || axis == Constants.DESCENDANT_SELF_AXIS || axis == Constants.DESCENDANT_ATTRIBUTE_AXIS) { ! domIter = docElemProxy.getDocument().getBroker().getNodeIterator(docElemProxy); NodeImpl node = (NodeImpl) domIter.next(); ! node.setOwnerDocument(docElemProxy.getDocument()); node.setGID(docElemProxy.gid); ! docElemProxy.setMatches(proxy.getMatches()); addChildren(docElemProxy, result, node, domIter, 0); } *************** *** 261,267 **** // -- end of insertion -- } else { ! domIter = proxy.doc.getBroker().getNodeIterator(proxy); NodeImpl node = (NodeImpl) domIter.next(); ! node.setOwnerDocument(proxy.doc); node.setGID(proxy.gid); addChildren(proxy, result, node, domIter, 0); --- 261,267 ---- // -- end of insertion -- } else { ! domIter = proxy.getDocument().getBroker().getNodeIterator(proxy); NodeImpl node = (NodeImpl) domIter.next(); ! node.setOwnerDocument(proxy.getDocument()); node.setGID(proxy.gid); addChildren(proxy, result, node, domIter, 0); *************** *** 287,291 **** p = new NodeProxy(child.ownerDocument, child.gid, child.getNodeType()); p.setInternalAddress(child.internalAddress); ! p.match = contextNode.match; if (test.matches(child)) { if (((axis == Constants.CHILD_AXIS --- 287,291 ---- p = new NodeProxy(child.ownerDocument, child.gid, child.getNodeType()); p.setInternalAddress(child.internalAddress); ! p.setMatches(contextNode.getMatches()); if (test.matches(child)) { if (((axis == Constants.CHILD_AXIS *************** *** 311,315 **** NodeProxy p = new NodeProxy(node.ownerDocument, node.gid, node.getNodeType()); p.setInternalAddress(node.internalAddress); ! p.match = contextNode.match; result.add(p); p.copyContext(contextNode); --- 311,315 ---- NodeProxy p = new NodeProxy(node.ownerDocument, node.gid, node.getNodeType()); p.setInternalAddress(node.internalAddress); ! p.setMatches(contextNode.getMatches()); result.add(p); p.copyContext(contextNode); Index: ExtArrayNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ExtArrayNodeSet.java 5 Aug 2004 09:13:05 -0000 1.22 --- ExtArrayNodeSet.java 12 Sep 2004 09:25:20 -0000 1.23 *************** *** 52,56 **** * @since 0.9.3 */ ! public final class ExtArrayNodeSet extends AbstractNodeSet { private TreeMap map; --- 52,56 ---- * @since 0.9.3 */ ! public class ExtArrayNodeSet extends AbstractNodeSetBase { private TreeMap map; *************** *** 96,100 **** public void add(NodeProxy proxy) { ! getPart(proxy.doc, true, initalSize).add(proxy); ++size; isSorted = false; --- 96,100 ---- public void add(NodeProxy proxy) { ! getPart(proxy.getDocument(), true, initalSize).add(proxy); ++size; isSorted = false; *************** *** 111,115 **** */ public void add(NodeProxy proxy, int sizeHint) { ! getPart(proxy.doc, true, sizeHint > -1 ? sizeHint : initalSize).add( proxy); ++size; --- 111,115 ---- */ public void add(NodeProxy proxy, int sizeHint) { ! getPart(proxy.getDocument(), true, sizeHint > -1 ? sizeHint : initalSize).add( proxy); ++size; *************** *** 197,201 **** */ public boolean contains(NodeProxy proxy) { ! final Part part = getPart(proxy.doc, false, 0); return part == null ? false : part.contains(proxy.gid); } --- 197,201 ---- */ public boolean contains(NodeProxy proxy) { ! final Part part = getPart(proxy.getDocument(), false, 0); return part == null ? false : part.contains(proxy.gid); } *************** *** 256,260 **** */ public NodeProxy get(NodeProxy p) { ! final Part part = getPart(p.doc, false, 0); return part == null ? null : part.get(p.gid); } --- 256,260 ---- */ public NodeProxy get(NodeProxy p) { ! final Part part = getPart(p.getDocument(), false, 0); return part == null ? null : part.get(p.gid); } *************** *** 287,296 **** */ public void remove(NodeProxy node) { ! final Part part = getPart(node.doc, false, 0); if (part == null) return; part.remove(node); if (part.length == 0) ! map.remove(node.doc); setHasChanged(); } --- 287,296 ---- */ public void remove(NodeProxy node) { ! final Part part = getPart(node.getDocument(), false, 0); if (part == null) return; part.remove(node); if (part.length == 0) ! map.remove(node.getDocument()); setHasChanged(); } *************** *** 303,307 **** public NodeSet hasChildrenInSet(NodeProxy parent, int mode, boolean rememberContext) { ! final Part part = getPart(parent.doc, false, 0); if (part == null) return new ArraySet(1); --- 303,307 ---- public NodeSet hasChildrenInSet(NodeProxy parent, int mode, boolean rememberContext) { ! final Part part = getPart(parent.getDocument(), false, 0); if (part == null) return new ArraySet(1); *************** *** 487,491 **** if(length == 0) return null; ! return array[0].doc; } --- 487,491 ---- if(length == 0) return null; ! return array[0].getDocument(); } *************** *** 542,546 **** // get the range of node ids reserved for children of the parent // node ! Range range = XMLUtil.getChildRange(parent.doc, parent.gid); int low = 0; int high = length - 1; --- 542,546 ---- // get the range of node ids reserved for children of the parent // node ! Range range = XMLUtil.getChildRange(parent.getDocument(), parent.gid); int low = 0; int high = length - 1; Index: XMLUtil.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/XMLUtil.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XMLUtil.java 1 Mar 2004 21:30:20 -0000 1.4 --- XMLUtil.java 12 Sep 2004 09:25:20 -0000 1.5 *************** *** 243,247 **** public final static long getParentId( NodeProxy node ) { ! return getParentId(node.doc, node.gid); } --- 243,247 ---- public final static long getParentId( NodeProxy node ) { ! return getParentId(node.getDocument(), node.gid); } *************** *** 322,332 **** return temp; if(level < 0) ! level = child.doc.getTreeLevel(child.gid); while (child.gid > 0) { // calculate parent's gid ! child.gid = (child.gid - child.doc.getLevelStartPoint(level)) ! / child.doc.getTreeLevelOrder(level) ! + child.doc.getLevelStartPoint(level - 1); ! if ((temp = contextSet.get(child.doc, child.gid)) != null) return temp; else --- 322,332 ---- return temp; if(level < 0) ! level = child.getDocument().getTreeLevel(child.gid); while (child.gid > 0) { // calculate parent's gid ! child.gid = (child.gid - child.getDocument().getLevelStartPoint(level)) ! / child.getDocument().getTreeLevelOrder(level) ! + child.getDocument().getLevelStartPoint(level - 1); ! if ((temp = contextSet.get(child.getDocument(), child.gid)) != null) return temp; else Index: DocumentOrderComparator.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/DocumentOrderComparator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DocumentOrderComparator.java 22 Dec 2003 18:48:45 -0000 1.1 --- DocumentOrderComparator.java 12 Sep 2004 09:25:21 -0000 1.2 *************** *** 40,47 **** final NodeProxy p1 = (NodeProxy) o1; final NodeProxy p2 = (NodeProxy) o2; ! final DocumentImpl doc = p1.doc; ! if (doc.docId > p2.doc.docId) return 1; ! else if (doc.docId < p2.doc.docId) return -1; else { --- 40,47 ---- final NodeProxy p1 = (NodeProxy) o1; final NodeProxy p2 = (NodeProxy) o2; ! final DocumentImpl doc = p1.getDocument(); ! if (doc.docId > p2.getDocument().docId) return 1; ! else if (doc.docId < p2.getDocument().docId) return -1; else { Index: SingleNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/SingleNodeSet.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SingleNodeSet.java 29 Jan 2004 15:06:46 -0000 1.4 --- SingleNodeSet.java 12 Sep 2004 09:25:20 -0000 1.5 *************** *** 47,51 **** */ public boolean contains(DocumentImpl doc, long nodeId) { ! return nodes[0].doc.getDocId() == doc.getDocId() && nodes[0].gid == nodeId; } --- 47,51 ---- */ public boolean contains(DocumentImpl doc, long nodeId) { ! return nodes[0].getDocument().getDocId() == doc.getDocId() && nodes[0].gid == nodeId; } *************** *** 54,58 **** */ public boolean contains(NodeProxy proxy) { ! return nodes[0].doc.getDocId() == proxy.doc.getDocId() && nodes[0].gid == proxy.gid; } --- 54,58 ---- */ public boolean contains(NodeProxy proxy) { ! return nodes[0].getDocument().getDocId() == proxy.getDocument().getDocId() && nodes[0].gid == proxy.gid; } --- TextSearchResult.java DELETED --- Index: EmptyNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/EmptyNodeSet.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EmptyNodeSet.java 29 Jan 2004 15:06:46 -0000 1.9 --- EmptyNodeSet.java 12 Sep 2004 09:25:20 -0000 1.10 *************** *** 29,33 **** import org.w3c.dom.Node; ! public class EmptyNodeSet extends AbstractNodeSet { private final static EmptyNodeSetIterator EMPTY_ITERATOR = new EmptyNodeSetIterator(); --- 29,33 ---- import org.w3c.dom.Node; ! public class EmptyNodeSet extends AbstractNodeSetBase { private final static EmptyNodeSetIterator EMPTY_ITERATOR = new EmptyNodeSetIterator(); Index: NodeProxy.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/NodeProxy.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** NodeProxy.java 23 Jun 2004 12:44:17 -0000 1.33 --- NodeProxy.java 12 Sep 2004 09:25:20 -0000 1.34 *************** *** 24,28 **** import java.util.Iterator; ! import org.exist.memtree.Receiver; import org.exist.storage.DBBroker; import org.exist.storage.serializers.Serializer; --- 24,28 ---- import java.util.Iterator; ! import org.exist.memtree.DocumentBuilderReceiver; import org.exist.storage.DBBroker; import org.exist.storage.serializers.Serializer; *************** *** 58,63 **** *@author Wolfgang Meier <wol...@ex...> */ ! public final class NodeProxy extends AbstractNodeSet implements NodeValue, Comparable { ! /** * The owner document of this node. --- 58,63 ---- *@author Wolfgang Meier <wol...@ex...> */ ! public class NodeProxy extends AbstractNodeSet implements NodeValue, Comparable { ! /** * The owner document of this node. *************** *** 87,91 **** private long internalAddress = -1; ! public NodeProxy() { } --- 87,91 ---- private long internalAddress = -1; ! public NodeProxy() { } *************** *** 265,268 **** --- 265,276 ---- } + public DocumentImpl getDocument() { + return doc; + } + + public void setDocument(DocumentImpl doc) { + this.doc = doc; + } + public long getGID() { return gid; *************** *** 334,338 **** this.nodeType = nodeType; } ! /** * Returns the storage address of this node in dom.dbx. --- 342,346 ---- this.nodeType = nodeType; } ! /** * Returns the storage address of this node in dom.dbx. *************** *** 361,364 **** --- 369,380 ---- } + public Match getMatches() { + return match; + } + + public void setMatches(Match match) { + this.match = match; + } + public boolean hasMatch(Match m) { if (m == null || match == null) *************** *** 407,411 **** if(p == this) return; ! Match m = p.match; while (m != null) { addMatch(new Match(m)); --- 423,427 ---- if(p == this) return; ! Match m = p.getMatches(); while (m != null) { addMatch(new Match(m)); *************** *** 448,452 **** if (context == null) { context = new ContextItem(node); - // Thread.dumpStack(); return; } --- 464,467 ---- *************** *** 461,474 **** next = next.getNextItem(); } - // Thread.dumpStack(); - } - - public void clearContext() { - context = null; } public void printContext() { ContextItem next = context; ! System.out.print(hashCode() + " " + gid + ": "); while (next != null) { System.out.print(next.getNode().gid); --- 476,484 ---- next = next.getNextItem(); } } public void printContext() { ContextItem next = context; ! System.out.print(gid + ": "); while (next != null) { System.out.print(next.getNode().gid); *************** *** 478,481 **** --- 488,492 ---- System.out.println(); } + public void copyContext(NodeProxy node) { context = node.getContext(); *************** *** 639,643 **** } ! public void copyTo(DBBroker broker, Receiver receiver) throws SAXException { if(nodeType == Node.ATTRIBUTE_NODE) { AttrImpl attr = (AttrImpl) getNode(); --- 650,654 ---- } ! public void copyTo(DBBroker broker, DocumentBuilderReceiver receiver) throws SAXException { if(nodeType == Node.ATTRIBUTE_NODE) { AttrImpl attr = (AttrImpl) getNode(); Index: AVLTreeNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/AVLTreeNodeSet.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AVLTreeNodeSet.java 23 Jun 2004 14:05:49 -0000 1.8 --- AVLTreeNodeSet.java 12 Sep 2004 09:25:20 -0000 1.9 *************** *** 7,11 **** import org.exist.xquery.value.SequenceIterator; ! public class AVLTreeNodeSet extends AbstractNodeSet { private Node root; --- 7,11 ---- import org.exist.xquery.value.SequenceIterator; ! public class AVLTreeNodeSet extends AbstractNodeSetBase { private Node root; *************** *** 286,290 **** Node tempNode = root; while (tempNode != null) { ! if (tempNode.data.doc.docId == doc.docId) { if (tempNode.data.gid == nodeId) return tempNode.data; --- 286,290 ---- Node tempNode = root; while (tempNode != null) { ! if (tempNode.data.getDocument().docId == doc.docId) { if (tempNode.data.gid == nodeId) return tempNode.data; *************** *** 293,297 **** else tempNode = tempNode.leftChild; ! } else if (tempNode.data.doc.docId < doc.docId) tempNode = tempNode.rightChild; else --- 293,297 ---- else tempNode = tempNode.leftChild; ! } else if (tempNode.data.getDocument().docId < doc.docId) tempNode = tempNode.rightChild; else *************** *** 306,312 **** Node tempNode = root; while (tempNode != null) { ! if (tempNode.data.doc.docId == doc.docId) { return true; ! } else if (tempNode.data.doc.docId < doc.docId) tempNode = tempNode.rightChild; else --- 306,312 ---- Node tempNode = root; while (tempNode != null) { ! if (tempNode.data.getDocument().docId == doc.docId) { return true; ! } else if (tempNode.data.getDocument().docId < doc.docId) tempNode = tempNode.rightChild; else Index: SortedNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/SortedNodeSet.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** SortedNodeSet.java 15 Jul 2004 08:28:52 -0000 1.21 --- SortedNodeSet.java 12 Sep 2004 09:25:20 -0000 1.22 *************** *** 4,12 **** import java.util.Iterator; - import org.apache.log4j.Category; import org.exist.EXistException; - import org.exist.xquery.parser.XQueryLexer; - import org.exist.xquery.parser.XQueryParser; - import org.exist.xquery.parser.XQueryTreeParser; import org.exist.security.User; import org.exist.storage.BrokerPool; --- 4,8 ---- *************** *** 14,19 **** import org.exist.util.OrderedLinkedList; import org.exist.xquery.PathExpr; - import org.exist.xquery.XQueryContext; import org.exist.xquery.XPathException; import org.exist.xquery.value.Item; import org.exist.xquery.value.Sequence; --- 10,18 ---- import org.exist.util.OrderedLinkedList; import org.exist.xquery.PathExpr; import org.exist.xquery.XPathException; + import org.exist.xquery.XQueryContext; + import org.exist.xquery.parser.XQueryLexer; + import org.exist.xquery.parser.XQueryParser; + import org.exist.xquery.parser.XQueryTreeParser; import org.exist.xquery.value.Item; import org.exist.xquery.value.Sequence; *************** *** 24,30 **** import antlr.collections.AST; ! public class SortedNodeSet extends AbstractNodeSet { ! ! private static Category LOG = Category.getInstance(SortedNodeSet.class.getName()); private PathExpr expr; --- 23,27 ---- import antlr.collections.AST; ! public class SortedNodeSet extends AbstractNodeSetBase { private PathExpr expr; *************** *** 53,57 **** for (Iterator i = other.iterator(); i.hasNext();) { p = (NodeProxy)i.next(); ! docs.add(p.doc); } DBBroker broker = null; --- 50,54 ---- for (Iterator i = other.iterator(); i.hasNext();) { p = (NodeProxy)i.next(); ! docs.add(p.getDocument()); } DBBroker broker = null; *************** *** 59,63 **** broker = pool.get(user); XQueryContext context = new XQueryContext(broker); ! XQueryLexer lexer = new XQueryLexer(new StringReader(sortExpr)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); --- 56,60 ---- broker = pool.get(user); XQueryContext context = new XQueryContext(broker); ! XQueryLexer lexer = new XQueryLexer(context, new StringReader(sortExpr)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); *************** *** 149,153 **** public Node item(int pos) { NodeProxy p = ((IteratorItem) list.get(pos)).proxy; ! return p == null ? null : p.doc.getNode(p); } --- 146,150 ---- public Node item(int pos) { NodeProxy p = ((IteratorItem) list.get(pos)).proxy; ! return p == null ? null : p.getDocument().getNode(p); } |