#全文ファイルテスト(FullText_MergeInvPack=2)

Begin;

SetSystemParameter "FullText_InsertMergeFileSize" 24576;
SetSystemParameter "FullText_ExpungeMergeFileSize" 24576;
# マージ閾値を3に変更
#SetSystemParameter "FullText_InsertMergeTupleSize" 3;
#SetSystemParameter "FullText_ExpungeMergeTupleSize" 3;

BeginTimeSpan;
Initialize;
EndTimeSpan;
InitializeSession "FullTextTest";

# 再びinsertを行う
Command "insert into T (N, C) values (1, ?)" [[textsjisfile "..\\..\\doc\\introduction.txt"]];
Command "select count(*) from T";
Command "insert into T (N, C) values (2, ?)" [[textsjisfile "..\\..\\doc\\RainyNight.txt"]];
Command "select count(*) from T";
Command "insert into T (N, C) values (3, ?)" [[textsjisfile "..\\..\\doc\\kenpou.txt"]];
# ここでマージが起こる
Command "select count(*) from T";
Command "insert into T (N, C) values (4, ?)" [[textsjisfile "..\\..\\doc\\Alangri-Gloriban.txt"]];
Command "select count(*) from T";
Command "insert into T (N, C) values (5, ?)" [[textsjisfile "..\\..\\doc\\rasyoumon.txt"]];
Command "select count(*) from T";
Command "insert into T (N, C) values (6, ?)" [[textsjisfile "..\\..\\doc\\Teihon.txt"]];
# ここでマージが起こる
Command "select count(*) from T";
Command "insert into T (N, C) values (7, ?)" [[textsjisfile "..\\..\\doc\\dictionary.txt"]];
Command "select count(*) from T";
Command "insert into T (N, C) values (8, ?)" [[textsjisfile "..\\..\\doc\\Teihon.txt"]];
Command "select count(*) from T";
Command "insert into T (N, C) values (9, ?)" [[textsjisfile "..\\..\\doc\\takekurabe.txt"]];
# ここでマージが起こる
Command "select count(*) from T";
Command "insert into T (N, C) values (10, ?)" [[textsjisfile "..\\..\\doc\\KINGARTHURS_ROUNDTABLE.txt"]];
Command "select count(*) from T";
Command "insert into T (N, C) values (11, ?)" [[textsjisfile "..\\..\\doc\\Alangri-Gloriban.txt"]];
Command "select count(*) from T";

# select(1回目)
Command "select count(*) from T";
Command "select N from T where C like '%内閣総理大臣%'";
Command "select N from T where C like '%老婆%'";
Command "select N from T where C like '%foo%'";
Command "select N from T where C like '%ls%'";
Command "select N from T where C like '%オプション%'";
Command "select N from T where C like '%打者%'";
Command "select N from T where C like '%cryptography%'";
Command "select N from T where C like '%ディレクトリ%'";
Command "select N from T where C like '%address%'";
Command "select N from T where C like '%RFC%'";

#- delete 
Command "delete from T where N= 1";
Command "delete from T where N= 8";
Command "delete from T where N= 2";
# ここでマージが発生
Command "delete from T where N= 4";
Command "delete from T where N= 5";
Command "delete from T where N=11";
# ここでマージは発生
# これで残り件数は{3, 6, 7, 9, 10}の5つとなる

#- select(2回目)
Command "select count(*) from T";
Command "select N from T where C like '%内閣総理大臣%'";
Command "select N from T where C like '%老婆%'";
Command "select N from T where C like '%foo%'";
Command "select N from T where C like '%ls%'";
Command "select N from T where C like '%オプション%'";
Command "select N from T where C like '%打者%'";
Command "select N from T where C like '%cryptography%'";
Command "select N from T where C like '%ディレクトリ%'";
Command "select N from T where C like '%address%'";
Command "select N from T where C like '%RFC%'";

#- 残り5タプルの内容を全てupdate
Command "update T set C=? where N= 3" [[textsjisfile "..\\..\\doc\\introduction.txt"]];
Command "update T set C=? where N= 6" [[textsjisfile "..\\..\\doc\\RainyNight.txt"]];
Command "update T set C=? where N= 7" [[textsjisfile "..\\..\\doc\\Alangri-Gloriban.txt"]];
Command "update T set C=? where N= 9" [[textsjisfile "..\\..\\doc\\rasyoumon.txt"]];
Command "update T set C=? where N=10" [[textsjisfile "..\\..\\doc\\Teihon.txt"]];

#- select(3回目)
Command "select count(*) from T";
Command "select N from T where C like '%内閣総理大臣%'";
Command "select N from T where C like '%老婆%'";
Command "select N from T where C like '%foo%'";
Command "select N from T where C like '%ls%'";
Command "select N from T where C like '%オプション%'";
Command "select N from T where C like '%打者%'";
Command "select N from T where C like '%cryptography%'";
Command "select N from T where C like '%ディレクトリ%'";
Command "select N from T where C like '%address%'";
Command "select N from T where C like '%RFC%'";

#- 全文ファイルテスト用の表を消去
Command "drop table T";
TerminateSession;

#- DBを消去
InitializeSession "";
Command "drop database FullTextTest";
TerminateSession;
# (障害回復を試すためTerminateしない)

#- Parameterをデフォルト値に戻す
#SetSystemParameter "FullText_InsertMergeTupleSize" 0;
#SetSystemParameter "FullText_ExpungeMergeTupleSize" 0;
End;

