|
4 | 4 | import db.schema.entity.Attribute;
|
5 | 5 | import db.schema.entity.Query;
|
6 | 6 | import db.schema.entity.Table;
|
| 7 | +import db.schema.entity.Workload; |
7 | 8 | import db.schema.types.AttributeType;
|
8 | 9 | import db.schema.types.TableType;
|
9 | 10 | import db.schema.utils.AttributeUtils;
|
|
15 | 16 | import java.io.FileWriter;
|
16 | 17 | import java.io.IOException;
|
17 | 18 | import java.sql.Types;
|
18 |
| -import java.util.ArrayList; |
19 |
| -import java.util.Arrays; |
20 |
| -import java.util.List; |
21 |
| -import java.util.Random; |
| 19 | +import java.util.*; |
22 | 20 |
|
23 | 21 | public class BenchmarkTables {
|
24 |
| - public static enum Type {TPC_H_CUSTOMER, TPC_H_LINEITEM, TPC_H_ORDERS, TPC_H_PART, TPC_H_PARTSUPP, TPC_H_SUPPLIER, TPC_H_NATION, TPC_H_REGION} |
| 22 | + public static enum Type {TPC_H_CUSTOMER, TPC_H_LINEITEM, TPC_H_ORDERS, TPC_H_PART, TPC_H_PARTSUPP, TPC_H_SUPPLIER, TPC_H_NATION, TPC_H_REGION, TPC_H_ALL} |
25 | 23 |
|
26 | 24 | public static class BenchmarkConfig {
|
27 | 25 | private String dataFileDir;
|
@@ -53,7 +51,65 @@ public void setTableType(TableType tableType) {
|
53 | 51 | }
|
54 | 52 | }
|
55 | 53 |
|
56 |
| - /*Begin Debugging Begin*/ |
| 54 | + public static Table tpchCustomer(BenchmarkConfig conf){ |
| 55 | + Attribute custKey = new Attribute("c_CustKey", AttributeType.Integer()); |
| 56 | + custKey.primaryKey = true; |
| 57 | + |
| 58 | + Attribute name = new Attribute("c_Name", AttributeType.CharacterVarying(25)); |
| 59 | + Attribute address = new Attribute("c_Address", AttributeType.CharacterVarying(40)); |
| 60 | + Attribute nationKey = new Attribute("c_NationKey", AttributeType.Integer()); |
| 61 | + Attribute phone = new Attribute("c_Phone", AttributeType.Character(15)); |
| 62 | + Attribute acctBal = new Attribute("c_AcctBal", AttributeType.Real()); |
| 63 | + Attribute mktSegment = new Attribute("c_MktSegment", AttributeType.Character(10)); |
| 64 | + Attribute comment = new Attribute("c_Comment", AttributeType.CharacterVarying(117)); |
| 65 | + |
| 66 | + List<Attribute> attributes = new ArrayList<Attribute>(); |
| 67 | + attributes.add(custKey); |
| 68 | + attributes.add(name); |
| 69 | + attributes.add(address); |
| 70 | + attributes.add(nationKey); |
| 71 | + attributes.add(phone); |
| 72 | + attributes.add(acctBal); |
| 73 | + attributes.add(mktSegment); |
| 74 | + attributes.add(comment); |
| 75 | + |
| 76 | + Table t = new Table("customer", conf.getTableType(), attributes); |
| 77 | + t.pk = "c_CustKey"; |
| 78 | + t.workload = BenchmarkWorkloads.tpchCustomer(attributes, conf.getScaleFactor()); |
| 79 | + t.workload.dataFileName = conf.getDataFileDir() + "customer.tbl"; |
| 80 | + return t; |
| 81 | + } |
| 82 | + |
| 83 | + public static Table tpchLineitem(BenchmarkConfig conf){ |
| 84 | + |
| 85 | + List<Attribute> attributes = new ArrayList<Attribute>(); |
| 86 | + |
| 87 | + attributes.add(new Attribute("l_OrderKey", AttributeType.Integer())); |
| 88 | + attributes.add(new Attribute("l_PartKey", AttributeType.Integer())); |
| 89 | + attributes.add(new Attribute("l_SuppKey", AttributeType.Integer())); |
| 90 | + attributes.add(new Attribute("l_Linenumber", AttributeType.Integer())); |
| 91 | + attributes.add(new Attribute("l_Quantity", AttributeType.Real())); |
| 92 | + attributes.add(new Attribute("l_ExtendedPrice", AttributeType.Real())); |
| 93 | + attributes.add(new Attribute("l_Discount", AttributeType.Real())); |
| 94 | + attributes.add(new Attribute("l_Tax", AttributeType.Real())); |
| 95 | + attributes.add(new Attribute("l_ReturnFlag", AttributeType.Character(1))); |
| 96 | + attributes.add(new Attribute("l_LineStatus", AttributeType.Character(1))); |
| 97 | + attributes.add(new Attribute("l_ShipDate", AttributeType.Date("yyyy-MM-dd"))); |
| 98 | + attributes.add(new Attribute("l_CommitDate", AttributeType.Date("yyyy-MM-dd"))); |
| 99 | + attributes.add(new Attribute("l_ReceiptDate", AttributeType.Date("yyyy-MM-dd"))); |
| 100 | + attributes.add(new Attribute("l_ShipInstruct", AttributeType.Character(25))); |
| 101 | + attributes.add(new Attribute("l_ShipMode", AttributeType.Character(10))); |
| 102 | + attributes.add(new Attribute("l_Comment", AttributeType.CharacterVarying(44))); |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + Table t = new Table("lineitem", conf.getTableType(), attributes); |
| 107 | + t.pk = "l_OrderKey,l_Linenumber"; |
| 108 | + t.workload = BenchmarkWorkloads.tpchLineitem(attributes, conf.getScaleFactor()); |
| 109 | + t.workload.dataFileName = conf.getDataFileDir() + "lineitem.tbl"; |
| 110 | + |
| 111 | + return t; |
| 112 | + } |
57 | 113 |
|
58 | 114 | public static Table tpchAll(BenchmarkConfig conf){
|
59 | 115 |
|
@@ -163,64 +219,35 @@ public static Table tpchAll(BenchmarkConfig conf){
|
163 | 219 | System.out.println(t.workload.dataFileName);
|
164 | 220 | return t;
|
165 | 221 | }
|
166 |
| - /*End Debugging End*/ |
167 | 222 |
|
168 |
| - public static Table tpchCustomer(BenchmarkConfig conf){ |
169 |
| - Attribute custKey = new Attribute("c_CustKey", AttributeType.Integer()); |
170 |
| - custKey.primaryKey = true; |
171 |
| - |
172 |
| - Attribute name = new Attribute("c_Name", AttributeType.CharacterVarying(25)); |
173 |
| - Attribute address = new Attribute("c_Address", AttributeType.CharacterVarying(40)); |
174 |
| - Attribute nationKey = new Attribute("c_NationKey", AttributeType.Integer()); |
175 |
| - Attribute phone = new Attribute("c_Phone", AttributeType.Character(15)); |
176 |
| - Attribute acctBal = new Attribute("c_AcctBal", AttributeType.Real()); |
177 |
| - Attribute mktSegment = new Attribute("c_MktSegment", AttributeType.Character(10)); |
178 |
| - Attribute comment = new Attribute("c_Comment", AttributeType.CharacterVarying(117)); |
179 |
| - |
180 |
| - List<Attribute> attributes = new ArrayList<Attribute>(); |
181 |
| - attributes.add(custKey); |
182 |
| - attributes.add(name); |
183 |
| - attributes.add(address); |
184 |
| - attributes.add(nationKey); |
185 |
| - attributes.add(phone); |
186 |
| - attributes.add(acctBal); |
187 |
| - attributes.add(mktSegment); |
188 |
| - attributes.add(comment); |
189 |
| - |
190 |
| - Table t = new Table("customer", conf.getTableType(), attributes); |
191 |
| - t.pk = "c_CustKey"; |
192 |
| - t.workload = BenchmarkWorkloads.tpchCustomer(attributes, conf.getScaleFactor()); |
193 |
| - t.workload.dataFileName = conf.getDataFileDir() + "customer.tbl"; |
194 |
| - return t; |
195 |
| - } |
| 223 | + public static Table bigbench(BenchmarkConfig conf, Map<String, List<Integer>> queryAttrs){ |
196 | 224 |
|
197 |
| - public static Table tpchLineitem(BenchmarkConfig conf){ |
198 |
| - |
199 |
| - List<Attribute> attributes = new ArrayList<Attribute>(); |
200 |
| - |
201 |
| - attributes.add(new Attribute("l_OrderKey", AttributeType.Integer())); |
202 |
| - attributes.add(new Attribute("l_PartKey", AttributeType.Integer())); |
203 |
| - attributes.add(new Attribute("l_SuppKey", AttributeType.Integer())); |
204 |
| - attributes.add(new Attribute("l_Linenumber", AttributeType.Integer())); |
205 |
| - attributes.add(new Attribute("l_Quantity", AttributeType.Real())); |
206 |
| - attributes.add(new Attribute("l_ExtendedPrice", AttributeType.Real())); |
207 |
| - attributes.add(new Attribute("l_Discount", AttributeType.Real())); |
208 |
| - attributes.add(new Attribute("l_Tax", AttributeType.Real())); |
209 |
| - attributes.add(new Attribute("l_ReturnFlag", AttributeType.Character(1))); |
210 |
| - attributes.add(new Attribute("l_LineStatus", AttributeType.Character(1))); |
211 |
| - attributes.add(new Attribute("l_ShipDate", AttributeType.Date("yyyy-MM-dd"))); |
212 |
| - attributes.add(new Attribute("l_CommitDate", AttributeType.Date("yyyy-MM-dd"))); |
213 |
| - attributes.add(new Attribute("l_ReceiptDate", AttributeType.Date("yyyy-MM-dd"))); |
214 |
| - attributes.add(new Attribute("l_ShipInstruct", AttributeType.Character(25))); |
215 |
| - attributes.add(new Attribute("l_ShipMode", AttributeType.Character(10))); |
216 |
| - attributes.add(new Attribute("l_Comment", AttributeType.CharacterVarying(44))); |
217 |
| - |
218 |
| - Table t = new Table("lineitem", conf.getTableType(), attributes); |
219 |
| - t.pk = "l_OrderKey,l_Linenumber"; |
220 |
| - t.workload = BenchmarkWorkloads.tpchLineitem(attributes, conf.getScaleFactor()); |
221 |
| - t.workload.dataFileName = conf.getDataFileDir() + "lineitem.tbl"; |
222 |
| - return t; |
223 |
| - } |
| 225 | + List<Attribute> attributes = new ArrayList<Attribute>(); |
| 226 | + |
| 227 | + attributes.add(new Attribute("pageURL", AttributeType.CharacterVarying(300))); |
| 228 | + attributes.add(new Attribute("pageRank", AttributeType.Integer())); |
| 229 | + attributes.add(new Attribute("avgDuration", AttributeType.Integer())); |
| 230 | + attributes.add(new Attribute("sourceIP", AttributeType.CharacterVarying(116))); |
| 231 | + attributes.add(new Attribute("visitDate", AttributeType.Date("yyyy-MM-dd"))); |
| 232 | + attributes.add(new Attribute("adRevenue", AttributeType.Real())); |
| 233 | + attributes.add(new Attribute("userAgent", AttributeType.CharacterVarying(256))); |
| 234 | + attributes.add(new Attribute("countryCode", AttributeType.Character(3))); |
| 235 | + attributes.add(new Attribute("languageCode", AttributeType.Character(6))); |
| 236 | + attributes.add(new Attribute("searchWord", AttributeType.CharacterVarying(32))); |
| 237 | + attributes.add(new Attribute("duration", AttributeType.Integer())); |
| 238 | + |
| 239 | + |
| 240 | + Table t = new Table("bigbench", conf.getTableType(), attributes); |
| 241 | + t.pk = "pageURL,sourceIP,visitDate"; |
| 242 | + |
| 243 | + |
| 244 | + |
| 245 | + t.workload = BenchmarkWorkloads.bigbench(attributes, conf.getScaleFactor(), queryAttrs); |
| 246 | + t.workload.dataFileName = conf.getDataFileDir() + "bigbench.tbl"; |
| 247 | + |
| 248 | + System.out.println(t.workload.dataFileName); |
| 249 | + return t; |
| 250 | + } |
224 | 251 |
|
225 | 252 | public static Table tpchPart(BenchmarkConfig conf){
|
226 | 253 |
|
|
0 commit comments