Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
* bump 1.4.0
  • Loading branch information
physikerwelt committed Nov 21, 2021
1 parent 785cc72 commit b26efc1
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 13 deletions.
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.formulasearchengine</groupId>
<artifactId>dbs-sql-check</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>1.4.0</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
Expand Down Expand Up @@ -48,6 +48,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<!--suppress MavenPackageUpdate -->
<version>2.11.0</version>
</dependency>
<dependency>
Expand All @@ -58,11 +59,11 @@
</dependencies>
<name>DBS SQL check</name>
<description>Checking of student solutions for SQL queries</description>
<url>http://www.formulasearchengine.com</url>
<url>https://www.formulasearchengine.com</url>
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand All @@ -21,7 +20,6 @@
public abstract class BaseChecker {
static final boolean SHOW_DEBUG = true;
private PrintStream orgStream;
private PrintStream myPrintStream;
protected Solution solution;
protected Path testFolder;
protected int points = 0;
Expand Down Expand Up @@ -144,14 +142,15 @@ public void go(String[] args) {
}

private void flushLog() {
System.out.println(output.toString());
System.out.println(output);
}

abstract public void run();

private void redirectStdOut() {
orgStream = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream myPrintStream;
try {
myPrintStream = new PrintStream(baos, true, "UTF-8");
} catch (UnsupportedEncodingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ private static int getHash(Boolean sorted, Statement statement, String solutionQ
if (sorted) {
actualHash = computeOrderAwareResultSetHash(actual);
} else {
// its not entirely clear to me hwo good the has code ist. At least in the current list of test cases
// there are no hash collisions.
actualHash = computeOrderTolerantResultHashes(actual).hashCode();
}
actual.close();
Expand All @@ -78,6 +76,7 @@ private static int computeOrderAwareResultSetHash(ResultSet result) throws SQLEx
hash = computeRowHash(result) | rowCnt++;

while (result.next()) {
//noinspection NumericOverflow
hash ^= (1315423911 ^ ((1315423911 << 5) + (computeRowHash(result) | rowCnt++) + (1315423911 >> 2)));
}

Expand All @@ -102,10 +101,12 @@ private static int computeRowHash(ResultSet result) throws SQLException {
for (int i = 1; i <= result.getMetaData().getColumnCount(); i++) {
if ("java.sql.Array".equals(result.getMetaData().getColumnClassName(i))) {
final ResultSet resultSet = result.getArray(i).getResultSet();
//noinspection NumericOverflow
hash ^= (1315423911 ^ ((1315423911 << 5) + computeOrderAwareResultSetHash(resultSet)+ (1315423911 >> 2)));
} else {
final Object o = result.getObject(i);
if (o != null) { // ignore null values
//noinspection NumericOverflow
hash ^= (1315423911 ^ ((1315423911 << 5) + o.hashCode() + (1315423911 >> 2)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void generateJsonFiles(String folder) throws IOException, URISyntaxExcept
e.printStackTrace();
}
} else {
System.out.println("Ignoring " + f.getFileName().toString());
System.out.println("Ignoring " + f.getFileName());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void writeOutput() {

}

public void compareWithResource(InputStream refStream, Double maxPoints, Class clazz) {
public void compareWithResource(InputStream refStream, Double maxPoints, @SuppressWarnings("rawtypes") Class clazz) {
compareWithResource(refStream, maxPoints, clazz, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.SortedSet;

@SuppressWarnings({"unused", "MismatchedQueryAndUpdateOfCollection"})
public class FunctionalDependency{
@CsvBindAndSplitByName(required = true, elementType = Integer.class)
private SortedSet<Integer> determinant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class Solution {
* // 4: str(env.user().last_name),
* // 5: str(env.solution().id)]
*
* @param args
*/
public Solution(String[] args) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public void basicSqlII() throws Exception {
final Node root = query.getChildren().get(0);
final Query noLimitQuery;
if (query.getLocation().isPresent()) {
//noinspection OptionalGetWithoutIsPresent
noLimitQuery = new Query(query.getLocation().get(), query.getWith(), query.getQueryBody(), query.getOrderBy(),query.getOffset(), Optional.empty());
} else {
noLimitQuery = new Query(query.getWith(), query.getQueryBody(), query.getOrderBy(), query.getOffset(), Optional.empty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.formulasearchengine.sql.check.dbs.ReferenceQuery;
import com.formulasearchengine.sql.check.dbs.pcstore.Seq1;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.fail;

Expand Down

0 comments on commit b26efc1

Please sign in to comment.