diff options
Diffstat (limited to 'src/storage/phrase_large_table.h')
-rw-r--r-- | src/storage/phrase_large_table.h | 61 |
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 |