diff options
author | Peng Wu <alexepico@gmail.com> | 2010-10-09 15:07:58 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2010-10-09 15:07:58 +0800 |
commit | 1f23a4aa0f7454d8e9dbc53e4366b7a3fe338aa7 (patch) | |
tree | b535dbd329c31d2aa2cb21985ad1f75655213819 /src | |
parent | 6c9813e7e9afa18720912fa737cc21915756b84c (diff) | |
download | libpinyin-1f23a4aa0f7454d8e9dbc53e4366b7a3fe338aa7.tar.gz libpinyin-1f23a4aa0f7454d8e9dbc53e4366b7a3fe338aa7.tar.xz libpinyin-1f23a4aa0f7454d8e9dbc53e4366b7a3fe338aa7.zip |
re-factor phrase large table
Diffstat (limited to 'src')
-rw-r--r-- | src/storage/phrase_large_table.cpp | 46 | ||||
-rw-r--r-- | src/storage/phrase_large_table.h | 35 |
2 files changed, 46 insertions, 35 deletions
diff --git a/src/storage/phrase_large_table.cpp b/src/storage/phrase_large_table.cpp index 7a7dfd0..ad3262f 100644 --- a/src/storage/phrase_large_table.cpp +++ b/src/storage/phrase_large_table.cpp @@ -23,6 +23,52 @@ #include <string.h> #include "phrase_large_table.h" + +/* class definition */ + +namespace novel{ + +class PhraseLengthIndexLevel{ +protected: + GArray* m_phrase_array_indexes; +public: + PhraseLengthIndexLevel(); + ~PhraseLengthIndexLevel(); + + /* load/store method */ + bool load(MemoryChunk * chunk, table_offset_t offset, table_offset_t end); + bool store(MemoryChunk * new_chunk, table_offset_t offset, table_offset_t & end); + + /* search/add_index/remove_index method */ + int search( 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); + int remove_index( int phrase_length, /* in */ utf16_t phrase[], /* out */ phrase_token_t & token); +}; + +template<size_t phrase_length> +class PhraseArrayIndexLevel{ +protected: + MemoryChunk m_chunk; +public: + bool load(MemoryChunk * chunk, table_offset_t offset, table_offset_t end); + bool store(MemoryChunk * new_chunk, table_offset_t offset, table_offset_t & end); + + /* search/add_index/remove_index method */ + int search( /* in */ utf16_t phrase[], + /* out */ phrase_token_t & token); + + int add_index(/* in */ utf16_t phrase[], /* in */ phrase_token_t token); + int remove_index(/* in */ utf16_t phrase[], /* out */ phrase_token_t & token); +}; + +}; + +using namespace novel; + +/* class implementation */ + template<size_t phrase_length> struct PhraseIndexItem{ phrase_token_t m_token; diff --git a/src/storage/phrase_large_table.h b/src/storage/phrase_large_table.h index 3c140b9..42eeec4 100644 --- a/src/storage/phrase_large_table.h +++ b/src/storage/phrase_large_table.h @@ -55,41 +55,6 @@ public: int remove_index( int phrase_length, /* in */ utf16_t phrase[], /* out */ phrase_token_t & token); }; -class PhraseLengthIndexLevel{ -protected: - GArray* m_phrase_array_indexes; -public: - PhraseLengthIndexLevel(); - ~PhraseLengthIndexLevel(); - - /* load/store method */ - bool load(MemoryChunk * chunk, table_offset_t offset, table_offset_t end); - bool store(MemoryChunk * new_chunk, table_offset_t offset, table_offset_t & end); - - /* search/add_index/remove_index method */ - int search( 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); - int remove_index( int phrase_length, /* in */ utf16_t phrase[], /* out */ phrase_token_t & token); -}; - -template<size_t phrase_length> -class PhraseArrayIndexLevel{ -protected: - MemoryChunk m_chunk; -public: - bool load(MemoryChunk * chunk, table_offset_t offset, table_offset_t end); - bool store(MemoryChunk * new_chunk, table_offset_t offset, table_offset_t & end); - - /* search/add_index/remove_index method */ - int search( /* in */ utf16_t phrase[], - /* out */ phrase_token_t & token); - - int add_index(/* in */ utf16_t phrase[], /* in */ phrase_token_t token); - int remove_index(/* in */ utf16_t phrase[], /* out */ phrase_token_t & token); -}; - class PhraseLargeTable{ protected: PhraseBitmapIndexLevel m_bitmap_table; |