summaryrefslogtreecommitdiffstats
path: root/tests/storage
diff options
context:
space:
mode:
Diffstat (limited to 'tests/storage')
-rw-r--r--tests/storage/test_phrase_table.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/storage/test_phrase_table.cpp b/tests/storage/test_phrase_table.cpp
index 58d634e..3c4c489 100644
--- a/tests/storage/test_phrase_table.cpp
+++ b/tests/storage/test_phrase_table.cpp
@@ -6,9 +6,10 @@
size_t bench_times = 1000;
int main(int argc, char * argv[]){
- PhraseLargeTable largetable;
+ PhraseLargeTable2 largetable;
+ FacadePhraseIndex phrase_index;
- if (!load_phrase_table(NULL, &largetable, NULL))
+ if (!load_phrase_table(NULL, &largetable, &phrase_index))
exit(ENOENT);
MemoryChunk * chunk = new MemoryChunk;
@@ -24,17 +25,25 @@ int main(int argc, char * argv[]){
glong phrase_len = g_utf8_strlen(linebuf, -1);
ucs4_t * new_phrase = g_utf8_to_ucs4(linebuf, -1, NULL, NULL, NULL);
- phrase_token_t token;
+ phrase_token_t token = null_token;
+
+ PhraseTokens tokens;
+ memset(tokens, 0, sizeof(PhraseTokens));
+ phrase_index.prepare_tokens(tokens);
guint32 start = record_time();
for ( size_t i = 0; i < bench_times; ++i){
- largetable.search(phrase_len, new_phrase, token);
+ largetable.search(phrase_len, new_phrase, tokens);
}
print_time(start, bench_times);
- int retval = largetable.search(phrase_len, new_phrase, token);
+ int retval = largetable.search(phrase_len, new_phrase, tokens);
+ int num = get_first_token(tokens, token);
+
+ phrase_index.destroy_tokens(tokens);
+
if ( retval & SEARCH_OK )
- printf("%s:\t%d\n", linebuf, token);
+ printf("%s: num:%d token:%d\n", linebuf, num, token);
else
printf("phrase %s not found.\n", linebuf);