From 1eacb0a42d5c7263369fb1f712506aa28d0c37f7 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 29 Nov 2011 16:31:08 +0800 Subject: write chewing large table in progress --- src/storage/chewing_large_table.cpp | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'src/storage/chewing_large_table.cpp') 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 +#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 +class ChewingArrayIndexLevel{ +protected: + MemoryChunk m_chunk; + + /* compress consecutive tokens */ + int convert(pinyin_option_t options, + ChewingKey keys[], + PinyinIndexItem2 * begin, + PinyinIndexItem2 * 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 */ -- cgit