src/filtertree/example.cc
void memAdvancedUsage() {
  cout << "----- MEM ADVANCED USAGE ----" << endl;

  // create gramgenerator and similarity metric
  GramGenFixedLen gramGen(2);
  SimMetricEd simMetric(gramGen);
  
  // create index compressed with holes, using TimeCost as hole selection algorithm 
  // and specifiying the non-default string container and Array<unsigned> as inverted list
  StringContainerRM strContainer;
  strContainer.createContainer("tmpcollection.txt");
  strContainer.openContainer("tmpcollection.txt");  
  strContainer.fillContainer(dictionary.begin(), dictionary.end());
  // params: string container, gram generator, compression ratio, training workload, training metric, training threshold, ratio cost, 
  //         data sampling fraction, queries sampling fraction, max sting length, fanout
  FtIndexerDiscardListsTimeCost<StringContainerRM, Array<unsigned> > 
    indexer(&strContainer, &gramGen, 0.5f, &dictionary, &simMetric, 2.0f, false, 0.01f, 0.25f, 20, 10);
  indexer.addPartFilter(new LengthFilter(20));
  indexer.buildIndex();
  
  // create merger specifying inverted list type
  ScanCountMerger<Array<unsigned> > merger(dictionary.size());
  // create searcher passing merger and indexer
  // specify all template arguments, need to specify merger if not default (DivideSkipMerger)
  FtSearcherMem<FtIndexerDiscardListsTimeCost<StringContainerRM, Array<unsigned> >, ScanCountMerger<Array<unsigned> > > searcher(&merger, &indexer);
  
  vector<unsigned> resultStringIDs;
  Query query("kathrin", simMetric, 1.0f);
  searcher.search(query, resultStringIDs);  
  cout << "SIMILAR STRINGS: " << endl;
  for(unsigned i = 0; i < resultStringIDs.size(); i++) {
    string tmp;
    strContainer.retrieveString(tmp, resultStringIDs.at(i));
    cout << tmp << endl;
  }
  
  cout << "SAVING INDEX" << endl;
  indexer.saveIndex("exampleindex.ix");

  cout << "LOADING INDEX" << endl;
  FtIndexerDiscardListsTimeCost<StringContainerRM, Array<unsigned> > indexerLoaded(&strContainer);
  indexerLoaded.loadIndex("exampleindex.ix");
  
  resultStringIDs.clear();
  searcher.setFtIndexer(&indexerLoaded);
  searcher.search(query, resultStringIDs);  
  cout << "SIMILAR STRINGS: " << endl;
  for(unsigned i = 0; i < resultStringIDs.size(); i++) {
    string tmp;
    strContainer.retrieveString(tmp, resultStringIDs.at(i));
    cout << tmp << endl;
  }
  
  cout << "-------------------------" << endl << endl;
}
// builds in-memory index with length filter for partitioning
// compresses index by discarding some inverted lists (based on impact tto given workload)
// fills index from existing collection
// uses non-default list-merging algorithm, ScanCount
// explicitly specifies template parameters, and constructor arguments
builds in-memory index with length filter for partitioning
compresses index by discarding some inverted lists (based on impact tto given workload)
fills index from existing collection
uses non-default list-merging algorithm, ScanCount
explicitly specifies template parameters, and constructor arguments
builds in - memory index with length filter for partitioning compresses index by discarding some inverted lists ( based on impact tto given workload ) fills index from existing collection uses non - default list - merging algorithm ScanCount explicitly specifies template parameters and constructor arguments
void memAdvancedUsage() {
  cout << "----- MEM ADVANCED USAGE ----" << endl;
  GramGenFixedLen gramGen(2);
  SimMetricEd simMetric(gramGen);
  StringContainerRM strContainer;
  strContainer.createContainer("tmpcollection.txt");
  strContainer.openContainer("tmpcollection.txt");  
  strContainer.fillContainer(dictionary.begin(), dictionary.end());
  FtIndexerDiscardListsTimeCost<StringContainerRM, Array<unsigned> > 
    indexer(&strContainer, &gramGen, 0.5f, &dictionary, &simMetric, 2.0f, false, 0.01f, 0.25f, 20, 10);
  indexer.addPartFilter(new LengthFilter(20));
  indexer.buildIndex();
  ScanCountMerger<Array<unsigned> > merger(dictionary.size());
  FtSearcherMem<FtIndexerDiscardListsTimeCost<StringContainerRM, Array<unsigned> >, ScanCountMerger<Array<unsigned> > > searcher(&merger, &indexer);
  vector<unsigned> resultStringIDs;
  Query query("kathrin", simMetric, 1.0f);
  searcher.search(query, resultStringIDs);  
  cout << "SIMILAR STRINGS: " << endl;
  for(unsigned i = 0; i < resultStringIDs.size(); i++) {
    string tmp;
    strContainer.retrieveString(tmp, resultStringIDs.at(i));
    cout << tmp << endl;
  }
  cout << "SAVING INDEX" << endl;
  indexer.saveIndex("exampleindex.ix");
  cout << "LOADING INDEX" << endl;
  FtIndexerDiscardListsTimeCost<StringContainerRM, Array<unsigned> > indexerLoaded(&strContainer);
  indexerLoaded.loadIndex("exampleindex.ix");
  resultStringIDs.clear();
  searcher.setFtIndexer(&indexerLoaded);
  searcher.search(query, resultStringIDs);  
  cout << "SIMILAR STRINGS: " << endl;
  for(unsigned i = 0; i < resultStringIDs.size(); i++) {
    string tmp;
    strContainer.retrieveString(tmp, resultStringIDs.at(i));
    cout << tmp << endl;
  }
  cout << "-------------------------" << endl << endl;
}
void memAdvancedUsage ( ) { cout << " " << endl ; GramGenFixedLen gramGen ( 2 ) ; SimMetricEd simMetric ( gramGen ) ; StringContainerRM strContainer ; strContainer . createContainer ( " " ) ; strContainer . openContainer ( " " ) ; strContainer . fillContainer ( dictionary . begin ( ) , dictionary . end ( ) ) ; FtIndexerDiscardListsTimeCost < StringContainerRM , Array < unsigned > > indexer ( & strContainer , & gramGen , 0.5f , & dictionary , & simMetric , 2.0f , false , 0.01f , 0.25f , 20 , 10 ) ; indexer . addPartFilter ( new LengthFilter ( 20 ) ) ; indexer . buildIndex ( ) ; ScanCountMerger < Array < unsigned > > merger ( dictionary . size ( ) ) ; FtSearcherMem < FtIndexerDiscardListsTimeCost < StringContainerRM , Array < unsigned > > , ScanCountMerger < Array < unsigned > > > searcher ( & merger , & indexer ) ; vector < unsigned > resultStringIDs ; Query query ( " " , simMetric , 1.0f ) ; searcher . search ( query , resultStringIDs ) ; cout << " " << endl ; for ( unsigned i = 0 ; i < resultStringIDs . size ( ) ; i ++ ) { string tmp ; strContainer . retrieveString ( tmp , resultStringIDs . at ( i ) ) ; cout << tmp << endl ; } cout << " " << endl ; indexer . saveIndex ( " " ) ; cout << " " << endl ; FtIndexerDiscardListsTimeCost < StringContainerRM , Array < unsigned > > indexerLoaded ( & strContainer ) ; indexerLoaded . loadIndex ( " " ) ; resultStringIDs . clear ( ) ; searcher . setFtIndexer ( & indexerLoaded ) ; searcher . search ( query , resultStringIDs ) ; cout << " " << endl ; for ( unsigned i = 0 ; i < resultStringIDs . size ( ) ; i ++ ) { string tmp ; strContainer . retrieveString ( tmp , resultStringIDs . at ( i ) ) ; cout << tmp << endl ; } cout << " " << endl << endl ; }
builds in-memory index with length filter for partitioning
compresses index by discarding some inverted lists (based on impact tto given workload)
fills index from existing collection
uses non-default list-merging algorithm, ScanCount
explicitly specifies template parameters, and constructor arguments
builds in - memory index with length filter for partitioning compresses index by discarding some inverted lists ( based on impact tto given workload ) fills index from existing collection uses non - default list - merging algorithm ScanCount explicitly specifies template parameters and constructor arguments
// create gramgenerator and similarity metric // create index compressed with holes, using TimeCost as hole selection algorithm  // and specifiying the non-default string container and Array<unsigned> as inverted list // params: string container, gram generator, compression ratio, training workload, training metric, training threshold, ratio cost,  //         data sampling fraction, queries sampling fraction, max sting length, fanout // create merger specifying inverted list type // create searcher passing merger and indexer // specify all template arguments, need to specify merger if not default (DivideSkipMerger)