-
Notifications
You must be signed in to change notification settings - Fork 3
/
generateQueries.sh
58 lines (51 loc) · 1.23 KB
/
generateQueries.sh
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
#!/bin/bash
usage() {
echo "Usage: $0 -s <seed> -n <streams>"
exit 1
}
while getopts ":s:n:" options; do
case "${options}" in
s)
seed=${OPTARG}
if [[ $seed -lt 10 || $seed%10 -ne 0 ]]; then
usage
fi
;;
n)
streams=${OPTARG}
if [[ $streams -lt 0 || $streams -gt 100 ]]; then
usage
fi
;;
*)
usage
;;
esac
done
# Input validation
if [[ -z ${seed} || -z ${streams} ]]; then
usage
fi
# Copy files from ./queries to current directory
cp ./queries/*.sql ./
# Creating directories
initial_seed=$seed
end_seed=$(( $seed + $streams))
for ((i=$initial_seed; i<=$end_seed; i++)); do
mkdir -p ./queries/${i}
done
# Creating SQL files
for ((i=$initial_seed; i<=$end_seed; i++)); do
for j in {1..22}; do
sudo ./qgen $j -s 1 -r $i > ./queries/${i}/${j}.sql
done
done
# Creating and moving refresh function files
counter=1
for ((i=$initial_seed+1; i<=$end_seed; i++)); do
sudo ./dbgen -U ${counter}
mv lineitem.tbl.u${counter} ./queries/${i}/
mv orders.tbl.u${counter} ./queries/${i}/
mv delete.${counter} ./queries/${i}/
counter=$((counter+1))
done