| CODENOTIFIER | HelpYou are not signed inSign in |
Project: ThruDB
Revision: 362
Author: jake
Date: 26 Apr 2008 16:32:35
Diff at Trac: http://trac.thrudb.org/changeset/362
Changes:Bloom filter size not configurable, need to implement dynamic blooms
Files:| ... | ...@@ -5,6 +5,7 @@ | |
| 5 | 5 | #undef HAVE_CONFIG_H |
| 6 | 6 | |
| 7 | 7 | #include "CLuceneBackend.h" |
| 8 | #include "ConfigFile.h" | |
| 8 | 9 | #include "utils.h" |
| 9 | 10 | #include <boost/filesystem.hpp> |
| 10 | 11 | #include <boost/filesystem/fstream.hpp> |
| ... | ...@@ -85,8 +86,10 @@ | |
| 85 | 86 | if(this->isValidIndex(index)) |
| 86 | 87 | return; |
| 87 | 88 | |
| 89 | size_t filter_space = ConfigManager->read<int>("FILTER_SPACE_SIZE",1000000); | |
| 90 | ||
| 88 | 91 | index_cache[index] = |
| 89 | shared_ptr<CLuceneIndex>(new CLuceneIndex(idx_root,index,analyzer)); | |
| 92 | shared_ptr<CLuceneIndex>(new CLuceneIndex(idx_root,index,filter_space,analyzer)); | |
| 90 | 93 | } |
| 91 | 94 | |
| 92 | 95 | |
| ... | ...@@ -101,7 +104,6 @@ | |
| 101 | 104 | throw ex; |
| 102 | 105 | } |
| 103 | 106 | |
| 104 | ||
| 105 | 107 | lucene::document::Document *doc = new lucene::document::Document(); |
| 106 | 108 | |
| 107 | 109 | try{ |
| ... | ...@@ -239,7 +241,7 @@ | |
| 239 | 241 | return "ok"; |
| 240 | 242 | } else if (op == "put_log_position") { |
| 241 | 243 | fs::ofstream outfile; |
| 242 | outfile.open( log_pos_file.c_str (), | |
| 244 | outfile.open( log_pos_file.c_str (), | |
| 243 | 245 | ios::out | ios::binary | ios::trunc); |
| 244 | 246 | if (!outfile.is_open ()) |
| 245 | 247 | { |
| ... | ...@@ -45,8 +45,8 @@ | |
| 45 | 45 | } |
| 46 | 46 | }; |
| 47 | 47 | |
| 48 | CLuceneIndex::CLuceneIndex(const string &index_root, const string &index_name, shared_ptr<Analyzer> analyzer) | |
| 49 | : index_root(index_root), index_name(index_name), analyzer(analyzer), filter_space(10000000), last_synched(0), syncing(false) | |
| 48 | CLuceneIndex::CLuceneIndex(const string &index_root, const string &index_name, const size_t &filter_space, shared_ptr<Analyzer> analyzer) | |
| 49 | : index_root(index_root), index_name(index_name), analyzer(analyzer), filter_space(filter_space), last_synched(0), syncing(false) | |
| 50 | 50 | { |
| 51 | 51 | |
| 52 | 52 | //Verify log dir |
| ... | ...@@ -166,10 +166,10 @@ | |
| 166 | 166 | |
| 167 | 167 | |
| 168 | 168 | modifier->flush(); |
| 169 | ||
| 169 | ||
| 170 | 170 | ram_searcher.reset(); |
| 171 | 171 | |
| 172 | //shared_ptr<CLuceneRAMDirectory> l_ram_readonly_directory = ram_readonly_directory; | |
| 172 | //shared_ptr<CLuceneRAMDirectory> l_ram_readonly_directory = ram_readonly_directory; | |
| 173 | 173 | |
| 174 | 174 | //make a copy of the ram dir since its not thread safe |
| 175 | 175 | ram_readonly_directory.reset( new CLuceneRAMDirectory( ram_directory.get() ), null_deleter() ); |
| ... | ...@@ -185,8 +185,8 @@ | |
| 185 | 185 | |
| 186 | 186 | if(syncing){ |
| 187 | 187 | //make a copy of the ram dir since its not thread safe |
| 188 | ram_readonly_prev_directory = shared_ptr<CLuceneRAMDirectory>(new CLuceneRAMDirectory( ram_prev_directory.get() ), null_deleter() ); | |
| 189 | ram_readonly_prev_directory->__cl_addref(); //trick clucene's lame ref counters | |
| 188 | ram_readonly_prev_directory = shared_ptr<CLuceneRAMDirectory>(new CLuceneRAMDirectory( ram_prev_directory.get() ), null_deleter() ); | |
| 189 | ram_readonly_prev_directory->__cl_addref(); //trick clucene's lame ref counters | |
| 190 | 190 | |
| 191 | 191 | ram_prev_searcher.reset(new IndexSearcher( ram_readonly_prev_directory.get() )); |
| 192 | 192 | searchers[2] = ram_prev_searcher.get(); |
| ... | ...@@ -46,6 +46,7 @@ | |
| 46 | 46 | public: |
| 47 | 47 | CLuceneIndex(const std::string &index_root, |
| 48 | 48 | const std::string &index_name, |
| 49 | const std::size_t &filter_space, | |
| 49 | 50 | boost::shared_ptr<lucene::analysis::Analyzer> analyzer); |
| 50 | 51 | |
| 51 | 52 | ~CLuceneIndex(); |
| ... | ...@@ -63,14 +64,13 @@ | |
| 63 | 64 | boost::shared_ptr<facebook::thrift::concurrency::Thread> monitor_thread; |
| 64 | 65 | |
| 65 | 66 | static log4cxx::LoggerPtr logger; |
| 66 | facebook::thrift::concurrency::Mutex mutex; | |
| 67 | //facebook::thrift::concurrency::ReadWriteMutex mutex; | |
| 67 | facebook::thrift::concurrency::Mutex mutex; | |
| 68 | 68 | |
| 69 | 69 | const std::string index_root; |
| 70 | 70 | const std::string index_name; |
| 71 | 71 | boost::shared_ptr<lucene::analysis::Analyzer> analyzer; |
| 72 | 72 | |
| 73 | int filter_space; | |
| 73 | std::size_t filter_space; | |
| 74 | 74 | |
| 75 | 75 | boost::shared_ptr<lucene::index::IndexModifier> modifier; |
| 76 | 76 | volatile int64_t last_modified; |