Changeset 29409


Ignore:
Timestamp:
2014-11-03T12:26:30+13:00 (9 years ago)
Author:
kjdon
Message:

adding a reset method to MGPPSearchWrapper. When we rebuild a collection, we are unloading then reloading the index data, however the default settings (stem method etc) were not being reset. This led to a problem: If a collection was built with accent folding on, and a query wsa done with accent folding on, then this was stored in defaultStemMethod. If the collection was then built without accent folding on, the accent folding setting wouldn't be unset and forever after, the stemMethod would be wrong and therefore no stem/casefold could be done. Now we can call reset after unloading the indexdata to get all the settings back to defaults.

Location:
main/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/common-src/indexers/mgpp/java/org/greenstone/mgpp/MGPPSearchWrapper.java

    r16583 r29409  
    8484    public native boolean unloadIndexData();
    8585
     86  /** reset all the params back to their defaults */
     87  public native void reset();
    8688    // query param methods
    8789
  • main/trunk/greenstone2/common-src/indexers/mgpp/jni/MGPPSearchWrapperImpl.cpp

    r26660 r29409  
    6767  }
    6868
     69  resetDefaults();
     70}
     71
     72MGPPSearchData::~MGPPSearchData() {
     73  if (indexData !=NULL) {
     74    delete indexData;
     75  }
     76  if (queryInfo !=NULL) {
     77    delete queryInfo;
     78  }
     79}
     80
     81void MGPPSearchData::resetDefaults() {
    6982  // set all the default params
    7083  SetCStr(queryInfo->docLevel, "Document"); // the level to search at
     
    8093  defaultBoolCombine=0;
    8194  maxNumeric = 4;
    82 }
    83 
    84 MGPPSearchData::~MGPPSearchData() {
    85   if (indexData !=NULL) {
    86     delete indexData;
    87   }
    88   if (queryInfo !=NULL) {
    89     delete queryInfo;
    90   }
     95
    9196}
    9297
     
    270275}
    271276
     277/* reset the stored settings
     278*/
     279JNIEXPORT void JNICALL
     280Java_org_greenstone_mgpp_MGPPSearchWrapper_reset (JNIEnv *j_env, jobject j_obj) {
     281
     282  jlong data_ptr = j_env->GetLongField(j_obj, FID_mgpp_data);
     283  MGPPSearchData * data = (MGPPSearchData *)data_ptr;
     284  data->resetDefaults();
     285 
     286
     287}
    272288/* do the actual query - the results are written to query_result held on the
    273289   java side */
  • main/trunk/greenstone2/common-src/indexers/mgpp/jni/MGPPSearchWrapperImpl.h

    r16583 r29409  
    3333  ~MGPPSearchData();
    3434
     35  void resetDefaults(); // reset the defaults
    3536};
  • main/trunk/greenstone2/common-src/indexers/mgpp/jni/org_greenstone_mgpp_MGPPSearchWrapper.h

    r16583 r29409  
    3838 */
    3939JNIEXPORT jboolean JNICALL Java_org_greenstone_mgpp_MGPPSearchWrapper_unloadIndexData
     40  (JNIEnv *, jobject);
     41
     42/*
     43 * Class:     org_greenstone_mgpp_MGPPSearchWrapper
     44 * Method:    reset
     45 * Signature: ()V
     46 */
     47JNIEXPORT void JNICALL Java_org_greenstone_mgpp_MGPPSearchWrapper_reset
    4048  (JNIEnv *, jobject);
    4149
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java

    r28966 r29409  
    6363        super.cleanUp();
    6464        mgpp_src.unloadIndexData();
     65        mgpp_src.reset(); // reset stored settings to defaults
    6566    }
    6667
Note: See TracChangeset for help on using the changeset viewer.