Ignore:
Timestamp:
2018-11-20T21:34:48+13:00 (5 years ago)
Author:
ak19
Message:

3 significant changes in 1 commit particularly impacting Lucene queries: 1. Instead if GS2LuceneSearch havinga GS2LuceneQuery object member variable for doing each and every search, each query now instantiates its own local GS2LuceneQuery object, configures it for that specific search, runs the search and then the GS2LuceneQuery object expires. This fixes a bug by preventing multiple concurrent searches getting the search configurations of other searches run at the same time. 2. Though GS2LuceneQuery objects need to be instantiated 1 per query over a collection, we don't want to keep reopening a collection's sidx and didx index folders with IndexReader objects for every query. Since IndexReaders support concurrent access, we'd like to use one IndexReader per collection index (one for didx, one for sidx) with the IndexReaders existing for the life of a collection. This meant moving the maintaining of IndexReader objects from GS2LuceneQuery into the GS2LuceneSearch service and turning them into singletons by using a HashMap to maintain index-dir, reader pairs. GS3 Services, e.g. GS2LuceneSearch, are loaded and unloaded on collection activate and deactivate respectively. On deactivate, cleanUp() is called on services and other GS3 modules. When GS2LuceneSearch.cleanUp() is called, we now finally close the singleton IndexReader objects/resources that a collection's GS2LuceneSearch object maintains. 3. Redid previous bugfix (then committed to GS2LuceneQuery): Point 2 again solves the filelocking problem of multiple handles to the index being opened and not all being closed on deactivate, but it's solved in a different and better/more optimal way than in the previous commit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java

    r32084 r32619  
    4343public class GS2MGPPSearch extends AbstractGS2FieldSearch
    4444{
    45     private static MGPPSearchWrapper mgpp_src = null;
     45    private static MGPPSearchWrapper mgpp_src = null; // STATIC!
    4646
    4747    private String physical_index_name = "idx";
     
    6565        mgpp_src.reset(); // reset stored settings to defaults
    6666    }
    67 
     67   
    6868    /** process a query */
    6969    protected Element processAnyQuery(Element request, int query_type)
    7070    {
     71        // don't know that the static (class variable) mgpp_src is "multi-threaded re-entrant" allowing multiple users
     72        // to search the same index at the same time. So leave code as-is: to synchronize on mgpp_src when running query
    7173        synchronized (mgpp_src)
    7274        {
     
    102104    }
    103105
    104     protected boolean setUpQueryer(HashMap<String, Serializable> params)
     106    protected Object setUpQueryer(HashMap<String, Serializable> params)
    105107    {
    106108
     
    199201        mgpp_src.loadIndexData(indexdir);
    200202
    201         return true;
    202     }
    203 
    204     protected Object runQuery(String query)
    205     {
     203        return mgpp_src; //return the query object
     204    }
     205
     206    protected Object runQuery(Object queryObject, String query)
     207    {
     208        // queryObject is mgpp_src, so use mgpp_src reference directly:
     209       
    206210        mgpp_src.runQuery(query);
    207211        MGPPQueryResult mqr = mgpp_src.getQueryResult();
Note: See TracChangeset for help on using the changeset viewer.