|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# ----------------------------------------------------------------------- |
| 3 | +# Copyright (C) 2011 |
| 4 | +# Andy Pavlo |
| 5 | +# http://www.cs.brown.edu/~pavlo/ |
| 6 | +# |
| 7 | +# Original Java Version: |
| 8 | +# Copyright (C) 2008 |
| 9 | +# Evan Jones |
| 10 | +# Massachusetts Institute of Technology |
| 11 | +# |
| 12 | +# Permission is hereby granted, free of charge, to any person obtaining |
| 13 | +# a copy of this software and associated documentation files (the |
| 14 | +# "Software"), to deal in the Software without restriction, including |
| 15 | +# without limitation the rights to use, copy, modify, merge, publish, |
| 16 | +# distribute, sublicense, and/or sell copies of the Software, and to |
| 17 | +# permit persons to whom the Software is furnished to do so, subject to |
| 18 | +# the following conditions: |
| 19 | +# |
| 20 | +# The above copyright notice and this permission notice shall be |
| 21 | +# included in all copies or substantial portions of the Software. |
| 22 | +# |
| 23 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 24 | +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 25 | +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT |
| 26 | +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 27 | +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 28 | +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 29 | +# OTHER DEALINGS IN THE SOFTWARE. |
| 30 | +# ----------------------------------------------------------------------- |
| 31 | + |
| 32 | +MONEY_DECIMALS = 2 |
| 33 | + |
| 34 | +# Item constants |
| 35 | +NUM_ITEMS = 100000 |
| 36 | +MIN_IM = 1 |
| 37 | +MAX_IM = 10000 |
| 38 | +MIN_PRICE = 1.00 |
| 39 | +MAX_PRICE = 100.00 |
| 40 | +MIN_I_NAME = 14 |
| 41 | +MAX_I_NAME = 24 |
| 42 | +MIN_I_DATA = 26 |
| 43 | +MAX_I_DATA = 50 |
| 44 | + |
| 45 | +# Warehouse constants |
| 46 | +MIN_TAX = 0 |
| 47 | +MAX_TAX = 0.2000 |
| 48 | +TAX_DECIMALS = 4 |
| 49 | +INITIAL_W_YTD = 300000.00 |
| 50 | +MIN_NAME = 6 |
| 51 | +MAX_NAME = 10 |
| 52 | +MIN_STREET = 10 |
| 53 | +MAX_STREET = 20 |
| 54 | +MIN_CITY = 10 |
| 55 | +MAX_CITY = 20 |
| 56 | +STATE = 2 |
| 57 | +ZIP_LENGTH = 9 |
| 58 | +ZIP_SUFFIX = "11111" |
| 59 | + |
| 60 | +# Stock constants |
| 61 | +MIN_QUANTITY = 10 |
| 62 | +MAX_QUANTITY = 100 |
| 63 | +DIST = 24 |
| 64 | +STOCK_PER_WAREHOUSE = 100000 |
| 65 | + |
| 66 | +# District constants |
| 67 | +DISTRICTS_PER_WAREHOUSE = 10 |
| 68 | +INITIAL_D_YTD = 30000.00 # different from Warehouse |
| 69 | +INITIAL_NEXT_O_ID = 3001 |
| 70 | + |
| 71 | +# Customer constants |
| 72 | +CUSTOMERS_PER_DISTRICT = 3000 |
| 73 | +INITIAL_CREDIT_LIM = 50000.00 |
| 74 | +MIN_DISCOUNT = 0.0000 |
| 75 | +MAX_DISCOUNT = 0.5000 |
| 76 | +DISCOUNT_DECIMALS = 4 |
| 77 | +INITIAL_BALANCE = -10.00 |
| 78 | +INITIAL_YTD_PAYMENT = 10.00 |
| 79 | +INITIAL_PAYMENT_CNT = 1 |
| 80 | +INITIAL_DELIVERY_CNT = 0 |
| 81 | +MIN_FIRST = 6 |
| 82 | +MAX_FIRST = 10 |
| 83 | +MIDDLE = "OE" |
| 84 | +PHONE = 16 |
| 85 | +MIN_C_DATA = 300 |
| 86 | +MAX_C_DATA = 500 |
| 87 | +GOOD_CREDIT = "GC" |
| 88 | +BAD_CREDIT = "BC" |
| 89 | + |
| 90 | +# Order constants |
| 91 | +MIN_CARRIER_ID = 1 |
| 92 | +MAX_CARRIER_ID = 10 |
| 93 | +# HACK: This is not strictly correct, but it works |
| 94 | +NULL_CARRIER_ID = 0L |
| 95 | +# o_id < than this value, carrier != null, >= -> carrier == null |
| 96 | +NULL_CARRIER_LOWER_BOUND = 2101 |
| 97 | +MIN_OL_CNT = 5 |
| 98 | +MAX_OL_CNT = 15 |
| 99 | +INITIAL_ALL_LOCAL = 1 |
| 100 | +INITIAL_ORDERS_PER_DISTRICT = 3000 |
| 101 | + |
| 102 | +# Used to generate new order transactions |
| 103 | +MAX_OL_QUANTITY = 10 |
| 104 | + |
| 105 | +# Order line constants |
| 106 | +INITIAL_QUANTITY = 5 |
| 107 | +MIN_AMOUNT = 0.01 |
| 108 | + |
| 109 | +# History constants |
| 110 | +MIN_DATA = 12 |
| 111 | +MAX_DATA = 24 |
| 112 | +INITIAL_AMOUNT = 10.00 |
| 113 | + |
| 114 | +# New order constants |
| 115 | +INITIAL_NEW_ORDERS_PER_DISTRICT = 900 |
| 116 | + |
| 117 | +# TPC-C 2.4.3.4 (page 31) says this must be displayed when new order rolls back. |
| 118 | +INVALID_ITEM_MESSAGE = "Item number is not valid" |
| 119 | + |
| 120 | +# Used to generate stock level transactions |
| 121 | +MIN_STOCK_LEVEL_THRESHOLD = 10 |
| 122 | +MAX_STOCK_LEVEL_THRESHOLD = 20 |
| 123 | + |
| 124 | +# Used to generate payment transactions |
| 125 | +MIN_PAYMENT = 1.0 |
| 126 | +MAX_PAYMENT = 5000.0 |
| 127 | + |
| 128 | +# Indicates "brand" items and stock in i_data and s_data. |
| 129 | +ORIGINAL_STRING = "ORIGINAL" |
| 130 | + |
| 131 | +# Table Names |
| 132 | +TABLENAME_ITEM = "ITEM" |
| 133 | +TABLENAME_WAREHOUSE = "WAREHOUSE" |
| 134 | +TABLENAME_DISTRICT = "DISTRICT" |
| 135 | +TABLENAME_CUSTOMER = "CUSTOMER" |
| 136 | +TABLENAME_STOCK = "STOCK" |
| 137 | +TABLENAME_ORDERS = "ORDERS" |
| 138 | +TABLENAME_NEW_ORDER = "NEW_ORDER" |
| 139 | +TABLENAME_ORDER_LINE = "ORDER_LINE" |
| 140 | +TABLENAME_HISTORY = "HISTORY" |
| 141 | + |
| 142 | +ALL_TABLES = [ |
| 143 | + TABLENAME_ITEM, |
| 144 | + TABLENAME_WAREHOUSE, |
| 145 | + TABLENAME_DISTRICT, |
| 146 | + TABLENAME_CUSTOMER, |
| 147 | + TABLENAME_STOCK, |
| 148 | + TABLENAME_ORDERS, |
| 149 | + TABLENAME_NEW_ORDER, |
| 150 | + TABLENAME_ORDER_LINE, |
| 151 | + TABLENAME_HISTORY, |
| 152 | +] |
| 153 | + |
| 154 | +# Transaction Types |
| 155 | +def enum(*sequential, **named): |
| 156 | + enums = dict(map(lambda x: (x, x), sequential)) |
| 157 | + # dict(zip(sequential, range(len(sequential))), **named) |
| 158 | + return type('Enum', (), enums) |
| 159 | +TransactionTypes = enum( |
| 160 | + "DELIVERY", |
| 161 | + "NEW_ORDER", |
| 162 | + "ORDER_STATUS", |
| 163 | + "PAYMENT", |
| 164 | + "STOCK_LEVEL", |
| 165 | +) |
0 commit comments