diff options
author | Peng Wu <alexepico@gmail.com> | 2011-10-27 14:37:43 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2011-10-27 14:44:44 +0800 |
commit | b6ddd796eb5169cb372c9baf63607dcc02458d30 (patch) | |
tree | 5798448dd3e2ef9717ba4552c31789d5a83544b5 | |
parent | c0ff923d2fc2a5e02d76decb95d3a8f4dd14c63c (diff) | |
download | libpinyin-b6ddd796eb5169cb372c9baf63607dcc02458d30.tar.gz libpinyin-b6ddd796eb5169cb372c9baf63607dcc02458d30.tar.xz libpinyin-b6ddd796eb5169cb372c9baf63607dcc02458d30.zip |
fixes load_db
-rw-r--r-- | src/storage/ngram.cpp | 16 |
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; |