forked from yuan-fei/TPCH-Greenplum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark_prepare.sh
59 lines (52 loc) · 1.15 KB
/
benchmark_prepare.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
59
#!/bin/sh
set -e
GP_TPCH_HOME=`readlink -f .`
DSS_TEMPLATES=$GP_TPCH_HOME/dss/templates
DSS_QUERIES=$GP_TPCH_HOME/dss/queries
DSS_DATA=$GP_TPCH_HOME/dss/data
DBGEN=$GP_TPCH_HOME/tpch/dbgen
gen_queries=false
gen_data=false
SIZE_G=false
while getopts 'qd:' flag; do
case "${flag}" in
q) gen_queries=true ;;
d)
gen_data=true
SIZE_G="${OPTARG}" ;;
*) error "Unexpected option ${flag}" ;;
esac
done
function generate_data(){
cd $DBGEN
make
rm -rf *.tbl
rm -rf *.csv
./dbgen -s $SIZE_G
# pg recognizable format: remove ending '|'
for i in `ls *.tbl`; do sed 's/|$//' $i > ${i/tbl/csv}; echo $i; done;
rm -rf $DSS_DATA
mkdir $DSS_DATA
mv *.csv $DSS_DATA/
rm -rf /tmp/dss-data
ln -s $DSS_DATA /tmp/dss-data
}
function generate_queries(){
cd $DBGEN
rm -rf $DSS_QUERIES
mkdir $DSS_QUERIES
# generate test queries
for q in `seq 1 22`
do
DSS_QUERY=$DSS_TEMPLATES ./qgen $q >> $DSS_QUERIES/$q.sql
sed 's/^select/explain select/' $DSS_QUERIES/$q.sql > $DSS_QUERIES/$q.explain.sql
done
}
if $gen_queries; then
echo 'generate queries'
generate_queries
fi
if $gen_data; then
echo "generate data with scale $SIZE_G G"
generate_data
fi