summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/storage/phrase_large_table3_kyotodb.cpp33
-rw-r--r--src/storage/phrase_large_table3_kyotodb.h1
2 files changed, 31 insertions, 3 deletions
diff --git a/src/storage/phrase_large_table3_kyotodb.cpp b/src/storage/phrase_large_table3_kyotodb.cpp
index ce99c99..fd7d476 100644
--- a/src/storage/phrase_large_table3_kyotodb.cpp
+++ b/src/storage/phrase_large_table3_kyotodb.cpp
@@ -42,8 +42,6 @@ void PhraseLargeTable3::reset() {
m_db = NULL;
}
- m_chunk.set_size(0);
-
if (m_entry) {
delete m_entry;
m_entry = NULL;
@@ -144,5 +142,36 @@ 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);
+
+ const char * kbuf = (char *) phrase;
+ const int32_t vsiz = m_db->check(kbuf, phrase_length * sizeof(ucs4_t));
+ /* -1 on failure. */
+ if (-1 == vsiz)
+ return result;
+
+ /* continue searching. */
+ result |= SEARCH_CONTINUED;
+ if (0 == vsiz)
+ return result;
+
+ m_entry->m_chunk.set_size(vsiz);
+ char * vbuf = (char *) m_entry->m_chunk.begin();
+ assert (vsiz == m_db->get(kbuf, phrase_length * sizeof(ucs4_t),
+ vbuf, vsiz));
+
+ result = m_entry->search(tokens) | result;
+
+ return result;
+}
+
};
diff --git a/src/storage/phrase_large_table3_kyotodb.h b/src/storage/phrase_large_table3_kyotodb.h
index 92439a2..2b5500f 100644
--- a/src/storage/phrase_large_table3_kyotodb.h
+++ b/src/storage/phrase_large_table3_kyotodb.h
@@ -34,7 +34,6 @@ class PhraseLargeTable3{
private:
/* member variables. */
kyotocabinet::BasicDB * m_db;
- MemoryChunk m_chunk;
protected:
PhraseTableEntry * m_entry;