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