001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 * 
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 * 
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 * 
019 */
020package org.apache.directory.server.xdbm.search;
021
022
023import org.apache.directory.api.ldap.model.constants.JndiPropertyConstants;
024import org.apache.directory.api.ldap.model.exception.LdapException;
025import org.apache.directory.api.ldap.model.filter.ExprNode;
026import org.apache.directory.api.ldap.model.schema.SchemaManager;
027import org.apache.directory.server.core.api.interceptor.context.SearchOperationContext;
028import org.apache.directory.server.core.api.partition.PartitionTxn;
029
030
031/**
032 * Given a search filter and a scope the search engine identifies valid
033 * candidate entries returning their ids.
034 * 
035 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
036 */
037public interface SearchEngine
038{
039    /**
040     * TODO put this in the right place
041     * The alias dereferencing mode key for JNDI providers
042     */
043    String ALIASMODE_KEY = JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES;
044    
045    /**
046     * TODO put this in the right place
047     * The alias dereferencing mode value for JNDI providers
048     */
049    String ALWAYS = "always";
050    
051    /**
052     * TODO put this in the right place
053     * The alias dereferencing mode value for JNDI providers
054     */
055    String NEVER = "never";
056    
057    /**
058     * TODO put this in the right place
059     * The alias dereferencing mode value for JNDI providers
060     */
061    String FINDING = "finding";
062    
063    /**
064     * TODO put this in the right place
065     * The alias dereferencing mode value for JNDI providers
066     */
067    String SEARCHING = "searching";
068
069
070    /**
071     * Gets the optimizer for this DefaultSearchEngine.
072     *
073     * @return the optimizer
074     */
075    Optimizer getOptimizer();
076
077
078    /**
079     * Conducts a search on a database. It returns a set of UUID we found for the 
080     * given filter.
081     * 
082     * @param partitionTxn The transaction to use
083     * @param schemaManager The SchemaManager instance
084     * @param searchContext the search context
085     * @return A set of UUID representing the full result, up to he sizeLimit
086     * @throws LdapException if the search fails
087     */
088    PartitionSearchResult computeResult( PartitionTxn partitionTxn, SchemaManager schemaManager, 
089            SearchOperationContext searchContext ) throws LdapException;
090
091
092    /**
093     * Builds an Evaluator for a filter expression.
094     * 
095     * @param partitionTxn The transaction to use
096     * @param filter the filter root AST node
097     * @return true if the filter passes the entry, false otherwise
098     * @throws LdapException if something goes wrong while accessing the db
099     */
100    Evaluator<? extends ExprNode> evaluator( PartitionTxn partitionTxn, ExprNode filter ) throws LdapException;
101}