diff options
author | Peng Wu <alexepico@gmail.com> | 2016-01-28 15:13:04 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2016-01-28 15:13:04 +0800 |
commit | 2c93495fd59031b4a6bbe04dad6399d263129e72 (patch) | |
tree | 2e90c1181f836cd1689fec02db8b1ea109b66fec /src/storage/phrase_large_table3_bdb.cpp | |
parent | 82e482b394d08ee2001cfbccc8fe72cf8fa9e438 (diff) | |
download | libpinyin-2c93495fd59031b4a6bbe04dad6399d263129e72.tar.gz libpinyin-2c93495fd59031b4a6bbe04dad6399d263129e72.tar.xz libpinyin-2c93495fd59031b4a6bbe04dad6399d263129e72.zip |
write class PhraseLargeTable3 in progress
Diffstat (limited to 'src/storage/phrase_large_table3_bdb.cpp')
-rw-r--r-- | src/storage/phrase_large_table3_bdb.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/storage/phrase_large_table3_bdb.cpp b/src/storage/phrase_large_table3_bdb.cpp index 19e7223..002c16f 100644 --- a/src/storage/phrase_large_table3_bdb.cpp +++ b/src/storage/phrase_large_table3_bdb.cpp @@ -179,5 +179,30 @@ bool PhraseLargeTable3::store_db(const char * new_filename) { return true; } +/* search method */ +int PhraseLargeTable3::search(int phrase_length, + /* in */ const ucs4_t phrase[], + /* out */ PhraseTokens tokens) const { + int result = SEARCH_NONE; + + if (NULL == m_db) + return result; + assert(NULL != m_entry); + + DBT db_key; + memset(&db_key, 0, sizeof(DBT)); + db_key.data = (void *)phrase; + db_key.size = phrase_length * sizeof(ucs4_t); + + DBT db_data; + memset(&db_data, 0, sizeof(DBT)); + int ret = m_db->get(m_db, NULL, &db_key, &db_data, 0); + if (ret != 0) + return result; + + m_entry->m_chunk.set_chunk(db_data.data, db_data.size, NULL); + result = m_entry->search(tokens); + return result; +} }; |