Changeset 15558


Ignore:
Timestamp:
2008-05-17T16:00:00+12:00 (16 years ago)
Author:
mdewsnip
Message:

(Adding new DB support) Changed lots of "gdbm"s to "db"s, in preparation for adding new DB types.

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

Legend:

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

    r13780 r15558  
    3030
    3131browsefilterclass::browsefilterclass () {
    32   gdbmptr = NULL;
     32  db_ptr = NULL;
    3333
    3434  // -- onePerQuery StartResults   integer
     
    8080  }
    8181  // get the filename for the database and make sure it exists
    82   gdbm_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", indexstem);
    83 
    84   if (littleEndian()) gdbm_filename += ".ldb";
    85   else gdbm_filename += ".bdb";
    86 
    87   if (!file_exists(gdbm_filename)) {
     82  db_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", indexstem);
     83
     84  if (littleEndian()) db_filename += ".ldb";
     85  else db_filename += ".bdb";
     86
     87  if (!file_exists(db_filename)) {
    8888    logout << text_t2ascii
    89        << "warning: gdbm database \"" //****
    90        << gdbm_filename << "\" does not exist\n\n";
    91     //    return false; //****
     89       << "warning: database \"" << db_filename << "\" does not exist\n\n";
     90    //    return false;
    9291  }
    9392
     
    103102  response.clear ();
    104103  err = noError;
    105   if (gdbmptr == NULL) {
     104  if (db_ptr == NULL) {
    106105    // most likely a configuration problem
    107106    logout << text_t2ascii
    108        << "configuration error: browsefilter contains a null gdbmclass\n\n";
     107       << "configuration error: browsefilter contains a null dbclass\n\n";
    109108    err = configurationError;
    110109    return;
     
    112111
    113112  // open the database
    114   gdbmptr->setlogout(&logout);
    115   if (!gdbmptr->opendatabase (gdbm_filename, GDBM_READER, 100, false)) {
    116     // most likely a system problem (we have already checked that the
    117     // gdbm database exists)
     113  db_ptr->setlogout(&logout);
     114  if (!db_ptr->opendatabase (db_filename, DB_READER, 100, false)) {
     115    // most likely a system problem (we have already checked that the database exists)
    118116    logout << text_t2ascii
    119        << "system problem: open on gdbm database \""
    120        << gdbm_filename << "\" failed\n\n";
     117       << "system problem: open on database \""
     118       << db_filename << "\" failed\n\n";
    121119    err = systemProblem;
    122120    return;
     
    149147
    150148  // translate any ".fc", ".pr" etc. stuff in the parentnode
    151   parentnode = gdbmptr->translate_OID (parentnode, info);
     149  parentnode = db_ptr->translate_OID (parentnode, info);
    152150
    153151  // adjust topmost browsing node
     
    157155  if ((request.filterResultOptions & FROID) ||
    158156      (request.filterResultOptions & FRmetadata)) {
    159     if (!gdbmptr->getinfo(parentnode, info)) {
     157    if (!db_ptr->getinfo(parentnode, info)) {
    160158      // didn't find the node
    161159      logout << text_t2ascii
     
    304302  }
    305303
    306   gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     304  db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    307305  response.numDocs = numDocs;
    308306  response.isApprox = Exact;
  • gsdl/trunk/src/colservr/browsefilter.h

    r15430 r15558  
    3333#include "comtypes.h"
    3434#include "filter.h"
    35 #include "gdbmclass.h"
     35#include "dbclass.h"
    3636
    3737
    3838class browsefilterclass : public filterclass {
    3939protected:
    40   text_t gdbm_filename;
     40  text_t db_filename;
    4141  text_t indexstem;
    42   gdbmclass *gdbmptr;
     42  dbclass *db_ptr;
    4343
    4444public:
     
    5050  virtual void configure (const text_t &key, const text_tarray &cfgline);
    5151
    52   // the gdbmptr remains the responsability of the calling code and
     52  // the db ptr remains the responsability of the calling code and
    5353  // should be destroyed after this browsefilter is destroyed
    54   void set_gdbmptr (gdbmclass *thegdbmptr) {gdbmptr = thegdbmptr;}
     54  void set_db_ptr (dbclass *db_ptr_arg) { db_ptr = db_ptr_arg; }
    5555
    5656  bool init (ostream &logout);
  • gsdl/trunk/src/colservr/collectset.cpp

    r15430 r15558  
    224224  // add a browse filter
    225225  browsefilterclass *browsefilter = new browsefilterclass();
    226   browsefilter->set_gdbmptr (gdbmhandler);
     226  browsefilter->set_db_ptr(gdbmhandler);
    227227
    228228  cserver->add_filter (browsefilter); 
     
    233233    // add a query filter
    234234    mgqueryfilterclass *queryfilter = new mgqueryfilterclass();
    235     queryfilter->set_gdbmptr (gdbmhandler);
     235    queryfilter->set_db_ptr(gdbmhandler);
    236236    queryfilter->set_textsearchptr (mgsearch);
    237237    cserver->add_filter (queryfilter);
     
    248248    // add a query filter
    249249    mgppqueryfilterclass *queryfilter = new mgppqueryfilterclass();
    250     queryfilter->set_gdbmptr (gdbmhandler);
     250    queryfilter->set_db_ptr(gdbmhandler);
    251251    queryfilter->set_textsearchptr (mgppsearch);
    252252    cserver->add_filter (queryfilter);
     
    264264    // add a query filter
    265265    lucenequeryfilterclass *queryfilter = new lucenequeryfilterclass();
    266     queryfilter->set_gdbmptr (gdbmhandler);
     266    queryfilter->set_db_ptr(gdbmhandler);
    267267    queryfilter->set_textsearchptr (lucenesearch);
    268268    cserver->add_filter (queryfilter);
  • gsdl/trunk/src/colservr/lucenequeryfilter.cpp

    r13780 r15558  
    122122  response.clear ();
    123123  err = noError;
    124   if (gdbmptr == NULL) {
     124  if (db_ptr == NULL) {
    125125    // most likely a configuration problem
    126126    logout << text_t2ascii
    127        << "configuration error: queryfilter contains a null gdbmclass\n\n";
     127       << "configuration error: queryfilter contains a null dbclass\n\n";
    128128    err = configurationError;
    129129    return;
     
    141141  }
    142142  // open the database
    143   gdbmptr->setlogout(&logout);
    144   if (!gdbmptr->opendatabase (gdbm_filename, GDBM_READER, 100, false)) {
    145     // most likely a system problem (we have already checked that the
    146     // gdbm database exists)
     143  db_ptr->setlogout(&logout);
     144  if (!db_ptr->opendatabase (db_filename, DB_READER, 100, false)) {
     145    // most likely a system problem (we have already checked that the database exists)
    147146    logout << text_t2ascii
    148        << "system problem: open on gdbm database \""
    149        << gdbm_filename << "\" failed\n\n";
     147       << "system problem: open on database \"" << db_filename << "\" failed\n\n";
    150148    err = systemProblem;
    151149    return;
     
    185183     
    186184        // translate the document number
    187         if (!translate(gdbmptr, *docorder_here, trans_OID))
     185        if (!translate(db_ptr, *docorder_here, trans_OID))
    188186          {
    189187            logout << text_t2ascii
     
    261259  }
    262260
    263   gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     261  db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    264262  response.numDocs = queryresults.docs_matched;
    265263  response.isApprox = queryresults.is_approx;
     
    319317}
    320318
    321 // lucenesearchptr and gdbmptr are assumed to be valid
     319// lucenesearchptr and db_ptr are assumed to be valid
    322320void lucenequeryfilterclass::do_multi_query (const FilterRequest_t &request,
    323321                       const vector<queryparamclass> &query_params,
  • gsdl/trunk/src/colservr/lucenequeryfilter.h

    r8027 r15558  
    3838  bool full_text_browse (int filterRequestOptions);
    3939
    40   // mgsearchptr and gdbmptr are assumed to be valid
     40  // mgsearchptr and db_ptr are assumed to be valid
    4141  void do_multi_query (const FilterRequest_t &request,
    4242               const vector<queryparamclass> &query_params,
  • gsdl/trunk/src/colservr/mgppqueryfilter.cpp

    r13780 r15558  
    132132  response.clear ();
    133133  err = noError;
    134   if (gdbmptr == NULL) {
     134  if (db_ptr == NULL) {
    135135    // most likely a configuration problem
    136136    logout << text_t2ascii
    137        << "configuration error: queryfilter contains a null gdbmclass\n\n";
     137       << "configuration error: queryfilter contains a null dbclass\n\n";
    138138    err = configurationError;
    139139    return;
     
    151151  }
    152152  // open the database
    153   gdbmptr->setlogout(&logout);
    154   if (!gdbmptr->opendatabase (gdbm_filename, GDBM_READER, 100, false)) {
    155     // most likely a system problem (we have already checked that the
    156     // gdbm database exists)
     153  db_ptr->setlogout(&logout);
     154  if (!db_ptr->opendatabase (db_filename, DB_READER, 100, false)) {
     155    // most likely a system problem (we have already checked that the database exists)
    157156    logout << text_t2ascii
    158        << "system problem: open on gdbm database \""
    159        << gdbm_filename << "\" failed\n\n";
     157       << "system problem: open on database \"" << db_filename << "\" failed\n\n";
    160158    err = systemProblem;
    161159    return;
     
    189187     
    190188      // translate the document number
    191       if (!translate(gdbmptr, *docorder_here, trans_OID)) {
     189      if (!translate(db_ptr, *docorder_here, trans_OID)) {
    192190    logout << text_t2ascii
    193191           << "warning: could not translate mgpp document number \""
     
    250248  }
    251249
    252   gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     250  db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    253251  response.numDocs = queryresults.docs_matched;
    254252  response.isApprox = queryresults.is_approx;
     
    308306}
    309307
    310 // mgppsearchptr and gdbmptr are assumed to be valid
     308// mgppsearchptr and db_ptr are assumed to be valid
    311309void mgppqueryfilterclass::do_multi_query (const FilterRequest_t &request,
    312310                       const vector<queryparamclass> &query_params,
  • gsdl/trunk/src/colservr/mgqueryfilter.cpp

    r13780 r15558  
    170170    docresultmap::iterator docs_end = queryresults.docs.docset.end();
    171171    while (docs_here != docs_end) {
    172       if (OID_phrase_search (*((mgsearchclass*)textsearchptr), *gdbmptr, queryparams.index,
     172      if (OID_phrase_search (*((mgsearchclass*)textsearchptr), *db_ptr, queryparams.index,
    173173                 queryparams.subcollection, queryparams.language,
    174174                 longindex, queryparams.collection, *this_phrase,
     
    187187
    188188// do query that might involve multiple sub queries
    189 // mgsearchptr and gdbmptr are assumed to be valid
     189// mgsearchptr and db_ptr are assumed to be valid
    190190void mgqueryfilterclass::do_multi_query (const FilterRequest_t &request,
    191191                       const vector<queryparamclass> &query_params,
     
    297297  response.clear ();
    298298  err = noError;
    299   if (gdbmptr == NULL) {
     299  if (db_ptr == NULL) {
    300300    // most likely a configuration problem
    301301    logout << text_t2ascii
    302        << "configuration error: mgqueryfilter contains a null gdbmclass\n\n";
     302       << "configuration error: mgqueryfilter contains a null dbclass\n\n";
    303303    err = configurationError;
    304304    return;
     
    313313
    314314  // open the database
    315   gdbmptr->setlogout(&logout);
    316   if (!gdbmptr->opendatabase (gdbm_filename, GDBM_READER, 100, false)) {
    317     // most likely a system problem (we have already checked that the
    318     // gdbm database exists)
     315  db_ptr->setlogout(&logout);
     316  if (!db_ptr->opendatabase (db_filename, DB_READER, 100, false)) {
     317    // most likely a system problem (we have already checked that the database exists)
    319318    logout << text_t2ascii
    320        << "system problem: open on gdbm database \""
    321        << gdbm_filename << "\" failed\n\n";
     319       << "system problem: open on database \"" << db_filename << "\" failed\n\n";
    322320    err = systemProblem;
    323321    return;
     
    383381     
    384382      // translate the document number
    385       if (!translate(gdbmptr, *docorder_here, trans_OID)) {
     383      if (!translate(db_ptr, *docorder_here, trans_OID)) {
    386384    logout << text_t2ascii
    387385           << "warning: could not translate mg document number \""
     
    445443  }
    446444
    447   gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     445  db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    448446  response.numDocs = queryresults.docs_matched;
    449447  response.isApprox = queryresults.is_approx;
  • gsdl/trunk/src/colservr/phrasequeryfilter.cpp

    r9620 r15558  
    4747    while (docs_here != docs_end) {
    4848      if ((*docs_here).second.num_query_terms_matched == queryresults.orgterms.size() &&
    49       OID_phrase_search (*(mgsearchclass *)textsearchptr, *gdbmptr, queryparams.index,
     49      OID_phrase_search (*(mgsearchclass *)textsearchptr, *db_ptr, queryparams.index,
    5050                 queryparams.subcollection, queryparams.language,
    5151                 longindex, queryparams.collection, queryresults.orgterms,
  • gsdl/trunk/src/colservr/phrasesearch.cpp

    r9631 r15558  
    7878}
    7979
    80 static void get_all_docnums (gdbmclass &gdbm, text_t OID, vector<int> &docnum_list) {
     80static void get_all_docnums (dbclass &db, text_t OID, vector<int> &docnum_list) {
    8181
    8282  infodbclass OID_info;
    8383 
    8484  // get OID
    85   if (!gdbm.getinfo (OID, OID_info)) return;
     85  if (!db.getinfo (OID, OID_info)) return;
    8686  if (OID_info["hastxt"] == "1" && !OID_info["docnum"].empty()) {
    8787    docnum_list.push_back (OID_info["docnum"].getint());
     
    106106  text_tarray::const_iterator end = contains.end();
    107107  while (here != end) {
    108     get_all_docnums (gdbm, *here, docnum_list);
     108    get_all_docnums (db, *here, docnum_list);
    109109    ++here;
    110110  }
     
    162162// an OID. This function has not been coded with all situations in mind
    163163bool OID_phrase_search (mgsearchclass &mgsearch,
    164             gdbmclass &gdbm,
     164            dbclass &db,
    165165            const text_t &index,
    166166            const text_t &subcollection,
     
    173173  // get OID
    174174  infodbclass docnum_info;
    175   if (!gdbm.getinfo (docnum, docnum_info)) return false;
     175  if (!db.getinfo (docnum, docnum_info)) return false;
    176176  text_t &OID = docnum_info["section"];
    177177  if (OID.empty()) return false;
     
    201201      // -- this is going to make a slow process even slower
    202202      vector<int> docnum_list; text_t fulldoc;
    203       get_all_docnums (gdbm, OID, docnum_list);
     203      get_all_docnums (db, OID, docnum_list);
    204204      vector<int>::const_iterator this_docnum = docnum_list.begin();
    205205      vector<int>::const_iterator end_docnum = docnum_list.end();
     
    230230 
    231231  // get field
    232   if (!gdbm.getinfo (OID, OID_info)) return false;
     232  if (!db.getinfo (OID, OID_info)) return false;
    233233
    234234  bool result = false;
  • gsdl/trunk/src/colservr/phrasesearch.h

    r15430 r15558  
    3232#include "unitool.h"
    3333#include "mgsearch.h"
    34 #include "gdbmclass.h"
     34#include "dbclass.h"
    3535
    3636
     
    3939// situations in mind and expects mgsearch and gdbm set up ready to go
    4040bool OID_phrase_search (mgsearchclass &mgsearch,
    41             gdbmclass &gdbm,
     41            dbclass &db,
    4242            const text_t &index,
    4343            const text_t &subcollection,
  • gsdl/trunk/src/colservr/queryfilter.cpp

    r12871 r15558  
    3131
    3232// translate will return true if successful
    33 bool queryfilterclass::translate (gdbmclass *gdbmptr, int docnum, text_t &trans_OID) {
     33bool queryfilterclass::translate (dbclass *db_ptr, int docnum, text_t &trans_OID) {
    3434  infodbclass info;
    3535
     
    3737
    3838  // get the info
    39   if (gdbmptr == NULL) return false;
    40   if (!gdbmptr->getinfo(docnum, info)) return false;
     39  if (db_ptr == NULL) return false;
     40  if (!db_ptr->getinfo(docnum, info)) return false;
    4141
    4242  // translate
     
    187187
    188188queryfilterclass::queryfilterclass () {
    189   gdbmptr = NULL;
     189  db_ptr = NULL;
    190190  textsearchptr = NULL;
    191191  maxnumeric = 4;
     
    326326
    327327queryfilterclass::~queryfilterclass () {
    328   // don't delete gdbmptr or mgsearchptr here, they'll
     328  // don't delete db_ptr or mgsearchptr here, they'll
    329329  // be cleaned up by mggdbmsource
    330330}
     
    409409    indexstem = collection;
    410410  }
    411   gdbm_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", indexstem);
    412 
    413   if (littleEndian()) gdbm_filename += ".ldb";
    414   else gdbm_filename += ".bdb";
    415 
    416   if (!file_exists(gdbm_filename)) {
     411  db_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", indexstem);
     412
     413  if (littleEndian()) db_filename += ".ldb";
     414  else db_filename += ".bdb";
     415
     416  if (!file_exists(db_filename)) {
    417417    logout << text_t2ascii
    418        << "warning: gdbm database \"" //****
    419        << gdbm_filename << "\" does not exist\n\n";
    420     //return false; //****
     418       << "warning: database \"" << db_filename << "\" does not exist\n\n";
     419    //return false;
    421420  }
    422421
  • gsdl/trunk/src/colservr/queryfilter.h

    r15430 r15558  
    3535#include "comtypes.h"
    3636#include "filter.h"
    37 #include "gdbmclass.h"
     37#include "dbclass.h"
    3838#include "maptools.h"
    3939#include "search.h"
     
    4848  stringmap languagemap;
    4949
    50   text_t gdbm_filename;
     50  text_t db_filename;
    5151  text_t indexstem;
    52   gdbmclass *gdbmptr;
     52  dbclass *db_ptr;
    5353 
    5454  searchclass *textsearchptr;
     
    6363
    6464  // do query that might involve multiple sub queries
    65   // textsearchptr and gdbmptr are assumed to be valid
     65  // textsearchptr and db_ptr are assumed to be valid
    6666  virtual void do_multi_query (const FilterRequest_t &request,
    6767               const vector<queryparamclass> &query_params,
     
    7373  virtual ~queryfilterclass ();
    7474
    75   // the gdbmptr remains the responsability of the calling code
    76   void set_gdbmptr (gdbmclass *thegdbmptr) {gdbmptr=thegdbmptr;}
     75  // the db_ptr remains the responsibility of the calling code
     76  void set_db_ptr (dbclass *db_ptr_arg) { db_ptr = db_ptr_arg; }
    7777
    7878  // the testsearchptr remains the responsability of the calling code
     
    8383
    8484  text_t get_filter_name () {return "QueryFilter";}
    85   bool translate(gdbmclass *gdbmptr, int docnum, text_t &trans_OID);
     85  bool translate(dbclass *db_ptr, int docnum, text_t &trans_OID);
    8686  bool need_matching_docs (int filterResultOptions);
    8787  bool need_term_info (int filterResultOptions);
Note: See TracChangeset for help on using the changeset viewer.