1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#!/usr/local/dist/bin/perl -w
# use this one on Linux
#!/usr/bin/perl -w
# This program generates query files for use with test_benchmark. It
# generates all files needed for executing the measurements specified
# in the PhD thesis. It is not too generic, most of the things are
# hardcoded.
# each query is repeated 20 times
$repeat = 20;
# the collections which are used.
@mdd = ( tomo_cubed, tomo_cubed_16, tomo_cubed_64, tomo_sliced );
# the file name suffixes used for the collections
@suffixes = ( _32, _16, _64, _s );
# the selectivities tested for each collection
@selectivity = ( .5, 1, 2, 5, 10, 20, 50 );
# the filenames used to store the results
sub calcQueryBox($$$$$$$$$);
sub randNum($$);
# initialize rand()
srand();
sub randNum($$)
{
my ($l, $h) = @_;
return int ( $l + rand()*($h-$l) );
}
# this function calculates a random query box given the spatial
#
sub calcQueryBox($$$$$$$$$)
{
my ( $xl, $xh, $yl, $yh, $zl, $zh, $xd, $yd, $zd ) = @_;
$x1 = randNum( $xl, $xh - $xd + 1);
$x2 = $x1 + ( $xd - 1 > 0 ? $xd - 1 : 0 );
$y1 = randNum( $yl, $yh - $yd + 1);
$y2 = $y1 + ( $yd - 1 > 0 ? $yd - 1 : 0 );
$z1 = randNum( $zl, $zh - $zd + 1);
$z2 = $z1 + ( $zd - 1 > 0 ? $zd - 1 : 0 );
return "[$x1:$x2, $y1:$y2, $z1:$z2]";
}
$headerStr = "
// Testing acces to tomo_cubed with moving query box on different
// selectivities.
";
foreach $tomo (@mdd)
{
$suffix = shift @suffixes;
$fName1 = "tcubemov" . $suffix . ".ql";
$fName2 = "tcubeavg" . $suffix . ".ql";
open(QUERY1,">$fName1");
open(QUERY2,">$fName2");
print QUERY1 "$headerStr\n\n";
print QUERY2 "$headerStr\n\n";
foreach $sel (@selectivity)
{
$dx = $dy = int ( ($sel/100)**(1/3) * 256 );
$dz = int ( ($sel/100)**(1/3) * 154 );
# adapt query box for better fit
if(++$dx * $dy * $dz <= $sel/100*256*256*154) {
if($dx * ++$dy * $dz <= $sel/100*256*256*154) {
if($dx * $dy * ++$dz <= $sel/100*256*256*154) {
}
else {
$dz--;
}
}
else {
$dy--;
}
}
else {
$dx--;
}
for ($i = 1; $i <= $repeat; $i++) {
$qBox = calcQueryBox( 0, 255, 0, 255, 0, 153, $dx, $dy, $dz );
# print Query
print QUERY1 "// [$sel]: $qBox\n";
print QUERY2 "// [$sel]: $qBox\n";
print QUERY1 "SELECT img$qBox\nFROM $tomo AS img\n";
print QUERY2 "SELECT avg_cells(img$qBox)\nFROM $tomo AS img\n";
}
}
}
@suffixes = ( _32, _16, _64, _s );
foreach $tomo (@mdd)
{
$suffix = shift @suffixes;
$fName1 = "tslicemov" . $suffix . ".ql";
$fName2 = "tsliceavg" . $suffix . ".ql";
open(QUERY1,">$fName1");
open(QUERY2,">$fName2");
print QUERY1 "$headerStr\n\n";
print QUERY2 "$headerStr\n\n";
foreach $sel (@selectivity)
{
$dx = int ( ($sel/100) * 256 );
for ($i = 1; $i <= $repeat; $i++) {
$qBox = calcQueryBox( 0, 255, 0, 255, 0, 153, $dx, 256, 154 );
# print Query
print QUERY1 "// [$sel]: $qBox\n";
print QUERY2 "// [$sel]: $qBox\n";
print QUERY1 "SELECT img$qBox\nFROM $tomo AS img\n";
print QUERY2 "SELECT avg_cells(img$qBox)\nFROM $tomo AS img\n";
}
}
}
|