Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamesjue committed Nov 9, 2016
2 parents fa5150c + f256f9a commit 54e096b
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions sql-generation/jdbc/src/PelotonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,44 @@ private RandomColumnPredicate GetRandomColumnPredicate(Map<String, List<String>
public void run() {
try {
Statement stmt = connection.createStatement();
int num_ops = 300;
int num_ops = 50000;

Random random = new Random();
//random.setSeed(new Date().getTime());
random.setSeed(new Date().getTime());

for (int i = 0; i < num_ops; i++) {
RandomColumnPredicate predicate =
GetRandomColumnPredicate(dict, min_dict, max_dict, random, null);

String query = "select count(*) from " + predicate.table_ +
" where " + predicate.column_ + ">" + predicate.low_ +
" and " + predicate.column_ + "<" + predicate.high_;
ResultSet rs = stmt.executeQuery(query);
" where " + predicate.column_ + ">=" + predicate.low_ +
" and " + predicate.column_ + "<=" + predicate.high_;

System.out.println(predicate.column_ + " " + predicate.low_ + " " + predicate.high_);

switch (query_type) {
case (SINGLE_COLUMN): {
query = query + ";";
break;
}
case (TWO_COLUMNS): {
RandomColumnPredicate predicate2 =
GetRandomColumnPredicate(dict, min_dict, max_dict, random, predicate.table_);
query += " and " + predicate2.column_ + ">=" + predicate2.low_ +
" and " + predicate2.column_ + "<=" + predicate2.high_ + ";";

if (predicate.column_.equals(predicate2.column_) &&
predicate.low_ == predicate2.low_ &&
predicate.high_ == predicate2.high_) {
System.out.println("hahahahha");
continue;
}

System.out.println(predicate2.column_ + " " + predicate2.low_ + " " + predicate2.high_);
break;
}
}
ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {
System.out.println(rs.getInt(1));
Expand Down

0 comments on commit 54e096b

Please sign in to comment.