00001 00006 #include "common.hpp" 00007 #include "io/FDRepr.hpp" 00008 #include "io/input/transaction_reader/TransactionReader.hpp" 00009 #include "io/input/transaction_reader/brBufferedTransactionReader.hpp" 00010 #include "io/input/transaction_reader/SortedTransactionReader.hpp" 00011 #include "io/output/OutputBase.hpp" 00012 #include "util/Formatter.hpp" 00013 #include <vector> 00014 00015 int main(int argc, char *argv[]) 00016 { 00017 if ( argc < 3 ) 00018 { 00019 log_err(0,"Error! There are 2 mandatory arguments: input_canon infile outfile"); 00020 return 1; 00021 } 00022 00023 typedef brBufferedTransactionReader< TransactionReader<FDRepr> > T_R; 00024 typedef SortedTransactionReader<T_R, true> S_T_R; 00025 S_T_R::params_t par_i; 00026 par_i.file_name = argv[1]; 00027 par_i.mode=FileReprBase::READ; 00028 par_i.file_buffer_size = 16 * 1024; 00029 S_T_R sorted_tr_reader(&par_i); 00030 00031 OutputBase<FDRepr>::params_t par_o; 00032 par_o.file_name=argv[2]; 00033 par_o.mode=FileReprBase::WRITE; 00034 OutputBase<FDRepr> of(&par_o); 00035 char buffer[60000]; 00036 std::streamsize endpos,pos; 00037 endpos=sizeof(buffer)-1; 00038 std::vector<item_t> trans; 00039 sorted_tr_reader.rewind(); 00040 while (sorted_tr_reader.nextTransactionBIS(trans)) 00041 { 00042 pos=endpos; 00043 Formatter::ItemsetToStringBack(trans.begin(),trans.end(),buffer,pos); 00044 buffer[endpos-1]='\n'; 00045 of.writeToFile(buffer+pos,endpos-pos); 00046 } 00047 of.flush(); 00048 return 0; 00049 }