BadgerDB
/afs/cs.wisc.edu/u/s/a/sangmin/private/btree/src/main.cpp
00001 
00008 #include <vector>
00009 #include "btree.h"
00010 #include "page.h"
00011 #include "filescan.h"
00012 #include "page_iterator.h"
00013 #include "file_iterator.h"
00014 #include "exceptions/insufficient_space_exception.h"
00015 #include "exceptions/index_scan_completed_exception.h"
00016 #include "exceptions/file_not_found_exception.h"
00017 #include "exceptions/no_such_key_found_exception.h"
00018 #include "exceptions/bad_scanrange_exception.h"
00019 #include "exceptions/bad_opcodes_exception.h"
00020 #include "exceptions/scan_not_initialized_exception.h"
00021 #include "exceptions/end_of_file_exception.h"
00022 
00023 #define checkPassFail(a, b)                                         \
00024 {                                                                   \
00025   if(a == b)                                                        \
00026     std::cout << "\nTest passed at line no:" << __LINE__ << "\n";   \
00027   else                                                              \
00028   {                                                                 \
00029     std::cout << "\nTest FAILS at line no:" << __LINE__;            \
00030     std::cout << "\nExpected no of records:" << b;                  \
00031     std::cout << "\nActual no of records found:" << a;              \
00032     std::cout << std::endl;                                         \
00033     exit(1);                                                        \
00034   }                                                                 \
00035 }
00036 
00037 using namespace badgerdb;
00038 
00039 // -----------------------------------------------------------------------------
00040 // Globals
00041 // -----------------------------------------------------------------------------
00042 int testNum = 1;
00043 const std::string relationName = "relA";
00044 //If the relation size is changed then the second parameter 2 chechPassFail may need to be changed to number of record that are expected to be found during the scan, else tests will erroneously be reported to have failed.
00045 const int relationSize = 5000;
00046 std::string intIndexName, doubleIndexName, stringIndexName;
00047 
00048 // This is the structure for tuples in the base relation
00049 
00050 typedef struct tuple {
00051   int i;
00052   double d;
00053   char s[64];
00054 } RECORD;
00055 
00056 PageFile* file1;
00057 RecordId rid;
00058 RECORD record1;
00059 std::string dbRecord1;
00060 
00061 BufMgr * bufMgr = new BufMgr(100);
00062 
00063 // -----------------------------------------------------------------------------
00064 // Forward declarations
00065 // -----------------------------------------------------------------------------
00066 
00067 void createRelationForward();
00068 void createRelationBackward();
00069 void createRelationRandom();
00070 void intTests();
00071 int intScan(BTreeIndex *index, int lowVal, Operator lowOp, int highVal, Operator highOp);
00072 void indexTests();
00073 void doubleTests();
00074 int doubleScan(BTreeIndex *index, double lowVal, Operator lowOp, double highVal, Operator highOp);
00075 void stringTests();
00076 int stringScan(BTreeIndex *index, int lowVal, Operator lowOp, int highVal, Operator highOp);
00077 void test1();
00078 void test2();
00079 void test3();
00080 void errorTests();
00081 void deleteRelation();
00082 
00083 int main(int argc, char **argv)
00084 {
00085   if( argc != 2 )
00086   {
00087     std::cout << "Expects one argument as a number between 1 to 3 to choose datatype of key.\n";
00088     std::cout << "For INTEGER keys run as: ./badgerdb_main 1\n";
00089     std::cout << "For DOUBLE keys run as: ./badgerdb_main 2\n";
00090     std::cout << "For STRING keys run as: ./badgerdb_main 3\n";
00091     return 0;
00092   }
00093 
00094   sscanf(argv[1],"%d",&testNum);
00095 
00096   switch(testNum)
00097   {
00098     case 1:
00099       std::cout << "leaf size:" << INTARRAYLEAFSIZE << " non-leaf size:" << INTARRAYNONLEAFSIZE << std::endl;
00100       break;
00101     case 2:
00102       std::cout << "leaf size:" << DOUBLEARRAYLEAFSIZE << " non-leaf size:" << DOUBLEARRAYNONLEAFSIZE << std::endl;
00103       break;
00104     case 3:
00105       std::cout << "leaf size:" << STRINGARRAYLEAFSIZE << " non-leaf size:" << STRINGARRAYNONLEAFSIZE << std::endl;
00106       break;
00107   }
00108 
00109 
00110   // Clean up from any previous runs that crashed.
00111   try
00112   {
00113     File::remove(relationName);
00114   }
00115   catch(FileNotFoundException)
00116   {
00117   }
00118 
00119   {
00120     // Create a new database file.
00121     PageFile new_file = PageFile::create(relationName);
00122 
00123     // Allocate some pages and put data on them.
00124     for (int i = 0; i < 20; ++i)
00125     {
00126       PageId new_page_number;
00127       Page new_page = new_file.allocatePage(new_page_number);
00128 
00129       sprintf(record1.s, "%05d string record", i);
00130       record1.i = i;
00131       record1.d = (double)i;
00132       std::string new_data(reinterpret_cast<char*>(&record1), sizeof(record1));
00133 
00134       new_page.insertRecord(new_data);
00135       new_file.writePage(new_page_number, new_page);
00136     }
00137 
00138   }
00139   // new_file goes out of scope here, so file is automatically closed.
00140 
00141   {
00142     FileScan fscan(relationName, bufMgr);
00143 
00144     try
00145     {
00146       RecordId scanRid;
00147       while(1)
00148       {
00149         fscan.scanNext(scanRid);
00150         //Assuming RECORD.i is our key, lets extract the key, which we know is INTEGER and whose byte offset is also know inside the record. 
00151         std::string recordStr = fscan.getRecord();
00152         const char *record = recordStr.c_str();
00153         int key = *((int *)(record + offsetof (RECORD, i)));
00154         std::cout << "Extracted : " << key << std::endl;
00155       }
00156     }
00157     catch(EndOfFileException e)
00158     {
00159       std::cout << "Read all records" << std::endl;
00160     }
00161   }
00162   // filescan goes out of scope here, so relation file gets closed.
00163 
00164   File::remove(relationName);
00165 
00166   test1();
00167   test2();
00168   test3();
00169   //errorTests();
00170 
00171   return 1;
00172 }
00173 
00174 void test1()
00175 {
00176   // Create a relation with tuples valued 0 to relationSize and perform index tests 
00177   // on attributes of all three types (int, double, string)
00178   std::cout << "---------------------" << std::endl;
00179   std::cout << "createRelationForward" << std::endl;
00180   createRelationForward();
00181   indexTests();
00182   deleteRelation();
00183 }
00184 
00185 void test2()
00186 {
00187   // Create a relation with tuples valued 0 to relationSize in reverse order and perform index tests 
00188   // on attributes of all three types (int, double, string)
00189   std::cout << "----------------------" << std::endl;
00190   std::cout << "createRelationBackward" << std::endl;
00191   createRelationBackward();
00192   indexTests();
00193   deleteRelation();
00194 }
00195 
00196 void test3()
00197 {
00198   // Create a relation with tuples valued 0 to relationSize in random order and perform index tests 
00199   // on attributes of all three types (int, double, string)
00200   std::cout << "--------------------" << std::endl;
00201   std::cout << "createRelationRandom" << std::endl;
00202   createRelationRandom();
00203   indexTests();
00204   deleteRelation();
00205 }
00206 
00207 // -----------------------------------------------------------------------------
00208 // createRelationForward
00209 // -----------------------------------------------------------------------------
00210 
00211 void createRelationForward()
00212 {
00213   std::vector<RecordId> ridVec;
00214   // destroy any old copies of relation file
00215   try
00216   {
00217     File::remove(relationName);
00218   }
00219   catch(FileNotFoundException e)
00220   {
00221   }
00222 
00223   file1 = new PageFile(relationName, true);
00224 
00225   // initialize all of record1.s to keep purify happy
00226   memset(record1.s, ' ', sizeof(record1.s));
00227   PageId new_page_number;
00228   Page new_page = file1->allocatePage(new_page_number);
00229 
00230   // Insert a bunch of tuples into the relation.
00231   for(int i = 0; i < relationSize; i++ )
00232   {
00233     sprintf(record1.s, "%05d string record", i);
00234     record1.i = i;
00235     record1.d = (double)i;
00236     std::string new_data(reinterpret_cast<char*>(&record1), sizeof(record1));
00237 
00238     while(1)
00239     {
00240       try
00241       {
00242         new_page.insertRecord(new_data);
00243         break;
00244       }
00245       catch(InsufficientSpaceException e)
00246       {
00247         file1->writePage(new_page_number, new_page);
00248         new_page = file1->allocatePage(new_page_number);
00249       }
00250     }
00251   }
00252 
00253   file1->writePage(new_page_number, new_page);
00254 }
00255 
00256 // -----------------------------------------------------------------------------
00257 // createRelationBackward
00258 // -----------------------------------------------------------------------------
00259 
00260 void createRelationBackward()
00261 {
00262   // destroy any old copies of relation file
00263   try
00264   {
00265     File::remove(relationName);
00266   }
00267   catch(FileNotFoundException e)
00268   {
00269   }
00270   file1 = new PageFile(relationName, true);
00271 
00272   // initialize all of record1.s to keep purify happy
00273   memset(record1.s, ' ', sizeof(record1.s));
00274   PageId new_page_number;
00275   Page new_page = file1->allocatePage(new_page_number);
00276 
00277   // Insert a bunch of tuples into the relation.
00278   for(int i = relationSize - 1; i >= 0; i-- )
00279   {
00280     sprintf(record1.s, "%05d string record", i);
00281     record1.i = i;
00282     record1.d = i;
00283 
00284     std::string new_data(reinterpret_cast<char*>(&record1), sizeof(RECORD));
00285 
00286     while(1)
00287     {
00288       try
00289       {
00290         new_page.insertRecord(new_data);
00291         break;
00292       }
00293       catch(InsufficientSpaceException e)
00294       {
00295         file1->writePage(new_page_number, new_page);
00296         new_page = file1->allocatePage(new_page_number);
00297       }
00298     }
00299   }
00300 
00301   file1->writePage(new_page_number, new_page);
00302 }
00303 
00304 // -----------------------------------------------------------------------------
00305 // createRelationRandom
00306 // -----------------------------------------------------------------------------
00307 
00308 void createRelationRandom()
00309 {
00310   // destroy any old copies of relation file
00311   try
00312   {
00313     File::remove(relationName);
00314   }
00315   catch(FileNotFoundException e)
00316   {
00317   }
00318   file1 = new PageFile(relationName, true);
00319 
00320   // initialize all of record1.s to keep purify happy
00321   memset(record1.s, ' ', sizeof(record1.s));
00322   PageId new_page_number;
00323   Page new_page = file1->allocatePage(new_page_number);
00324 
00325   // insert records in random order
00326 
00327   std::vector<int> intvec(relationSize);
00328   for( int i = 0; i < relationSize; i++ )
00329   {
00330     intvec[i] = i;
00331   }
00332 
00333   long pos;
00334   int val;
00335   int i = 0;
00336   while( i < relationSize )
00337   {
00338     pos = random() % (relationSize-i);
00339     val = intvec[pos];
00340     sprintf(record1.s, "%05d string record", val);
00341     record1.i = val;
00342     record1.d = val;
00343 
00344     std::string new_data(reinterpret_cast<char*>(&record1), sizeof(RECORD));
00345 
00346     while(1)
00347     {
00348       try
00349       {
00350         new_page.insertRecord(new_data);
00351         break;
00352       }
00353       catch(InsufficientSpaceException e)
00354       {
00355         file1->writePage(new_page_number, new_page);
00356         new_page = file1->allocatePage(new_page_number);
00357       }
00358     }
00359 
00360     int temp = intvec[relationSize-1-i];
00361     intvec[relationSize-1-i] = intvec[pos];
00362     intvec[pos] = temp;
00363     i++;
00364   }
00365   
00366   file1->writePage(new_page_number, new_page);
00367 }
00368 
00369 // -----------------------------------------------------------------------------
00370 // indexTests
00371 // -----------------------------------------------------------------------------
00372 
00373 void indexTests()
00374 {
00375   if(testNum == 1)
00376   {
00377     intTests();
00378     try
00379     {
00380       File::remove(intIndexName);
00381     }
00382     catch(FileNotFoundException e)
00383     {
00384     }
00385   }
00386   else if(testNum == 2)
00387   {
00388     doubleTests();
00389     try
00390     {
00391       File::remove(doubleIndexName);
00392     }
00393     catch(FileNotFoundException e)
00394     {
00395     }
00396   }
00397   else if(testNum == 3)
00398   {
00399     stringTests();
00400     try
00401     {
00402       File::remove(stringIndexName);
00403     }
00404     catch(FileNotFoundException e)
00405     {
00406     }
00407   }
00408 }
00409 
00410 // -----------------------------------------------------------------------------
00411 // intTests
00412 // -----------------------------------------------------------------------------
00413 
00414 void intTests()
00415 {
00416   std::cout << "Create a B+ Tree index on the integer field" << std::endl;
00417   BTreeIndex index(relationName, intIndexName, bufMgr, offsetof(tuple,i), INTEGER);
00418 
00419   // run some tests
00420   checkPassFail(intScan(&index,25,GT,40,LT), 14)
00421   checkPassFail(intScan(&index,20,GTE,35,LTE), 16)
00422   checkPassFail(intScan(&index,-3,GT,3,LT), 3)
00423   checkPassFail(intScan(&index,996,GT,1001,LT), 4)
00424   checkPassFail(intScan(&index,0,GT,1,LT), 0)
00425   checkPassFail(intScan(&index,300,GT,400,LT), 99)
00426   checkPassFail(intScan(&index,3000,GTE,4000,LT), 1000)
00427 }
00428 
00429 int intScan(BTreeIndex * index, int lowVal, Operator lowOp, int highVal, Operator highOp)
00430 {
00431   RecordId scanRid;
00432   Page *curPage;
00433 
00434   std::cout << "Scan for ";
00435   if( lowOp == GT ) { std::cout << "("; } else { std::cout << "["; }
00436   std::cout << lowVal << "," << highVal;
00437   if( highOp == LT ) { std::cout << ")"; } else { std::cout << "]"; }
00438   std::cout << std::endl;
00439 
00440   int numResults = 0;
00441   
00442   try
00443   {
00444     index->startScan(&lowVal, lowOp, &highVal, highOp);
00445   }
00446   catch(NoSuchKeyFoundException e)
00447   {
00448     std::cout << "No Key Found satisfying the scan criteria." << std::endl;
00449     return 0;
00450   }
00451 
00452   while(1)
00453   {
00454     try
00455     {
00456       index->scanNext(scanRid);
00457       bufMgr->readPage(file1, scanRid.page_number, curPage);
00458       RECORD myRec = *(reinterpret_cast<const RECORD*>(curPage->getRecord(scanRid).data()));
00459       bufMgr->unPinPage(file1, scanRid.page_number, false);
00460 
00461       if( numResults < 5 )
00462       {
00463         std::cout << "at:" << scanRid.page_number << "," << scanRid.slot_number;
00464         std::cout << " -->:" << myRec.i << ":" << myRec.d << ":" << myRec.s << ":" <<std::endl;
00465       }
00466       else if( numResults == 5 )
00467       {
00468         std::cout << "..." << std::endl;
00469       }
00470     }
00471     catch(IndexScanCompletedException e)
00472     {
00473       break;
00474     }
00475 
00476     numResults++;
00477   }
00478 
00479   if( numResults >= 5 )
00480   {
00481     std::cout << "Number of results: " << numResults << std::endl;
00482   }
00483   index->endScan();
00484   std::cout << std::endl;
00485 
00486   return numResults;
00487 }
00488 
00489 // -----------------------------------------------------------------------------
00490 // doubleTests
00491 // -----------------------------------------------------------------------------
00492 
00493 void doubleTests()
00494 {
00495   std::cout << "Create a B+ Tree index on the double field" << std::endl;
00496   BTreeIndex index(relationName, doubleIndexName, bufMgr, offsetof(tuple,d), DOUBLE);
00497 
00498   // run some tests
00499   checkPassFail(doubleScan(&index,25,GT,40,LT), 14)
00500   checkPassFail(doubleScan(&index,20,GTE,35,LTE), 16)
00501   checkPassFail(doubleScan(&index,-3,GT,3,LT), 3)
00502   checkPassFail(doubleScan(&index,996,GT,1001,LT), 4)
00503   checkPassFail(doubleScan(&index,0,GT,1,LT), 0)
00504   checkPassFail(doubleScan(&index,300,GT,400,LT), 99)
00505   checkPassFail(doubleScan(&index,3000,GTE,4000,LT), 1000)
00506 }
00507 
00508 int doubleScan(BTreeIndex * index, double lowVal, Operator lowOp, double highVal, Operator highOp)
00509 {
00510   RecordId scanRid;
00511   Page *curPage;
00512 
00513   std::cout << "Scan for ";
00514   if( lowOp == GT ) { std::cout << "("; } else { std::cout << "["; }
00515   std::cout << lowVal << "," << highVal;
00516   if( highOp == LT ) { std::cout << ")"; } else { std::cout << "]"; }
00517   std::cout << std::endl;
00518 
00519   int numResults = 0;
00520 
00521   try
00522   {
00523     index->startScan(&lowVal, lowOp, &highVal, highOp);
00524   }
00525   catch(NoSuchKeyFoundException e)
00526   {
00527     std::cout << "No Key Found satisfying the scan criteria." << std::endl;
00528     return 0;
00529   }
00530 
00531   while(1)
00532   {
00533     try
00534     {
00535       index->scanNext(scanRid);
00536       bufMgr->readPage(file1, scanRid.page_number, curPage);
00537       RECORD myRec = *(reinterpret_cast<const RECORD*>(curPage->getRecord(scanRid).data()));
00538       bufMgr->unPinPage(file1, scanRid.page_number, false);
00539 
00540       if( numResults < 5 )
00541       {
00542         std::cout << "rid:" << scanRid.page_number << "," << scanRid.slot_number;
00543         std::cout << " -->:" << myRec.i << ":" << myRec.d << ":" << myRec.s << ":" <<std::endl;
00544       }
00545       else if( numResults == 5 )
00546       {
00547         std::cout << "..." << std::endl;
00548       }
00549     }
00550     catch(IndexScanCompletedException e)
00551     {
00552       break;
00553     }
00554 
00555     numResults++;
00556   }
00557 
00558   if( numResults >= 5 )
00559   {
00560     std::cout << "Number of results: " << numResults << std::endl;
00561   }
00562   index->endScan();
00563   std::cout << std::endl;
00564 
00565   return numResults;
00566 }
00567 
00568 // -----------------------------------------------------------------------------
00569 // stringTests
00570 // -----------------------------------------------------------------------------
00571 
00572 void stringTests()
00573 {
00574   std::cout << "Create a B+ Tree index on the string field" << std::endl;
00575   BTreeIndex index(relationName, stringIndexName, bufMgr, offsetof(tuple,s), STRING);
00576 
00577   // run some tests
00578   checkPassFail(stringScan(&index,25,GT,40,LT), 14)
00579   checkPassFail(stringScan(&index,20,GTE,35,LTE), 16)
00580   checkPassFail(stringScan(&index,-3,GT,3,LT), 3)
00581   checkPassFail(stringScan(&index,996,GT,1001,LT), 4)
00582   checkPassFail(stringScan(&index,0,GT,1,LT), 0)
00583   checkPassFail(stringScan(&index,300,GT,400,LT), 99)
00584   checkPassFail(stringScan(&index,3000,GTE,4000,LT), 1000)
00585 }
00586 
00587 int stringScan(BTreeIndex * index, int lowVal, Operator lowOp, int highVal, Operator highOp)
00588 {
00589   RecordId scanRid;
00590   Page *curPage;
00591 
00592   std::cout << "Scan for ";
00593   if( lowOp == GT ) { std::cout << "("; } else { std::cout << "["; }
00594   std::cout << lowVal << "," << highVal;
00595   if( highOp == LT ) { std::cout << ")"; } else { std::cout << "]"; }
00596   std::cout << std::endl;
00597 
00598   char lowValStr[100];
00599   sprintf(lowValStr,"%05d string record",lowVal);
00600   char highValStr[100];
00601   sprintf(highValStr,"%05d string record",highVal);
00602 
00603   int numResults = 0;
00604 
00605   try
00606   {
00607     index->startScan(lowValStr, lowOp, highValStr, highOp);
00608   }
00609   catch(NoSuchKeyFoundException e)
00610   {
00611     std::cout << "No Key Found satisfying the scan criteria." << std::endl;
00612     return 0;
00613   }
00614 
00615   while(1)
00616   {
00617     try
00618     {
00619       index->scanNext(scanRid);
00620       bufMgr->readPage(file1, scanRid.page_number, curPage);
00621       RECORD myRec = *(reinterpret_cast<const RECORD*>(curPage->getRecord(scanRid).data()));
00622       bufMgr->unPinPage(file1, scanRid.page_number, false);
00623 
00624       if( numResults < 5 )
00625       {
00626         std::cout << "rid:" << scanRid.page_number << "," << scanRid.slot_number;
00627         std::cout << " -->:" << myRec.i << ":" << myRec.d << ":" << myRec.s << ":" <<std::endl;
00628       }
00629       else if( numResults == 5 )
00630       {
00631         std::cout << "..." << std::endl;
00632       }
00633     }
00634     catch(IndexScanCompletedException e)
00635     {
00636       break;
00637     }
00638 
00639     numResults++;
00640   }
00641 
00642   if( numResults >= 5 )
00643   {
00644     std::cout << "Number of results: " << numResults << std::endl;
00645   }
00646   index->endScan();
00647   std::cout << std::endl;
00648 
00649   return numResults;
00650 }
00651 
00652 // -----------------------------------------------------------------------------
00653 // errorTests
00654 // -----------------------------------------------------------------------------
00655 
00656 void errorTests()
00657 {
00658   std::cout << "Error handling tests" << std::endl;
00659   std::cout << "--------------------" << std::endl;
00660   // Given error test
00661 
00662   try
00663   {
00664     File::remove(relationName);
00665   }
00666   catch(FileNotFoundException e)
00667   {
00668   }
00669 
00670   file1 = new PageFile(relationName, true);
00671   
00672   // initialize all of record1.s to keep purify happy
00673   memset(record1.s, ' ', sizeof(record1.s));
00674   PageId new_page_number;
00675   Page new_page = file1->allocatePage(new_page_number);
00676 
00677   // Insert a bunch of tuples into the relation.
00678   for(int i = 0; i <10; i++ ) 
00679   {
00680     sprintf(record1.s, "%05d string record", i);
00681     record1.i = i;
00682     record1.d = (double)i;
00683     std::string new_data(reinterpret_cast<char*>(&record1), sizeof(record1));
00684 
00685     while(1)
00686     {
00687       try
00688       {
00689         new_page.insertRecord(new_data);
00690         break;
00691       }
00692       catch(InsufficientSpaceException e)
00693       {
00694         file1->writePage(new_page_number, new_page);
00695         new_page = file1->allocatePage(new_page_number);
00696       }
00697     }
00698   }
00699 
00700   file1->writePage(new_page_number, new_page);
00701 
00702   BTreeIndex index(relationName, intIndexName, bufMgr, offsetof(tuple,i), INTEGER);
00703   
00704   int int2 = 2;
00705   int int5 = 5;
00706 
00707   // Scan Tests
00708   std::cout << "Call endScan before startScan" << std::endl;
00709   try
00710   {
00711     index.endScan();
00712     std::cout << "ScanNotInitialized Test 1 Failed." << std::endl;
00713   }
00714   catch(ScanNotInitializedException e)
00715   {
00716     std::cout << "ScanNotInitialized Test 1 Passed." << std::endl;
00717   }
00718   
00719   std::cout << "Call scanNext before startScan" << std::endl;
00720   try
00721   {
00722     RecordId foo;
00723     index.scanNext(foo);
00724     std::cout << "ScanNotInitialized Test 2 Failed." << std::endl;
00725   }
00726   catch(ScanNotInitializedException e)
00727   {
00728     std::cout << "ScanNotInitialized Test 2 Passed." << std::endl;
00729   }
00730   
00731   std::cout << "Scan with bad lowOp" << std::endl;
00732   try
00733   {
00734     index.startScan(&int2, LTE, &int5, LTE);
00735     std::cout << "BadOpcodesException Test 1 Failed." << std::endl;
00736   }
00737   catch(BadOpcodesException e)
00738   {
00739     std::cout << "BadOpcodesException Test 1 Passed." << std::endl;
00740   }
00741   
00742   std::cout << "Scan with bad highOp" << std::endl;
00743   try
00744   {
00745     index.startScan(&int2, GTE, &int5, GTE);
00746     std::cout << "BadOpcodesException Test 2 Failed." << std::endl;
00747   }
00748   catch(BadOpcodesException e)
00749   {
00750     std::cout << "BadOpcodesException Test 2 Passed." << std::endl;
00751   }
00752 
00753 
00754   std::cout << "Scan with bad range" << std::endl;
00755   try
00756   {
00757     index.startScan(&int5, GTE, &int2, LTE);
00758     std::cout << "BadScanrangeException Test 1 Failed." << std::endl;
00759   }
00760   catch(BadScanrangeException e)
00761   {
00762     std::cout << "BadScanrangeException Test 1 Passed." << std::endl;
00763   }
00764 
00765   deleteRelation();
00766 }
00767 
00768 void deleteRelation()
00769 {
00770   if(file1)
00771   {
00772     bufMgr->flushFile(file1);
00773     delete file1;
00774     file1 = NULL;
00775   }
00776   try
00777   {
00778     File::remove(relationName);
00779   }
00780   catch(FileNotFoundException e)
00781   {
00782   }
00783 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends