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/AbstractGS2FieldSearch.java

    r32547 r32619  
    672672        indexField = field;
    673673        // set up the appropriate query system
    674         if (!setUpQueryer(params))
    675         {
     674        Object queryObject = setUpQueryer(params);
     675        if (queryObject == null)
     676        {           
    676677            return result;
    677678        }
     
    689690            query = parseAdvancedFieldQueryParams(params);
    690691            break;
    691         }
     692        }       
    692693       
    693         // run the query
    694         Object query_result = runQuery(query);
     694        // run the query       
     695        Object query_result = runQuery(queryObject, query);
     696       
    695697       
    696698        // We want highlighted text to be returned right now!
     
    817819            }
    818820        }
    819 
    820821       
     822        queryObject = null;
    821823        return result;
    822824
     
    824826
    825827    /** methods to handle actually doing the query */
    826     /** do any initialisation of the query object */
    827     abstract protected boolean setUpQueryer(HashMap<String, Serializable> params);
    828 
    829     /** do the query */
    830     abstract protected Object runQuery(String query);
     828    /** do any initialisation of the query object. Call before runQuery()
     829      * @return the queryObject (e.g. GS2LuceneQuery)
     830    */ 
     831    abstract protected Object setUpQueryer(HashMap<String, Serializable> params);
     832
     833    /** do the query
     834      * The queryObject parameter is the return value of setUpQueryer.
     835    */
     836    abstract protected Object runQuery(Object queryObject, String query);
    831837
    832838    /** get the total number of docs that match */
Note: See TracChangeset for help on using the changeset viewer.