summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-05-21 15:34:06 +0800
committerPeng Wu <alexepico@gmail.com>2012-05-21 15:34:06 +0800
commitc34f87b345d762882c265a638d306f10b21d4cf8 (patch)
tree1d67471d4158109c59b11397b40ebd455d324149
parent4f7701c4d33c8b2df7c1cc29b1abf81ab7110e5c (diff)
downloadlibpinyin-c34f87b345d762882c265a638d306f10b21d4cf8.zip
libpinyin-c34f87b345d762882c265a638d306f10b21d4cf8.tar.gz
libpinyin-c34f87b345d762882c265a638d306f10b21d4cf8.tar.xz
rename compat to compact
-rw-r--r--src/pinyin.cpp2
-rw-r--r--src/storage/phrase_index.cpp2
-rw-r--r--src/storage/phrase_index.h6
-rw-r--r--tests/storage/test_phrase_index.cpp4
-rw-r--r--utils/storage/gen_binary_files.cpp2
5 files changed, 9 insertions, 7 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index c028dc0..eb3dde0 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -190,6 +190,8 @@ bool pinyin_save(pinyin_context_t * context){
if (!context->m_modified)
return false;
+ context->m_phrase_index->compact();
+
MemoryChunk * oldchunk = new MemoryChunk;
MemoryChunk * newlog = new MemoryChunk;
diff --git a/src/storage/phrase_index.cpp b/src/storage/phrase_index.cpp
index 39abeee..ad7c60c 100644
--- a/src/storage/phrase_index.cpp
+++ b/src/storage/phrase_index.cpp
@@ -530,7 +530,7 @@ int SubPhraseIndex::get_range(/* out */ PhraseIndexRange & range){
return ERROR_OK;
}
-bool FacadePhraseIndex::compat(){
+bool FacadePhraseIndex::compact(){
for ( size_t index = 0; index < PHRASE_INDEX_LIBRARY_COUNT; ++index) {
SubPhraseIndex * sub_phrase = m_sub_phrase_indices[index];
if ( !sub_phrase )
diff --git a/src/storage/phrase_index.h b/src/storage/phrase_index.h
index bb3f84b..4deac16 100644
--- a/src/storage/phrase_index.h
+++ b/src/storage/phrase_index.h
@@ -530,13 +530,13 @@ public:
bool merge(guint8 phrase_index, MemoryChunk * log);
/**
- * FacadePhraseIndex::compat:
- * @returns: whether the compat operation is successful.
+ * FacadePhraseIndex::compact:
+ * @returns: whether the compact operation is successful.
*
* Compat all sub phrase index memory usage.
*
*/
- bool compat();
+ bool compact();
/**
* FacadePhraseIndex::get_sub_phrase_range:
diff --git a/tests/storage/test_phrase_index.cpp b/tests/storage/test_phrase_index.cpp
index 4f1fe58..f9cb8d2 100644
--- a/tests/storage/test_phrase_index.cpp
+++ b/tests/storage/test_phrase_index.cpp
@@ -89,7 +89,7 @@ int main(int argc, char * argv[]){
g_free(filename);
}
- phrase_index.compat();
+ phrase_index.compact();
MemoryChunk* store1 = new MemoryChunk;
phrase_index_load.store(1, store1);
@@ -99,7 +99,7 @@ int main(int argc, char * argv[]){
phrase_index_load.store(2, store2);
phrase_index_load.load(2, store2);
- phrase_index.compat();
+ phrase_index.compact();
phrase_index_load.get_phrase_item(16870553, item2);
assert( item2.get_phrase_length() == 14);
diff --git a/utils/storage/gen_binary_files.cpp b/utils/storage/gen_binary_files.cpp
index fc3c439..1ec6fe3 100644
--- a/utils/storage/gen_binary_files.cpp
+++ b/utils/storage/gen_binary_files.cpp
@@ -86,7 +86,7 @@ int main(int argc, char * argv[]){
new_chunk->save("phrase_index.bin");
phraselargetable.load(new_chunk);
- phrase_index.compat();
+ phrase_index.compact();
if (!save_phrase_index(&phrase_index))
exit(ENOENT);