~codership/randgen/randgen_gc

« back to all changes in this revision

Viewing changes to util/maxigen/maxigen.sh

  • Committer: Raghavendra D Prabhu
  • Date: 2013-10-10 18:30:19 UTC
  • mfrom: (858.1.69 randgen-coding)
  • Revision ID: raghavendra.prabhu@percona.com-20131010183019-smhqjw797ni1pkro
Merged upstream randgen

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
fi
25
25
 
26
26
RND_DIR=$(echo $RANDOM$RANDOM$RANDOM | sed 's/..\(......\).*/\1/')
27
 
NR_OF_GRAMMARS=500
28
 
LINES_PER_GRAM=3     # The number of queries (rules) to extract from each sub-grammar created from the existing RQG grammars by maxigen.pl
 
27
NR_OF_GRAMMARS=300
 
28
LINES_PER_GRAM=7     # The number of queries (rules) to extract from each sub-grammar created from the existing RQG grammars by maxigen.pl
29
29
QUERIES=$[$NR_OF_GRAMMARS * $LINES_PER_GRAM]
30
30
 
31
31
mkdir /tmp/$RND_DIR
38
38
 
39
39
FIN_GRAM_SIZE=$[$LINES_PER_GRAM * $LOOP]
40
40
echo "----------------------------------------------------------------------------------------"
41
 
echo "| Welcome to MaxiGen v0.40 - A Powerfull RQG Random Grammar Generator"
 
41
echo "| Welcome to MaxiGen v0.41 - A Powerfull RQG Random Grammar Generator"
42
42
echo "----------------------------------------------------------------------------------------"
43
43
echo "| IMPORTANT: by default a Percona-Server-only compatible cc file is used (maxigen.cc)"
44
44
echo "| If you would like to use the MySQL-Server compatible cc file maxigenMS.cc (and thus"
75
75
  #egrep -v "^$|^[; \t]*$|Sentence is now longer|return undef|no strict|{|}" $GRAMMAR > ${GRAMMAR}.new
76
76
  # Maybe Perl is not so unhandy after all. Example:
77
77
  #  SELECT * FROM { if (scalar(@created_tables) > 0) { $prng->arrayElement(\@created_tables) } else { $prng->letter() } };
78
 
  # To be tested, may be ok for some, not ok for others
79
 
  egrep -v "^$|^[; \t]*$|SET SESSION debug|SET GLOBAL debug|Sentence is now longer" $GRAMMAR > ${GRAMMAR}.new
 
78
  # To be tested, may be ok for some, not ok for others. Example: filtering " table1 " as queries with this string create all trials to fail.
 
79
  egrep -v "^$|^[; \t]*$|SET SESSION debug|SET GLOBAL debug| table1 |Sentence is now longer" $GRAMMAR > ${GRAMMAR}.new
80
80
  rm ${GRAMMAR}
81
81
  mv ${GRAMMAR}.new ${GRAMMAR}
82
82
  echo -n "$LOOP..."
93
93
done
94
94
 
95
95
LOOP=0
96
 
echo -e "\n\nStage 4 ($NR_OF_GRAMMARS): Shuffle mix all queries generated from existing RQG grammars into $NR_OF_GRAMMARS new grammars"
 
96
echo -e "\n\nStage 4 ($ORIG_GRAMMARS): Shuffle mix all queries generated from existing RQG grammars into $NR_OF_GRAMMARS new grammars"
97
97
for GRAMMAR in $(find /tmp/$RND_DIR/ -name '*.yy'); do
98
98
  LOOP=$[$LOOP +1]
99
99
  for ((i=1;i<=$NR_OF_GRAMMARS;i++)); do
100
100
    TOP=$[ $i * $LINES_PER_GRAM - $LINES_PER_GRAM + 1]
101
101
    END=$[ $i * $LINES_PER_GRAM ]
 
102
    # This sed will *not* duplicate end-of-file lines if there aren't sufficient lines; output will simply be blank when addressing past EOF
102
103
    sed -n "${TOP},${END}p" $GRAMMAR >> /tmp/$RND_DIR/_${i}.yy
103
104
  done
104
105
  echo -n "$LOOP..."
108
109
rm /tmp/$RND_DIR/[0-9]*.yy
109
110
 
110
111
LOOP=0
111
 
echoi -e "\n\nStage 5 ($NR_OF_GRAMMARS): Setup grammars to be correctly formed"
 
112
echo -e "\n\nStage 5 ($NR_OF_GRAMMARS): Setup grammars to be correctly formed"
112
113
for GRAMMAR in $(find /tmp/$RND_DIR/ -name '*.yy'); do
113
114
  LOOP=$[$LOOP +1]
114
115
  echo "query:" > /tmp/$RND_DIR/${LOOP}.yy