summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-10-27 14:37:43 +0800
committerPeng Wu <alexepico@gmail.com>2011-10-27 14:40:13 +0800
commitcdd9f5355a24f59f3aa587842d5b0a7e9fce4394 (patch)
treef4e238f76f5891694370e2933c3916f71f2db78e
parent6df832baaa4c06bcffed93620edf5431ee9249fc (diff)
downloadlibpinyin-cdd9f5355a24f59f3aa587842d5b0a7e9fce4394.tar.gz
libpinyin-cdd9f5355a24f59f3aa587842d5b0a7e9fce4394.tar.xz
libpinyin-cdd9f5355a24f59f3aa587842d5b0a7e9fce4394.zip
fixes load_db
-rw-r--r--src/storage/ngram.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/storage/ngram.cpp b/src/storage/ngram.cpp
index 17c7e9b..fedd744 100644
--- a/src/storage/ngram.cpp
+++ b/src/storage/ngram.cpp
@@ -224,20 +224,22 @@ bool SingleGram::set_freq( /* in */ phrase_token_t token,
bool Bigram::load_db(const char * dbfile){
reset();
- DB * tmp_db = NULL;
- int ret = db_create(&tmp_db, NULL, 0);
+ /* create in memory db. */
+ int ret = db_create(&m_db, NULL, 0);
assert(ret == 0);
- ret = tmp_db->open(tmp_db, NULL, dbfile, NULL,
- DB_HASH, DB_RDONLY, 0600);
+ ret = m_db->open(m_db, NULL, NULL, NULL,
+ DB_HASH, DB_CREATE, 0600);
if ( ret != 0 )
return false;
- ret = db_create(&m_db, NULL, 0);
+ /* load db into memory. */
+ DB * tmp_db = NULL;
+ ret = db_create(&tmp_db, NULL, 0);
assert(ret == 0);
- ret = m_db->open(m_db, NULL, NULL, NULL,
- DB_HASH, DB_CREATE, 0600);
+ ret = tmp_db->open(tmp_db, NULL, dbfile, NULL,
+ DB_HASH, DB_RDONLY, 0600);
if ( ret != 0 )
return false;