summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2019-01-17 15:20:32 +0800
committerPeng Wu <alexepico@gmail.com>2019-01-17 15:20:32 +0800
commit35adc8e4fc41dd8c989dc16760e179b63637203a (patch)
tree992e26addaa7717bdb2cf3751bf874c6c146cc50 /src
parentb825ba207cec09f53f100fa48c177c1fddf9949b (diff)
downloadlibpinyin-35adc8e4fc41dd8c989dc16760e179b63637203a.tar.gz
libpinyin-35adc8e4fc41dd8c989dc16760e179b63637203a.tar.xz
libpinyin-35adc8e4fc41dd8c989dc16760e179b63637203a.zip
Revert "not use in-memory DBM in src/storage"
This reverts commit 5607752c2b989849923676f4a925e5315a3303d4.
Diffstat (limited to 'src')
-rw-r--r--src/storage/chewing_large_table2_bdb.cpp2
-rw-r--r--src/storage/chewing_large_table2_bdb.h8
-rw-r--r--src/storage/chewing_large_table2_kyotodb.cpp2
-rw-r--r--src/storage/chewing_large_table2_kyotodb.h8
-rw-r--r--src/storage/facade_chewing_table2.h12
-rw-r--r--src/storage/facade_phrase_table3.h12
-rw-r--r--src/storage/ngram_bdb.cpp2
-rw-r--r--src/storage/ngram_bdb.h8
-rw-r--r--src/storage/ngram_kyotodb.cpp3
-rw-r--r--src/storage/ngram_kyotodb.h8
-rw-r--r--src/storage/phrase_large_table3_bdb.cpp2
-rw-r--r--src/storage/phrase_large_table3_bdb.h8
-rw-r--r--src/storage/phrase_large_table3_kyotodb.cpp4
-rw-r--r--src/storage/phrase_large_table3_kyotodb.h8
14 files changed, 6 insertions, 81 deletions
diff --git a/src/storage/chewing_large_table2_bdb.cpp b/src/storage/chewing_large_table2_bdb.cpp
index 8ede82e..6741ffd 100644
--- a/src/storage/chewing_large_table2_bdb.cpp
+++ b/src/storage/chewing_large_table2_bdb.cpp
@@ -70,7 +70,6 @@ bool ChewingLargeTable2::attach(const char * dbfile, guint32 flags) {
return true;
}
-#if 0
/* load/store method */
bool ChewingLargeTable2::load_db(const char * filename) {
reset();
@@ -136,7 +135,6 @@ 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 d629f42..e12855e 100644
--- a/src/storage/chewing_large_table2_bdb.h
+++ b/src/storage/chewing_large_table2_bdb.h
@@ -89,19 +89,11 @@ 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 f579aa3..b2bc9fc 100644
--- a/src/storage/chewing_large_table2_kyotodb.cpp
+++ b/src/storage/chewing_large_table2_kyotodb.cpp
@@ -63,7 +63,6 @@ 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) {
@@ -109,7 +108,6 @@ 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 51bb381..92f317b 100644
--- a/src/storage/chewing_large_table2_kyotodb.h
+++ b/src/storage/chewing_large_table2_kyotodb.h
@@ -88,19 +88,11 @@ 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 941ca63..1cf2a1f 100644
--- a/src/storage/facade_chewing_table2.h
+++ b/src/storage/facade_chewing_table2.h
@@ -84,25 +84,17 @@ public:
}
if (user_filename) {
m_user_chewing_table = new ChewingLargeTable2;
- result = m_user_chewing_table->attach
- (user_filename, ATTACH_READWRITE|ATTACH_CREATE) || result;
+ result = m_user_chewing_table->load_db
+ (user_filename) || 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 69b4cfd..3f71421 100644
--- a/src/storage/facade_phrase_table3.h
+++ b/src/storage/facade_phrase_table3.h
@@ -83,25 +83,17 @@ public:
}
if (user_filename) {
m_user_phrase_table = new PhraseLargeTable3;
- result = m_user_phrase_table->attach
- (user_filename, ATTACH_READWRITE|ATTACH_CREATE) || result;
+ result = m_user_phrase_table->load_db
+ (user_filename) || 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 2521266..a13b431 100644
--- a/src/storage/ngram_bdb.cpp
+++ b/src/storage/ngram_bdb.cpp
@@ -44,7 +44,6 @@ void Bigram::reset(){
}
}
-#if 0
bool Bigram::load_db(const char * dbfile){
reset();
@@ -107,7 +106,6 @@ 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 8ab3c1b..76a3116 100644
--- a/src/storage/ngram_bdb.h
+++ b/src/storage/ngram_bdb.h
@@ -56,7 +56,6 @@ public:
*/
~Bigram();
-#if 0
/**
* Bigram::load_db:
* @dbfile: the Berkeley DB file name.
@@ -76,7 +75,6 @@ public:
*
*/
bool save_db(const char * dbfile);
-#endif
/**
* Bigram::attach:
@@ -89,12 +87,6 @@ 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 01689a2..98f2f59 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,7 +94,6 @@ 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 429c46e..f1f28d8 100644
--- a/src/storage/ngram_kyotodb.h
+++ b/src/storage/ngram_kyotodb.h
@@ -60,7 +60,6 @@ public:
*/
~Bigram();
-#if 0
/**
* Bigram::load_db:
* @dbfile: the Berkeley DB file name.
@@ -80,7 +79,6 @@ public:
*
*/
bool save_db(const char * dbfile);
-#endif
/**
* Bigram::attach:
@@ -93,12 +91,6 @@ 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 a18dcf6..03632ae 100644
--- a/src/storage/phrase_large_table3_bdb.cpp
+++ b/src/storage/phrase_large_table3_bdb.cpp
@@ -72,7 +72,6 @@ bool PhraseLargeTable3::attach(const char * dbfile, guint32 flags) {
return true;
}
-#if 0
/* load/store method */
bool PhraseLargeTable3::load_db(const char * filename) {
reset();
@@ -138,7 +137,6 @@ 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 3ca6f20..73f7625 100644
--- a/src/storage/phrase_large_table3_bdb.h
+++ b/src/storage/phrase_large_table3_bdb.h
@@ -47,19 +47,11 @@ 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 80eb075..529aa65 100644
--- a/src/storage/phrase_large_table3_kyotodb.cpp
+++ b/src/storage/phrase_large_table3_kyotodb.cpp
@@ -67,7 +67,6 @@ 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) {
@@ -95,7 +94,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;
@@ -113,7 +112,6 @@ 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 711efa4..d122de0 100644
--- a/src/storage/phrase_large_table3_kyotodb.h
+++ b/src/storage/phrase_large_table3_kyotodb.h
@@ -49,19 +49,11 @@ 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);