From 7406937daebad383739e14ab9a384e1fcb2f9dd4 Mon Sep 17 00:00:00 2001 From: Karel Hubl Date: Fri, 17 Jul 2020 17:08:44 +0200 Subject: [PATCH 1/2] Update findbugs-maven-plugin version 3.0.4, since project does not build with 3.0.3 version using maven 3.6.3. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 894e8ab..7de2228 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ org.codehaus.mojo findbugs-maven-plugin - 3.0.3 + 3.0.4 ${air.check.skip-findbugs} -Xmx${air.build.jvmsize} From a1df8433aa8c203143a85b28c61c8900d0c60944 Mon Sep 17 00:00:00 2001 From: Karel Hubl Date: Fri, 17 Jul 2020 17:11:09 +0200 Subject: [PATCH 2/2] Added charset option, so generated file encoding may be changed. --- src/main/java/com/teradata/tpcds/Options.java | 7 +++- src/main/java/com/teradata/tpcds/Session.java | 32 ++++++++++++++----- .../com/teradata/tpcds/TableGenerator.java | 4 +-- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/teradata/tpcds/Options.java b/src/main/java/com/teradata/tpcds/Options.java index c221578..9fbffa4 100644 --- a/src/main/java/com/teradata/tpcds/Options.java +++ b/src/main/java/com/teradata/tpcds/Options.java @@ -30,6 +30,7 @@ public class Options public static final boolean DEFAULT_NO_SEXISM = false; public static final int DEFAULT_PARALLELISM = 1; public static final boolean DEFAULT_OVERWRITE = false; + public static final String DEFAULT_CHARSET = "ISO_8859_1"; @Option(name = {"--scale", "-s"}, title = "scale", description = "Volume of data to generate in GB (Default: 1)") public double scale = DEFAULT_SCALE; @@ -43,6 +44,9 @@ public class Options @Option(name = {"--table", "-t"}, title = "table", description = "Build only the specified table. If this property is not specified, all tables will be generated") public String table = DEFAULT_TABLE; + @Option(name = {"--charset"}, title = "charset", description = "Charset used for output files. (Default: ISO_8859_1)") + public String charset = DEFAULT_CHARSET; + @Option(name = {"--null"}, title = "null", description = "String representation for null values (Default: the empty string)") public String nullString = DEFAULT_NULL_STRING; @@ -77,7 +81,8 @@ public Session toSession() doNotTerminate, noSexism, parallelism, - overwrite); + overwrite, + charset); } private static Optional toTableOptional(String table) diff --git a/src/main/java/com/teradata/tpcds/Session.java b/src/main/java/com/teradata/tpcds/Session.java index a1477dd..ce4f069 100644 --- a/src/main/java/com/teradata/tpcds/Session.java +++ b/src/main/java/com/teradata/tpcds/Session.java @@ -16,6 +16,7 @@ import java.util.Optional; +import static com.teradata.tpcds.Options.DEFAULT_CHARSET; import static com.teradata.tpcds.Options.DEFAULT_DIRECTORY; import static com.teradata.tpcds.Options.DEFAULT_DO_NOT_TERMINATE; import static com.teradata.tpcds.Options.DEFAULT_NO_SEXISM; @@ -39,13 +40,14 @@ public class Session private final int parallelism; private final int chunkNumber; private final boolean overwrite; + private final String charset; - public Session(double scale, String targetDirectory, String suffix, Optional
table, String nullString, char separator, boolean doNotTerminate, boolean noSexism, int parallelism, boolean overwrite) + public Session(double scale, String targetDirectory, String suffix, Optional
table, String nullString, char separator, boolean doNotTerminate, boolean noSexism, int parallelism, boolean overwrite, String charset) { - this(scale, targetDirectory, suffix, table, nullString, separator, doNotTerminate, noSexism, parallelism, 1, overwrite); + this(scale, targetDirectory, suffix, table, nullString, separator, doNotTerminate, noSexism, parallelism, 1, overwrite, charset); } - public Session(double scale, String targetDirectory, String suffix, Optional
table, String nullString, char separator, boolean doNotTerminate, boolean noSexism, int parallelism, int chunkNumber, boolean overwrite) + public Session(double scale, String targetDirectory, String suffix, Optional
table, String nullString, char separator, boolean doNotTerminate, boolean noSexism, int parallelism, int chunkNumber, boolean overwrite, String charset) { this.scaling = new Scaling(scale); this.targetDirectory = targetDirectory; @@ -58,6 +60,7 @@ public Session(double scale, String targetDirectory, String suffix, Optional 0) { diff --git a/src/main/java/com/teradata/tpcds/TableGenerator.java b/src/main/java/com/teradata/tpcds/TableGenerator.java index d42971e..f4e0e14 100644 --- a/src/main/java/com/teradata/tpcds/TableGenerator.java +++ b/src/main/java/com/teradata/tpcds/TableGenerator.java @@ -19,7 +19,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; -import java.nio.charset.StandardCharsets; +import java.nio.charset.Charset; import java.util.List; import java.util.stream.Collectors; @@ -77,7 +77,7 @@ private OutputStreamWriter addFileWriterForTable(Table table) } } - return new OutputStreamWriter(new FileOutputStream(path, true), StandardCharsets.ISO_8859_1); + return new OutputStreamWriter(new FileOutputStream(path, true), Charset.forName(session.getCharset())); } private String getPath(Table table)