Skip to content
This repository was archived by the owner on Apr 21, 2020. It is now read-only.

Commit e07d0bb

Browse files
committed
Fixed test infrastructure to work with cexpr sql architecture
1 parent e822fe3 commit e07d0bb

File tree

6 files changed

+48
-15
lines changed

6 files changed

+48
-15
lines changed

resources/tests/data.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
using books =
99
sql::schema<
1010
sql::index<>,
11+
#ifdef CROSS
1112
sql::column<"book", std::string>,
13+
#else
14+
sql::column<"title", std::string>,
15+
#endif
1216
sql::column<"genre", std::string>,
1317
sql::column<"year", unsigned>,
1418
sql::column<"pages", unsigned>
@@ -17,7 +21,11 @@ using books =
1721
using stories =
1822
sql::schema<
1923
sql::index<>,
24+
#ifdef CROSS
2025
sql::column<"story", std::string>,
26+
#else
27+
sql::column<"title", std::string>,
28+
#endif
2129
sql::column<"genre", std::string>,
2230
sql::column<"year", unsigned>
2331
>;

resources/tests/data/library.db

144 KB
Binary file not shown.

resources/tests/data/stories-table.tsv

-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,6 @@ The Flower of Shazui science fiction 2012
489489
The Forces that Crush science fiction 1958
490490
The Form of the Sword fiction 1942
491491
The Funeral science fiction 1972
492-
The Funeral science fiction 1972
493492
The Fusion Bomb science fiction 1972
494493
The Garden of Forking Paths fiction 1941
495494
The Gateway Asteroid science fiction 1990

resources/tests/generate.py

+20-10
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
tables = ["books", "stories", "authored", "collected"]
88
columns = {
9-
"books": ["book", "genre", "year", "pages"],
10-
"stories": ["story", "genre", "year"],
9+
# "books": ["book", "genre", "year", "pages"],
10+
"books": ["title", "genre", "year", "pages"],
11+
# "stories": ["story", "genre", "year"],
12+
"stories": ["title", "genre", "year"],
1113
"authored": ["title", "name"],
1214
"collected": ["title", "collection", "pages"]
1315
}
@@ -17,10 +19,11 @@
1719
"authored": [],
1820
"collected": []
1921
}
20-
joins = ["cross", "natural"]
22+
# joins = ["cross"]
23+
joins = ["natural"]
2124
renames = {
2225
"genre": "type",
23-
"year": "published",
26+
"year": "published"
2427
}
2528
integral = ["year", "pages"]
2629
all_comp = ["=", "!=", "<>"]
@@ -33,8 +36,11 @@
3336
"pages": [300],
3437
"genre": ["science fiction"]
3538
}
36-
37-
query_output = open("all-queries.txt", "w")
39+
outfiles = {
40+
"joinless": open("joinless-queries.txt", "w"),
41+
# "cross": open("cross-queries.txt", "w"),
42+
"natural": open("natural-queries.txt", "w")
43+
}
3844

3945
def col_list(cs):
4046
cl = []
@@ -57,23 +63,25 @@ def col_list(cs):
5763

5864
def froms(ts):
5965
f = []
66+
output = outfiles["joinless"]
6067
if len(ts) == 1:
6168
f = [ts[0]]
6269
else:
6370
for j in joins:
71+
output = outfiles[j]
6472
if random.random() < 0.3333:
6573
j = j.upper()
6674
f += [ts[0] + " " + j + " join " + ts[1]]
67-
return f
75+
return f, output
6876

6977
def compose(ts, cs, pred):
7078
if pred != "":
7179
pred = " where " + pred
7280
cols = col_list(cs)
73-
sel = froms(ts)
81+
sel, output = froms(ts)
7482
for s in sel:
7583
for c in cols:
76-
query_output.write("select " + c + " from " + s + pred + "\n")
84+
output.write("select " + c + " from " + s + pred + "\n")
7785

7886
def next(cs, ci):
7987
if ci >= len(cs):
@@ -139,4 +147,6 @@ def main():
139147

140148
if __name__ == "__main__":
141149
main()
142-
query_output.close()
150+
outfiles["joinless"].close()
151+
# outfiles["cross"].close()
152+
outfiles["natural"].close()

resources/tests/runner.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
def main():
44
os.system("python3 select.py")
55
num = 1
6+
token = ""
67
with open("test-queries.txt", "r") as queries:
78
for query in queries:
8-
query.strip()
9+
query = query.strip()
10+
if query[0] != "s":
11+
token = query
12+
continue
913
q = open("query.txt", "w")
1014
q.write(query + "\n")
1115
q.close()
1216
os.system("python3 compose.py")
13-
os.system("g++ -std=c++2a -O3 -I../../include -o test test.cpp")
17+
os.system("g++ -std=c++2a " + "-D" + token + " -O3 -I../../include -o test test.cpp")
1418
os.system("./test | sort > cpp-results.txt")
1519
os.system("sqlite3 data/library.db \"" + query + ";\" | sort > sql-results.txt")
1620
stream = os.popen("diff cpp-results.txt sql-results.txt")

resources/tests/select.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,21 @@
33
import random
44

55
def main():
6-
h = 500 / 1380000
76
outfile = open("test-queries.txt", "w")
8-
with open("all-queries.txt", "r") as infile:
7+
h = 100 / 23000
8+
outfile.write("JOINLESS\n")
9+
with open("joinless-queries.txt", "r") as infile:
10+
for line in infile:
11+
if random.random() < h:
12+
outfile.write(line)
13+
h = 500 / 700000
14+
outfile.write("CROSS\n")
15+
with open("cross-queries.txt", "r") as infile:
16+
for line in infile:
17+
if random.random() < h:
18+
outfile.write(line)
19+
outfile.write("NATURAL\n")
20+
with open("natural-queries.txt", "r") as infile:
921
for line in infile:
1022
if random.random() < h:
1123
outfile.write(line)

0 commit comments

Comments
 (0)