summaryrefslogtreecommitdiffstats
path: root/src/storage/phrase_large_table.h
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2010-08-24 13:56:30 +0800
committerPeng Wu <alexepico@gmail.com>2010-08-24 13:56:30 +0800
commit7a5db88ba5e7a4c38e9206fcfb8286073201f1f9 (patch)
tree09caf114dd0f3b1c30f9f96c24f80af6f8707b5a /src/storage/phrase_large_table.h
parentfb377d5bbbba988cd34d78e22d6403295956004c (diff)
downloadlibpinyin-7a5db88ba5e7a4c38e9206fcfb8286073201f1f9.tar.gz
libpinyin-7a5db88ba5e7a4c38e9206fcfb8286073201f1f9.tar.xz
libpinyin-7a5db88ba5e7a4c38e9206fcfb8286073201f1f9.zip
add phrase large table impl.
Diffstat (limited to 'src/storage/phrase_large_table.h')
-rw-r--r--src/storage/phrase_large_table.h39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/storage/phrase_large_table.h b/src/storage/phrase_large_table.h
index 810b8ac..1d18100 100644
--- a/src/storage/phrase_large_table.h
+++ b/src/storage/phrase_large_table.h
@@ -84,19 +84,48 @@ protected:
PhraseBitmapIndexLevel m_bitmap_table;
MemoryChunk * m_chunk;
+ void reset(){
+ if ( m_chunk ){
+ delete m_chunk;
+ m_chunk = NULL;
+ }
+ }
public:
+ PhraseLargeTable(){
+ m_chunk = NULL;
+ }
+
+ ~PhraseLargeTable(){
+ reset();
+ }
+
/* load/store method */
- bool load(MemoryChunk * chunk);
- bool store(MemoryChunk * new_chunk);
+ bool load(MemoryChunk * chunk){
+ reset();
+ m_chunk = chunk;
+ return m_bitmap_table.load(chunk, 0, chunk->size());
+ }
+
+ bool store(MemoryChunk * new_chunk){
+ table_offset_t end;
+ return m_bitmap_table.store(new_chunk, 0, end);
+ }
bool load_text(FILE * file);
/* search/add_index/remove_index method */
int search( int phrase_length, /* in */ utf16_t phrase[],
- /* out */ phrase_token_t & token);
+ /* out */ phrase_token_t & token){
+ return m_bitmap_table.search(phrase_length, phrase, 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);
+ int add_index( int phrase_length, /* in */ utf16_t phrase[], /* in */ phrase_token_t token){
+ return m_bitmap_table.add_index(phrase_length, phrase, token);
+ }
+
+ int remove_index( int phrase_length, /* in */ utf16_t phrase[], /* out */ phrase_token_t & token){
+ return m_bitmap_table.remove_index(phrase_length, phrase, token);
+ }
};
};