Changeset 15584


Ignore:
Timestamp:
2008-05-20T10:22:16+12:00 (16 years ago)
Author:
mdewsnip
Message:

(Adding new DB support) Changed the gdbmsource classes to use dbclass instead of gdbmclass, as part of reducing the dependence on gdbm.

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

Legend:

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

    r15558 r15584  
    2929#include "colservrconfig.h"
    3030#include "gsdlsitecfg.h"
     31#include "gdbmclass.h"
    3132#include "filter.h"
    3233#include "browsefilter.h"
     
    239240    // add a mg and gdbm source
    240241    mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
    241     mggdbmsource->set_gdbmptr (gdbmhandler);
     242    mggdbmsource->set_db_ptr (gdbmhandler);
    242243    mggdbmsource->set_textsearchptr (mgsearch);
    243244    cserver->add_source (mggdbmsource);
     
    254255    // add a mg and gdbm source
    255256    mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
    256     mggdbmsource->set_gdbmptr (gdbmhandler);
     257    mggdbmsource->set_db_ptr (gdbmhandler);
    257258    mggdbmsource->set_textsearchptr (mgppsearch);
    258259    cserver->add_source (mggdbmsource);
     
    270271    // add a lucene and gdbm source
    271272    lucenegdbmsourceclass *lucenegdbmsource = new lucenegdbmsourceclass ();
    272     lucenegdbmsource->set_gdbmptr (gdbmhandler);
     273    lucenegdbmsource->set_db_ptr (gdbmhandler);
    273274    lucenegdbmsource->set_textsearchptr (lucenesearch);
    274275    cserver->add_source (lucenegdbmsource);
  • gsdl/trunk/src/colservr/gdbmsource.cpp

    r13780 r15584  
    3131
    3232gdbmsourceclass::gdbmsourceclass () {
    33   gdbmptr = NULL;
     33  db_ptr = NULL;
    3434  textsearchptr = NULL;
    3535  classname = "gdbmsource";
     
    3737
    3838gdbmsourceclass::~gdbmsourceclass () {
    39   if (gdbmptr != NULL) delete gdbmptr;
     39  if (db_ptr != NULL) delete db_ptr;
    4040  if (textsearchptr != NULL) delete textsearchptr;
    4141}
     
    117117    indexstem = collection;
    118118  }
    119   gdbm_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", indexstem);
    120   if (littleEndian()) gdbm_filename += ".ldb";
    121   else gdbm_filename += ".bdb";
    122 
    123   if (!file_exists(gdbm_filename)) {
     119  db_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", indexstem);
     120  if (littleEndian()) db_filename += ".ldb";
     121  else db_filename += ".bdb";
     122
     123  if (!file_exists(db_filename)) {
    124124    logout << text_t2ascii
    125        << "warning: gdbm database \"" //****
    126        << gdbm_filename << "\" does not exist\n\n";
    127     // return false; //****
     125       << "warning: database \"" << db_filename << "\" does not exist\n\n";
     126    // return false;
    128127  }
    129128 
     
    137136
    138137  err = noError;
    139   if (gdbmptr == NULL) {
     138  if (db_ptr == NULL) {
    140139    // most likely a configuration problem
    141140    logout << text_t2ascii
    142        << "configuration error: " << classname << " contains a null gdbmclass\n\n";
     141       << "configuration error: " << classname << " contains a null dbclass\n\n";
    143142    err = configurationError;
    144143    return true;
     
    146145
    147146  // open the database
    148   gdbmptr->setlogout(&logout);
    149   if (!gdbmptr->opendatabase (gdbm_filename, GDBM_READER, 100, false)) {
    150     // most likely a system problem (we have already checked that the
    151     // gdbm database exists)
     147  db_ptr->setlogout(&logout);
     148  if (!db_ptr->opendatabase (db_filename, DB_READER, 100, false)) {
     149    // most likely a system problem (we have already checked that the database exists)
    152150    logout << text_t2ascii
    153        << "system problem: open on gdbm database \""
    154        << gdbm_filename << "\" failed\n\n";
     151       << "system problem: open on database \"" << db_filename << "\" failed\n\n";
    155152    err = systemProblem;
    156153    return true;
     
    158155
    159156  infodbclass info;
    160   OIDout = gdbmptr->translate_OID (OIDin, info);
    161   gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     157  OIDout = db_ptr->translate_OID (OIDin, info);
     158  db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    162159  return true;
    163160}
     
    172169
    173170  err = noError;
    174   if (gdbmptr == NULL) {
     171  if (db_ptr == NULL) {
    175172    // most likely a configuration problem
    176173    logout << text_t2ascii
    177        << "configuration error: " << classname <<" contains a null gdbmclass\n\n";
     174       << "configuration error: " << classname <<" contains a null dbclass\n\n";
    178175    err = configurationError;
    179176    return true;
     
    181178
    182179  // open the database
    183   gdbmptr->setlogout(&logout);
    184   if (!gdbmptr->opendatabase (gdbm_filename, GDBM_READER, 100, false)) {
    185     // most likely a system problem (we have already checked that the
    186     // gdbm database exists)
     180  db_ptr->setlogout(&logout);
     181  if (!db_ptr->opendatabase (db_filename, DB_READER, 100, false)) {
     182    // most likely a system problem (we have already checked that the database exists)
    187183    logout << text_t2ascii
    188        << "system problem: open on gdbm database \""
    189        << gdbm_filename << "\" failed\n\n";
     184       << "system problem: open on database \"" << db_filename << "\" failed\n\n";
    190185    err = systemProblem;
    191186    return true;
     
    204199  while (this_OID != end_OID) {
    205200    infodbclass info;
    206     if (!gdbmptr->getinfo(*this_OID, info)) return false;
     201    if (!db_ptr->getinfo(*this_OID, info)) return false;
    207202
    208203    // adjust the metadata
     
    260255          parentOID = thisparent;
    261256          parentcontents.erase(parentcontents.begin(), parentcontents.end());
    262           if (gdbmptr->getinfo(parentOID, parentinfo)) {
     257          if (db_ptr->getinfo(parentOID, parentinfo)) {
    263258        text_t &parentinfocontains = parentinfo["contains"];
    264259        if (!parentinfocontains.empty())
     
    316311  }
    317312
    318   gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     313  db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    319314  return true;
    320315}
     
    327322
    328323  err = noError;
    329   if (gdbmptr == NULL) {
     324  if (db_ptr == NULL) {
    330325    // most likely a configuration problem
    331326    logout << text_t2ascii
    332        << "configuration error: " << classname << " contains a null gdbmclass\n\n";
     327       << "configuration error: " << classname << " contains a null dbclass\n\n";
    333328    err = configurationError;
    334329    return true;
     
    336331
    337332  // open the database
    338   gdbmptr->setlogout(&logout);
    339   if (!gdbmptr->opendatabase (gdbm_filename, GDBM_READER, 100, false)) {
    340     // most likely a system problem (we have already checked that the
    341     // gdbm database exists)
     333  db_ptr->setlogout(&logout);
     334  if (!db_ptr->opendatabase (db_filename, DB_READER, 100, false)) {
     335    // most likely a system problem (we have already checked that the database exists)
    342336    logout << text_t2ascii
    343        << "system problem: open on gdbm database \""
    344        << gdbm_filename << "\" failed\n\n";
     337       << "system problem: open on database \"" << db_filename << "\" failed\n\n";
    345338    err = systemProblem;
    346339    return true;
     
    351344    translate_OID (OID, tOID, err, logout);
    352345  infodbclass info;
    353   if (!gdbmptr->getinfo(tOID, info)) {
    354     gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     346  if (!db_ptr->getinfo(tOID, info)) {
     347    db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    355348    return false;
    356349  }
     
    367360  }
    368361
    369   gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     362  db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    370363  return true;
    371364}
  • gsdl/trunk/src/colservr/gdbmsource.h

    r15430 r15584  
    3131#include "text_t.h"
    3232#include "comtypes.h"
    33 #include "gdbmclass.h"
     33#include "dbclass.h"
    3434#include "maptools.h"
    3535#include "search.h"
     
    5959  text_tarray parentcontents;
    6060
    61   text_t gdbm_filename;
    62   gdbmclass *gdbmptr;
     61  text_t db_filename;
     62  dbclass *db_ptr;
    6363 
    6464  searchclass *textsearchptr;
     
    6868  virtual ~gdbmsourceclass ();
    6969
    70   // the gdbmptr remains the responsability of the calling code
    71   void set_gdbmptr (gdbmclass *thegdbmptr) {gdbmptr=thegdbmptr;}
     70  // the DB ptr remains the responsibility of the calling code
     71  void set_db_ptr (dbclass *db_ptr_arg) { db_ptr = db_ptr_arg; }
    7272
    73   // the textsearchptr remains the responsability of the calling code
     73  // the textsearchptr remains the responsibility of the calling code
    7474  void set_textsearchptr (searchclass *thetextsearchptr) {textsearchptr=thetextsearchptr;}
    7575
  • gsdl/trunk/src/colservr/lucenegdbmsource.cpp

    r15162 r15584  
    4444  outconvertclass text_t2ascii;
    4545  err = noError;
    46   if (gdbmptr == NULL) {
     46  if (db_ptr == NULL) {
    4747    // most likely a configuration problem
    4848    logout << text_t2ascii
    49        << "configuration error: lucenegdbmsource contains a null gdbmclass\n\n";
     49       << "configuration error: lucenegdbmsource contains a null dbclass\n\n";
    5050    err = configurationError;
    5151    return true;
     
    5353
    5454  // open the database
    55   gdbmptr->setlogout(&logout);
    56   if (!gdbmptr->opendatabase (gdbm_filename, GDBM_READER, 100, false)) {
    57     // most likely a system problem (we have already checked that the
    58     // gdbm database exists)
     55  db_ptr->setlogout(&logout);
     56  if (!db_ptr->opendatabase (db_filename, DB_READER, 100, false)) {
     57    // most likely a system problem (we have already checked that the database exists)
    5958    logout << text_t2ascii
    60        << "system problem: open on gdbm database \""
    61        << gdbm_filename << "\" failed\n\n";
     59       << "system problem: open on database \"" << db_filename << "\" failed\n\n";
    6260    err = systemProblem;
    6361    return true;
     
    6866    translate_OID (OID, tOID, err, logout);
    6967  infodbclass info;
    70   if (!gdbmptr->getinfo(tOID, info)) {
    71     gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     68  if (!db_ptr->getinfo(tOID, info)) {
     69    db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    7270    return false;
    7371  }
     
    8280  get_top(tOID, parent_OID);
    8381 
    84   // locate the parent info ingdbm db
    85   if (!gdbmptr->getinfo(parent_OID, info)) {
    86     gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     82  if (!db_ptr->getinfo(parent_OID, info)) {
     83    db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    8784    return false;
    8885  }
     
    9289 
    9390  doc.clear();
    94   gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     91  db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    9592  expat_document(full_path_to_doc, ((lucenesearchclass*)textsearchptr)->gdbm_level, text_t(docnum), doc);
    9693  return true;
Note: See TracChangeset for help on using the changeset viewer.