>> -----Original Message-----
>> From: Oliver Zeigermann [mailto:[EMAIL PROTECTED] 
>> Sent: Monday, January 19, 2004 12:03 PM
>> To: Slide Developers Mailing List
>> Subject: Re: Indexing store
>> 
>> 
>> Nick!
>> 
>> First of all let me say "thanks"! Then let me ask if you can 
>> think of 
>> any way integrating your efforts with what Christophe has 
>> already done?

I can't actually find Christophe's original proposal in the mail
archives. But I remember seeing it, and I don't see any problem. My
implementation uses all the BasicQuery API, doesn't do anything
non-standard from the Slide point of view, although (as SQL) it does
check the permissions table to see if any of the returned results have
defined permissions, so as to accelerate.

>> 
>> I have also seen you use some JDK1.4 specific methods which might be 
>> troublesome as we decided to support 1.3 as well...


ahhh...regular expressions. The attached version doesn't use them.

>> 
>> What is this virtual store? By the way, you need to close all 
>> connections to make them go back into the pool...

It was a silly bug, now fixed. I've explained what I call a virtual
store in a reply to Stefano.

>> > So> a few notes/queries on the implementation. I can upload my 
>> > So> sources,
>> > but I'd need a little time to make it slightly less 
>> embarassing, and 
>> > any input/critiques I can get on the solution below 
>> (architecturally I 
>> > find Slide a completely impossible act to follow. Which makes me a 
>> > little shy).
>> 
>> I agree we really need *much* better developer docs. Will 
>> you be able to 
>> contribute anything describing your experience with Slide's 
>> internals? 
>> Maybe a starting point for better docs...

Sure. But - maybe it's an Australianism - I meant the architecture's
great.

>> > Which sort of begs the question, why not allow PROPFIND to 
>> just call a 
>> > SEARCH, if appropriate? (And yes, I have got classes to generate a 
>> > SEARCH body).
>> 
>> Which also raises the question, why is PROPFIND sooo slow?

Because of the architecture. Clean, and no shortcuts. (see the
invocation tree).

As a starter, 
StructureImpl.getChildren() shouldn't be performed more than once for
the parent folder, but is done each time a child is retreived (ACL)

ComputedPropertyProvider.isSupportedProperty () should be cached.

Performance notes:
Even when PROPFIND is reading for the first time, the stats are:
Java 90% cpu usage
MySQL 10%


>> 
>> 
>> Oliver
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>> 
/*
 * $Header: /home/cvspublic/jakarta-slide/src/share/org/apache/slide/search/SearchImpl.java,v 1.13 2002/06/19 11:00:13 juergen Exp $
 * $Revision: 1.13 $
 * $Date: 2002/06/19 11:00:13 $
 *
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowlegement:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowlegement may appear in the software itself,
 *    if and wherever such third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", "Slide", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written
 *    permission, please contact [EMAIL PROTECTED]
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Group.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 * [Additional notices, if required by prior licensing conditions]
 *
 */

package org.apache.slide.search;

import java.io.IOException;

import java.util.HashMap;
import java.util.Map;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.StringTokenizer;
import org.apache.slide.common.Namespace;
import org.apache.slide.common.NamespaceConfig;
import org.apache.slide.common.ServiceAccessException;
import org.apache.slide.common.SlideToken;
import org.apache.slide.structure.Structure;
import org.apache.slide.content.Content;
import org.apache.slide.authenticate.CredentialsToken;
import org.apache.slide.common.Domain;
import org.apache.slide.util.Configuration;
import org.apache.slide.util.logger.Logger;
import org.apache.slide.search.basic.BasicSearchLanguage;

import org.jdom.Element;


/**
 * Search helper.
 *
 * @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
 * @version $Revision: 1.13 $
 */
public final class SearchImpl implements Search {
    
    // ----------------------------------------------------------- Constructors
    
    
    /**
     * Constructor.
     *
     * @param namespace Namespace
     * @param namespaceConfig Namespace configuration
     */
    public SearchImpl (Namespace namespace,
    NamespaceConfig namespaceConfig,
    Structure structureHelper,
    Content contentHelper) {
        this.namespace = namespace;
        this.namespaceConfig = namespaceConfig;
        this.structureHelper = structureHelper;
        this.contentHelper = contentHelper;
        initializeLanguages ();
    }
    
    private void initializeLanguages () {
        String languageClassNames = namespaceConfig.getParameter ("search_language_classes");
        if (languageClassNames == null){
            languageClassNames = "org.apache.slide.search.basic.BasicSearchLanguage";
        }
        StringTokenizer languages = new StringTokenizer (languageClassNames, " ,\t\f\n\r");
        try{
            while (languages.hasMoreElements ()){
                SearchLanguage language =
                (SearchLanguage) Class.forName (languages.nextToken ()).newInstance ();
                grammarByUri.put (language.getGrammarUri (),
                language);
            }
        }
        catch (Exception e){
            getLogger ().log ("Unable to instantiate search language", LOG_CHANNEL, Logger.WARNING);
            grammarByUri = new HashMap (1);
            SearchLanguage language = new BasicSearchLanguage ();
            grammarByUri.put (language.getGrammarUri (),
            language);
            
        }
    }
    private Logger getLogger () {
        Logger logger = null;
        if (namespace != null) {
            logger = this.namespace.getLogger ();
        }
        
        return logger;
    }
    
    // ----------------------------------------------------- Instance Variables
    
    // TODO: must be configurable in domain.xml (Namespace.java)
    private  SearchLanguage [] searchLanguages ;
    
    
    private   Map grammarByUri = new HashMap ();
    
    
    /**
     * Log channel for logger
     */
    private final static String LOG_CHANNEL = SearchImpl.class.getName ();
    
    
    /**
     * Namespace.
     */
    private Namespace namespace;
    
    /**
     * Structure.
     */
    private Structure structureHelper;
    
    
    /**
     * Namespace configuration.
     */
    private NamespaceConfig namespaceConfig;
    
    /**
     * Namespace configuration.
     */
    private Content contentHelper;
    
    
    // ------------------------------------------------------- Security Methods
    
    
    /**
     * Search.
     *
     * @param token Credentials token
     * @param object Object on which permission is granted
     * @exception ServiceAccessException DataSource access error
     */
    public SearchQueryResult search (SlideToken token, SearchQuery query)
    throws ServiceAccessException {
        return query.execute ();
    }
    
    
    /**
     * Return the allowed query languages.
     */
    public SearchLanguage[] getSupportedLanguages () {
        return searchLanguages;
    }
    
    
    /**
     * Retrieve a SearchLanguage identified by the grammar uri (namespace)
     *
     * @param    grammarUri          identifier for the SearchLanguage
     *
     * @return   the SearchLanguage
     *
     * @throws   BadQueryException
     *
     */
    public SearchLanguage getLanguage (String grammarUri)
    throws BadQueryException {
        SearchLanguage result =(SearchLanguage) grammarByUri.get (grammarUri);
        if (result == null)
            throw new BadQueryException ("grammar not found: " + grammarUri);
        
        return result;
    }
    
    
    
    
    /**
     * Creates a SearchQuery.
     *
     * @param    grammarUri          identifier for the SearchLanguage
     * @param    queryElement        the JDOM element containing the query
     * @param    token               the SlideToken
     * @param    maxDepth            may be 0, 1 or INFINIT
     *
     * @return   the SearchQuery
     *
     * @throws   BadQueryException
     *
     */
    public SearchQuery createSearchQuery (String grammarUri,
    Element queryElement,
    SlideToken token,
    int maxDepth)
    throws BadQueryException {
        return createSearchQuery (grammarUri, queryElement, token, maxDepth, (PropertyProvider)null);
    }
    
    /**
     * Creates a SearchQuery.
     *
     * @param    grammarUri            identifier for the SearchLanguage.
     * @param    searchRequestElement  the JDOM element containing the query
     * @param    token                 the SlideToken.
     * @param    maxDepth              may be 0, 1 or INFINITY.
     * @param    propertyProvider      the  PropertyProvider to use (may be
     *                                 <code>null</code>).
     *
     * @return   the SearchQuery
     *
     * @throws   BadQueryException
     */
    public SearchQuery createSearchQuery (String grammarUri,
    Element searchRequestElement,
    SlideToken token,
    int maxDepth,
    PropertyProvider propertyProvider)
    throws BadQueryException {
        return createSearchQuery (grammarUri, searchRequestElement, token, maxDepth, propertyProvider, null);
    }
    
    /**
     * Creates a SearchQuery.
     *
     * @param    grammarUri          identifier for the SearchLanguage
     * @param    queryElement        the JDOM element containing the query
     * @param    token               the SlideToken
     * @param    maxDepth            may be 0, 1 or INFINIT
     *
     * @return   the SearchQuery
     *
     * @throws   BadQueryException
     *
     */
    public SearchQuery createSearchQuery (String grammarUri,
    Element queryElement,
    SlideToken token,
    int maxDepth,
    String requestUri)
    throws BadQueryException {
        return createSearchQuery (grammarUri, queryElement, token, maxDepth, null, requestUri);
    }
    
    /**
     * Creates a SearchQuery.
     *
     * @param    grammarUri            identifier for the SearchLanguage.
     * @param    searchRequestElement  the JDOM element containing the query
     * @param    token                 the SlideToken.
     * @param    maxDepth              may be 0, 1 or INFINITY.
     * @param    propertyProvider      the  PropertyProvider to use (may be
     *                                 <code>null</code>).
     * @param    requestUri            the  URI of the request.
     *
     * @return   the SearchQuery
     *
     * @throws   BadQueryException
     */
    public SearchQuery createSearchQuery (String grammarUri,
    Element searchRequestElement,
    SlideToken token,
    int maxDepth,
    PropertyProvider propertyProvider,
    String requestUri)
    throws BadQueryException {
        SearchQuery result = null;
        // create search token
        SearchToken searchToken =
        SearchToken.createSearchToken (token, contentHelper,
        structureHelper, maxDepth,
        requestUri, namespace);
        
        SearchLanguage language = getLanguage (grammarUri);
        result = language.parseQuery (searchRequestElement, searchToken, propertyProvider);
        
        return result;
    }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to