Changeset 9937


Ignore:
Timestamp:
2005-05-24T14:21:02+12:00 (19 years ago)
Author:
kjdon
Message:

modified the filters/sources etc so that if an indexstem is specified in the build.cfg file, then this will be used as the root of the index/gdbm filenames instead of the collection name. colleciton name still used by default. this means that we can rename a coll directory without rebuilding.

Location:
trunk/gsdl/src/colservr
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/colservr/browsefilter.cpp

    r9620 r9937  
    6464}
    6565
     66void browsefilterclass::configure (const text_t &key, const text_tarray &cfgline) {
     67  filterclass::configure (key, cfgline);
     68  if (key == "indexstem") {
     69    indexstem = cfgline[0];
     70  }
     71}
     72
    6673bool browsefilterclass::init (ostream &logout) {
    6774  outconvertclass text_t2ascii;
     
    6976  if (!filterclass::init(logout)) return false;
    7077
     78  if (indexstem.empty()) {
     79    indexstem = collection;
     80  }
    7181  // get the filename for the database and make sure it exists
    72   gdbm_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", collection);
     82  gdbm_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", indexstem);
    7383
    7484  if (littleEndian()) gdbm_filename += ".ldb";
  • trunk/gsdl/src/colservr/browsefilter.h

    r1285 r9937  
    3939protected:
    4040  text_t gdbm_filename;
     41  text_t indexstem;
    4142  gdbmclass *gdbmptr;
    4243
     
    4445  browsefilterclass ();
    4546  virtual ~browsefilterclass ();
     47
     48  // configure should be called once for each configuration line
     49  // default configures the default filter options
     50  virtual void configure (const text_t &key, const text_tarray &cfgline);
    4651
    4752  // the gdbmptr remains the responsability of the calling code and
  • trunk/gsdl/src/colservr/collectset.cpp

    r9631 r9937  
    123123       
    124124        mgppsearch = new mgppsearchclass();
    125        
     125               
    126126        // add a query filter
    127127        mgppqueryfilterclass *queryfilter = new mgppqueryfilterclass();
  • trunk/gsdl/src/colservr/gdbmsource.cpp

    r9620 r9937  
    6666    languagemap.importmap (cfgline);
    6767
    68   } else if (key == "defaultlanguage")
     68  } else if (key == "defaultlanguage") {
    6969    languagemap.from2to (cfgline[0], defaultlanguage);
     70  } else if (key == "indexstem") {
     71    indexstem = cfgline[0];
     72  }
     73 
    7074}
    7175
     
    110114 
    111115  // get the filename for the database and make sure it exists
    112   gdbm_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", collection);
     116  if (indexstem.empty()) {
     117    indexstem = collection;
     118  }
     119  gdbm_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", indexstem);
    113120  if (littleEndian()) gdbm_filename += ".ldb";
    114121  else gdbm_filename += ".bdb";
  • trunk/gsdl/src/colservr/gdbmsource.h

    r9345 r9937  
    4343  text_t collection;
    4444  text_t collectdir;
    45 
     45 
    4646  // these maps are only needed to convert the default indexes
    4747  stringmap indexmap;
     
    5252  text_t defaultsubcollection;
    5353  text_t defaultlanguage;
     54
     55  text_t indexstem;
    5456
    5557  text_t parentOID;
  • trunk/gsdl/src/colservr/lucenesearch.cpp

    r9915 r9937  
    4646
    4747
    48 static text_t getindexsuffix(const queryparamclass &qp) {
     48text_t lucenesearchclass::getindexsuffix(const queryparamclass &qp) {
    4949  text_t indexsuffix = "index";
    5050  // get the first char of the level to be the start of the index name
  • trunk/gsdl/src/colservr/lucenesearch.h

    r9189 r9937  
    8181
    8282  text_t gdbm_level; // the default level used for retrieval, and in the gdbm file
    83  
     83 protected:
     84  text_t getindexsuffix(const queryparamclass &qp);
    8485};
    8586
  • trunk/gsdl/src/colservr/mgppqueryfilter.cpp

    r9620 r9937  
    111111  } else if (key == "textlevel") {
    112112      ((mgppsearchclass *)textsearchptr)->set_gdbm_level( cfgline[0]);
     113  } else if (key == "indexstem") {
     114    ((mgppsearchclass *)textsearchptr)->set_indexstem (cfgline[0]);
    113115  }
    114116 
  • trunk/gsdl/src/colservr/mgppsearch.cpp

    r9631 r9937  
    3535
    3636
    37 static text_t getindexsuffix(const queryparamclass &qp) {
    38   text_t indexsuffix = "index";
    39   text_t ind = qp.index;
    40   text_t sub = qp.subcollection;
    41   text_t lang = qp.language;
    42    
    43   indexsuffix = filename_cat(indexsuffix, ind + sub + lang, qp.collection);
     37text_t mgppsearchclass::getindexsuffix(const queryparamclass &qp) {
     38  return getindexsuffix(qp.collection, qp.index+qp.subcollection+qp.language);
     39
     40}
     41
     42text_t mgppsearchclass::getindexsuffix (const text_t &collection,
     43                  const text_t &index) {
     44
     45  text_t indexsuffix = "index"; 
     46  indexsuffix = filename_cat (indexsuffix, index);
     47  if (indexstem.empty()) {
     48    // no index stem, use the coll name
     49    indexsuffix = filename_cat (indexsuffix, collection);
     50  } else {
     51    indexsuffix = filename_cat (indexsuffix, indexstem);
     52  }
    4453  return indexsuffix;
    45 
    4654}
    4755
     
    7583void mgppsearchclass::set_gdbm_level(const text_t &level) {
    7684  gdbm_level = level;
     85 
     86}
     87void mgppsearchclass::set_indexstem(const text_t &stem) {
     88  indexstem = stem;
    7789 
    7890}
     
    282294  char basepath[] = "/";
    283295#endif
    284    char *textname = (filename_cat(collectdir, "index", "text", collection)).getcstr();;
     296  char *textname = (filename_cat(collectdir, getindexsuffix(collection, "text"))).getcstr();
    285297 
    286298  TextData textdata;
  • trunk/gsdl/src/colservr/mgppsearch.h

    r8024 r9937  
    7575           char *&UDoc, int &ULen);
    7676  */
     77 
    7778  void set_gdbm_level(const text_t &level);
     79 
     80  void set_indexstem(const text_t &indexstem);
    7881
    7982  // used to clear any cached databases for persistent versions of
     
    8184  void unload_database ();
    8285 protected:
     86 
    8387  text_t gdbm_level; // the default level used for retrieval, and in the gdbm file
    84  
     88  text_t indexstem; // the stem of the index file names
    8589  IndexData *indexData; // the index data structure needed for MGQuery - keep
    8690  // as a cache
     91 
     92  text_t getindexsuffix(const queryparamclass &qp);
     93  text_t getindexsuffix (const text_t &collection, const text_t &index);
    8794
    8895};
  • trunk/gsdl/src/colservr/mgqueryfilter.cpp

    r9620 r9937  
    9292    maxnumeric = cfgline[0].getint();
    9393  }
     94  else if (key == "indexstem") {
     95    ((mgsearchclass *)textsearchptr)->set_indexstem (cfgline[0]);
     96  }
     97 
    9498}
    9599
  • trunk/gsdl/src/colservr/mgsearch.cpp

    r9631 r9937  
    215215
    216216
    217 static text_t getindexsuffix (const text_t &collection,
     217text_t mgsearchclass::getindexsuffix (const text_t &collection,
    218218                  const text_t &index) {
    219219
    220220  text_t indexsuffix = "index"; 
    221221  indexsuffix = filename_cat (indexsuffix, index);
    222   indexsuffix = filename_cat (indexsuffix, collection);
     222  if (indexstem.empty()) {
     223    // no index stem, use the coll name
     224    indexsuffix = filename_cat (indexsuffix, collection);
     225  } else {
     226    indexsuffix = filename_cat (indexsuffix, indexstem);
     227  }
    223228  return indexsuffix;
    224229}
     
    243248      cache = NULL;
    244249    }
     250}
     251
     252void mgsearchclass::set_indexstem(const text_t &stem) {
     253  indexstem = stem;
     254 
    245255}
    246256
     
    264274  char *txtsuffix = (getindexsuffix (collection, "text")).getcstr();
    265275  assert (txtsuffix != NULL);
    266 
    267276#ifdef __WIN32__
    268277  char *ccollectdir = (collectdir+"\\").getcstr(); assert (ccollectdir != NULL);
  • trunk/gsdl/src/colservr/mgsearch.h

    r8024 r9937  
    8686  void unload_database ();
    8787
     88  void set_indexstem(const text_t &indexstem);
    8889
    8990protected:
    9091
     92  text_t indexstem; // the stem of the index files - defaults to the collectionname
    9193  void setsearchmode (const queryparamclass &queryparams);
    9294  void submitquery (const queryparamclass &queryparams);
    9395  void getresults (const queryparamclass &queryparams, queryresultsclass &queryresults);
    94 
     96  text_t getindexsuffix (const text_t &collection, const text_t &index);
    9597  virtual void filterquery (text_t &ttquerystring);
    9698};
  • trunk/gsdl/src/colservr/queryfilter.cpp

    r9620 r9937  
    331331  } else if (key == "defaultlanguage") {
    332332    languagemap.from2to (cfgline[0], filterOptions["Language"].defaultValue);
     333  } else if (key == "indexstem") {
     334    indexstem = cfgline[0];
    333335  }
    334336}
     
    367369
    368370  // get the filename for the database and make sure it exists
    369   gdbm_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", collection);
     371  if (indexstem.empty()) {
     372    indexstem = collection;
     373  }
     374  gdbm_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", indexstem);
    370375
    371376  if (littleEndian()) gdbm_filename += ".ldb";
  • trunk/gsdl/src/colservr/queryfilter.h

    r8024 r9937  
    4949
    5050  text_t gdbm_filename;
     51  text_t indexstem;
    5152  gdbmclass *gdbmptr;
    5253 
Note: See TracChangeset for help on using the changeset viewer.