From b6ddd796eb5169cb372c9baf63607dcc02458d30 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 27 Oct 2011 14:37:43 +0800 Subject: fixes load_db --- src/storage/ngram.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/storage/ngram.cpp') 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; -- cgit