开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 0

万里数据库/BenchmarkSQL

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
master
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
benchmarksql
/
src
/
LoadData
/
LoadDataWorker.java
benchmarksql
/
src
/
LoadData
/
LoadDataWorker.java
LoadDataWorker.java 20.15 KB
一键复制 编辑 原始数据 按行查看 历史
GreatSQL 提交于 2024年12月06日 09:45 +08:00 . GreatSQL社区更新:
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 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766
/*
* LoadDataWorker - Class to load one Warehouse (or in a special case
* the ITEM table).
*
* Copyright (C) 2016, Denis Lussier
* Copyright (C) 2016, Jan Wieck
*
*/
import java.sql.*;
import java.util.*;
import java.io.*;
public class LoadDataWorker implements Runnable
{
private int worker;
private Connection dbConn;
private jTPCCRandom rnd;
private StringBuffer sb;
private Formatter fmt;
private boolean writeCSV = false;
private String csvNull = null;
private PreparedStatement stmtConfig = null;
private PreparedStatement stmtItem = null;
private PreparedStatement stmtWarehouse = null;
private PreparedStatement stmtDistrict = null;
private PreparedStatement stmtStock = null;
private PreparedStatement stmtCustomer = null;
private PreparedStatement stmtHistory = null;
private PreparedStatement stmtOrder = null;
private PreparedStatement stmtOrderLine = null;
private PreparedStatement stmtNewOrder = null;
private StringBuffer sbConfig = null;
private Formatter fmtConfig = null;
private StringBuffer sbItem = null;
private Formatter fmtItem = null;
private StringBuffer sbWarehouse = null;
private Formatter fmtWarehouse = null;
private StringBuffer sbDistrict = null;
private Formatter fmtDistrict = null;
private StringBuffer sbStock = null;
private Formatter fmtStock = null;
private StringBuffer sbCustomer = null;
private Formatter fmtCustomer = null;
private StringBuffer sbHistory = null;
private Formatter fmtHistory = null;
private StringBuffer sbOrder = null;
private Formatter fmtOrder = null;
private StringBuffer sbOrderLine = null;
private Formatter fmtOrderLine = null;
private StringBuffer sbNewOrder = null;
private Formatter fmtNewOrder = null;
LoadDataWorker(int worker, String csvNull, jTPCCRandom rnd)
{
this.worker = worker;
this.csvNull = csvNull;
this.rnd = rnd;
this.sb = new StringBuffer();
this.fmt = new Formatter(sb);
this.writeCSV = true;
this.sbConfig = new StringBuffer();
this.fmtConfig = new Formatter(sbConfig);
this.sbItem = new StringBuffer();
this.fmtItem = new Formatter(sbItem);
this.sbWarehouse = new StringBuffer();
this.fmtWarehouse = new Formatter(sbWarehouse);
this.sbDistrict = new StringBuffer();
this.fmtDistrict = new Formatter(sbDistrict);
this.sbStock = new StringBuffer();
this.fmtStock = new Formatter(sbStock);
this.sbCustomer = new StringBuffer();
this.fmtCustomer = new Formatter(sbCustomer);
this.sbHistory = new StringBuffer();
this.fmtHistory = new Formatter(sbHistory);
this.sbOrder = new StringBuffer();
this.fmtOrder = new Formatter(sbOrder);
this.sbOrderLine = new StringBuffer();
this.fmtOrderLine = new Formatter(sbOrderLine);
this.sbNewOrder = new StringBuffer();
this.fmtNewOrder = new Formatter(sbNewOrder);
}
LoadDataWorker(int worker, Connection dbConn, jTPCCRandom rnd)
throws SQLException
{
this.worker = worker;
this.dbConn = dbConn;
this.rnd = rnd;
this.sb = new StringBuffer();
this.fmt = new Formatter(sb);
stmtConfig = dbConn.prepareStatement(
"INSERT INTO bmsql_config (" +
" cfg_name, cfg_value) " +
"VALUES (?, ?)"
);
stmtItem = dbConn.prepareStatement(
"INSERT INTO bmsql_item (" +
" i_id, i_im_id, i_name, i_price, i_data) " +
"VALUES (?, ?, ?, ?, ?)"
);
stmtWarehouse = dbConn.prepareStatement(
"INSERT INTO bmsql_warehouse (" +
" w_id, w_name, w_street_1, w_street_2, w_city, " +
" w_state, w_zip, w_tax, w_ytd) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
stmtStock = dbConn.prepareStatement(
"INSERT INTO bmsql_stock ("+
" s_i_id, s_w_id, s_quantity, s_dist_01, s_dist_02, " +
" s_dist_03, s_dist_04, s_dist_05, s_dist_06, " +
" s_dist_07, s_dist_08, s_dist_09, s_dist_10, " +
" s_ytd, s_order_cnt, s_remote_cnt, s_data) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
stmtDistrict = dbConn.prepareStatement(
"INSERT INTO bmsql_district ("+
" d_id, d_w_id, d_name, d_street_1, d_street_2, " +
" d_city, d_state, d_zip, d_tax, d_ytd, d_next_o_id) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
stmtCustomer = dbConn.prepareStatement(
"INSERT INTO bmsql_customer (" +
" c_id, c_d_id, c_w_id, c_first, c_middle, c_last, " +
" c_street_1, c_street_2, c_city, c_state, c_zip, " +
" c_phone, c_since, c_credit, c_credit_lim, c_discount, " +
" c_balance, c_ytd_payment, c_payment_cnt, " +
" c_delivery_cnt, c_data) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " +
" ?, ?, ?, ?, ?, ?)"
);
stmtHistory = dbConn.prepareStatement(
"INSERT INTO bmsql_history (" +
" hist_id, h_c_id, h_c_d_id, h_c_w_id, h_d_id, h_w_id, " +
" h_date, h_amount, h_data) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
stmtOrder = dbConn.prepareStatement(
"INSERT INTO bmsql_oorder (" +
" o_id, o_d_id, o_w_id, o_c_id, o_entry_d, " +
" o_carrier_id, o_ol_cnt, o_all_local) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
);
stmtOrderLine = dbConn.prepareStatement(
"INSERT INTO bmsql_order_line (" +
" ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, " +
" ol_supply_w_id, ol_delivery_d, ol_quantity, " +
" ol_amount, ol_dist_info) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
stmtNewOrder = dbConn.prepareStatement(
"INSERT INTO bmsql_new_order (" +
" no_o_id, no_d_id, no_w_id) " +
"VALUES (?, ?, ?)"
);
}
/*
* run()
*/
public void run()
{
int job;
try
{
while ((job = LoadData.getNextJob()) >= 0)
{
if (job == 0)
{
fmt.format("Worker %03d: Loading ITEM", worker);
System.out.println(sb.toString());
sb.setLength(0);
loadItem();
fmt.format("Worker %03d: Loading ITEM done", worker);
System.out.println(sb.toString());
sb.setLength(0);
}
else
{
fmt.format("Worker %03d: Loading Warehouse %6d",
worker, job);
System.out.println(sb.toString());
sb.setLength(0);
loadWarehouse(job);
fmt.format("Worker %03d: Loading Warehouse %6d done",
worker, job);
System.out.println(sb.toString());
sb.setLength(0);
}
}
/*
* Close the DB connection if in direct DB mode.
*/
if (!writeCSV)
dbConn.close();
}
catch (SQLException se)
{
while (se != null)
{
fmt.format("Worker %03d: ERROR: %s", worker, se.getMessage());
System.err.println(sb.toString());
sb.setLength(0);
se = se.getNextException();
}
}
catch (Exception e)
{
fmt.format("Worker %03d: ERROR: %s", worker, e.getMessage());
System.err.println(sb.toString());
sb.setLength(0);
e.printStackTrace();
return;
}
} // End run()
/* ----
* loadItem()
*
* Load the content of the ITEM table.
* ----
*/
private void loadItem()
throws SQLException, IOException
{
int i_id;
if (writeCSV)
{
/*
* Saving CONFIG information in CSV mode.
*/
fmtConfig.format("warehouses,%d\n", LoadData.getNumWarehouses());
fmtConfig.format("nURandCLast,%d\n", rnd.getNURandCLast());
fmtConfig.format("nURandCC_ID,%d\n", rnd.getNURandCC_ID());
fmtConfig.format("nURandCI_ID,%d\n", rnd.getNURandCI_ID());
LoadData.configAppend(sbConfig);
}
else
{
/*
* Saving CONFIG information in DB mode.
*/
stmtConfig.setString(1, "warehouses");
stmtConfig.setString(2, "" + LoadData.getNumWarehouses());
stmtConfig.execute();
stmtConfig.setString(1, "nURandCLast");
stmtConfig.setString(2, "" + rnd.getNURandCLast());
stmtConfig.execute();
stmtConfig.setString(1, "nURandCC_ID");
stmtConfig.setString(2, "" + rnd.getNURandCC_ID());
stmtConfig.execute();
stmtConfig.setString(1, "nURandCI_ID");
stmtConfig.setString(2, "" + rnd.getNURandCI_ID());
stmtConfig.execute();
}
for (i_id = 1; i_id <= 100000; i_id++)
{
String iData;
if (i_id != 1 && (i_id - 1) % 1000 == 0)
{
if (writeCSV)
{
LoadData.itemAppend(sbItem);
}
else
{
stmtItem.executeBatch();
stmtItem.clearBatch();
}
}
// Clause 4.3.3.1 for ITEM
if (rnd.nextInt(1, 100) <= 10)
{
int len = rnd.nextInt(26, 50);
int off = rnd.nextInt(0, len - 8);
iData = rnd.getAString(off, off) +
"ORIGINAL" +
rnd.getAString(len - off - 8, len - off - 8);
}
else
{
iData = rnd.getAString(26, 50);
}
if (writeCSV)
{
fmtItem.format("%d,%s,%.2f,%s,%d\n",
i_id,
rnd.getAString(14, 24),
((double)rnd.nextLong(100, 10000)) / 100.0,
iData,
rnd.nextInt(1, 10000));
}
else
{
stmtItem.setInt(1, i_id);
stmtItem.setInt(2, rnd.nextInt(1, 10000));
stmtItem.setString(3, rnd.getAString(14, 24));
stmtItem.setDouble(4, ((double)rnd.nextLong(100, 10000)) / 100.0);
stmtItem.setString(5, iData);
stmtItem.addBatch();
}
}
if (writeCSV)
{
LoadData.itemAppend(sbItem);
}
else
{
stmtItem.executeBatch();
stmtItem.clearBatch();
stmtItem.close();
dbConn.commit();
}
} // End loadItem()
/* ----
* loadWarehouse()
*
* Load the content of one warehouse.
* ----
*/
private void loadWarehouse(int w_id)
throws SQLException, IOException
{
/*
* Load the WAREHOUSE row.
*/
if (writeCSV)
{
fmtWarehouse.format("%d,%.2f,%.4f,%s,%s,%s,%s,%s,%s\n",
w_id,
300000.0,
((double)rnd.nextLong(0, 2000)) / 10000.0,
rnd.getAString(6, 10),
rnd.getAString(10, 20),
rnd.getAString(10, 20),
rnd.getAString(10, 20),
rnd.getState(),
rnd.getNString(4, 4) + "11111");
LoadData.warehouseAppend(sbWarehouse);
}
else
{
stmtWarehouse.setInt(1, w_id);
stmtWarehouse.setString(2, rnd.getAString(6, 10));
stmtWarehouse.setString(3, rnd.getAString(10, 20));
stmtWarehouse.setString(4, rnd.getAString(10, 20));
stmtWarehouse.setString(5, rnd.getAString(10, 20));
stmtWarehouse.setString(6, rnd.getState());
stmtWarehouse.setString(7, rnd.getNString(4, 4) + "11111");
stmtWarehouse.setDouble(8, ((double)rnd.nextLong(0, 2000)) / 10000.0);
stmtWarehouse.setDouble(9, 300000.0);
stmtWarehouse.execute();
}
/*
* For each WAREHOUSE there are 100,000 STOCK rows.
*/
for (int s_i_id = 1; s_i_id <= 100000; s_i_id++)
{
String sData;
/*
* Load the data in batches of 10,000 rows.
*/
if (s_i_id != 1 && (s_i_id - 1) % 10000 == 0)
{
if (writeCSV)
LoadData.warehouseAppend(sbWarehouse);
else
{
stmtStock.executeBatch();
stmtStock.clearBatch();
}
}
// Clause 4.3.3.1 for STOCK
if (rnd.nextInt(1, 100) <= 10)
{
int len = rnd.nextInt(26, 50);
int off = rnd.nextInt(0, len - 8);
sData = rnd.getAString(off, off) +
"ORIGINAL" +
rnd.getAString(len - off - 8, len - off - 8);
}
else
{
sData = rnd.getAString(26, 50);
}
if (writeCSV)
{
fmtStock.format("%d,%d,%d,%d,%d,%d,%s," +
"%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n",
s_i_id,
w_id,
rnd.nextInt(10, 100),
0,
0,
0,
sData,
rnd.getAString(24, 24),
rnd.getAString(24, 24),
rnd.getAString(24, 24),
rnd.getAString(24, 24),
rnd.getAString(24, 24),
rnd.getAString(24, 24),
rnd.getAString(24, 24),
rnd.getAString(24, 24),
rnd.getAString(24, 24),
rnd.getAString(24, 24));
}
else
{
stmtStock.setInt(1, s_i_id);
stmtStock.setInt(2, w_id);
stmtStock.setInt(3, rnd.nextInt(10, 100));
stmtStock.setString(4, rnd.getAString(24, 24));
stmtStock.setString(5, rnd.getAString(24, 24));
stmtStock.setString(6, rnd.getAString(24, 24));
stmtStock.setString(7, rnd.getAString(24, 24));
stmtStock.setString(8, rnd.getAString(24, 24));
stmtStock.setString(9, rnd.getAString(24, 24));
stmtStock.setString(10, rnd.getAString(24, 24));
stmtStock.setString(11, rnd.getAString(24, 24));
stmtStock.setString(12, rnd.getAString(24, 24));
stmtStock.setString(13, rnd.getAString(24, 24));
stmtStock.setInt(14, 0);
stmtStock.setInt(15, 0);
stmtStock.setInt(16, 0);
stmtStock.setString(17, sData);
stmtStock.addBatch();
}
}
if (writeCSV)
{
LoadData.stockAppend(sbStock);
}
else
{
stmtStock.executeBatch();
stmtStock.clearBatch();
}
/*
* For each WAREHOUSE there are 10 DISTRICT rows.
*/
for (int d_id = 1; d_id <= 10; d_id++)
{
if (writeCSV)
{
fmtDistrict.format("%d,%d,%.2f,%.4f,%d,%s,%s,%s,%s,%s,%s\n",
d_id,
w_id,
30000.0,
((double)rnd.nextLong(0, 2000)) / 10000.0,
3001,
rnd.getAString(6, 10),
rnd.getAString(10, 20),
rnd.getAString(10, 20),
rnd.getAString(10, 20),
rnd.getState(),
rnd.getNString(4, 4) + "11111");
LoadData.districtAppend(sbDistrict);
}
else
{
stmtDistrict.setInt(1, d_id);
stmtDistrict.setInt(2, w_id);
stmtDistrict.setString(3, rnd.getAString(6, 10));
stmtDistrict.setString(4, rnd.getAString(10, 20));
stmtDistrict.setString(5, rnd.getAString(10, 20));
stmtDistrict.setString(6, rnd.getAString(10, 20));
stmtDistrict.setString(7, rnd.getState());
stmtDistrict.setString(8, rnd.getNString(4, 4) + "11111");
stmtDistrict.setDouble(9, ((double)rnd.nextLong(0, 2000)) / 10000.0);
stmtDistrict.setDouble(10, 30000.0);
stmtDistrict.setInt(11, 3001);
stmtDistrict.execute();
}
/*
* Within each DISTRICT there are 3,000 CUSTOMERs.
*/
for (int c_id = 1; c_id <= 3000; c_id++)
{
if (writeCSV)
{
fmtCustomer.format("%d,%d,%d,%.4f,%s,%s,%s," +
"%.2f,%.2f,%.2f,%d,%d," +
"%s,%s,%s,%s,%s,%s,%s,%s,%s\n",
c_id,
d_id,
w_id,
((double)rnd.nextLong(0, 5000)) / 10000.0,
(rnd.nextInt(1, 100) <= 90) ? "GC" : "BC",
(c_id <= 1000) ? rnd.getCLast(c_id - 1) : rnd.getCLast(),
rnd.getAString(8, 16),
50000.00,
-10.00,
10.00,
1,
0,
rnd.getAString(10, 20),
rnd.getAString(10, 20),
rnd.getAString(10, 20),
rnd.getState(),
rnd.getNString(4, 4) + "11111",
rnd.getNString(16, 16),
new java.sql.Timestamp(System.currentTimeMillis()).toString(),
"OE",
rnd.getAString(300, 500));
}
else
{
stmtCustomer.setInt(1, c_id);
stmtCustomer.setInt(2, d_id);
stmtCustomer.setInt(3, w_id);
stmtCustomer.setString(4, rnd.getAString(8, 16));
stmtCustomer.setString(5, "OE");
if (c_id <= 1000)
stmtCustomer.setString(6, rnd.getCLast(c_id - 1));
else
stmtCustomer.setString(6, rnd.getCLast());
stmtCustomer.setString(7, rnd.getAString(10, 20));
stmtCustomer.setString(8, rnd.getAString(10, 20));
stmtCustomer.setString(9, rnd.getAString(10, 20));
stmtCustomer.setString(10, rnd.getState());
stmtCustomer.setString(11, rnd.getNString(4, 4) + "11111");
stmtCustomer.setString(12, rnd.getNString(16, 16));
stmtCustomer.setTimestamp(13, new java.sql.Timestamp(System.currentTimeMillis()));
if (rnd.nextInt(1, 100) <= 90)
stmtCustomer.setString(14, "GC");
else
stmtCustomer.setString(14, "BC");
stmtCustomer.setDouble(15, 50000.00);
stmtCustomer.setDouble(16, ((double)rnd.nextLong(0, 5000)) / 10000.0);
stmtCustomer.setDouble(17, -10.00);
stmtCustomer.setDouble(18, 10.00);
stmtCustomer.setInt(19, 1);
stmtCustomer.setInt(20, 1);
stmtCustomer.setString(21, rnd.getAString(300, 500));
stmtCustomer.addBatch();
}
/*
* For each CUSTOMER there is one row in HISTORY.
*/
if (writeCSV)
{
fmtHistory.format("%d,%d,%d,%d,%d,%d,%s,%.2f,%s\n",
(w_id - 1) * 30000 + (d_id - 1) * 3000 + c_id,
c_id,
d_id,
w_id,
d_id,
w_id,
new java.sql.Timestamp(System.currentTimeMillis()).toString(),
10.00,
rnd.getAString(12, 24));
}
else
{
stmtHistory.setInt(1, (w_id - 1) * 30000 + (d_id - 1) * 3000 + c_id);
stmtHistory.setInt(2, c_id);
stmtHistory.setInt(3, d_id);
stmtHistory.setInt(4, w_id);
stmtHistory.setInt(5, d_id);
stmtHistory.setInt(6, w_id);
stmtHistory.setTimestamp(7, new java.sql.Timestamp(System.currentTimeMillis()));
stmtHistory.setDouble(8, 10.00);
stmtHistory.setString(9, rnd.getAString(12, 24));
stmtHistory.addBatch();
}
}
if (writeCSV)
{
LoadData.customerAppend(sbCustomer);
LoadData.historyAppend(sbHistory);
}
else
{
stmtCustomer.executeBatch();
stmtCustomer.clearBatch();
stmtHistory.executeBatch();
stmtHistory.clearBatch();
}
/*
* For the ORDER rows the TPC-C specification demands that they
* are generated using a random permutation of all 3,000
* customers. To do that we set up an array with all C_IDs
* and then randomly shuffle it.
*/
int randomCID[] = new int[3000];
for (int i = 0; i < 3000; i++)
randomCID[i] = i + 1;
for (int i = 0; i < 3000; i++)
{
int x = rnd.nextInt(0, 2999);
int y = rnd.nextInt(0, 2999);
int tmp = randomCID[x];
randomCID[x] = randomCID[y];
randomCID[y] = tmp;
}
for (int o_id = 1; o_id <= 3000; o_id++)
{
int o_ol_cnt = rnd.nextInt(5, 15);
if (writeCSV)
{
fmtOrder.format("%d,%d,%d,%d,%s,%d,%d,%s\n",
o_id,
w_id,
d_id,
randomCID[o_id - 1],
(o_id < 2101) ? rnd.nextInt(1, 10) : csvNull,
o_ol_cnt,
1,
new java.sql.Timestamp(System.currentTimeMillis()).toString());
}
else
{
stmtOrder.setInt(1, o_id);
stmtOrder.setInt(2, d_id);
stmtOrder.setInt(3, w_id);
stmtOrder.setInt(4, randomCID[o_id - 1]);
stmtOrder.setTimestamp(5, new java.sql.Timestamp(System.currentTimeMillis()));
if (o_id < 2101)
stmtOrder.setInt(6, rnd.nextInt(1, 10));
else
stmtOrder.setNull(6, java.sql.Types.INTEGER);
stmtOrder.setInt(7, o_ol_cnt);
stmtOrder.setInt(8, 1);
stmtOrder.addBatch();
}
/*
* Create the ORDER_LINE rows for this ORDER.
*/
for (int ol_number = 1; ol_number <= o_ol_cnt; ol_number++)
{
long now = System.currentTimeMillis();
if (writeCSV)
{
fmtOrderLine.format("%d,%d,%d,%d,%d,%s,%.2f,%d,%d,%s\n",
w_id,
d_id,
o_id,
ol_number,
rnd.nextInt(1, 100000),
(o_id < 2101) ? new java.sql.Timestamp(now).toString() : csvNull,
(o_id < 2101) ? 0.00 : ((double)rnd.nextLong(1, 999999)) / 100.0,
w_id,
5,
rnd.getAString(24, 24));
}
else
{
stmtOrderLine.setInt(1, o_id);
stmtOrderLine.setInt(2, d_id);
stmtOrderLine.setInt(3, w_id);
stmtOrderLine.setInt(4, ol_number);
stmtOrderLine.setInt(5, rnd.nextInt(1, 100000));
stmtOrderLine.setInt(6, w_id);
if (o_id < 2101)
stmtOrderLine.setTimestamp(7, new java.sql.Timestamp(now));
else
stmtOrderLine.setNull(7, java.sql.Types.TIMESTAMP);
stmtOrderLine.setInt(8, 5);
if (o_id < 2101)
stmtOrderLine.setDouble(9, 0.00);
else
stmtOrderLine.setDouble(9, ((double)rnd.nextLong(1, 999999)) / 100.0);
stmtOrderLine.setString(10, rnd.getAString(24, 24));
stmtOrderLine.addBatch();
}
}
/*
* The last 900 ORDERs are not yet delieverd and have a
* row in NEW_ORDER.
*/
if (o_id >= 2101)
{
if (writeCSV)
{
fmtNewOrder.format("%d,%d,%d\n",
w_id,
d_id,
o_id);
}
else
{
stmtNewOrder.setInt(1, o_id);
stmtNewOrder.setInt(2, d_id);
stmtNewOrder.setInt(3, w_id);
stmtNewOrder.addBatch();
}
}
}
if (writeCSV)
{
LoadData.orderAppend(sbOrder);
LoadData.orderLineAppend(sbOrderLine);
LoadData.newOrderAppend(sbNewOrder);
}
else
{
stmtOrder.executeBatch();
stmtOrder.clearBatch();
stmtOrderLine.executeBatch();
stmtOrderLine.clearBatch();
stmtNewOrder.executeBatch();
stmtNewOrder.clearBatch();
}
}
if (!writeCSV)
dbConn.commit();
} // End loadWarehouse()
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

TPC-C 性能测试工具,增加支持 MySQL/GreatSQL 数据库,并修复在 RR 模式下测试结束后可能因为逻辑不严谨产生死循环问题
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/GreatSQL/benchmarksql.git
git@gitee.com:GreatSQL/benchmarksql.git
GreatSQL
benchmarksql
BenchmarkSQL
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /