From: <wol...@us...> - 2004-03-05 11:37:28
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5368/src/org/exist/xmldb Modified Files: LocalXPathQueryService.java LocalCollectionManagementService.java Log Message: Fixed some synchronization issues in the XQuery engine: * Compiled XQuery expressions are no longer shared between different threads. The XQuery cache in XQueryServlet and XQueryGenerator is declared as thread local now. * The XQueryContext of a compiled XQuery now gets the correct database broker object set. Index: LocalXPathQueryService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalXPathQueryService.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** LocalXPathQueryService.java 25 Feb 2004 15:31:58 -0000 1.33 --- LocalXPathQueryService.java 5 Mar 2004 11:15:27 -0000 1.34 *************** *** 119,160 **** public ResourceSet execute(CompiledExpression expression) throws XMLDBException { DBBroker broker = null; ! DocumentSet docs = null; try { broker = brokerPool.get(user); ! docs = collection.collection.allDocs(broker, new DocumentSet(), true); } catch (EXistException e) { ! throw new XMLDBException( ! ErrorCodes.UNKNOWN_ERROR, ! "error while loading documents: " + e.getMessage(), ! e); } finally { brokerPool.release(broker); } ! expression.reset(); ! XQueryContext context = ((PathExpr)expression).getContext(); ! context.setBackwardsCompatibility(xpathCompatible); ! context.setStaticallyKnownDocuments(docs); ! ! Map.Entry entry; ! // declare namespace/prefix mappings ! for (Iterator i = namespaceDecls.entrySet().iterator(); i.hasNext();) { ! entry = (Map.Entry) i.next(); ! context.declareNamespace((String) entry.getKey(), (String) entry.getValue()); ! } ! // declare static variables ! for (Iterator i = variableDecls.entrySet().iterator(); i.hasNext();) { ! entry = (Map.Entry) i.next(); ! try { ! context.declareVariable((String) entry.getKey(), entry.getValue()); ! } catch (XPathException e) { ! throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); ! } ! } ! return doQuery(expression, docs, null, null); } public CompiledExpression compile(String query) throws XMLDBException { - //LOG.debug("compiling " + query); DBBroker broker = null; try { --- 119,172 ---- public ResourceSet execute(CompiledExpression expression) throws XMLDBException { + return execute(null, null, expression, null); + } + + private ResourceSet execute(DocumentSet docs, + NodeSet contextSet, CompiledExpression expression, String sortExpr) + throws XMLDBException { DBBroker broker = null; ! Sequence result; try { broker = brokerPool.get(user); ! if(docs == null) ! docs = collection.collection.allDocs(broker, new DocumentSet(), true); ! ! expression.reset(); ! XQueryContext context = ((PathExpr)expression).getContext(); ! context.setBroker(broker); ! context.setBackwardsCompatibility(xpathCompatible); ! context.setStaticallyKnownDocuments(docs); ! ! Map.Entry entry; ! // declare namespace/prefix mappings ! for (Iterator i = namespaceDecls.entrySet().iterator(); i.hasNext();) { ! entry = (Map.Entry) i.next(); ! context.declareNamespace((String) entry.getKey(), (String) entry.getValue()); ! } ! // declare static variables ! for (Iterator i = variableDecls.entrySet().iterator(); i.hasNext();) { ! entry = (Map.Entry) i.next(); ! try { ! context.declareVariable((String) entry.getKey(), entry.getValue()); ! } catch (XPathException e) { ! throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); ! } ! } ! result = ((PathExpr)expression).eval(contextSet, null); ! expression.reset(); } catch (EXistException e) { ! throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); ! } catch (XPathException e) { ! throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); } finally { brokerPool.release(broker); } ! if(result != null) ! return new LocalResourceSet(user, brokerPool, collection, properties, result, sortExpr); ! else ! return null; } public CompiledExpression compile(String query) throws XMLDBException { DBBroker broker = null; try { *************** *** 168,172 **** for (Iterator i = namespaceDecls.entrySet().iterator(); i.hasNext();) { entry = (Map.Entry) i.next(); - LOG.debug("prefix " + entry.getKey() + " = " + entry.getValue()); context.declareNamespace( (String) entry.getKey(), --- 180,183 ---- *************** *** 191,195 **** AST ast = parser.getAST(); - LOG.debug("generated AST: " + ast.toStringList()); PathExpr expr = new PathExpr(context); --- 202,205 ---- *************** *** 225,232 **** throws XMLDBException { CompiledExpression expr = compile(query); ! return doQuery(expr, docs, contextSet, sortExpr); } ! protected ResourceSet doQuery( CompiledExpression compiled, DocumentSet docs, --- 235,242 ---- throws XMLDBException { CompiledExpression expr = compile(query); ! return execute(docs, contextSet, expr, sortExpr); } ! /* protected ResourceSet doQuery( CompiledExpression compiled, DocumentSet docs, *************** *** 253,257 **** throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); } ! } public ResourceSet queryResource(String resource, String query) --- 263,267 ---- throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); } ! } */ public ResourceSet queryResource(String resource, String query) Index: LocalCollectionManagementService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalCollectionManagementService.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** LocalCollectionManagementService.java 16 Sep 2003 12:34:08 -0000 1.7 --- LocalCollectionManagementService.java 5 Mar 2004 11:15:27 -0000 1.8 *************** *** 21,31 **** Category.getInstance( LocalCollection.class.getName() ); - /** - * Constructor for the LocalCollectionManagementService object - * - *@param pool Description of the Parameter - *@param parent Description of the Parameter - *@param user Description of the Parameter - */ public LocalCollectionManagementService( User user, BrokerPool pool, LocalCollection parent ) { --- 21,24 ---- *************** *** 37,48 **** } - - /** - * Description of the Method - * - *@param collName Description of the Parameter - *@return Description of the Return Value - *@exception XMLDBException Description of the Exception - */ public Collection createCollection( String collName ) throws XMLDBException { collName = parent.getPath() + '/' + collName; --- 30,33 ---- *************** *** 83,128 **** } - - /** - * Gets the name attribute of the LocalCollectionManagementService object - * - *@return The name value - *@exception XMLDBException Description of the Exception - */ public String getName() throws XMLDBException { return "CollectionManagementService"; } - - /** - * Gets the property attribute of the LocalCollectionManagementService - * object - * - *@param property Description of the Parameter - *@return The property value - */ public String getProperty( String property ) { return null; } - - /** - * Gets the version attribute of the LocalCollectionManagementService - * object - * - *@return The version value - *@exception XMLDBException Description of the Exception - */ public String getVersion() throws XMLDBException { return "1.0"; } - - /** - * Description of the Method - * - *@param collName Description of the Parameter - *@exception XMLDBException Description of the Exception - */ public void removeCollection( String collName ) throws XMLDBException { String path = (collName.startsWith("/db") ? collName : --- 68,83 ---- *************** *** 145,168 **** } - - /** - * Sets the collection attribute of the LocalCollectionManagementService - * object - * - *@param parent The new collection value - *@exception XMLDBException Description of the Exception - */ public void setCollection( Collection parent ) throws XMLDBException { this.parent = (LocalCollection) parent; } - - /** - * Sets the property attribute of the LocalCollectionManagementService - * object - * - *@param property The new property value - *@param value The new property value - */ public void setProperty( String property, String value ) { --- 100,107 ---- |