# 複数結果を返す機能をKdTree索引
# Bug report 2327

Begin;
Initialize;
InitializeSession "RVSTest";
Command "create database RVSTest";
Command "create table Feature(pageid int, location float array[4] hint 'fixed', descriptor float array[32] hint heap)";

Command "insert into Feature values(0,array[551.495,310.218,2.75214,101.565],array[-5.86785,7.98651,-3.91733,-4.80196,4.55692,8.784,0.599392,0.829529,-5.71158,-6.11135,5.13918,-2.20816,-6.50402,-4.74902,-6.77222,4.22719,-2.8171,-7.89984,-1.54242,-9.52326,-0.967748,3.69404,-0.958691,-5.39129,-3.72875,1.01296,-4.14864,3.11964,5.34116,-3.22217,0.0601813,-2.9221])";
Command "insert into Feature values(0,array[199.563,177.776,5.56807,99.4595],array[9.32828,0.150305,3.27083,1.03594,11.867,11.4914,-0.460348,-0.947733,-2.80578,2.19199,5.49035,-2.32271,5.33898,-0.501778,-2.71151,-5.27847,-1.47833,-8.45601,-0.476848,-0.377861,3.13159,7.25209,5.56542,8.44895,-2.36617,-9.40228,3.10935,3.23405,-1.71107,0.868578,2.349,0.825743])";
Command "insert into Feature values(0,array[199.563,177.776,2.79001,99.4595],array[9.16625,2.44399,-0.460757,-1.62799,8.97917,4.81384,8.27629,-3.76048,-3.81488,-4.27118,0.84154,-5.36818,-3.79997,-3.41495,-2.56132,-3.19873,2.0189,16.7265,0.324819,-0.594918,-8.45537,3.1612,-2.39693,-0.659436,-4.574,-5.68548,-1.96829,6.59797,4.42361,-8.33702,6.65332,3.51618])";
Command "insert into Feature values(0,array[543.313,971.236,4.57894,67.1585],array[-7.76655,-2.06204,3.51066,0.173323,-1.27919,9.9584,-8.48457,2.67199,-4.62442,0.843711,1.59162,2.87296,-2.80092,0.631922,3.55341,-11.0049,0.806002,4.52096,2.17997,-1.62397,-5.75173,-1.82865,1.81778,0.250228,1.59607,-0.744901,-5.8065,-1.1111,-0.422613,4.22739,2.82671,7.36337])";
Command "insert into Feature values(0,array[112.41,111.761,5.74362,48.7499],array[-2.05201,2.62482,-8.61348,-3.21599,10.576,8.76957,-5.14318,4.25491,1.92023,-0.856912,8.29038,-10.2187,0.327773,0.332023,-3.2482,6.42823,-1.54763,-7.64965,-4.54357,-10.6137,-0.526735,1.39449,-1.00328,-3.47224,2.81624,8.25947,6.03755,6.37776,-2.393,-0.46087,6.96274,3.14425])";
Command "insert into Feature values(0,array[112.41,111.761,5.29076,48.7499],array[0.00893382,3.47944,-7.62951,-6.7564,8.01797,11.5306,-1.64696,-1.90097,1.02038,3.35348,4.43258,-5.68648,4.15418,8.92611,-0.0446371,4.96484,3.29165,-11.6447,-2.89148,-7.34789,-0.324906,1.44345,-7.22625,-1.70024,-8.91559,2.11124,1.87694,10.0168,-1.71835,0.464679,2.48237,1.19945])";
Command "insert into Feature values(0,array[715.942,87.6775,4.4005,47.7517],array[10.5445,-0.286774,1.64194,0.0791318,10.2018,7.47832,0.548828,2.18189,-0.462821,-2.60717,2.0512,-13.4886,-3.35876,-0.145599,-6.18255,-7.89176,0.560848,1.3195,1.25758,1.18509,4.525,2.06662,2.65387,-5.26133,-2.02587,-0.00791392,5.86898,0.877567,-0.848627,-2.09733,5.1383,2.58819])";
Command "insert into Feature values(0,array[715.942,87.6775,0.949452,47.7517],array[8.14184,3.99234,-0.180232,3.35505,8.24749,4.10181,6.4294,-0.178247,0.955278,4.96682,4.25582,1.85596,4.20817,2.85189,8.44899,0.437658,-1.755,8.61994,12.7859,2.51448,-5.85459,7.97187,0.513816,3.17361,0.174951,-1.41149,4.32842,4.17226,4.35042,4.77209,7.81064,7.08714])";
Command "insert into Feature values(0,array[547.392,769.9,6.15157,44.539],array[11.73,4.64334,2.14931,2.66997,5.71938,6.39625,0.290781,-8.69124,6.15554,3.69423,2.63907,-0.154841,4.7195,2.3796,-0.249291,-5.85613,-2.65387,7.91614,3.60942,2.98837,0.874405,3.53115,-0.102832,0.809305,2.20252,-1.67893,-0.112746,3.46256,4.13605,-4.03535,2.45246,-5.61855])";
Command "insert into Feature values(0,array[547.392,769.9,2.54783,44.539],array[10.9542,6.5553,1.44103,-2.09213,5.52049,6.46994,2.44322,4.65317,7.7689,-5.39472,6.84865,-3.45675,0.388677,-1.50076,-1.93389,-5.41232,7.13951,4.05269,-3.51745,-2.4516,1.24999,1.45298,-0.608593,-0.165947,-4.42111,1.75746,9.6292,1.36009,0.736265,1.96345,-3.66362,2.99532])";

