-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_sql.sh
executable file
·76 lines (64 loc) · 1.94 KB
/
run_sql.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
chmod +x ./project_sql/run_project.sh
if [ -f "dimacs_pg.graph" ]; then
rm dimacs_pg.graph
fi
if [ -f "dimacs_jg.graph" ]; then
rm dimacs_jg.graph
fi
if [ $# -eq 0 ]; then
echo "No query file or benchmark directory specified."
exit 0
fi
BENCHMARK=""
SCHEMA=""
cd project_sql/
BENCHMARK="../$1/*.sql"
SCHEMA="$1/schema.txt"
RESULTS="results_$1.txt"
if [[ "$BENCHMARK" != "" ]]; then
if [ -f $RESULTS ]; then
rm $RESULTS
fi
COUNTER=1
TOTAL=$(ls -l $BENCHMARK | wc -l)
echo "Benchmark: $1"
for FILE in $BENCHMARK; do
echo "QUERY: " $FILE >> $RESULTS
echo -ne "$COUNTER / $TOTAL \r"
./run_project.sh "$SCHEMA" "$1/$FILE" > res.log 2>&1
../Triangulator/main -treewidth < ../dimacs_pg.graph 2>&1 | \
while IFS= read line; do
if [[ "$line" == Treewidth* ]]; then
echo "tw(H) = ${line#'Treewidth: '}" >> $RESULTS
fi
done
../Triangulator/main -treewidth < ../dimacs_jg.graph 2>&1 | \
while IFS= read line; do
if [[ "$line" == Treewidth* ]]; then
echo "tw(H') = ${line#'Treewidth: '}" >> $RESULTS
fi
done
K=1
FOUND=false
while [ $FOUND == "false" ]; do
while IFS= read line; do
if [[ "$line" == 'Hypertree of width'*'not found'* ]]; then
break
elif [[ "$line" == *hypertree-width:* ]]; then
hw=${line#*'hypertree-width: '}
hw=${hw%').'}
echo "hw(H) = $hw for k = $K" >> $RESULTS
FOUND=true
fi
done <<<$( ../newdetkdecomp/bin/detkdecomp $K ../hypergraph.txt 2>&1)
(( K++ ))
done
COUNTER=$((COUNTER+1))
rm ../dimacs_pg.graph
done
echo $'\n'
exit 0
fi
./run_project.sh "$@"
../Triangulator/main -treewidth <../dimacs_pg.graph