-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.py
55 lines (44 loc) · 1.8 KB
/
generator.py
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
# _____ _
# / ____| | |
# | | __ ___ _ __ ___ _ __ __ _| |_ ___ _ __
# | | |_ |/ _ \ '_ \ / _ \ '__/ _` | __/ _ \| '__|
# | |__| | __/ | | | __/ | | (_| | || (_) | |
# \_____|\___|_| |_|\___|_| \__,_|\__\___/|_|
# Basic utility to generate data sets for benchmarking join algorithms.
# This script is called by controller.py and is not required to be run independently
import sys
import json
from colours import bcolors
table1 = []
table2 = []
if (len(sys.argv) != 5):
print(
bcolors.FAIL + "Bad input params! Requires 3 inputs: the number of rows to generate and the ouput names of the two files to create" + bcolors.ENDC)
sys.exit(1)
rows = sys.argv[1]
fileName1 = sys.argv[2]
fileName2 = sys.argv[3]
mode = sys.argv[4]
if "equal" in mode:
for index in range(0, int(rows)):
key1 = "table" + str(index)
key2 = "table" + str(int(sys.argv[1]) - index)
table1.append((key1, "1", "2", "3", "4"))
table2.append((key2, "5", "6", "7", "8"))
with open(fileName1, 'w') as tableOut1:
json.dump(table1, tableOut1)
with open(fileName2, 'w') as tableOut2:
json.dump(table2, tableOut2)
print(bcolors.OKGREEN + "Tables generated with {} rows".format(rows) + bcolors.ENDC)
if "best" in mode:
for index in range(0, int(rows)):
key1 = "table" + str(index)
table1.append((key1, "1", "2", "3", "4"))
if index%5==0:
key2 = "table" + str(int(sys.argv[1]) - index)
table2.append((key2, "5", "6", "7", "8"))
with open(fileName1, 'w') as tableOut1:
json.dump(table1, tableOut1)
with open(fileName2, 'w') as tableOut2:
json.dump(table2, tableOut2)
print(bcolors.OKGREEN + "Tables generated with {} rows".format(rows) + bcolors.ENDC)