summaryrefslogtreecommitdiffstats
path: root/src/storage/phrase_large_table3_bdb.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-01-28 15:13:04 +0800
committerPeng Wu <alexepico@gmail.com>2016-01-28 15:13:04 +0800
commit2c93495fd59031b4a6bbe04dad6399d263129e72 (patch)
tree2e90c1181f836cd1689fec02db8b1ea109b66fec /src/storage/phrase_large_table3_bdb.cpp
parent82e482b394d08ee2001cfbccc8fe72cf8fa9e438 (diff)
downloadlibpinyin-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.cpp25
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;
+}
};