summaryrefslogtreecommitdiffstats
path: root/tests/storage/test_phrase_table.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-02-22 14:24:50 +0800
committerPeng Wu <alexepico@gmail.com>2016-02-22 14:24:50 +0800
commit81724d8500464fc86e6e440a4d9012d889c8a742 (patch)
treef38126dd744af9bbbeb217b9f69a0244828980bd /tests/storage/test_phrase_table.cpp
parent520dc8d10941ef08bf1ffaa24d2325182f4b6d5f (diff)
downloadlibpinyin-81724d8500464fc86e6e440a4d9012d889c8a742.tar.gz
libpinyin-81724d8500464fc86e6e440a4d9012d889c8a742.tar.xz
libpinyin-81724d8500464fc86e6e440a4d9012d889c8a742.zip
update test_phrase_table
Diffstat (limited to 'tests/storage/test_phrase_table.cpp')
-rw-r--r--tests/storage/test_phrase_table.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/storage/test_phrase_table.cpp b/tests/storage/test_phrase_table.cpp
index 88c5c1b..d1bb954 100644
--- a/tests/storage/test_phrase_table.cpp
+++ b/tests/storage/test_phrase_table.cpp
@@ -23,9 +23,11 @@ int main(int argc, char * argv[]){
if (!load_phrase_table(phrase_files, NULL, &largetable, &phrase_index))
exit(ENOENT);
+#if 0
MemoryChunk * chunk = new MemoryChunk;
largetable.store(chunk);
largetable.load(chunk);
+#endif
char* linebuf = NULL; size_t size = 0; ssize_t read;
while ((read = getline(&linebuf, &size, stdin)) != -1) {
@@ -47,14 +49,24 @@ int main(int argc, char * argv[]){
phrase_index.prepare_tokens(tokens);
guint32 start = record_time();
- for (size_t i = 0; i < bench_times; ++i){
+ size_t i = 0;
+ for (i = 0; i < bench_times; ++i){
phrase_index.clear_tokens(tokens);
largetable.search(phrase_len, new_phrase, tokens);
}
print_time(start, bench_times);
+ /* test search continued information. */
+ int retval = SEARCH_NONE;
+ for (i = 1; i < phrase_len; ++i) {
+ phrase_index.clear_tokens(tokens);
+ retval = largetable.search(i, new_phrase, tokens);
+ if (retval & SEARCH_CONTINUED)
+ printf("return continued information with length:%d\n", i);
+ }
+
phrase_index.clear_tokens(tokens);
- int retval = largetable.search(phrase_len, new_phrase, tokens);
+ retval = largetable.search(phrase_len, new_phrase, tokens);
if (retval & SEARCH_OK) {
for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {