OSDN Git Service

Improve test coverages for cache mechanism in pgs2norm and pgs2snippet1.
authorMasaoFujii <masao.fujii@gmail.com>
Tue, 1 Sep 2015 08:51:38 +0000 (17:51 +0900)
committerMasaoFujii <masao.fujii@gmail.com>
Tue, 1 Sep 2015 08:51:38 +0000 (17:51 +0900)
expected/pgs2-debug.out
sql/pgs2-debug.sql

index 5cb5e1d..48b3145 100644 (file)
@@ -113,6 +113,17 @@ LOG:  pgs2norm(): complete (set result cache): ㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕
  キログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラム株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社
 (1 row)
 
+-- Even if norm_cache_limit is decreased to the smaller size than the current
+-- cache size, the cached result is returned if the argument is the same as
+-- the cached one.
+SET ludia_funcs.norm_cache_limit TO '1kB';
+SELECT pgs2norm(repeat(chr(13077),35) || repeat(chr(13183),35));
+LOG:  pgs2norm(): quick exit: ㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㌕㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿㍿
+                                                                                                                                                                                                                                                                                                                        pgs2norm                                                                                                                                                                                                                                                                                                                        
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ キログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラムキログラム株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社株式会社
+(1 row)
+
 -- Check that both input and normalized strings are always cached
 -- if norm_cache_size is set to 0.
 SET ludia_funcs.norm_cache_limit TO 0;
@@ -124,5 +135,58 @@ LOG:  pgs2norm(): complete (set result cache): ㌀㌁㌂㌃㌄㌅㌆㌇㌈㌉㌊
  アパートアルファアンペアアールイニングインチウォンエスクードエーカーオンスオームカイリカラットカロリーガロンガンマギガギニーキュリーギルダーキロキログラムキロメートルキロワットグラムグラムトンクルゼイロクローネケースコルナコーポサイクルサンチームシリングセンチセントダースデシドルトンナノノットハイツパーセントパーツバーレルピアストルピクルピコビルファラッドフィートブッシェルフランヘクタールペソペニヒヘルツペンスページベータポイントボルトホンポンドホールホーンマイクロマイルマッハマルクマンションミクロンミリミリバールメガメガトンメートルヤードヤールユアンリットルリラルピールーブルレムレントゲンワット
 (1 row)
 
+-- Unless norm_cache_limit is decreased, the cache memory is not shrunk
+-- even if the memory size that pgs2norm() requests for the cache is very
+-- smaller than the amount of currently-allocated one.
+SET ludia_funcs.norm_cache_limit TO '4kB';
+SELECT pgs2norm(string_agg(chr(num) || chr(12441), '')) FROM generate_series(12353, 12438) num;
+LOG:  pgs2malloc(): buflen 2048, needed 973, maxlen 4096
+LOG:  pgs2norm(): complete (set result cache): ぁ゙あ゙ぃ゙い゙ぅ゙ゔぇ゙え゙ぉ゙お゙がが゙ぎぎ゙ぐぐ゙げげ゙ごご゙ざざ゙じじ゙ずず゙ぜぜ゙ぞぞ゙だだ゙ぢぢ゙っ゙づづ゙でで゙どど゙な゙に゙ぬ゙ね゙の゙ばば゙ぱ゙びび゙ぴ゙ぶぶ゙ぷ゙べべ゙ぺ゙ぼぼ゙ぽ゙ま゙み゙む゙め゙も゙ゃ゙や゙ゅ゙ゆ゙ょ゙よ゙ら゙り゙る゙れ゙ろ゙ゎ゙わ゙ゐ゙ゑ゙を゙ん゙ゔ゙ゕ゙ゖ゙
+                                                                                   pgs2norm                                                                                   
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ ぁ゙あ゙ぃ゙い゙ぅ゙ゔぇ゙え゙ぉ゙お゙がが゙ぎぎ゙ぐぐ゙げげ゙ごご゙ざざ゙じじ゙ずず゙ぜぜ゙ぞぞ゙だだ゙ぢぢ゙っ゙づづ゙でで゙どど゙な゙に゙ぬ゙ね゙の゙ばば゙ぱ゙びび゙ぴ゙ぶぶ゙ぷ゙べべ゙ぺ゙ぼぼ゙ぽ゙ま゙み゙む゙め゙も゙ゃ゙や゙ゅ゙ゆ゙ょ゙よ゙ら゙り゙る゙れ゙ろ゙ゎ゙わ゙ゐ゙ゑ゙を゙ん゙ゔ゙ゕ゙ゖ゙
+(1 row)
+
+SELECT pgs2norm(string_agg(chr(num) || chr(12443), '')) FROM generate_series(65393, 65437) num;
+LOG:  pgs2malloc(): buflen 2048, needed 478, maxlen 4096
+LOG:  pgs2norm(): complete (set result cache): ア゛イ゛ウ゛エ゛オ゛カ゛キ゛ク゛ケ゛コ゛サ゛シ゛ス゛セ゛ソ゛タ゛チ゛ツ゛テ゛ト゛ナ゛ニ゛ヌ゛ネ゛ノ゛ハ゛ヒ゛フ゛ヘ゛ホ゛マ゛ミ゛ム゛メ゛モ゛ヤ゛ユ゛ヨ゛ラ゛リ゛ル゛レ゛ロ゛ワ゛ン゛
+                                          pgs2norm                                          
+--------------------------------------------------------------------------------------------
+ ア゙イ゙ヴエ゙オ゙ガギグゲゴザジズゼゾダヂヅデドナ゙ニ゙ヌ゙ネ゙ノ゙バビブベボマ゙ミ゙ム゙メ゙モ゙ヤ゙ユ゙ヨ゙ラ゙リ゙ル゙レ゙ロ゙ヷン゙
+(1 row)
+
+-- If norm_cache_limit is decreased, the cache memory is shrunk as necessary.
+SET ludia_funcs.norm_cache_limit TO '1kB';
+SELECT pgs2norm(string_agg(chr(num) || chr(12442), '')) FROM generate_series(12449, 12534) num;
+LOG:  pgs2malloc(): buflen 2048, needed 1021, maxlen 1024
+LOG:  pgs2norm(): complete (set result cache): ァ゚ア゚ィ゚イ゚ゥ゚ウ゚ェ゚エ゚ォ゚オ゚カ゚ガ゚キ゚ギ゚ク゚グ゚ケ゚ゲ゚コ゚ゴ゚サ゚ザ゚シ゚ジ゚ス゚ズ゚セ゚ゼ゚ソ゚ゾ゚タ゚ダ゚チ゚ヂ゚ッ゚ツ゚ヅ゚テ゚デ゚ト゚ド゚ナ゚ニ゚ヌ゚ネ゚ノ゚パバ゚パ゚ピビ゚ピ゚プブ゚プ゚ペベ゚ペ゚ポボ゚ポ゚マ゚ミ゚ム゚メ゚モ゚ャ゚ヤ゚ュ゚ユ゚ョ゚ヨ゚ラ゚リ゚ル゚レ゚ロ゚ヮ゚ワ゚ヰ゚ヱ゚ヲ゚ン゚ヴ゚ヵ゚ヶ゚
+                                                                                   pgs2norm                                                                                   
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ ァ゚ア゚ィ゚イ゚ゥ゚ウ゚ェ゚エ゚ォ゚オ゚カ゚ガ゚キ゚ギ゚ク゚グ゚ケ゚ゲ゚コ゚ゴ゚サ゚ザ゚シ゚ジ゚ス゚ズ゚セ゚ゼ゚ソ゚ゾ゚タ゚ダ゚チ゚ヂ゚ッ゚ツ゚ヅ゚テ゚デ゚ト゚ド゚ナ゚ニ゚ヌ゚ネ゚ノ゚パバ゚パ゚ピビ゚ピ゚プブ゚プ゚ペベ゚ペ゚ポボ゚ポ゚マ゚ミ゚ム゚メ゚モ゚ャ゚ヤ゚ュ゚ユ゚ョ゚ヨ゚ラ゚リ゚ル゚レ゚ロ゚ヮ゚ワ゚ヰ゚ヱ゚ヲ゚ン゚ヴ゚ヵ゚ヶ゚
+(1 row)
+
+SELECT pgs2norm(string_agg(chr(num) || chr(803) || chr(774), '')) FROM generate_series(65313, 65338) num;
+LOG:  pgs2malloc(): buflen 1024, needed 314, maxlen 1024
+LOG:  pgs2norm(): complete (set result cache): ẶḄ̆C̣̆Ḍ̆Ẹ̆F̣̆Ğ̣Ḥ̆Ị̆J̣̆Ḳ̆Ḷ̆Ṃ̆Ṇ̆Ọ̆P̣̆Q̣̆Ṛ̆Ṣ̆Ṭ̆Ụ̆Ṿ̆Ẉ̆X̣̆Ỵ̆Ẓ̆
+          pgs2norm          
+----------------------------
+ ặḅ̆c̣̆ḍ̆ẹ̆f̣̆ğ̣ḥ̆ị̆j̣̆ḳ̆ḷ̆ṃ̆ṇ̆ọ̆p̣̆q̣̆ṛ̆ṣ̆ṭ̆ụ̆ṿ̆ẉ̆x̣̆ỵ̆ẓ̆
+(1 row)
+
+-- If the cached Seena query is returned if the same keyword has been used
+-- the last time in pgs2snippet1().
+SELECT pgs2snippet1(1,300,1,'∇','∇',0,'エおA','あ?う?おabcdeか?く?こjklmn');
+ pgs2snippet1 
+--------------
+(1 row)
+
+SELECT pgs2snippet1(1,300,1,'∇','∇',0,'エおA','あ?う?おabcdeか?く?こjklmn');
+LOG:  GetSennaQuery(): quick exit: エおA
+ pgs2snippet1 
+--------------
+(1 row)
+
 -- Clean up ludia_funcs module
 DROP EXTENSION ludia_funcs;
