summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/storage/chewing_large_table.cpp69
-rw-r--r--src/storage/chewing_large_table.h11
2 files changed, 80 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 */
diff --git a/src/storage/chewing_large_table.h b/src/storage/chewing_large_table.h
index 52ee01b..071101f 100644
--- a/src/storage/chewing_large_table.h
+++ b/src/storage/chewing_large_table.h
@@ -56,6 +56,12 @@ public:
ChewingBitmapIndexLevel(pinyin_option_t options) : m_options(options){}
~ChewingBitmapIndexLevel() { reset(); }
+ /* set options method */
+ bool set_options(pinyin_option_t options) {
+ m_options = options;
+ return true;
+ }
+
/* load/store method */
bool load(MemoryChunk * chunk, table_offset_t offset, table_offset_t end);
bool store(MemoryChunk * new_chunk, table_offset_t offset,
@@ -91,6 +97,11 @@ public:
~ChewingLargeTable() { reset(); }
+ /* set options method */
+ bool set_options(pinyin_option_t options) {
+ return m_bitmap_table.set_options(options);
+ }
+
/* load/store method */
bool load(MemoryChunk * chunk) {
reset();