1 ///###//////////////////////////////////////////////////////////////////////// 2 // 3 // Burton Computer Corporation 4 // http://www.burton-computer.com 5 // http://www.cooldevtools.com 6 // $Id: FrequencyDBImpl_split.h 272 2007-01-06 19:37:27Z brian $ 7 // 8 // Copyright (C) 2007 Burton Computer Corporation 9 // ALL RIGHTS RESERVED 10 // 11 // This program is open source software; you can redistribute it 12 // and/or modify it under the terms of the Q Public License (QPL) 13 // version 1.0. Use of this software in whole or in part, including 14 // linking it (modified or unmodified) into other programs is 15 // subject to the terms of the QPL. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // Q Public License for more details. 21 // 22 // You should have received a copy of the Q Public License 23 // along with this program; see the file LICENSE.txt. If not, visit 24 // the Burton Computer Corporation or CoolDevTools web site 25 // QPL pages at: 26 // 27 // http://www.burton-computer.com/qpl.html 28 // http://www.cooldevtools.com/qpl.html 29 // 30 31 #ifndef _FrequencyDBImpl_split_h 32 #define _FrequencyDBImpl_split_h 33 34 #ifdef USE_MMAP 35 36 #include "FrequencyDBImpl.h" 37 38 class FrequencyDBImpl_split : public FrequencyDBImpl 39 { 40 public: 41 FrequencyDBImpl_split(const DatabaseConfig *config); 42 ~FrequencyDBImpl_split(); 43 44 bool open(const string &filename, 45 bool read_only, 46 int create_mode); 47 void close(); 48 49 void flush(); 50 51 void beginTransaction(); 52 53 void endTransaction(bool commit); 54 55 void writeWord(const string &word, 56 const WordData &word_data); 57 58 bool readWord(const string &word, 59 WordData &word_data); 60 61 bool firstWord(string &word, 62 WordData &counts); 63 64 bool nextWord(string &word, 65 WordData &counts); 66 67 string getDatabaseType() const; 68 69 void sweepOutOldTerms(const CleanupManager &cleanman); 70 71 bool canCacheTerm(const string &word); 72 73 static FrequencyDBImpl *factory(const DatabaseConfig *); 74 75 private: 76 /// Not implemented. 77 FrequencyDBImpl_split(const FrequencyDBImpl_split &); 78 79 /// Not implemented. 80 FrequencyDBImpl_split& operator=(const FrequencyDBImpl_split &); 81 82 private: 83 const DatabaseConfig *m_config; 84 int m_cursor; 85 Ptr<FrequencyDBImpl> m_db; 86 Ptr<FrequencyDBImpl> m_hash; 87 }; 88 89 #endif // USE_MMAP 90 91 #endif // _FrequencyDBImpl_split_h 92