summaryrefslogtreecommitdiffstats
path: root/src/storage/phrase_large_table.h
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2010-08-23 14:02:19 +0800
committerPeng Wu <alexepico@gmail.com>2010-08-23 14:02:19 +0800
commit241aedc1bcd468389851ad3aaa748463c73a8a5a (patch)
tree37a59e3ea9ba86df3ec8b2c8d9e3bd0cf5b6ff8a /src/storage/phrase_large_table.h
parent8170190273c2211311ce6c501b7bbb2d65067c75 (diff)
downloadlibpinyin-241aedc1bcd468389851ad3aaa748463c73a8a5a.tar.gz
libpinyin-241aedc1bcd468389851ad3aaa748463c73a8a5a.tar.xz
libpinyin-241aedc1bcd468389851ad3aaa748463c73a8a5a.zip
add phrase large table interface
Diffstat (limited to 'src/storage/phrase_large_table.h')
-rw-r--r--src/storage/phrase_large_table.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/storage/phrase_large_table.h b/src/storage/phrase_large_table.h
index 4578b7a..08ffa73 100644
--- a/src/storage/phrase_large_table.h
+++ b/src/storage/phrase_large_table.h
@@ -22,6 +22,63 @@
#ifndef PHRASE_LARGE_TABLE_H
#define PHRASE_LARGE_TABLE_H
+#include <stdio.h>
+#include "novel_types.h"
+#include "memory_chunk.h"
+
+namespace novel{
+
+const size_t PHRASE_Number_Of_Bitmap_Index = 1<<16;
+
+class PhraseLengthIndexLevel;
+
+class PhraseBitmapIndexLevel{
+protected:
+ PhraseLengthIndexLevel * m_phrase_length_indexes[PHRASE_Number_Of_Bitmap_Index];
+ //shift one utf16_t for class PhraseLengthIndexLevel, just like PinyinLengthIndexLevel.
+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( 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);
+};
+
+class PhraseLengthIndexLevel{
+protected:
+ GArray* m_phrase_array_indexes;
+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( 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;
@@ -42,4 +99,8 @@ public:
int remove_index( int phrase_length, /* in */ utf16_t phrase[], /* out */ phrase_token_t & token);
};
+};
+
+using namespace novel;
+
#endif