diff options
Diffstat (limited to 'src/storage/chewing_large_table.cpp')
-rw-r--r-- | src/storage/chewing_large_table.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/storage/chewing_large_table.cpp b/src/storage/chewing_large_table.cpp index aec2b71..db803ec 100644 --- a/src/storage/chewing_large_table.cpp +++ b/src/storage/chewing_large_table.cpp @@ -20,3 +20,72 @@ */ #include "chewing_large_table.h" +#include <assert.h> +#include "pinyin_phrase2.h" + + +/* internal class definition */ + +namespace pinyin{ +class ChewingLengthIndexLevel{ + +protected: + GArray * m_chewing_array_indexes; + +public: + /* constructor/destructor */ + ChewingLengthIndexLevel(); + ~ChewingLengthIndexLevel(); + + /* 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 method */ + int search(pinyin_option_t options, int phrase_length, + /* in */ ChewingKey keys[], + /* out */ PhraseIndexRanges ranges); + + /* add/remove index method */ + int add_index(int phrase_length, /* in */ ChewingKey keys[], + /* in */ phrase_token_t token); + int remove_index(int phrase_length, /* in */ ChewingKey keys[], + /* in */ phrase_token_t token); +}; + + +template<size_t phrase_length> +class ChewingArrayIndexLevel{ +protected: + MemoryChunk m_chunk; + + /* compress consecutive tokens */ + int convert(pinyin_option_t options, + ChewingKey keys[], + PinyinIndexItem2<phrase_length> * begin, + PinyinIndexItem2<phrase_length> * end, + PhraseIndexRanges ranges); + +public: + /* 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 method */ + int search(pinyin_option_t options, /* in */ChewingKey keys[], + /* out */ PhraseIndexRanges ranges); + + /* add/remove index method */ + int add_index(/* in */ ChewingKey keys[], /* in */ phrase_token_t token); + int remove_index(/* in */ ChewingKey keys[], + /* in */ phrase_token_t token); +}; + +}; + + +using namespace pinyin; + +/* class implementation */ |