1 | /* |
2 | * Legal Notice |
3 | * |
4 | * This document and associated source code (the "Work") is a part of a |
5 | * benchmark specification maintained by the TPC. |
6 | * |
7 | * The TPC reserves all right, title, and interest to the Work as provided |
8 | * under U.S. and international laws, including without limitation all patent |
9 | * and trademark rights therein. |
10 | * |
11 | * No Warranty |
12 | * |
13 | * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION |
14 | * CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE |
15 | * AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER |
16 | * WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, |
17 | * INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, |
18 | * DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR |
19 | * PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF |
20 | * WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. |
21 | * ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, |
22 | * QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT |
23 | * WITH REGARD TO THE WORK. |
24 | * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO |
25 | * ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE |
26 | * COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS |
27 | * OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, |
28 | * INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY, |
29 | * OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT |
30 | * RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD |
31 | * ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. |
32 | * |
33 | * Contributors |
34 | * - Sergey Vasilevskiy |
35 | * - Doug Johnson |
36 | */ |
37 | |
38 | /****************************************************************************** |
39 | * Description: Implementation of the Company input file that scales |
40 | * with the database size. |
41 | ******************************************************************************/ |
42 | |
43 | #ifndef COMPANY_FILE_H |
44 | #define COMPANY_FILE_H |
45 | |
46 | #include "utilities/EGenStandardTypes.h" |
47 | #include "DataFileTypes.h" |
48 | |
49 | namespace TPCE { |
50 | |
51 | class CCompanyFile { |
52 | CompanyDataFile_t const *m_dataFile; |
53 | |
54 | // Configured and active number of companies in the database. |
55 | // Depends on the configured and active number of customers. |
56 | // |
57 | TIdent m_iConfiguredCompanyCount; |
58 | TIdent m_iActiveCompanyCount; |
59 | |
60 | public: |
61 | /* |
62 | * Constructor. |
63 | * |
64 | * PARAMETERS: |
65 | * IN str - file name of the |
66 | * CompanyCompetitor input flat file IN iConfiguredCustomerCount - total |
67 | * configured number of customers in the database IN iActiveCustomerCount |
68 | * - active number of customers in the database (provided for engineering |
69 | * purposes) |
70 | * |
71 | * RETURNS: |
72 | * not applicable. |
73 | */ |
74 | CCompanyFile(const CompanyDataFile_t &dataFile, TIdent iConfiguredCustomerCount, TIdent iActiveCustomerCount); |
75 | |
76 | /* |
77 | * Calculate company count for the specified number of customers. |
78 | * Sort of a static method. Used in parallel generation of company related |
79 | * tables. |
80 | * |
81 | * PARAMETERS: |
82 | * IN iCustomerCount - number of customers |
83 | * |
84 | * RETURNS: |
85 | * number of company competitors. |
86 | */ |
87 | TIdent CalculateCompanyCount(TIdent iCustomerCount) const; |
88 | |
89 | /* |
90 | * Calculate the first company id (0-based) for the specified customer id. |
91 | * |
92 | * PARAMETERS: |
93 | * IN iStartFromCustomer - customer id |
94 | * |
95 | * RETURNS: |
96 | * company competitor id. |
97 | */ |
98 | TIdent CalculateStartFromCompany(TIdent iStartFromCustomer) const; |
99 | |
100 | /* |
101 | * Create company name with appended suffix based on the |
102 | * load unit number. |
103 | * |
104 | * PARAMETERS: |
105 | * IN iIndex - row number in the Company Competitor file |
106 | * (0-based) IN szOutput - output buffer for company name IN iOutputLen |
107 | * - size of the output buffer |
108 | * |
109 | * RETURNS: |
110 | * none. |
111 | */ |
112 | void CreateName(TIdent iIndex, // row number |
113 | char *szOutput, // output buffer |
114 | size_t iOutputLen // size of the output buffer |
115 | ) const; |
116 | |
117 | /* |
118 | * Return company id for the specified row. |
119 | * Index can exceed the size of the Company input file. |
120 | * |
121 | * PARAMETERS: |
122 | * IN iIndex - row number in the Company Competitor file |
123 | * (0-based) |
124 | * |
125 | * RETURNS: |
126 | * company id. |
127 | */ |
128 | TIdent GetCompanyId(TIdent iIndex) const; |
129 | |
130 | /* |
131 | * Return the number of companies in the database for |
132 | * the configured number of customers. |
133 | * |
134 | * PARAMETERS: |
135 | * none. |
136 | * |
137 | * RETURNS: |
138 | * number of rows in the file. |
139 | */ |
140 | TIdent GetSize() const; |
141 | |
142 | /* |
143 | * Return the number of companies in the database for |
144 | * the configured number of customers. |
145 | * |
146 | * PARAMETERS: |
147 | * none. |
148 | * |
149 | * RETURNS: |
150 | * configured company count. |
151 | */ |
152 | TIdent GetConfiguredCompanyCount() const; |
153 | |
154 | /* |
155 | * Return the number of companies in the database for |
156 | * the active number of customers. |
157 | * |
158 | * PARAMETERS: |
159 | * none. |
160 | * |
161 | * RETURNS: |
162 | * active company count. |
163 | */ |
164 | TIdent GetActiveCompanyCount() const; |
165 | |
166 | /* |
167 | * Overload GetRecord to wrap around indices that |
168 | * are larger than the flat file |
169 | * |
170 | * PARAMETERS: |
171 | * IN iIndex - row number in the Company file (0-based) |
172 | * |
173 | * RETURNS: |
174 | * reference to the row structure in the Company file. |
175 | */ |
176 | const CompanyDataFileRecord &GetRecord(TIdent index) const; |
177 | }; |
178 | |
179 | } // namespace TPCE |
180 | |
181 | #endif // COMPANY_FILE_H |
182 | |