Changeset 327

Show
Ignore:
Timestamp:
03/07/08 05:15:27 (9 months ago)
Author:
jake
Message:

Query perf speedup

Location:
trunk/thrudex/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/thrudex/src/CLuceneIndex.cpp

    r325 r327  
    155155    if(last_refresh < last_modified || last_refresh < last_synched){ 
    156156 
     157 
    157158        modifier->flush(); 
    158159 
    159         ram_searcher.reset(new IndexSearcher( ram_directory.get() )); 
     160 
     161        ram_searcher.reset(); 
     162 
     163        //make a copy of the ram dir since its not thread safe 
     164        ram_readonly_directory = shared_ptr<CLuceneRAMDirectory>(new CLuceneRAMDirectory( ram_directory.get() )); 
     165        ram_readonly_directory->__cl_addref(); //trick clucene's lame ref counters 
     166 
     167        ram_searcher.reset(new IndexSearcher( ram_readonly_directory.get() )); 
     168 
    160169 
    161170        //since clucene doesn't use shared_ptr we need to get the 
     
    282291    } 
    283292 
    284  
     293    shared_ptr<CLuceneRAMDirectory> l_ram_readonly_directory; 
     294    shared_ptr<CLuceneRAMDirectory> l_ram_directory; 
     295    shared_ptr<CLuceneRAMDirectory> l_ram_prev_directory; 
     296    shared_ptr<IndexSearcher>       l_ram_searcher; 
     297    shared_ptr<IndexSearcher>       l_ram_prev_searcher; 
     298    shared_ptr<IndexSearcher>       l_disk_searcher; 
     299    shared_ptr<UpdateFilter>        l_disk_filter; 
     300    shared_ptr<MultiSearcher>       l_searcher; 
    285301    //RWGuard g(mutex); 
    286     Guard g(mutex); 
    287  
    288  
    289     //making sure references to underlying objects stay above 0 
    290     //for the duration of this function 
    291     shared_ptr<CLuceneRAMDirectory> l_ram_directory      = ram_directory; 
    292     shared_ptr<CLuceneRAMDirectory> l_ram_prev_directory = ram_prev_directory; 
    293     shared_ptr<IndexSearcher>       l_ram_searcher       = ram_searcher; 
    294     shared_ptr<IndexSearcher>       l_ram_prev_searcher  = ram_prev_searcher; 
    295     shared_ptr<IndexSearcher>       l_disk_searcher      = disk_searcher; 
    296  
    297  
    298     shared_ptr<MultiSearcher> l_searcher    = this->getSearcher(); 
    299     shared_ptr<UpdateFilter>  l_disk_filter = disk_filter; 
     302    { 
     303        Guard g(mutex); 
     304 
     305        l_searcher    = this->getSearcher(); 
     306 
     307        //making sure references to underlying objects stay above 0 
     308        //for the duration of this function 
     309        l_ram_readonly_directory  = ram_readonly_directory; 
     310        l_ram_directory      = ram_directory; 
     311        l_ram_prev_directory = ram_prev_directory; 
     312        l_ram_searcher       = ram_searcher; 
     313        l_ram_prev_searcher  = ram_prev_searcher; 
     314        l_disk_searcher      = disk_searcher; 
     315 
     316        l_disk_filter = disk_filter; 
     317 
     318    } 
    300319 
    301320    Query *query; 
  • trunk/thrudex/src/CLuceneIndex.h

    r325 r327  
    9191    boost::shared_ptr<lucene::store::CLuceneRAMDirectory>  ram_prev_directory; 
    9292    boost::shared_ptr<lucene::store::CLuceneRAMDirectory>  ram_prev_prev_directory; 
     93    boost::shared_ptr<lucene::store::CLuceneRAMDirectory>  ram_readonly_directory; 
    9394 
    9495    boost::shared_ptr<lucene::search::IndexSearcher> ram_searcher; 
  • trunk/thrudex/src/CLuceneRAMDirectory.cpp

    r264 r327  
    103103        } 
    104104 
     105 
     106 
    105107        // graceful cleanup 
    106108        is->close(); 
     
    109111        _CLDELETE(os); 
    110112    } 
     113 
    111114    if (closeDir) 
    112115        dir->close();