From bc159b170a0ada37a10e46d84938f13e613ec20f Mon Sep 17 00:00:00 2001 From: Marco Vogt Date: Tue, 7 Jun 2022 15:04:52 +0200 Subject: [PATCH] Improvements for benchmarking Polypheny (#16) --- .travis.yml | 2 +- README.md | 10 +-- config/polypheny-fram/smallbank.xml | 4 +- config/polypheny-fram/tpcc.xml | 4 + .../auctionmark.xml | 2 + .../{polypheny-db => polypheny}/smallbank.xml | 2 +- config/{polypheny-db => polypheny}/tpcc.xml | 2 +- config/{polypheny-db => polypheny}/tpch.xml | 0 config/{polypheny-db => polypheny}/ycsb.xml | 0 .../auctionmark/AuctionMarkLoader.java | 69 +++++++------- .../ddls/auctionmark-polypheny-ddl.sql | 38 ++++---- .../dialects/polypheny-dialects.xml | 90 +++++++++++++++++++ .../auctionmark/util/CategoryParser.java | 24 ++--- .../ddls/smallbank-polypheny-ddl.sql | 6 +- ...l.sql => smallbank-polypheny-fram-ddl.sql} | 6 +- .../tpcc/ddls/tpcc-polypheny-ddl.sql | 26 +++--- ...eny-db-ddl.sql => tpcc-polypheny-fram.sql} | 25 +++--- 17 files changed, 198 insertions(+), 112 deletions(-) rename config/{polypheny-db => polypheny}/auctionmark.xml (96%) rename config/{polypheny-db => polypheny}/smallbank.xml (95%) rename config/{polypheny-db => polypheny}/tpcc.xml (96%) rename config/{polypheny-db => polypheny}/tpch.xml (100%) rename config/{polypheny-db => polypheny}/ycsb.xml (100%) create mode 100644 src/com/oltpbenchmark/benchmarks/auctionmark/dialects/polypheny-dialects.xml rename src/com/oltpbenchmark/benchmarks/smallbank/ddls/{smallbank-polypheny-db-ddl.sql => smallbank-polypheny-fram-ddl.sql} (78%) rename src/com/oltpbenchmark/benchmarks/tpcc/ddls/{tpcc-polypheny-db-ddl.sql => tpcc-polypheny-fram.sql} (89%) diff --git a/.travis.yml b/.travis.yml index a75a488d3..a483b1796 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ cache: # openjdk9 + oraclejdk10 were both removed from Ubuntu language: java jdk: + - openjdk17 - openjdk11 - - openjdk10 - openjdk8 # - oraclejdk8 diff --git a/README.md b/README.md index 6292863d9..0d60bda63 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,15 @@ Please consult the documentation of the original repository on how to further us ### Supported Benchmarks for Polypheny #### [Polypheny-DB](https://github.com/polypheny/Polypheny-DB) -* [AuctionMark](./config/polypheny-db/auctionmark.xml)\ +* [AuctionMark](./config/polypheny/auctionmark.xml)\ `./bin/oltpbenchmark -b auctionmark -c ./config/polypheny-db/auctionmark.xml --create=true --load=true --execute=true` -* [SmallBank](./config/polypheny-db/smallbank.xml)\ +* [SmallBank](./config/polypheny/smallbank.xml)\ `./bin/oltpbenchmark -b smallbank -c ./config/polypheny-db/smallbank.xml --create=true --load=true --execute=true` -* [TPC-C](./config/polypheny-db/tpcc.xml)\ +* [TPC-C](./config/polypheny/tpcc.xml)\ `./bin/oltpbenchmark -b tpcc -c ./config/polypheny-db/tpcc.xml --create=true --load=true --execute=true` -* [TPC-H](./config/polypheny-db/tpch.xml)\ +* [TPC-H](./config/polypheny/tpch.xml)\ `./bin/oltpbenchmark -b tpch -c ./config/polypheny-db/tpch.xml --create=true --load=true --execute=true` -* [YCSB](./config/polypheny-db/ycsb.xml)\ +* [YCSB](./config/polypheny/ycsb.xml)\ `./bin/oltpbenchmark -b ycsb -c ./config/polypheny-db/ycsb.xml --create=true --load=true --execute=true` #### [Polypheny-FRAM](https://github.com/polypheny/Polypheny-FRAM) diff --git a/config/polypheny-fram/smallbank.xml b/config/polypheny-fram/smallbank.xml index 0f81f8e38..7ec69bef0 100644 --- a/config/polypheny-fram/smallbank.xml +++ b/config/polypheny-fram/smallbank.xml @@ -9,7 +9,9 @@ TRANSACTION_SERIALIZABLE 128 - + + smallbank-polypheny-fram-ddl.sql + 1 diff --git a/config/polypheny-fram/tpcc.xml b/config/polypheny-fram/tpcc.xml index c3bd972a9..fa4493451 100644 --- a/config/polypheny-fram/tpcc.xml +++ b/config/polypheny-fram/tpcc.xml @@ -10,6 +10,10 @@ TRANSACTION_SERIALIZABLE 128 + + + tpcc-polypheny-fram-ddl.sql + 1 diff --git a/config/polypheny-db/auctionmark.xml b/config/polypheny/auctionmark.xml similarity index 96% rename from config/polypheny-db/auctionmark.xml rename to config/polypheny/auctionmark.xml index ace87ba1b..d2f31994d 100644 --- a/config/polypheny-db/auctionmark.xml +++ b/config/polypheny/auctionmark.xml @@ -16,6 +16,8 @@ 10 + polypheny-dialects.xml + 1 diff --git a/config/polypheny-db/smallbank.xml b/config/polypheny/smallbank.xml similarity index 95% rename from config/polypheny-db/smallbank.xml rename to config/polypheny/smallbank.xml index f5c2306c0..0a66beb3e 100644 --- a/config/polypheny-db/smallbank.xml +++ b/config/polypheny/smallbank.xml @@ -9,7 +9,7 @@ pa - smallbank-polypheny-db-ddl.sql + smallbank-polypheny-ddl.sql TRANSACTION_SERIALIZABLE 128 diff --git a/config/polypheny-db/tpcc.xml b/config/polypheny/tpcc.xml similarity index 96% rename from config/polypheny-db/tpcc.xml rename to config/polypheny/tpcc.xml index a89cab79c..dc5e8544e 100644 --- a/config/polypheny-db/tpcc.xml +++ b/config/polypheny/tpcc.xml @@ -11,7 +11,7 @@ - tpcc-polypheny-db-ddl.sql + tpcc-polypheny-ddl.sql diff --git a/config/polypheny-db/tpch.xml b/config/polypheny/tpch.xml similarity index 100% rename from config/polypheny-db/tpch.xml rename to config/polypheny/tpch.xml diff --git a/config/polypheny-db/ycsb.xml b/config/polypheny/ycsb.xml similarity index 100% rename from config/polypheny-db/ycsb.xml rename to config/polypheny/ycsb.xml diff --git a/src/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java b/src/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java index 4af9954db..5e51bacf8 100644 --- a/src/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java +++ b/src/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java @@ -16,8 +16,29 @@ package com.oltpbenchmark.benchmarks.auctionmark; -import java.io.File; +import com.oltpbenchmark.api.Loader; +import com.oltpbenchmark.benchmarks.auctionmark.util.Category; +import com.oltpbenchmark.benchmarks.auctionmark.util.CategoryParser; +import com.oltpbenchmark.benchmarks.auctionmark.util.GlobalAttributeGroupId; +import com.oltpbenchmark.benchmarks.auctionmark.util.GlobalAttributeValueId; +import com.oltpbenchmark.benchmarks.auctionmark.util.ItemId; +import com.oltpbenchmark.benchmarks.auctionmark.util.ItemStatus; +import com.oltpbenchmark.benchmarks.auctionmark.util.LoaderItemInfo; +import com.oltpbenchmark.benchmarks.auctionmark.util.UserId; +import com.oltpbenchmark.benchmarks.auctionmark.util.UserIdGenerator; +import com.oltpbenchmark.catalog.Column; +import com.oltpbenchmark.catalog.Table; +import com.oltpbenchmark.util.CollectionUtil; +import com.oltpbenchmark.util.CompositeId; +import com.oltpbenchmark.util.Histogram; +import com.oltpbenchmark.util.Pair; +import com.oltpbenchmark.util.RandomDistribution.Flat; +import com.oltpbenchmark.util.RandomDistribution.Zipf; +import com.oltpbenchmark.util.SQLUtil; +import java.io.IOException; +import java.io.InputStreamReader; import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -36,31 +57,11 @@ import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; - +import java.util.zip.GZIPInputStream; import org.apache.commons.collections15.CollectionUtils; import org.apache.commons.collections15.map.ListOrderedMap; import org.apache.log4j.Logger; -import com.oltpbenchmark.api.Loader; -import com.oltpbenchmark.benchmarks.auctionmark.util.Category; -import com.oltpbenchmark.benchmarks.auctionmark.util.CategoryParser; -import com.oltpbenchmark.benchmarks.auctionmark.util.GlobalAttributeGroupId; -import com.oltpbenchmark.benchmarks.auctionmark.util.GlobalAttributeValueId; -import com.oltpbenchmark.benchmarks.auctionmark.util.ItemId; -import com.oltpbenchmark.benchmarks.auctionmark.util.ItemStatus; -import com.oltpbenchmark.benchmarks.auctionmark.util.LoaderItemInfo; -import com.oltpbenchmark.benchmarks.auctionmark.util.UserId; -import com.oltpbenchmark.benchmarks.auctionmark.util.UserIdGenerator; -import com.oltpbenchmark.catalog.Column; -import com.oltpbenchmark.catalog.Table; -import com.oltpbenchmark.util.CollectionUtil; -import com.oltpbenchmark.util.CompositeId; -import com.oltpbenchmark.util.Histogram; -import com.oltpbenchmark.util.Pair; -import com.oltpbenchmark.util.RandomDistribution.Flat; -import com.oltpbenchmark.util.RandomDistribution.Zipf; -import com.oltpbenchmark.util.SQLUtil; - /** * @author pavlo * @author visawee @@ -86,7 +87,7 @@ public class AuctionMarkLoader extends Loader { private final Histogram tableSizes = new Histogram(); - private final File category_file; + private final InputStreamReader category_reader; private boolean fail = false; @@ -96,8 +97,6 @@ public class AuctionMarkLoader extends Loader { /** * Constructor - * - * @param args */ public AuctionMarkLoader(AuctionMarkBenchmark benchmark) { super(benchmark); @@ -105,7 +104,11 @@ public AuctionMarkLoader(AuctionMarkBenchmark benchmark) { // BenchmarkProfile this.profile = new AuctionMarkProfile(benchmark, benchmark.getRandomGenerator()); - this.category_file = new File(benchmark.getDataDir().getAbsolutePath() + "/table.category.gz"); + try { + this.category_reader = new InputStreamReader( new GZIPInputStream(AuctionMarkBenchmark.class.getResourceAsStream( "data/table.category.gz" )), StandardCharsets.UTF_8 ); // new File(benchmark.getDataDir().getAbsolutePath() + "/table.category.gz"); + } catch ( IOException e ) { + throw new RuntimeException( e ); + } try { // --------------------------- @@ -113,7 +116,7 @@ public AuctionMarkLoader(AuctionMarkBenchmark benchmark) { // --------------------------- this.registerGenerator(new RegionGenerator()); - this.registerGenerator(new CategoryGenerator(category_file)); + this.registerGenerator(new CategoryGenerator(category_reader)); this.registerGenerator(new GlobalAttributeGroupGenerator()); this.registerGenerator(new GlobalAttributeValueGenerator()); @@ -322,7 +325,6 @@ protected abstract class AbstractTableGenerator extends LoaderThread { /** * Constructor - * @param catalog_tbl */ public AbstractTableGenerator(String tableName, String...dependencies) throws SQLException { super(); @@ -712,17 +714,14 @@ protected int populateRow(Object[] row) { * CATEGORY Generator **********************************************************************************************/ protected class CategoryGenerator extends AbstractTableGenerator { - private final File data_file; + private final InputStreamReader reader; private final Map categoryMap; private final LinkedList categories = new LinkedList(); - public CategoryGenerator(File data_file) throws SQLException { + public CategoryGenerator( InputStreamReader reader) throws SQLException { super(AuctionMarkConstants.TABLENAME_CATEGORY); - this.data_file = data_file; - assert(this.data_file.exists()) : - "The data file for the category generator does not exist: " + this.data_file; - - this.categoryMap = (new CategoryParser(data_file)).getCategoryMap(); + this.reader = reader; + this.categoryMap = (new CategoryParser(reader)).getCategoryMap(); this.tableSize = (long)this.categoryMap.size(); } diff --git a/src/com/oltpbenchmark/benchmarks/auctionmark/ddls/auctionmark-polypheny-ddl.sql b/src/com/oltpbenchmark/benchmarks/auctionmark/ddls/auctionmark-polypheny-ddl.sql index 1cc5fa5fd..3a69537b0 100644 --- a/src/com/oltpbenchmark/benchmarks/auctionmark/ddls/auctionmark-polypheny-ddl.sql +++ b/src/com/oltpbenchmark/benchmarks/auctionmark/ddls/auctionmark-polypheny-ddl.sql @@ -68,14 +68,14 @@ CREATE TABLE useracct ( u_sattr5 VARCHAR(64), u_sattr6 VARCHAR(64), u_sattr7 VARCHAR(64), - u_iattr0 BIGINT DEFAULT NULL, - u_iattr1 BIGINT DEFAULT NULL, - u_iattr2 BIGINT DEFAULT NULL, - u_iattr3 BIGINT DEFAULT NULL, - u_iattr4 BIGINT DEFAULT NULL, - u_iattr5 BIGINT DEFAULT NULL, - u_iattr6 BIGINT DEFAULT NULL, - u_iattr7 BIGINT DEFAULT NULL, + u_iattr0 BIGINT NULL, + u_iattr1 BIGINT NULL, + u_iattr2 BIGINT NULL, + u_iattr3 BIGINT NULL, + u_iattr4 BIGINT NULL, + u_iattr5 BIGINT NULL, + u_iattr6 BIGINT NULL, + u_iattr7 BIGINT NULL, PRIMARY KEY (u_id) ); ALTER TABLE useracct ADD CONSTRAINT C_FKEY_USERACCT_REGION FOREIGN KEY (u_r_id) REFERENCES region (r_id) ON DELETE RESTRICT; @@ -166,7 +166,7 @@ CREATE TABLE item ( i_c_id BIGINT NOT NULL, i_name VARCHAR(100), i_description VARCHAR(1024), - i_user_attributes VARCHAR(255) DEFAULT NULL, + i_user_attributes VARCHAR(255) NULL, i_initial_price REAL NOT NULL, i_current_price REAL NOT NULL, i_num_bids BIGINT, @@ -178,14 +178,14 @@ CREATE TABLE item ( i_status INTEGER DEFAULT 0, i_created TIMESTAMP, i_updated TIMESTAMP, - i_iattr0 BIGINT DEFAULT NULL, - i_iattr1 BIGINT DEFAULT NULL, - i_iattr2 BIGINT DEFAULT NULL, - i_iattr3 BIGINT DEFAULT NULL, - i_iattr4 BIGINT DEFAULT NULL, - i_iattr5 BIGINT DEFAULT NULL, - i_iattr6 BIGINT DEFAULT NULL, - i_iattr7 BIGINT DEFAULT NULL, + i_iattr0 BIGINT NULL, + i_iattr1 BIGINT NULL, + i_iattr2 BIGINT NULL, + i_iattr3 BIGINT NULL, + i_iattr4 BIGINT NULL, + i_iattr5 BIGINT NULL, + i_iattr6 BIGINT NULL, + i_iattr7 BIGINT NULL, PRIMARY KEY (i_id, i_u_id) ); ALTER TABLE item ADD CONSTRAINT C_FKEY_ITEM_ACCT FOREIGN KEY (i_u_id) REFERENCES useracct (u_id) ON DELETE RESTRICT; @@ -205,7 +205,7 @@ CREATE TABLE item_attribute ( ia_u_id BIGINT NOT NULL, ia_gav_id BIGINT NOT NULL, ia_gag_id BIGINT NOT NULL, - ia_sattr0 VARCHAR(64) DEFAULT NULL, + ia_sattr0 VARCHAR(64) NULL, PRIMARY KEY (ia_id, ia_i_id, ia_u_id) ); ALTER TABLE item_attribute ADD CONSTRAINT C_FKEY_ITEM_ATTRIBUTE_ITEM FOREIGN KEY (ia_i_id, ia_u_id) REFERENCES item (i_id, i_u_id) ON DELETE RESTRICT; @@ -243,7 +243,7 @@ CREATE TABLE item_comment ( ic_u_id BIGINT NOT NULL, ic_buyer_id BIGINT NOT NULL, ic_question VARCHAR(128) NOT NULL, - ic_response VARCHAR(128) DEFAULT NULL, + ic_response VARCHAR(128) NULL, ic_created TIMESTAMP, ic_updated TIMESTAMP, PRIMARY KEY (ic_id, ic_i_id, ic_u_id) diff --git a/src/com/oltpbenchmark/benchmarks/auctionmark/dialects/polypheny-dialects.xml b/src/com/oltpbenchmark/benchmarks/auctionmark/dialects/polypheny-dialects.xml new file mode 100644 index 000000000..ffd2abd60 --- /dev/null +++ b/src/com/oltpbenchmark/benchmarks/auctionmark/dialects/polypheny-dialects.xml @@ -0,0 +1,90 @@ + + + + + UPDATE item SET i_status = ?, i_updated = ? WHERE i_id = ? AND i_u_id = ? + SELECT i_id, i_u_id, i_name, i_current_price, i_num_bids, i_end_date, i_status FROM item WHERE (i_start_date BETWEEN ? AND ?) AND i_status = 0 ORDER BY i_id ASC LIMIT 100 + SELECT imb_ib_id, ib_buyer_id FROM item_max_bid, item_bid WHERE imb_i_id = ? AND imb_u_id = ? AND ib_id = imb_ib_id AND ib_i_id = imb_i_id AND ib_u_id = imb_u_id + INSERT INTO useracct_item(ui_u_id, ui_i_id, ui_i_u_id, ui_created) VALUES(?, ?, ?, ?) + + + SELECT u_id, u_rating, u_created, u_sattr0, u_sattr1, u_sattr2, u_sattr3, u_sattr4, r_name FROM useracct, region WHERE u_id = ? AND u_r_id = r_id + SELECT i_id, i_u_id, i_name, i_current_price, i_num_bids, i_end_date, i_status FROM item WHERE i_id = ? AND i_u_id = ? + + + SELECT u_id, u_rating, u_created, u_balance, u_sattr0, u_sattr1, u_sattr2, u_sattr3, u_sattr4, r_name FROM useracct, region WHERE u_id = ? AND u_r_id = r_id + SELECT u_id, u_rating, u_sattr0, u_sattr1, uf_rating, uf_date, uf_sattr0 FROM useracct, useracct_feedback WHERE u_id = ? AND uf_u_id = u_id ORDER BY uf_date DESC LIMIT 25 + SELECT i_id, i_u_id, i_name, i_current_price, i_num_bids, i_end_date, i_status FROM useracct_item, item WHERE ui_u_id = ? AND ui_i_id = i_id AND ui_i_u_id = i_u_id ORDER BY i_end_date DESC LIMIT 25 + SELECT i_id, i_u_id, i_name, i_current_price, i_num_bids, i_end_date, i_status FROM item WHERE i_u_id = ? ORDER BY i_end_date DESC LIMIT 25 + SELECT i_id, i_u_id, i_name, i_current_price, i_num_bids, i_end_date, i_status, uw_u_id, uw_created FROM useracct_watch, item WHERE uw_u_id = ? AND uw_i_id = i_id AND uw_i_u_id = i_u_id ORDER BY i_end_date DESC LIMIT 25 + SELECT i_id, i_u_id, i_name, i_current_price, i_num_bids, i_end_date, i_status, ic_id, ic_i_id, ic_u_id, ic_buyer_id, ic_question, ic_created FROM item, item_comment WHERE i_u_id = ? AND i_status = ? AND i_id = ic_i_id AND i_u_id = ic_u_id AND ic_response IS NULL ORDER BY ic_created DESC LIMIT 25 + + + SELECT * FROM config_profile + SELECT ic_id, ic_i_id, ic_u_id, ic_buyer_id FROM item_comment WHERE ic_response IS NULL + SELECT i_c_id, COUNT(i_id) FROM item GROUP BY i_c_id + SELECT gag_id FROM global_attribute_group + SELECT i_id, i_current_price, i_end_date, i_num_bids, i_status FROM item, config_profile WHERE i_status = ? AND i_end_date <= cfp_loader_start ORDER BY i_end_date ASC LIMIT 5000 + SELECT i_id, i_current_price, i_end_date, i_num_bids, i_status FROM item, config_profile WHERE i_status = ? AND i_end_date > cfp_loader_start ORDER BY i_end_date ASC LIMIT 5000 + + + UPDATE item_max_bid SET imb_ib_id = ?, imb_ib_i_id = ?, imb_ib_u_id = ?, imb_updated = ? WHERE imb_i_id = ? AND imb_u_id = ? + SELECT MAX(ib_id) FROM item_bid WHERE ib_i_id = ? AND ib_u_id = ? + SELECT i_initial_price, i_current_price, i_num_bids, i_end_date, i_status FROM item WHERE i_id = ? AND i_u_id = ? + SELECT imb_ib_id, ib_bid, ib_max_bid, ib_buyer_id FROM item_max_bid, item_bid WHERE imb_i_id = ? AND imb_u_id = ? AND imb_ib_id = ib_id AND imb_ib_i_id = ib_i_id AND imb_ib_u_id = ib_u_id + INSERT INTO item_max_bid(imb_i_id, imb_u_id, imb_ib_id, imb_ib_i_id, imb_ib_u_id, imb_created, imb_updated ) VALUES (?, ?, ?, ?, ?, ?, ? ) + INSERT INTO item_bid(ib_id, ib_i_id, ib_u_id, ib_buyer_id, ib_bid, ib_max_bid, ib_created, ib_updated ) VALUES (?, ?, ?, ?, ?, ?, ?, ? ) + UPDATE item_bid SET ib_bid = ?, ib_max_bid = ?, ib_updated = ? WHERE ib_id = ? AND ib_i_id = ? AND ib_u_id = ? + UPDATE item SET i_num_bids = i_num_bids + 1, i_current_price = ?, i_updated = ? WHERE i_id = ? AND i_u_id = ? + + + INSERT INTO item_comment(ic_id,ic_i_id,ic_u_id,ic_buyer_id,ic_question, ic_created,ic_updated ) VALUES (?,?,?,?,?,?,?) + UPDATE item SET i_num_comments = i_num_comments + 1 WHERE i_id = ? AND i_u_id = ? + SELECT i_num_comments FROM item WHERE i_id = ? AND i_u_id = ? + UPDATE useracct SET u_comments = u_comments + 1, u_updated = ? WHERE u_id = ? + + + UPDATE item_comment SET ic_response = ?, ic_updated = ? WHERE ic_id = ? AND ic_i_id = ? AND ic_u_id = ? + UPDATE useracct SET u_comments = u_comments - 1, u_updated = ? WHERE u_id = ? + + + SELECT uf_i_id, uf_i_u_id, uf_from_id FROM useracct_feedback WHERE uf_u_id = ? AND uf_i_id = ? AND uf_i_u_id = ? AND uf_from_id = ? + INSERT INTO useracct_feedback( uf_u_id, uf_i_id,uf_i_u_id,uf_from_id,uf_rating,uf_date,uf_sattr0) VALUES (?,?,?,?,?,?,?) + UPDATE useracct SET u_rating = u_rating + ?, u_updated = ? WHERE u_id = ? + + + INSERT INTO item_image(ii_id,ii_i_id,ii_u_id,ii_sattr0) VALUES(?, ?, ?, ?) + SELECT * FROM category WHERE c_id = ? + SELECT COUNT(*) FROM item WHERE i_u_id = ? + INSERT INTO item_attribute(ia_id,ia_i_id,ia_u_id,ia_gav_id,ia_gag_id) VALUES(?, ?, ?, ?, ?) + SELECT * FROM category WHERE c_parent_id = ? + UPDATE useracct SET u_balance = u_balance - 1, u_updated = ? WHERE u_id = ? + SELECT gag_name, gav_name, gag_c_id FROM global_attribute_group, global_attribute_value WHERE gav_id = ? AND gav_gag_id = ? AND gav_gag_id = gag_id + INSERT INTO item(i_id,i_u_id,i_c_id,i_name,i_description,i_user_attributes,i_initial_price,i_current_price,i_num_bids,i_num_images,i_num_global_attrs,i_start_date,i_end_date,i_status,i_created,i_updated,i_iattr0) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,1) + + + SELECT * FROM item_max_bid WHERE imb_i_id = ? AND imb_u_id = ? + INSERT INTO item_max_bid (imb_i_id, imb_u_id, imb_ib_id, imb_ib_i_id, imb_ib_u_id, imb_created, imb_updated ) VALUES (?, ?, ?, ?, ?, ?, ? ) + SELECT * FROM item_bid WHERE imb_i_id = ? AND imb_u_id = ? ORDER BY ib_bid DESC LIMIT 1 + INSERT INTO item_purchase(ip_id,ip_ib_id,ip_ib_i_id,ip_ib_u_id,ip_date) VALUES(?,?,?,?,?) + SELECT u_id, u_balance FROM useracct WHERE u_id = ? + SELECT i_num_bids, i_current_price, i_end_date, ib_id, ib_buyer_id, u_balance FROM item, item_max_bid, item_bid, useracct WHERE i_id = ? AND i_u_id = ? AND imb_i_id = i_id AND imb_u_id = i_u_id AND imb_ib_id = ib_id AND imb_ib_i_id = ib_i_id AND imb_ib_u_id = ib_u_id AND ib_buyer_id = u_id + UPDATE useracct SET u_balance = u_balance + ? WHERE u_id = ? + INSERT INTO useracct_item (ui_u_id, ui_i_id, ui_i_u_id, ui_ip_id, ui_ip_ib_id, ui_ip_ib_i_id, ui_ip_ib_u_id, ui_created) VALUES (?, ?, ?, ?, ?, ?, ?, ?) + UPDATE useracct_item SET ui_ip_id = ?, ui_ip_ib_id = ?, ui_ip_ib_i_id = ?, ui_ip_ib_u_id = ? WHERE ui_u_id = ? AND ui_i_id = ? AND ui_i_u_id = ? + UPDATE item SET i_status = 3, i_updated = ? WHERE i_id = ? AND i_u_id = ? + + + DELETE FROM item_purchase WHERE ip_date > ? + UPDATE item SET i_status = ?, i_updated = ? WHERE i_status != ? AND i_updated > ? + SELECT cfp_loader_stop FROM config_profile + + + SELECT MAX(ia_id) FROM item_attribute WHERE ia_i_id = ? AND ia_u_id = ? + INSERT INTO item_attribute(ia_id,ia_i_id,ia_u_id,ia_gav_id,ia_gag_id) VALUES (?, ?, ?, ?, ?) + DELETE FROM item_attribute WHERE ia_id = ? AND ia_i_id = ? AND ia_u_id = ? + UPDATE item SET i_description = ?, i_updated = ? WHERE i_id = ? AND i_u_id = ? + + + + diff --git a/src/com/oltpbenchmark/benchmarks/auctionmark/util/CategoryParser.java b/src/com/oltpbenchmark/benchmarks/auctionmark/util/CategoryParser.java index 14ec16aad..96a4f2b9b 100644 --- a/src/com/oltpbenchmark/benchmarks/auctionmark/util/CategoryParser.java +++ b/src/com/oltpbenchmark/benchmarks/auctionmark/util/CategoryParser.java @@ -18,14 +18,11 @@ package com.oltpbenchmark.benchmarks.auctionmark.util; import java.io.BufferedReader; -import java.io.File; +import java.io.InputStreamReader; import java.util.Map; import java.util.TreeMap; - import org.apache.log4j.Logger; -import com.oltpbenchmark.util.FileUtil; - public class CategoryParser { private static final Logger LOG = Logger.getLogger(CategoryParser.class); @@ -34,18 +31,18 @@ public class CategoryParser { private int _nextCategoryID; String _fileName; - public CategoryParser(File file) { + public CategoryParser(InputStreamReader reader) { _categoryMap = new TreeMap(); _nextCategoryID = 0; try { - BufferedReader br = FileUtil.getReader(file); + BufferedReader br = new BufferedReader(reader); String strLine; - while ((strLine = br.readLine()) != null) { - extractCategory(strLine); + while ((strLine = br.readLine()) != null) { //System.out.println(strLine); + extractCategory(strLine); } } catch (Exception ex) { throw new RuntimeException("Failed to load in category file", ex); @@ -111,16 +108,7 @@ public Category addNewCategory(String fullCategoryName, int itemCount, boolean i return category; } - public Map getCategoryMap(){ + public Map getCategoryMap() { return _categoryMap; } - - public static void main(String args[]) throws Exception { - CategoryParser ebp = new CategoryParser(new File("bin/edu/brown/benchmark/auctionmark/data/categories.txt")); - - for (String key : ebp.getCategoryMap().keySet()){ - LOG.info(key + " : " + ebp.getCategoryMap().get(key).getCategoryID() + " : " + ebp.getCategoryMap().get(key).getParentCategoryID() + " : " + ebp.getCategoryMap().get(key).getItemCount()); - } - //addNewCategory("001/123456/789", 0, true); - } } diff --git a/src/com/oltpbenchmark/benchmarks/smallbank/ddls/smallbank-polypheny-ddl.sql b/src/com/oltpbenchmark/benchmarks/smallbank/ddls/smallbank-polypheny-ddl.sql index 3caffe1bd..56e4e3499 100644 --- a/src/com/oltpbenchmark/benchmarks/smallbank/ddls/smallbank-polypheny-ddl.sql +++ b/src/com/oltpbenchmark/benchmarks/smallbank/ddls/smallbank-polypheny-ddl.sql @@ -21,7 +21,7 @@ CREATE TABLE CHECKING ( PRIMARY KEY (custid) ); -ALTER TABLE SAVINGS ADD CONSTRAINT S_FKEY_A FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid) ON DELETE CASCADE; -ALTER TABLE CHECKING ADD CONSTRAINT C_FKEY_A FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid) ON DELETE CASCADE; +ALTER TABLE SAVINGS ADD CONSTRAINT S_FKEY_A FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid) ON DELETE RESTRICT; +ALTER TABLE CHECKING ADD CONSTRAINT C_FKEY_A FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid) ON DELETE RESTRICT; -CREATE INDEX IDX_ACCOUNTS_NAME ON ACCOUNTS (name); +ALTER TABLE ACCOUNTS ADD INDEX IDX_ACCOUNTS_NAME ON (name); diff --git a/src/com/oltpbenchmark/benchmarks/smallbank/ddls/smallbank-polypheny-db-ddl.sql b/src/com/oltpbenchmark/benchmarks/smallbank/ddls/smallbank-polypheny-fram-ddl.sql similarity index 78% rename from src/com/oltpbenchmark/benchmarks/smallbank/ddls/smallbank-polypheny-db-ddl.sql rename to src/com/oltpbenchmark/benchmarks/smallbank/ddls/smallbank-polypheny-fram-ddl.sql index 56e4e3499..3caffe1bd 100644 --- a/src/com/oltpbenchmark/benchmarks/smallbank/ddls/smallbank-polypheny-db-ddl.sql +++ b/src/com/oltpbenchmark/benchmarks/smallbank/ddls/smallbank-polypheny-fram-ddl.sql @@ -21,7 +21,7 @@ CREATE TABLE CHECKING ( PRIMARY KEY (custid) ); -ALTER TABLE SAVINGS ADD CONSTRAINT S_FKEY_A FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid) ON DELETE RESTRICT; -ALTER TABLE CHECKING ADD CONSTRAINT C_FKEY_A FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid) ON DELETE RESTRICT; +ALTER TABLE SAVINGS ADD CONSTRAINT S_FKEY_A FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid) ON DELETE CASCADE; +ALTER TABLE CHECKING ADD CONSTRAINT C_FKEY_A FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid) ON DELETE CASCADE; -ALTER TABLE ACCOUNTS ADD INDEX IDX_ACCOUNTS_NAME ON (name); +CREATE INDEX IDX_ACCOUNTS_NAME ON ACCOUNTS (name); diff --git a/src/com/oltpbenchmark/benchmarks/tpcc/ddls/tpcc-polypheny-ddl.sql b/src/com/oltpbenchmark/benchmarks/tpcc/ddls/tpcc-polypheny-ddl.sql index 06cee3bfa..d3abef717 100644 --- a/src/com/oltpbenchmark/benchmarks/tpcc/ddls/tpcc-polypheny-ddl.sql +++ b/src/com/oltpbenchmark/benchmarks/tpcc/ddls/tpcc-polypheny-ddl.sql @@ -93,7 +93,8 @@ CREATE TABLE HISTORY ( H_W_ID INT NOT NULL, H_DATE TIMESTAMP NOT NULL, H_AMOUNT DECIMAL(6,2) NOT NULL, - H_DATA VARCHAR(24) NOT NULL + H_DATA VARCHAR(24) NOT NULL, + PRIMARY KEY (H_C_ID,H_C_D_ID,H_C_W_ID,H_D_ID,H_W_ID) ); CREATE TABLE ITEM ( @@ -140,15 +141,16 @@ CREATE TABLE ORDER_LINE ( PRIMARY KEY (OL_W_ID,OL_D_ID,OL_O_ID,OL_NUMBER) ); -ALTER TABLE CUSTOMER ADD CONSTRAINT C_FKEY_D FOREIGN KEY (C_W_ID, C_D_ID) REFERENCES DISTRICT (D_W_ID, D_ID) ON DELETE CASCADE; -ALTER TABLE DISTRICT ADD CONSTRAINT D_FKEY_W FOREIGN KEY (D_W_ID) REFERENCES WAREHOUSE (W_ID) ON DELETE CASCADE; -ALTER TABLE HISTORY ADD CONSTRAINT H_FKEY_C FOREIGN KEY (H_C_W_ID, H_C_D_ID, H_C_ID) REFERENCES CUSTOMER (C_W_ID, C_D_ID, C_ID) ON DELETE CASCADE; -ALTER TABLE HISTORY ADD CONSTRAINT H_FKEY_D FOREIGN KEY (H_W_ID, H_D_ID) REFERENCES DISTRICT (D_W_ID, D_ID) ON DELETE CASCADE; -ALTER TABLE NEW_ORDER ADD CONSTRAINT NO_FKEY_O FOREIGN KEY (NO_W_ID, NO_D_ID, NO_O_ID) REFERENCES OORDER (O_W_ID, O_D_ID, O_ID) ON DELETE CASCADE; -ALTER TABLE STOCK ADD CONSTRAINT S_FKEY_W FOREIGN KEY (S_W_ID) REFERENCES WAREHOUSE (W_ID) ON DELETE CASCADE; -ALTER TABLE STOCK ADD CONSTRAINT S_FKEY_I FOREIGN KEY (S_I_ID) REFERENCES ITEM (I_ID) ON DELETE CASCADE; -ALTER TABLE OORDER ADD CONSTRAINT O_FKEY_C FOREIGN KEY (O_W_ID, O_D_ID, O_C_ID) REFERENCES CUSTOMER (C_W_ID, C_D_ID, C_ID) ON DELETE CASCADE; -ALTER TABLE ORDER_LINE ADD CONSTRAINT OL_FKEY_O FOREIGN KEY (OL_W_ID, OL_D_ID, OL_O_ID) REFERENCES OORDER (O_W_ID, O_D_ID, O_ID) ON DELETE CASCADE; -ALTER TABLE ORDER_LINE ADD CONSTRAINT OL_FKEY_S FOREIGN KEY (OL_SUPPLY_W_ID, OL_I_ID) REFERENCES STOCK (S_W_ID, S_I_ID) ON DELETE CASCADE; +ALTER TABLE CUSTOMER ADD CONSTRAINT C_FKEY_D FOREIGN KEY (C_W_ID, C_D_ID) REFERENCES DISTRICT (D_W_ID, D_ID) ON DELETE RESTRICT; +ALTER TABLE DISTRICT ADD CONSTRAINT D_FKEY_W FOREIGN KEY (D_W_ID) REFERENCES WAREHOUSE (W_ID) ON DELETE RESTRICT; +ALTER TABLE HISTORY ADD CONSTRAINT H_FKEY_C FOREIGN KEY (H_C_W_ID, H_C_D_ID, H_C_ID) REFERENCES CUSTOMER (C_W_ID, C_D_ID, C_ID) ON DELETE RESTRICT; +ALTER TABLE HISTORY ADD CONSTRAINT H_FKEY_D FOREIGN KEY (H_W_ID, H_D_ID) REFERENCES DISTRICT (D_W_ID, D_ID) ON DELETE RESTRICT; +ALTER TABLE NEW_ORDER ADD CONSTRAINT NO_FKEY_O FOREIGN KEY (NO_W_ID, NO_D_ID, NO_O_ID) REFERENCES OORDER (O_W_ID, O_D_ID, O_ID) ON DELETE RESTRICT; +ALTER TABLE STOCK ADD CONSTRAINT S_FKEY_W FOREIGN KEY (S_W_ID) REFERENCES WAREHOUSE (W_ID) ON DELETE RESTRICT; +ALTER TABLE STOCK ADD CONSTRAINT S_FKEY_I FOREIGN KEY (S_I_ID) REFERENCES ITEM (I_ID) ON DELETE RESTRICT; +ALTER TABLE OORDER ADD CONSTRAINT O_FKEY_C FOREIGN KEY (O_W_ID, O_D_ID, O_C_ID) REFERENCES CUSTOMER (C_W_ID, C_D_ID, C_ID) ON DELETE RESTRICT; +ALTER TABLE ORDER_LINE ADD CONSTRAINT OL_FKEY_O FOREIGN KEY (OL_W_ID, OL_D_ID, OL_O_ID) REFERENCES OORDER (O_W_ID, O_D_ID, O_ID) ON DELETE RESTRICT; +ALTER TABLE ORDER_LINE ADD CONSTRAINT OL_FKEY_S FOREIGN KEY (OL_SUPPLY_W_ID, OL_I_ID) REFERENCES STOCK (S_W_ID, S_I_ID) ON DELETE RESTRICT; -CREATE INDEX IDX_CUSTOMER_NAME ON CUSTOMER (C_W_ID,C_D_ID,C_LAST,C_FIRST); +ALTER TABLE CUSTOMER ADD INDEX IDX_CUSTOMER_NAME ON (C_W_ID,C_D_ID,C_LAST,C_FIRST); +ALTER TABLE OORDER ADD INDEX IDX_ORDER ON (O_W_ID,O_D_ID,O_C_ID,O_ID); diff --git a/src/com/oltpbenchmark/benchmarks/tpcc/ddls/tpcc-polypheny-db-ddl.sql b/src/com/oltpbenchmark/benchmarks/tpcc/ddls/tpcc-polypheny-fram.sql similarity index 89% rename from src/com/oltpbenchmark/benchmarks/tpcc/ddls/tpcc-polypheny-db-ddl.sql rename to src/com/oltpbenchmark/benchmarks/tpcc/ddls/tpcc-polypheny-fram.sql index 185bf62af..06cee3bfa 100644 --- a/src/com/oltpbenchmark/benchmarks/tpcc/ddls/tpcc-polypheny-db-ddl.sql +++ b/src/com/oltpbenchmark/benchmarks/tpcc/ddls/tpcc-polypheny-fram.sql @@ -93,8 +93,7 @@ CREATE TABLE HISTORY ( H_W_ID INT NOT NULL, H_DATE TIMESTAMP NOT NULL, H_AMOUNT DECIMAL(6,2) NOT NULL, - H_DATA VARCHAR(24) NOT NULL, - PRIMARY KEY (H_C_ID,H_C_D_ID,H_C_W_ID,H_D_ID,H_W_ID) + H_DATA VARCHAR(24) NOT NULL ); CREATE TABLE ITEM ( @@ -141,15 +140,15 @@ CREATE TABLE ORDER_LINE ( PRIMARY KEY (OL_W_ID,OL_D_ID,OL_O_ID,OL_NUMBER) ); -ALTER TABLE CUSTOMER ADD CONSTRAINT C_FKEY_D FOREIGN KEY (C_W_ID, C_D_ID) REFERENCES DISTRICT (D_W_ID, D_ID) ON DELETE RESTRICT; -ALTER TABLE DISTRICT ADD CONSTRAINT D_FKEY_W FOREIGN KEY (D_W_ID) REFERENCES WAREHOUSE (W_ID) ON DELETE RESTRICT; -ALTER TABLE HISTORY ADD CONSTRAINT H_FKEY_C FOREIGN KEY (H_C_W_ID, H_C_D_ID, H_C_ID) REFERENCES CUSTOMER (C_W_ID, C_D_ID, C_ID) ON DELETE RESTRICT; -ALTER TABLE HISTORY ADD CONSTRAINT H_FKEY_D FOREIGN KEY (H_W_ID, H_D_ID) REFERENCES DISTRICT (D_W_ID, D_ID) ON DELETE RESTRICT; -ALTER TABLE NEW_ORDER ADD CONSTRAINT NO_FKEY_O FOREIGN KEY (NO_W_ID, NO_D_ID, NO_O_ID) REFERENCES OORDER (O_W_ID, O_D_ID, O_ID) ON DELETE RESTRICT; -ALTER TABLE STOCK ADD CONSTRAINT S_FKEY_W FOREIGN KEY (S_W_ID) REFERENCES WAREHOUSE (W_ID) ON DELETE RESTRICT; -ALTER TABLE STOCK ADD CONSTRAINT S_FKEY_I FOREIGN KEY (S_I_ID) REFERENCES ITEM (I_ID) ON DELETE RESTRICT; -ALTER TABLE OORDER ADD CONSTRAINT O_FKEY_C FOREIGN KEY (O_W_ID, O_D_ID, O_C_ID) REFERENCES CUSTOMER (C_W_ID, C_D_ID, C_ID) ON DELETE RESTRICT; -ALTER TABLE ORDER_LINE ADD CONSTRAINT OL_FKEY_O FOREIGN KEY (OL_W_ID, OL_D_ID, OL_O_ID) REFERENCES OORDER (O_W_ID, O_D_ID, O_ID) ON DELETE RESTRICT; -ALTER TABLE ORDER_LINE ADD CONSTRAINT OL_FKEY_S FOREIGN KEY (OL_SUPPLY_W_ID, OL_I_ID) REFERENCES STOCK (S_W_ID, S_I_ID) ON DELETE RESTRICT; +ALTER TABLE CUSTOMER ADD CONSTRAINT C_FKEY_D FOREIGN KEY (C_W_ID, C_D_ID) REFERENCES DISTRICT (D_W_ID, D_ID) ON DELETE CASCADE; +ALTER TABLE DISTRICT ADD CONSTRAINT D_FKEY_W FOREIGN KEY (D_W_ID) REFERENCES WAREHOUSE (W_ID) ON DELETE CASCADE; +ALTER TABLE HISTORY ADD CONSTRAINT H_FKEY_C FOREIGN KEY (H_C_W_ID, H_C_D_ID, H_C_ID) REFERENCES CUSTOMER (C_W_ID, C_D_ID, C_ID) ON DELETE CASCADE; +ALTER TABLE HISTORY ADD CONSTRAINT H_FKEY_D FOREIGN KEY (H_W_ID, H_D_ID) REFERENCES DISTRICT (D_W_ID, D_ID) ON DELETE CASCADE; +ALTER TABLE NEW_ORDER ADD CONSTRAINT NO_FKEY_O FOREIGN KEY (NO_W_ID, NO_D_ID, NO_O_ID) REFERENCES OORDER (O_W_ID, O_D_ID, O_ID) ON DELETE CASCADE; +ALTER TABLE STOCK ADD CONSTRAINT S_FKEY_W FOREIGN KEY (S_W_ID) REFERENCES WAREHOUSE (W_ID) ON DELETE CASCADE; +ALTER TABLE STOCK ADD CONSTRAINT S_FKEY_I FOREIGN KEY (S_I_ID) REFERENCES ITEM (I_ID) ON DELETE CASCADE; +ALTER TABLE OORDER ADD CONSTRAINT O_FKEY_C FOREIGN KEY (O_W_ID, O_D_ID, O_C_ID) REFERENCES CUSTOMER (C_W_ID, C_D_ID, C_ID) ON DELETE CASCADE; +ALTER TABLE ORDER_LINE ADD CONSTRAINT OL_FKEY_O FOREIGN KEY (OL_W_ID, OL_D_ID, OL_O_ID) REFERENCES OORDER (O_W_ID, O_D_ID, O_ID) ON DELETE CASCADE; +ALTER TABLE ORDER_LINE ADD CONSTRAINT OL_FKEY_S FOREIGN KEY (OL_SUPPLY_W_ID, OL_I_ID) REFERENCES STOCK (S_W_ID, S_I_ID) ON DELETE CASCADE; -ALTER TABLE CUSTOMER ADD INDEX IDX_CUSTOMER_NAME ON (C_W_ID,C_D_ID,C_LAST,C_FIRST); +CREATE INDEX IDX_CUSTOMER_NAME ON CUSTOMER (C_W_ID,C_D_ID,C_LAST,C_FIRST);