diff options
author | Peng Wu <alexepico@gmail.com> | 2010-08-24 13:56:30 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2010-08-24 13:56:30 +0800 |
commit | 7a5db88ba5e7a4c38e9206fcfb8286073201f1f9 (patch) | |
tree | 09caf114dd0f3b1c30f9f96c24f80af6f8707b5a | |
parent | fb377d5bbbba988cd34d78e22d6403295956004c (diff) | |
download | libpinyin-7a5db88ba5e7a4c38e9206fcfb8286073201f1f9.tar.gz libpinyin-7a5db88ba5e7a4c38e9206fcfb8286073201f1f9.tar.xz libpinyin-7a5db88ba5e7a4c38e9206fcfb8286073201f1f9.zip |
add phrase large table impl.
-rw-r--r-- | src/storage/phrase_large_table.h | 39 | ||||
-rwxr-xr-x | src/storage/pinyin_large_table.h | 2 |
2 files changed, 35 insertions, 6 deletions
diff --git a/src/storage/phrase_large_table.h b/src/storage/phrase_large_table.h index 810b8ac..1d18100 100644 --- a/src/storage/phrase_large_table.h +++ b/src/storage/phrase_large_table.h @@ -84,19 +84,48 @@ protected: PhraseBitmapIndexLevel m_bitmap_table; MemoryChunk * m_chunk; + void reset(){ + if ( m_chunk ){ + delete m_chunk; + m_chunk = NULL; + } + } public: + PhraseLargeTable(){ + m_chunk = NULL; + } + + ~PhraseLargeTable(){ + reset(); + } + /* load/store method */ - bool load(MemoryChunk * chunk); - bool store(MemoryChunk * new_chunk); + bool load(MemoryChunk * chunk){ + reset(); + m_chunk = chunk; + return m_bitmap_table.load(chunk, 0, chunk->size()); + } + + bool store(MemoryChunk * new_chunk){ + table_offset_t end; + return m_bitmap_table.store(new_chunk, 0, end); + } bool load_text(FILE * file); /* search/add_index/remove_index method */ int search( int phrase_length, /* in */ utf16_t phrase[], - /* out */ phrase_token_t & token); + /* out */ phrase_token_t & token){ + return m_bitmap_table.search(phrase_length, phrase, token); + } - int add_index( int phrase_length, /* in */ utf16_t phrase[], /* in */ phrase_token_t token); - int remove_index( int phrase_length, /* in */ utf16_t phrase[], /* out */ phrase_token_t & token); + int add_index( int phrase_length, /* in */ utf16_t phrase[], /* in */ phrase_token_t token){ + return m_bitmap_table.add_index(phrase_length, phrase, token); + } + + int remove_index( int phrase_length, /* in */ utf16_t phrase[], /* out */ phrase_token_t & token){ + return m_bitmap_table.remove_index(phrase_length, phrase, token); + } }; }; diff --git a/src/storage/pinyin_large_table.h b/src/storage/pinyin_large_table.h index b1e5386..add8f67 100755 --- a/src/storage/pinyin_large_table.h +++ b/src/storage/pinyin_large_table.h @@ -131,7 +131,7 @@ public: bool load(MemoryChunk * chunk){ reset(); m_chunk = chunk; - return m_bitmap_table.load(chunk, 0 , chunk->size()); + return m_bitmap_table.load(chunk, 0, chunk->size()); } bool store(MemoryChunk * new_chunk){ |