index 262b0f5..65867d2 100644 (file)
@@ -39,10 +39,33 @@ SET ludia_funcs.norm_cache_limit TO -1;
 SET work_mem TO '64kB';
 SELECT pgs2norm(repeat(chr(13077),35) || repeat(chr(13183),35));
 
+-- Even if norm_cache_limit is decreased to the smaller size than the current
+-- cache size, the cached result is returned if the argument is the same as
+-- the cached one.
+SET ludia_funcs.norm_cache_limit TO '1kB';
+SELECT pgs2norm(repeat(chr(13077),35) || repeat(chr(13183),35));
+
 -- Check that both input and normalized strings are always cached
 -- if norm_cache_size is set to 0.
 SET ludia_funcs.norm_cache_limit TO 0;
 SELECT pgs2norm(string_agg(chr(num), '')) from generate_series(13056, 13143) num;
 
+-- Unless norm_cache_limit is decreased, the cache memory is not shrunk
+-- even if the memory size that pgs2norm() requests for the cache is very
+-- smaller than the amount of currently-allocated one.
+SET ludia_funcs.norm_cache_limit TO '4kB';
+SELECT pgs2norm(string_agg(chr(num) || chr(12441), '')) FROM generate_series(12353, 12438) num;
+SELECT pgs2norm(string_agg(chr(num) || chr(12443), '')) FROM generate_series(65393, 65437) num;
+
+-- If norm_cache_limit is decreased, the cache memory is shrunk as necessary.
+SET ludia_funcs.norm_cache_limit TO '1kB';
+SELECT pgs2norm(string_agg(chr(num) || chr(12442), '')) FROM generate_series(12449, 12534) num;
+SELECT pgs2norm(string_agg(chr(num) || chr(803) || chr(774), '')) FROM generate_series(65313, 65338) num;
+
+-- If the cached Seena query is returned if the same keyword has been used
+-- the last time in pgs2snippet1().
+SELECT pgs2snippet1(1,300,1,'∇','∇',0,'エおA','あ?う?おabcdeか?く?こjklmn');
+SELECT pgs2snippet1(1,300,1,'∇','∇',0,'エおA','あ?う?おabcdeか?く?こjklmn');
+
 -- Clean up ludia_funcs module
 DROP EXTENSION ludia_funcs;