diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/storage/chewing_large_table2_bdb.cpp | 2 | ||||
-rw-r--r-- | src/storage/chewing_large_table2_bdb.h | 8 | ||||
-rw-r--r-- | src/storage/chewing_large_table2_kyotodb.cpp | 2 | ||||
-rw-r--r-- | src/storage/chewing_large_table2_kyotodb.h | 8 | ||||
-rw-r--r-- | src/storage/facade_chewing_table2.h | 12 | ||||
-rw-r--r-- | src/storage/facade_phrase_table3.h | 12 | ||||
-rw-r--r-- | src/storage/ngram_bdb.cpp | 2 | ||||
-rw-r--r-- | src/storage/ngram_bdb.h | 8 | ||||
-rw-r--r-- | src/storage/ngram_kyotodb.cpp | 3 | ||||
-rw-r--r-- | src/storage/ngram_kyotodb.h | 8 | ||||
-rw-r--r-- | src/storage/phrase_large_table3_bdb.cpp | 2 | ||||
-rw-r--r-- | src/storage/phrase_large_table3_bdb.h | 8 | ||||
-rw-r--r-- | src/storage/phrase_large_table3_kyotodb.cpp | 4 | ||||
-rw-r--r-- | src/storage/phrase_large_table3_kyotodb.h | 8 |
14 files changed, 81 insertions, 6 deletions
diff --git a/src/storage/chewing_large_table2_bdb.cpp b/src/storage/chewing_large_table2_bdb.cpp index 6741ffd..8ede82e 100644 --- a/src/storage/chewing_large_table2_bdb.cpp +++ b/src/storage/chewing_large_table2_bdb.cpp @@ -70,6 +70,7 @@ bool ChewingLargeTable2::attach(const char * dbfile, guint32 flags) { return true; } +#if 0 /* load/store method */ bool ChewingLargeTable2::load_db(const char * filename) { reset(); @@ -135,6 +136,7 @@ bool ChewingLargeTable2::store_db(const char * new_filename) { return true; } +#endif template<int phrase_length> int ChewingLargeTable2::search_internal(/* in */ const ChewingKey index[], diff --git a/src/storage/chewing_large_table2_bdb.h b/src/storage/chewing_large_table2_bdb.h index e12855e..d629f42 100644 --- a/src/storage/chewing_large_table2_bdb.h +++ b/src/storage/chewing_large_table2_bdb.h @@ -89,11 +89,19 @@ public: /* attach method */ bool attach(const char * dbfile, guint32 flags); + bool sync() { + assert(NULL != m_db); + m_db->sync(m_db, 0); + return true; + } + +#if 0 /* load/store method */ /* use in-memory DBM here, for better performance. */ bool load_db(const char * filename); bool store_db(const char * new_filename); +#endif bool load_text(FILE * infile, TABLE_PHONETIC_TYPE type); diff --git a/src/storage/chewing_large_table2_kyotodb.cpp b/src/storage/chewing_large_table2_kyotodb.cpp index b2bc9fc..f579aa3 100644 --- a/src/storage/chewing_large_table2_kyotodb.cpp +++ b/src/storage/chewing_large_table2_kyotodb.cpp @@ -63,6 +63,7 @@ bool ChewingLargeTable2::attach(const char * dbfile, guint32 flags) { return m_db->open(dbfile, mode); } +#if 0 /* load/store method */ /* use in-memory DBM here, for better performance. */ bool ChewingLargeTable2::load_db(const char * filename) { @@ -108,6 +109,7 @@ bool ChewingLargeTable2::store_db(const char * new_filename) { return true; } +#endif template<int phrase_length> int ChewingLargeTable2::search_internal(/* in */ const ChewingKey index[], diff --git a/src/storage/chewing_large_table2_kyotodb.h b/src/storage/chewing_large_table2_kyotodb.h index 92f317b..51bb381 100644 --- a/src/storage/chewing_large_table2_kyotodb.h +++ b/src/storage/chewing_large_table2_kyotodb.h @@ -88,11 +88,19 @@ public: /* attach method */ bool attach(const char * dbfile, guint32 flags); + bool sync() { + assert(NULL != m_db); + m_db->synchronize(); + return true; + } + +#if 0 /* load/store method */ /* use in-memory DBM here, for better performance. */ bool load_db(const char * filename); bool store_db(const char * new_filename); +#endif bool load_text(FILE * infile, TABLE_PHONETIC_TYPE type); diff --git a/src/storage/facade_chewing_table2.h b/src/storage/facade_chewing_table2.h index 1cf2a1f..941ca63 100644 --- a/src/storage/facade_chewing_table2.h +++ b/src/storage/facade_chewing_table2.h @@ -84,17 +84,25 @@ public: } if (user_filename) { m_user_chewing_table = new ChewingLargeTable2; - result = m_user_chewing_table->load_db - (user_filename) || result; + result = m_user_chewing_table->attach + (user_filename, ATTACH_READWRITE|ATTACH_CREATE) || result; } return result; } + bool sync() { + if (NULL == m_user_chewing_table) + return false; + return m_user_chewing_table->sync(); + } + +#if 0 bool store(const char * new_user_filename) { if (NULL == m_user_chewing_table) return false; return m_user_chewing_table->store_db(new_user_filename); } +#endif /** * FacadeChewingTable2::search: diff --git a/src/storage/facade_phrase_table3.h b/src/storage/facade_phrase_table3.h index 3f71421..69b4cfd 100644 --- a/src/storage/facade_phrase_table3.h +++ b/src/storage/facade_phrase_table3.h @@ -83,17 +83,25 @@ public: } if (user_filename) { m_user_phrase_table = new PhraseLargeTable3; - result = m_user_phrase_table->load_db - (user_filename) || result; + result = m_user_phrase_table->attach + (user_filename, ATTACH_READWRITE|ATTACH_CREATE) || result; } return result; } + bool sync() { + if (NULL == m_user_phrase_table) + return false; + return m_user_phrase_table->sync(); + } + +#if 0 bool store(const char * new_user_filename) { if (NULL == m_user_phrase_table) return false; return m_user_phrase_table->store_db(new_user_filename); } +#endif /** * FacadePhraseTable3::search: diff --git a/src/storage/ngram_bdb.cpp b/src/storage/ngram_bdb.cpp index a13b431..2521266 100644 --- a/src/storage/ngram_bdb.cpp +++ b/src/storage/ngram_bdb.cpp @@ -44,6 +44,7 @@ void Bigram::reset(){ } } +#if 0 bool Bigram::load_db(const char * dbfile){ reset(); @@ -106,6 +107,7 @@ bool Bigram::save_db(const char * dbfile){ return true; } +#endif bool Bigram::attach(const char * dbfile, guint32 flags){ reset(); diff --git a/src/storage/ngram_bdb.h b/src/storage/ngram_bdb.h index 76a3116..8ab3c1b 100644 --- a/src/storage/ngram_bdb.h +++ b/src/storage/ngram_bdb.h @@ -56,6 +56,7 @@ public: */ ~Bigram(); +#if 0 /** * Bigram::load_db: * @dbfile: the Berkeley DB file name. @@ -75,6 +76,7 @@ public: * */ bool save_db(const char * dbfile); +#endif /** * Bigram::attach: @@ -87,6 +89,12 @@ public: */ bool attach(const char * dbfile, guint32 flags); + bool sync() { + assert(NULL != m_db); + m_db->sync(m_db, 0); + return true; + } + /** * Bigram::load: * @index: the previous token in the bi-gram. diff --git a/src/storage/ngram_kyotodb.cpp b/src/storage/ngram_kyotodb.cpp index 98f2f59..01689a2 100644 --- a/src/storage/ngram_kyotodb.cpp +++ b/src/storage/ngram_kyotodb.cpp @@ -49,7 +49,7 @@ void Bigram::reset(){ } } - +#if 0 /* Use ProtoHashDB for load_db/save_db methods. */ bool Bigram::load_db(const char * dbfile){ reset(); @@ -94,6 +94,7 @@ bool Bigram::save_db(const char * dbfile){ return true; } +#endif bool Bigram::attach(const char * dbfile, guint32 flags){ reset(); diff --git a/src/storage/ngram_kyotodb.h b/src/storage/ngram_kyotodb.h index f1f28d8..429c46e 100644 --- a/src/storage/ngram_kyotodb.h +++ b/src/storage/ngram_kyotodb.h @@ -60,6 +60,7 @@ public: */ ~Bigram(); +#if 0 /** * Bigram::load_db: * @dbfile: the Berkeley DB file name. @@ -79,6 +80,7 @@ public: * */ bool save_db(const char * dbfile); +#endif /** * Bigram::attach: @@ -91,6 +93,12 @@ public: */ bool attach(const char * dbfile, guint32 flags); + bool sync() { + assert(NULL != m_db); + m_db->synchronize(); + return true; + } + /** * Bigram::load: * @index: the previous token in the bi-gram. diff --git a/src/storage/phrase_large_table3_bdb.cpp b/src/storage/phrase_large_table3_bdb.cpp index 03632ae..a18dcf6 100644 --- a/src/storage/phrase_large_table3_bdb.cpp +++ b/src/storage/phrase_large_table3_bdb.cpp @@ -72,6 +72,7 @@ bool PhraseLargeTable3::attach(const char * dbfile, guint32 flags) { return true; } +#if 0 /* load/store method */ bool PhraseLargeTable3::load_db(const char * filename) { reset(); @@ -137,6 +138,7 @@ bool PhraseLargeTable3::store_db(const char * new_filename) { return true; } +#endif /* search method */ int PhraseLargeTable3::search(int phrase_length, diff --git a/src/storage/phrase_large_table3_bdb.h b/src/storage/phrase_large_table3_bdb.h index 73f7625..3ca6f20 100644 --- a/src/storage/phrase_large_table3_bdb.h +++ b/src/storage/phrase_large_table3_bdb.h @@ -47,11 +47,19 @@ public: /* attach method */ bool attach(const char * dbfile, guint32 flags); + bool sync() { + assert(NULL != m_db); + m_db->sync(m_db, 0); + return true; + } + +#if 0 /* load/store method */ /* use in-memory DBM here, for better performance. */ bool load_db(const char * filename); bool store_db(const char * new_filename); +#endif bool load_text(FILE * infile); diff --git a/src/storage/phrase_large_table3_kyotodb.cpp b/src/storage/phrase_large_table3_kyotodb.cpp index 529aa65..80eb075 100644 --- a/src/storage/phrase_large_table3_kyotodb.cpp +++ b/src/storage/phrase_large_table3_kyotodb.cpp @@ -67,6 +67,7 @@ bool PhraseLargeTable3::attach(const char * dbfile, guint32 flags) { return m_db->open(dbfile, mode); } +#if 0 /* load_db/store_db method */ /* use in-memory DBM here, for better performance. */ bool PhraseLargeTable3::load_db(const char * filename) { @@ -94,7 +95,7 @@ bool PhraseLargeTable3::load_db(const char * filename) { return true; } -bool PhraseLargeTable3::store_db(const char * new_filename){ +bool PhraseLargeTable3::store_db(const char * new_filename) { int ret = unlink(new_filename); if ( ret != 0 && errno != ENOENT) return false; @@ -112,6 +113,7 @@ bool PhraseLargeTable3::store_db(const char * new_filename){ return true; } +#endif /* search method */ int PhraseLargeTable3::search(int phrase_length, diff --git a/src/storage/phrase_large_table3_kyotodb.h b/src/storage/phrase_large_table3_kyotodb.h index d122de0..711efa4 100644 --- a/src/storage/phrase_large_table3_kyotodb.h +++ b/src/storage/phrase_large_table3_kyotodb.h @@ -49,11 +49,19 @@ public: /* attach method */ bool attach(const char * dbfile, guint32 flags); + bool sync() { + assert(NULL != m_db); + m_db->synchronize(); + return true; + } + +#if 0 /* load_db/store_db method */ /* use in-memory DBM here, for better performance. */ bool load_db(const char * filename); bool store_db(const char * new_filename); +#endif bool load_text(FILE * infile); |