Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

TestGetSetMethods.cpp

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2000-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: TestGetSetMethods.cpp,v 12.2 2005/10/25 23:41:22 mjc Exp $
00008  */
00009 
00010 /*
00011  * Do some regression tests for simple get/set access methods
00012  * on DbEnv, DbTxn, Db.  We don't currently test that they have
00013  * the desired effect, only that they operate and return correctly.
00014  */
00015 
00016 #include <db_cxx.h>
00017 #include <iostream.h>
00018 
00019 int main(int argc, char *argv[])
00020 {
00021         try {
00022                 DbEnv *dbenv = new DbEnv(0);
00023                 DbTxn *dbtxn;
00024                 u_int8_t conflicts[10];
00025 
00026                 dbenv->set_error_stream(&cerr);
00027                 dbenv->set_timeout(0x90000000,
00028                                    DB_SET_LOCK_TIMEOUT);
00029                 dbenv->set_lg_bsize(0x1000);
00030                 dbenv->set_lg_dir(".");
00031                 dbenv->set_lg_max(0x10000000);
00032                 dbenv->set_lg_regionmax(0x100000);
00033                 dbenv->set_lk_conflicts(conflicts, sizeof(conflicts));
00034                 dbenv->set_lk_detect(DB_LOCK_DEFAULT);
00035                 // exists, but is deprecated:
00036                 // dbenv->set_lk_max(0);
00037                 dbenv->set_lk_max_lockers(100);
00038                 dbenv->set_lk_max_locks(10);
00039                 dbenv->set_lk_max_objects(1000);
00040                 dbenv->set_mp_mmapsize(0x10000);
00041 
00042                 // Need to open the environment so we
00043                 // can get a transaction.
00044                 //
00045                 dbenv->open(".", DB_CREATE | DB_INIT_TXN |
00046                             DB_INIT_LOCK | DB_INIT_LOG |
00047                             DB_INIT_MPOOL,
00048                             0644);
00049 
00050                 dbenv->txn_begin(NULL, &dbtxn, DB_TXN_NOWAIT);
00051                 dbtxn->set_timeout(0xA0000000, DB_SET_TXN_TIMEOUT);
00052                 dbtxn->abort();
00053 
00054                 dbenv->close(0);
00055 
00056                 // We get a db, one for each type.
00057                 // That's because once we call (for instance)
00058                 // set_bt_minkey, DB 'knows' that this is a
00059                 // Btree Db, and it cannot be used to try Hash
00060                 // or Recno functions.
00061                 //
00062                 Db *db_bt = new Db(NULL, 0);
00063                 db_bt->set_bt_minkey(100);
00064                 db_bt->set_cachesize(0, 0x100000, 0);
00065                 db_bt->close(0);
00066 
00067                 Db *db_h = new Db(NULL, 0);
00068                 db_h->set_h_ffactor(0x10);
00069                 db_h->set_h_nelem(100);
00070                 db_h->set_lorder(0);
00071                 db_h->set_pagesize(0x10000);
00072                 db_h->close(0);
00073 
00074                 Db *db_re = new Db(NULL, 0);
00075                 db_re->set_re_delim('@');
00076                 db_re->set_re_pad(10);
00077                 db_re->set_re_source("re.in");
00078                 db_re->close(0);
00079 
00080                 Db *db_q = new Db(NULL, 0);
00081                 db_q->set_q_extentsize(200);
00082                 db_q->close(0);
00083 
00084         }
00085         catch (DbException &dbe) {
00086                 cerr << "Db Exception: " << dbe.what() << "\n";
00087         }
00088         return 0;
00089 }

Generated on Sun Dec 25 12:14:52 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2