Command "create kdtree index Feature_descriptor on Feature(descriptor) hint 'maxcalculatecount=100, tracetype=rvs'";

Command "select pageid, location from Feature where neighbor(descriptor) in (array[-7.32811,1.44494,-14.1816,1.20234,-0.0323605,-4.76759,-1.7767,1.21465,0.735355,-4.07512,-4.31307,2.04,-2.75697,-0.820752,-3.19484,-6.15097,-3.71182,0.721054,-5.86679,0.173303,2.70669,0.732093,3.81001,-0.818156,-3.62014,-4.10679,4.28485,2.92131,-2.86646,0.340651,2.32838,-0.514865],array[-8.06229,10.0215,4.74109,-12.4151,-6.49127,-7.42886,0.314012,1.00807,-3.39074,-0.448173,2.44048,1.12883,0.708119,-4.7842,-3.85837,3.42984,-0.692436,0.50288,-2.19444,3.78336,0.269917,5.55502,0.792979,-4.07934,-0.783239,0.752185,-4.05653,2.72716,-2.95701,-4.69478,-3.24898,3.53384])";

Command "select pageid, location from Feature where neighbor(descriptor) in (array[-7.32811,1.44494,-14.1816,1.20234,-0.0323605,-4.76759,-1.7767,1.21465,0.735355,-4.07512,-4.31307,2.04,-2.75697,-0.820752,-3.19484,-6.15097,-3.71182,0.721054,-5.86679,0.173303,2.70669,0.732093,3.81001,-0.818156,-3.62014,-4.10679,4.28485,2.92131,-2.86646,0.340651,2.32838,-0.514865]) order by neighbor(descriptor).distance limit 3";

Command "select pageid, location, neighbor(descriptor).id from Feature where neighbor(descriptor) in (array[-7.32811,1.44494,-14.1816,1.20234,-0.0323605,-4.76759,-1.7767,1.21465,0.735355,-4.07512,-4.31307,2.04,-2.75697,-0.820752,-3.19484,-6.15097,-3.71182,0.721054,-5.86679,0.173303,2.70669,0.732093,3.81001,-0.818156,-3.62014,-4.10679,4.28485,2.92131,-2.86646,0.340651,2.32838,-0.514865],array[-8.06229,10.0215,4.74109,-12.4151,-6.49127,-7.42886,0.314012,1.00807,-3.39074,-0.448173,2.44048,1.12883,0.708119,-4.7842,-3.85837,3.42984,-0.692436,0.50288,-2.19444,3.78336,0.269917,5.55502,0.792979,-4.07934,-0.783239,0.752185,-4.05653,2.72716,-2.95701,-4.69478,-3.24898,3.53384]) order by neighbor(descriptor).distance limit 3";

Command "select pageid, location, neighbor(descriptor).id, neighbor(descriptor).distance from Feature where neighbor(descriptor) in (array[-7.32811,1.44494,-14.1816,1.20234,-0.0323605,-4.76759,-1.7767,1.21465,0.735355,-4.07512,-4.31307,2.04,-2.75697,-0.820752,-3.19484,-6.15097,-3.71182,0.721054,-5.86679,0.173303,2.70669,0.732093,3.81001,-0.818156,-3.62014,-4.10679,4.28485,2.92131,-2.86646,0.340651,2.32838,-0.514865],array[-8.06229,10.0215,4.74109,-12.4151,-6.49127,-7.42886,0.314012,1.00807,-3.39074,-0.448173,2.44048,1.12883,0.708119,-4.7842,-3.85837,3.42984,-0.692436,0.50288,-2.19444,3.78336,0.269917,5.55502,0.792979,-4.07934,-0.783239,0.752185,-4.05653,2.72716,-2.95701,-4.69478,-3.24898,3.53384]) order by neighbor(descriptor).distance limit 3";

