summaryrefslogtreecommitdiffstats
path: root/src/storage/phrase_large_table.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2010-10-09 15:07:58 +0800
committerPeng Wu <alexepico@gmail.com>2010-10-09 15:07:58 +0800
commit1f23a4aa0f7454d8e9dbc53e4366b7a3fe338aa7 (patch)
treeb535dbd329c31d2aa2cb21985ad1f75655213819 /src/storage/phrase_large_table.cpp
parent6c9813e7e9afa18720912fa737cc21915756b84c (diff)
downloadlibpinyin-1f23a4aa0f7454d8e9dbc53e4366b7a3fe338aa7.tar.gz
libpinyin-1f23a4aa0f7454d8e9dbc53e4366b7a3fe338aa7.tar.xz
libpinyin-1f23a4aa0f7454d8e9dbc53e4366b7a3fe338aa7.zip
re-factor phrase large table
Diffstat (limited to 'src/storage/phrase_large_table.cpp')
-rw-r--r--src/storage/phrase_large_table.cpp46
1 files changed, 46 insertions, 0 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;