@@ -108,10 +108,15 @@ public void afterLoad() {
108
108
final int lo = i * loadPerThread ;
109
109
final int hi = Math .min (this .num_users , (i + 1 ) * loadPerThread );
110
110
111
+ // To ensure that we don't wind up with an empty trust table for
112
+ // small scales we have the first loader thread ensure that at
113
+ // least a single trust record is inserted.
114
+ final boolean firstLoader = (i == 0 );
115
+
111
116
threads .add (new LoaderThread (this .benchmark ) {
112
117
@ Override
113
118
public void load (Connection conn ) throws SQLException {
114
- loadTrust (conn , lo , hi );
119
+ loadTrust (conn , lo , hi , firstLoader );
115
120
}
116
121
117
122
@ Override
@@ -309,7 +314,7 @@ private void loadReviews(Connection conn, int lo, int hi) throws SQLException {
309
314
* Zipfian distribution Trusted users are not correlated to heavy
310
315
* reviewers (drawn using a scrambled distribution)
311
316
*/
312
- public void loadTrust (Connection conn , int lo , int hi ) throws SQLException {
317
+ public void loadTrust (Connection conn , int lo , int hi , boolean firstLoader ) throws SQLException {
313
318
Table catalog_tbl = this .benchmark .getCatalog ().getTable ("trust" );
314
319
String sql = SQLUtil .getInsertSQL (catalog_tbl , this .getDatabaseType ());
315
320
@@ -324,6 +329,12 @@ public void loadTrust(Connection conn, int lo, int hi) throws SQLException {
324
329
for (int i = lo ; i < hi ; i ++) {
325
330
long timestamp = System .currentTimeMillis ();
326
331
int trust_count = numTrust .nextInt ();
332
+ // To avoid having an empty trust table during small scale
333
+ // tests, we make sure that at least one trust record is
334
+ // inserted to the table.
335
+ if (firstLoader && i == lo ) {
336
+ trust_count = Math .max (trust_count , 1 );
337
+ }
327
338
for (int tc = 0 ; tc < trust_count ; ) {
328
339
int u_id = reviewed .nextInt ();
329
340
if (!trusted .contains (u_id )) {
0 commit comments