Skip to content

Commit

Permalink
Add catalog tests (cmu-db#141)
Browse files Browse the repository at this point in the history
Fixes cmu-db#24
  • Loading branch information
jkosh44 authored Mar 27, 2022
1 parent aa20749 commit ee85c99
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 188 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/oltpbenchmark/catalog/HSQLDBCatalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private void init() throws SQLException, IOException {
*
* @return A map from the original table names to the uppercase HSQLDB table names.
*/
private Map<String, String> getOriginalTableNames() {
Map<String, String> getOriginalTableNames() {
// Get the contents of the HSQLDB DDL for the current benchmark.
String ddlPath = this.benchmarkModule.getDatabaseDDLPath(DatabaseType.HSQLDB);
String ddlContents;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/oltpbenchmark/catalog/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class Index extends AbstractCatalogObject {
private final int type;
private final boolean unique;

private static class IndexColumn implements Serializable {
static class IndexColumn implements Serializable {
private final String name;
private final SortDirectionType dir;

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/oltpbenchmark/catalog/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public Index getIndex(String indexName) {
return (null);
}

public List<Index> getIndexes() {
return this.indexes;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
23 changes: 21 additions & 2 deletions src/main/java/com/oltpbenchmark/util/SQLUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,26 @@ public static boolean isStringType(int sqlType) {
}
}

/**
* Returns true if the given sqlType identifier is an Integer data type
*
* @param sqlType
* @return
* @see java.sql.Types
*/
public static boolean isIntegerType(int sqlType) {
switch (sqlType) {
case Types.TINYINT:
case Types.SMALLINT:
case Types.INTEGER:
case Types.BIGINT: {
return (true);
}
default:
return (false);
}
}

/**
* Return the COUNT(*) SQL to calculate the number of records
*
Expand Down Expand Up @@ -418,9 +438,8 @@ public static AbstractCatalog getCatalog(BenchmarkModule benchmarkModule, Databa
* This supports databases that may not support all of the SQL standard just yet.
*
* @return
* @throws SQLException
*/
private static AbstractCatalog getCatalogHSQLDB(BenchmarkModule benchmarkModule) throws SQLException {
private static AbstractCatalog getCatalogHSQLDB(BenchmarkModule benchmarkModule) {
return new HSQLDBCatalog(benchmarkModule);
}

Expand Down
10 changes: 1 addition & 9 deletions src/test/java/com/oltpbenchmark/api/MockBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
public class MockBenchmark extends BenchmarkModule {
public MockBenchmark() {
super(new WorkloadConfiguration());
this.workConf.setBenchmarkName("mockbenchmark");
}

@Override
Expand All @@ -46,13 +47,4 @@ protected List<Worker<? extends BenchmarkModule>> makeWorkersImpl() throws IOExc
// TODO Auto-generated method stub
return null;
}

public URL getDatabaseDDL(DatabaseType db_type) {
// Get our sample DDL file
URL testDDLURL = MockBenchmark.class.getResource("test-ddl.sql");
assert (testDDLURL != null) : "Unable to get " + MockBenchmark.class.getSimpleName() + " DDL file";
File testDDL = new File(testDDLURL.getPath());
assert (testDDL.exists()) : testDDL.getAbsolutePath();
return (testDDLURL);
}
} // END CLASS
175 changes: 0 additions & 175 deletions src/test/java/com/oltpbenchmark/catalog/TestCatalog.java

This file was deleted.

Loading

0 comments on commit ee85c99

Please sign in to comment.