Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

DBCacheTester.cpp

Go to the documentation of this file.
00001 #ifndef DBCacheTester_CPP
00002 #define DBCacheTester_CPP
00003 
00004 
00009 #include "common.hpp"
00010 #include "test/io/db_cache/DBCacheTester.hpp"
00011 
00012 #include "io/output/normal/BufferedNormalOutput.hpp"
00013 #include "io/input/transaction_reader/brBufferedTransactionReader.hpp"
00014 #include "util/FrequentFilter.cpp"
00015 #include "io/input/transaction_reader/SortedTransactionReader.hpp"
00016 
00017 
00018 #include "io/db_cache/OrderedVectorDBCache.hpp"
00019 #include "io/db_cache/OrderedArrayDBCache.hpp"
00020 #include "io/db_cache/PrefixArrayListDBCache.hpp"
00021 #include "io/db_cache/RBTreeDBCache.hpp"
00022 
00023 #include "datastructures/trie/TrieBase.hpp"
00024 #include "datastructures/trie/edgelist/Edgelist.hpp"
00025 #include "datastructures/trie/edgelist/OrderedEdgelist.hpp"
00026 #include "datastructures/trie/edgelist/OffsetIndexVector.hpp"
00027 #include "datastructures/trie/edgelist/IndexVector.hpp"
00028 #include "datastructures/trie/edgelist/MapRepr.hpp"
00029 #include "io/db_cache/TrieDBCache.hpp"
00030 
00031 #include "io/db_cache/BuildTreeDBCache.hpp"
00032 
00033 #include <iostream>
00034 
00035 //counter_t TrieBase< Bodon::Edgelist< >, counter_t >::def_data = 0;
00036 //counter_t TrieBase< Bodon::OrderedEdgelist< > >::def_data = 0;
00037 //counter_t TrieBase< Bodon::OffsetIndexVector< > >::def_data = 0;
00038 //counter_t TrieBase< Bodon::IndexVector >::def_data = 0;
00039 //counter_t TrieBase< Bodon::MapRepr  >::def_data = 0;
00040 
00041 void DBCacheTester::usageDBCacheTester()
00042 {
00043    std::cerr << "\nUsage: dbcache input_file min_supp nr_of_traversals code_mode output_file cacher [cacher_option]"<<std::endl;
00044    std::cerr << " code_mode\t {ASC, DESC, NOCARE}"<<std::endl;
00045    std::cerr << " cacher\t\t {ordered-vector, ordered-array, RB-tree, trie, bracz}"<<std::endl<<std::endl;
00046    std::cerr << " In case of trie cacher the possible cacher_options are: "<<std::endl;
00047    std::cerr << " \t\t list,\n\t\t ordered-list,\n\t\t indexvector,\n\t\t offsetindexvector,\n\t\t or map. "<<std::endl;
00048    std::cerr << " In case of bracz cacher the possible cacher_options are: "<<std::endl;
00049    std::cerr << " \t\t trie,\n \t\t patricia. "<<std::endl<<std::endl;
00050 
00051 
00052 }
00053 
00054 void DBCacheTester::doTest( int argc, char *argv[] )
00055 {
00056    if( argc < 5 )
00057       usageDBCacheTester();
00058    else
00059    {
00060       typedef brBufferedTransactionReader< > T_R;
00061       T_R::params_t par_i;
00062       par_i.file_name = argv[1];
00063       log_info(0,"The name of the input file is: %s", argv[1]);
00064       par_i.mode=FileReprBase::READ;
00065       T_R tr_reader(&par_i);
00066    
00067       std::vector< std::pair<counter_t, item_t> > freq_items_with_counters;
00068       counter_t nr_of_transactions;
00069       counter_t min_supp = atoi(argv[2]);
00070       log_info(0,"min_supp is set to %d", min_supp);
00071       int nr_of_traversals = atoi(argv[3]);
00072       log_info(0,"The transaction cacher will be traversed %d times", nr_of_traversals);
00073       FrequentFilter<T_R>
00074          fr_filter(tr_reader);
00075 
00076       std::cout<<"\nFinding frequent items."<<std::flush;
00077       fr_filter.findFrequentItems( freq_items_with_counters,  
00078                                    nr_of_transactions, min_supp);
00079       std::cout<<"\t\t\t\t\tDone!"<<std::endl;
00080 
00081       log_info(0,"The name of the ouput file is: %s", argv[5]);
00082       std::cout<<"Doing a cache decoder."<<std::flush;
00083       D::params_t par_d;
00084       par_d.file_name = argv[5];
00085       par_d.mode=FileReprBase::WRITE;
00086       D decoder(&par_d);
00087       std::cout<<"\t\t\t\t\tDone!"<<std::endl;
00088       typedef SortedTransactionReader<Coder<T_R, D>, false> S_C;
00089 
00090       char* cacher = argv[6];
00091       if( strcmp(cacher, "ordered-vector") == 0)
00092       {
00093          log_info(0,"Order-vector cacher is chosen");    
00094          selectMode< OrderedVectorDBCache<S_C, std::vector<item_t> > >(
00095             argv[4], argv[1], nr_of_traversals, 
00096             tr_reader.getLargestItem(), &decoder, &freq_items_with_counters);
00097       }
00098       else if( strcmp(cacher, "ordered-array") == 0)
00099       {
00100          log_info(0,"Order-array cacher is chosen");     
00101          selectMode< OrderedArrayDBCache<S_C, std::vector<item_t> > >(
00102             argv[4], argv[1], nr_of_traversals, 
00103             tr_reader.getLargestItem(), &decoder, &freq_items_with_counters);
00104       }
00105 /*      else if( strcmp(cacher, "prefix-array") == 0)
00106       {
00107          log_info(0,"Prefix-array cacher is chosen");    
00108          selectMode< PrefixArrayListDBCache<S_C> >(
00109             argv[4], argv[1], nr_of_traversals, 
00110             tr_reader.getLargestItem(), &decoder, &freq_items_with_counters);
00111             }*/
00112       else if( strcmp(cacher, "RB-tree") == 0)
00113       {
00114          log_info(0,"Red-black tree cacher is chosen");  
00115          selectMode< Bodon::RBTreeDBCache<S_C, std::vector<item_t> > >(
00116             argv[4], argv[1], nr_of_traversals, 
00117             tr_reader.getLargestItem(), &decoder, &freq_items_with_counters);
00118       }
00119       else if( strcmp(cacher, "trie") == 0) 
00120       {
00121          log_info(0,"Trie cacher is chosen");    
00122          if (argc<8) 
00123          {
00124             log_info(0,"No edge representation is chosen for trie cacher");                 log_info(0,"Default (list) is used!");       
00125             selectMode< TrieDBCache<S_C, Bodon::Edgelist< std::vector<Edge> > > >(
00126                argv[4], argv[1], nr_of_traversals, 
00127                tr_reader.getLargestItem(), &decoder, &freq_items_with_counters);
00128          }
00129          else if( strcmp(argv[7], "list") == 0)
00130          {
00131             log_info(0,"Unordered list edge representation is chosen");  
00132             selectMode< TrieDBCache<S_C, Bodon::Edgelist< std::vector<Edge> > > >(
00133                argv[4], argv[1], nr_of_traversals, 
00134                tr_reader.getLargestItem(), &decoder, &freq_items_with_counters);
00135          }
00136          else if( strcmp(argv[7], "ordered-list") == 0)
00137          {
00138             log_info(0,"Ordered list edge representation is chosen");    
00139             selectMode< TrieDBCache<S_C, Bodon::OrderedEdgelist< std::vector<Edge> > > >(
00140                argv[4], argv[1], nr_of_traversals, 
00141                tr_reader.getLargestItem(), &decoder, &freq_items_with_counters);
00142          }
00143          else if( strcmp(argv[7], "offsetindexvector") == 0)
00144          {
00145             log_info(0,"Offsetindex-vector edge representation is chosen");      
00146             selectMode< TrieDBCache<S_C, Bodon::OffsetIndexVector<std::vector<void*> > > >(
00147                argv[4], argv[1], nr_of_traversals,
00148                tr_reader.getLargestItem(), &decoder, &freq_items_with_counters);
00149          }
00150          else if( strcmp(argv[7], "map") == 0)
00151          {
00152             log_info(0,"Map-based edge representation is chosen");
00153             selectMode< TrieDBCache<S_C, Bodon::MapRepr> >(
00154                argv[4], argv[1], nr_of_traversals,
00155                tr_reader.getLargestItem(), &decoder, &freq_items_with_counters);
00156          }
00157          else       
00158             log_info(0,"Unknown edge representation is chosen: %s", argv[7]);
00159             
00160 
00161       }
00162       else if( strcmp(cacher, "bracz") == 0) 
00163       {
00164          log_info(0,"Cacher made by bracz is chosen");   
00165          if (argc<8) 
00166          {
00167             log_info(0,"No other option for bracz is given");    
00168             log_info(0,"Default value (patricia) is used.");     
00169             selectMode< bracz::BuildTreeDBCache< S_C,  std::vector<item_t>, 
00170                bracz::EndPatriciaBuildTree<true> > >(
00171                   argv[4], argv[1], nr_of_traversals,
00172                   tr_reader.getLargestItem(), &decoder, &freq_items_with_counters);
00173          }
00174          else if( strcmp(argv[7], "trie") == 0)
00175          {
00176             log_info(0,"Trie cacher is chosen");         
00177             selectMode< bracz::BuildTreeDBCache< S_C,  std::vector<item_t>, 
00178                bracz::TrieBuildTree<true> > >(
00179                   argv[4], argv[1], nr_of_traversals,
00180                   tr_reader.getLargestItem(), &decoder, &freq_items_with_counters);
00181          }
00182          else if( strcmp(argv[7], "patricia") == 0)
00183          {
00184             log_info(0,"Patricia cacher is chosen");     
00185             selectMode< bracz::BuildTreeDBCache< S_C,  std::vector<item_t>, 
00186                bracz::EndPatriciaBuildTree<true> > >(
00187                   argv[4], argv[1], nr_of_traversals,
00188                   tr_reader.getLargestItem(), &decoder, &freq_items_with_counters);
00189          }
00190          else
00191             log_info(0,"Unknown option is chosen: %s", argv[7]);
00192 
00193       }
00194       else
00195          usageDBCacheTester();
00196 
00197    }
00198 }
00199 
00200 
00201 #endif
00202 

Generated on Sun Sep 17 17:50:38 2006 for FIM environment by  doxygen 1.4.4