From: Wolfgang M. M. <wol...@us...> - 2004-04-27 15:47:11
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/memtree In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28184/src/org/exist/memtree Modified Files: Receiver.java MemTreeBuilder.java Log Message: * XQuery node construction consumed too much memory: instead of generating a SAX stream, nodes are now directly copied to the created output fragment. * QName objects are now created through the global name pool and thus shared between node objects. Index: MemTreeBuilder.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/memtree/MemTreeBuilder.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MemTreeBuilder.java 29 Jan 2004 15:06:49 -0000 1.6 --- MemTreeBuilder.java 27 Apr 2004 15:47:02 -0000 1.7 *************** *** 105,131 **** public int startElement(QName qn, Attributes attributes) { int nodeNr = doc.addNode(Node.ELEMENT_NODE, level, qn); ! // parse attributes ! String attrPrefix; ! String attrLocalName; ! String attrNS; ! String attrQName; ! int p; ! for (int i = 0; i < attributes.getLength(); i++) { ! attrNS = attributes.getURI(i); ! attrLocalName = attributes.getLocalName(i); ! attrQName = attributes.getQName(i); ! // skip xmlns-attributes and attributes in eXist's namespace ! if (!(attrQName.startsWith("xmlns") ! || attrNS.equals("http://exist.sourceforge.net/NS/exist"))) { ! p = attrQName.indexOf(':'); ! attrPrefix = (p > -1) ? attrQName.substring(0, p) : null; ! p = ! doc.addAttribute( ! nodeNr, ! new QName(attrLocalName, attrNS, attrPrefix), ! attributes.getValue(i)); } } - // update links if (level + 1 >= prevNodeInLevel.length) { --- 105,132 ---- public int startElement(QName qn, Attributes attributes) { int nodeNr = doc.addNode(Node.ELEMENT_NODE, level, qn); ! if(attributes != null) { ! // parse attributes ! String attrPrefix; ! String attrLocalName; ! String attrNS; ! String attrQName; ! int p; ! for (int i = 0; i < attributes.getLength(); i++) { ! attrNS = attributes.getURI(i); ! attrLocalName = attributes.getLocalName(i); ! attrQName = attributes.getQName(i); ! // skip xmlns-attributes and attributes in eXist's namespace ! if (!(attrQName.startsWith("xmlns") ! || attrNS.equals("http://exist.sourceforge.net/NS/exist"))) { ! p = attrQName.indexOf(':'); ! attrPrefix = (p > -1) ? attrQName.substring(0, p) : null; ! p = ! doc.addAttribute( ! nodeNr, ! new QName(attrLocalName, attrNS, attrPrefix), ! attributes.getValue(i)); ! } } } // update links if (level + 1 >= prevNodeInLevel.length) { *************** *** 154,158 **** int lastNode = doc.getLastNode(); if(doc.nodeKind[lastNode] != Node.ELEMENT_NODE) { - System.out.println("appending attribute as text; last = " + doc.nodeKind[lastNode]); characters(value); } else { --- 155,158 ---- Index: Receiver.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/memtree/Receiver.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Receiver.java 22 Dec 2003 18:48:44 -0000 1.2 --- Receiver.java 27 Apr 2004 15:47:01 -0000 1.3 *************** *** 100,103 **** --- 100,107 ---- } + public void startElement(QName qname) { + builder.startElement(qname, null); + } + /* (non-Javadoc) * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) *************** *** 108,111 **** --- 112,119 ---- } + public void endElement(QName qname) throws SAXException { + builder.endElement(); + } + public void characters(CharSequence seq) throws SAXException { builder.characters(seq); |