Command "select pageid, location, neighbor(descriptor).id, neighbor(descriptor).distance from Feature where neighbor(descriptor hint 'maxcalculatecount=1000') in (array[-7.32811,1.44494,-14.1816,1.20234,-0.0323605,-4.76759,-1.7767,1.21465,0.735355,-4.07512,-4.31307,2.04,-2.75697,-0.820752,-3.19484,-6.15097,-3.71182,0.721054,-5.86679,0.173303,2.70669,0.732093,3.81001,-0.818156,-3.62014,-4.10679,4.28485,2.92131,-2.86646,0.340651,2.32838,-0.514865],array[-8.06229,10.0215,4.74109,-12.4151,-6.49127,-7.42886,0.314012,1.00807,-3.39074,-0.448173,2.44048,1.12883,0.708119,-4.7842,-3.85837,3.42984,-0.692436,0.50288,-2.19444,3.78336,0.269917,5.55502,0.792979,-4.07934,-0.783239,0.752185,-4.05653,2.72716,-2.95701,-4.69478,-3.24898,3.53384]) order by neighbor(descriptor).distance limit 3";

Command "select pageid, location, neighbor(descriptor).id, neighbor(descriptor).distance from Feature where neighbor(descriptor hint 'tracetype=serial') in (array[-7.32811,1.44494,-14.1816,1.20234,-0.0323605,-4.76759,-1.7767,1.21465,0.735355,-4.07512,-4.31307,2.04,-2.75697,-0.820752,-3.19484,-6.15097,-3.71182,0.721054,-5.86679,0.173303,2.70669,0.732093,3.81001,-0.818156,-3.62014,-4.10679,4.28485,2.92131,-2.86646,0.340651,2.32838,-0.514865],array[-8.06229,10.0215,4.74109,-12.4151,-6.49127,-7.42886,0.314012,1.00807,-3.39074,-0.448173,2.44048,1.12883,0.708119,-4.7842,-3.85837,3.42984,-0.692436,0.50288,-2.19444,3.78336,0.269917,5.55502,0.792979,-4.07934,-0.783239,0.752185,-4.05653,2.72716,-2.95701,-4.69478,-3.24898,3.53384]) order by neighbor(descriptor).distance limit 3";

Command "select pageid, location, neighbor(descriptor).id, neighbor(descriptor).distance from Feature where neighbor(descriptor hint 'tracetype=normal, maxcalculatecount=1000') in (array[-7.32811,1.44494,-14.1816,1.20234,-0.0323605,-4.76759,-1.7767,1.21465,0.735355,-4.07512,-4.31307,2.04,-2.75697,-0.820752,-3.19484,-6.15097,-3.71182,0.721054,-5.86679,0.173303,2.70669,0.732093,3.81001,-0.818156,-3.62014,-4.10679,4.28485,2.92131,-2.86646,0.340651,2.32838,-0.514865],array[-8.06229,10.0215,4.74109,-12.4151,-6.49127,-7.42886,0.314012,1.00807,-3.39074,-0.448173,2.44048,1.12883,0.708119,-4.7842,-3.85837,3.42984,-0.692436,0.50288,-2.19444,3.78336,0.269917,5.55502,0.792979,-4.07934,-0.783239,0.752185,-4.05653,2.72716,-2.95701,-4.69478,-3.24898,3.53384]) order by neighbor(descriptor).distance limit 3";

Command "select pageid, location, neighbor(descriptor).id, neighbor(descriptor).distance from Feature where neighbor(descriptor hint 'maxcalculatecount=1000, tracetype=rvs') in (array[-7.32811,1.44494,-14.1816,1.20234,-0.0323605,-4.76759,-1.7767,1.21465,0.735355,-4.07512,-4.31307,2.04,-2.75697,-0.820752,-3.19484,-6.15097,-3.71182,0.721054,-5.86679,0.173303,2.70669,0.732093,3.81001,-0.818156,-3.62014,-4.10679,4.28485,2.92131,-2.86646,0.340651,2.32838,-0.514865],array[-8.06229,10.0215,4.74109,-12.4151,-6.49127,-7.42886,0.314012,1.00807,-3.39074,-0.448173,2.44048,1.12883,0.708119,-4.7842,-3.85837,3.42984,-0.692436,0.50288,-2.19444,3.78336,0.269917,5.55502,0.792979,-4.07934,-0.783239,0.752185,-4.05653,2.72716,-2.95701,-4.69478,-3.24898,3.53384]) order by neighbor(descriptor).distance limit 3";

Command "drop database RVSTest";

TerminateSession;
Terminate;
End;
