Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Missing Test cases and test case refactoring #144

Merged
merged 17 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions src/main/java/com/oltpbenchmark/api/TransactionTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.commons.collections4.map.ListOrderedMap;

import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

Expand All @@ -29,14 +28,8 @@ public class TransactionTypes implements Collection<TransactionType> {
private final ListOrderedMap<String, TransactionType> types = new ListOrderedMap<>();

public TransactionTypes(List<TransactionType> transactiontypes) {
transactiontypes.sort(new Comparator<TransactionType>() {
@Override
public int compare(TransactionType o1, TransactionType o2) {
return o1.compareTo(o2);
}
});
transactiontypes.sort(TransactionType::compareTo);
for (TransactionType tt : transactiontypes) {
// System.err.println("Adding " + tt + " - " + this.types + " / " + transactiontypes);
String key = tt.getName().toUpperCase();
this.types.put(key, tt);
}
Expand Down Expand Up @@ -68,7 +61,6 @@ public boolean add(TransactionType tt) {

@Override
public boolean addAll(Collection<? extends TransactionType> c) {
// TODO Auto-generated method stub
return false;
}

Expand All @@ -79,7 +71,6 @@ public void clear() {

@Override
public boolean contains(Object o) {
// TODO Auto-generated method stub
return false;
}

Expand All @@ -100,19 +91,16 @@ public Iterator<TransactionType> iterator() {

@Override
public boolean remove(Object o) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean removeAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean retainAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ protected List<Worker<? extends BenchmarkModule>> makeWorkersImpl() {
int keyRange = numKeys / workConf.getTerminals();
LOG.warn("numkeys={}, keyRange={}", numKeys, keyRange);
// TODO: check ranges
for (int i = 0; i < workConf.getTerminals(); ++i) {
workers.add(new ResourceStresserWorker(this, i, numKeys, keyRange));
for (int i = 0; i < workConf.getTerminals(); i++) {
workers.add(new ResourceStresserWorker(this, i + 1, numKeys, keyRange));
}

return workers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void run(Connection conn, int howManyKeys, int howManyUpdates, int sleepL


for (int sel = 0; sel < howManyUpdates; ++sel) {
int leftKey = ResourceStresserWorker.gen.nextInt(numKeys - howManyKeys);
int leftKey = ResourceStresserWorker.gen.nextInt(Math.max(1, numKeys - howManyKeys));
int rightKey = leftKey + howManyKeys;
int salary = ResourceStresserWorker.gen.nextInt();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void run(Connection conn, int myId, int howManyColsPerRow, int howManyUpd
int startingKey = myId * keyRange;

for (int up = 0; up < howManyUpdatesPerTransaction; ++up) {
int leftKey = ResourceStresserWorker.gen.nextInt(keyRange - howManyRowsPerUpdate) + startingKey;
int leftKey = ResourceStresserWorker.gen.nextInt(Math.max(1, keyRange - howManyRowsPerUpdate)) + startingKey;
int rightKey = leftKey + howManyRowsPerUpdate;

try (PreparedStatement stmt = this.getPreparedStatement(conn, ioUpdate)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,26 @@ public Object[][] run(Connection conn, String f_id) throws SQLException {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};


double base_price;
long seats_total;
long seats_left;
double seat_price;
double base_price = 0.0;
long seats_total = 0;
long seats_left = 0;
double seat_price = 0.0;

// First calculate the seat price using the flight's base price
// and the number of seats that remaining
try (PreparedStatement f_stmt = this.getPreparedStatement(conn, GetFlight)) {
f_stmt.setString(1, f_id);
try (ResultSet f_results = f_stmt.executeQuery()) {
f_results.next();

// long status = results[0].getLong(0);
base_price = f_results.getDouble(2);
seats_total = f_results.getLong(3);
seats_left = f_results.getLong(4);
seat_price = f_results.getDouble(5);
if (f_results.next()) {

// long status = results[0].getLong(0);
base_price = f_results.getDouble(2);
seats_total = f_results.getLong(3);
seats_left = f_results.getLong(4);
seat_price = f_results.getDouble(5);
} else {
LOG.warn("flight {} had no seats; this may be a data problem or a code problem. previously this threw an unhandled exception.", f_id);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ protected void loadFollowData(Connection conn, int lo, int hi) throws SQLExcepti

total++;
batchSize++;
f++;


if ((batchSize % workConf.getBatchSize()) == 0) {
followsInsert.executeBatch();
Expand All @@ -300,6 +300,8 @@ protected void loadFollowData(Connection conn, int lo, int hi) throws SQLExcepti
}
}
}

f++;
}
}
if (batchSize > 0) {
Expand Down
31 changes: 21 additions & 10 deletions src/main/java/com/oltpbenchmark/util/Histogram.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,6 @@ public Histogram(boolean keepZeroEntries) {
this.keep_zero_entries = keepZeroEntries;
}

@Override
public boolean equals(Object obj) {
if (obj instanceof Histogram<?>) {
Histogram<?> other = (Histogram<?>) obj;
return (this.histogram.equals(other.histogram));
}
return (false);
}

public boolean hasDebugLabels() {
return (this.debug_names != null && !this.debug_names.isEmpty());
}
Expand Down Expand Up @@ -204,7 +195,9 @@ private synchronized void calculateInternalValues() {
// Is this value the new min/max values?
if (this.min_value == null || this.min_value.compareTo(value) > 0) {
this.min_value = value;
} else if (this.max_value == null || this.max_value.compareTo(value) < 0) {
}

if (this.max_value == null || this.max_value.compareTo(value) < 0) {
this.max_value = value;
}

Expand All @@ -215,6 +208,7 @@ private synchronized void calculateInternalValues() {
this.min_count_values.add(value);
this.min_count = cnt;
}

if (cnt >= this.max_count) {
if (cnt > this.max_count) {
this.max_count_values.clear();
Expand Down Expand Up @@ -485,6 +479,23 @@ public boolean contains(X value) {
return (this.histogram.containsKey(value));
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Histogram<?> histogram1 = (Histogram<?>) o;
return Objects.equals(histogram, histogram1.histogram);
}

@Override
public int hashCode() {
return Objects.hash(histogram);
}

// ----------------------------------------------------------------------------
// DEBUG METHODS
// ----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/benchmarks/auctionmark/ddl-generic.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CREATE TABLE config_profile (
cfp_scale_factor FLOAT NOT NULL,
cfp_loader_start TIMESTAMP NOT NULL,
cfp_loader_stop TIMESTAMP NOT NULL,
cfp_user_item_histogram TEXT NOT NULL
cfp_user_item_histogram VARCHAR(1024) NOT NULL
);

-- ================================================================
Expand Down
22 changes: 12 additions & 10 deletions src/main/resources/benchmarks/chbenchmark/ddl-generic.sql
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
DROP TABLE IF EXISTS region;
DROP TABLE IF EXISTS nation;
DROP TABLE IF EXISTS supplier;
DROP TABLE IF EXISTS region CASCADE;
DROP TABLE IF EXISTS nation CASCADE;
DROP TABLE IF EXISTS supplier CASCADE;

create table region (
r_regionkey int not null,
r_name char(55) not null,
r_comment char(152) not null,
PRIMARY KEY ( r_regionkey )
create table region
(
r_regionkey int not null,
r_name char(55) not null,
r_comment char(152) not null,
PRIMARY KEY (r_regionkey)
);

create table nation (
n_nationkey int not null,
create table nation
(
n_nationkey int not null,
n_name char(25) not null,
n_regionkey int not null references region(r_regionkey) ON DELETE CASCADE,
n_comment char(152) not null,
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/benchmarks/epinions/ddl-generic.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
DROP TABLE IF EXISTS trust;
DROP TABLE IF EXISTS review;
DROP TABLE IF EXISTS review_rating;
DROP TABLE IF EXISTS useracct;
DROP TABLE IF EXISTS item;
DROP TABLE IF EXISTS trust CASCADE;
DROP TABLE IF EXISTS review CASCADE;
DROP TABLE IF EXISTS review_rating CASCADE;
DROP TABLE IF EXISTS useracct CASCADE;
DROP TABLE IF EXISTS item CASCADE;

CREATE TABLE useracct (
u_id int NOT NULL,
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/benchmarks/noop/dialect-hsqldb.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<dialects>
<dialect type="HSQLDB">
<procedure name="NoOp">
<statement name="noopStmt">
<![CDATA[SELECT 1]]>
</statement>
</procedure>
</dialect>
</dialects>
25 changes: 25 additions & 0 deletions src/main/resources/benchmarks/resourcestresser/dialect-hsqldb.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<dialects>
<dialect type="HSQLDB">
<procedure name="CPU1">
<statement name="cpuSelect">
<![CDATA[SELECT count(*) FROM (SELECT concat(concat(concat(concat(concat(passwd,?),?),?),?),?) FROM cputable WHERE empid >= 0 AND empid < 100) AS T1]]>
</statement>
</procedure>
<procedure name="CPU2">
<statement name="cpuSelect">
<![CDATA[SELECT count(*) FROM (SELECT concat(concat(concat(concat(concat(passwd,?),?),?),?),?) FROM cputable WHERE empid >= 0 AND empid < 100) AS T2]]>
</statement>
</procedure>
<procedure name="Contention1">
<statement name="lockSleep">
select 1 from locktable where empid = ?
</statement>
</procedure>
<procedure name="Contention2">
<statement name="lockSleep">
select 1 from locktable where empid = ?
</statement>
</procedure>
</dialect>
</dialects>
Loading