-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fixes #24 - Teach Table Generator how to write to a HDFS file. #25
base: master
Are you sure you want to change the base?
Conversation
* Make session & scaling serializable so it can be passed around * Teach session factory pattern to take in a hadoop config object * Make a serializable hadoop config object to ensure Session is serializable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Sorry it took me a while to get to it. Can you explain the motivation for making the session serializable? It seems unrelated to adding support for writing to hdfs.
If it is necessary, I think it would be good to put those changes in a separate commit.
Also, we generally don't include the issue number in the commit message title, so you can just say "Teach TableGenerator to write to an HDFS file"
@@ -47,17 +52,26 @@ public Session(double scale, String targetDirectory, String suffix, Optional<Tab | |||
|
|||
public Session(double scale, String targetDirectory, String suffix, Optional<Table> table, String nullString, char separator, boolean doNotTerminate, boolean noSexism, int parallelism, int chunkNumber, boolean overwrite) | |||
{ | |||
this(scale, targetDirectory, suffix, table, nullString, separator, doNotTerminate, noSexism, parallelism, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the function arguments don't fit nicely on one line, can you put one per line?
this(
scale,
targetDirectory,
....)
this.nullString, | ||
this.separator, | ||
this.doNotTerminate, | ||
noSexism, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.noSexism
to match the rest of the arguments
@@ -255,3 +310,38 @@ public String getCommandLineArguments() | |||
return output.toString(); | |||
} | |||
} | |||
|
|||
class SerializableHadoopConfiguration implements Serializable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be private?
@@ -26,19 +30,20 @@ | |||
import static com.teradata.tpcds.Options.DEFAULT_SEPARATOR; | |||
import static com.teradata.tpcds.Options.DEFAULT_SUFFIX; | |||
|
|||
public class Session | |||
public class Session implements Serializable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implements should be on a newline to match the style of the rest of the project. (I thought that would be caught by checkstyle, but I guess not)
@@ -255,3 +310,38 @@ public String getCommandLineArguments() | |||
return output.toString(); | |||
} | |||
} | |||
|
|||
class SerializableHadoopConfiguration implements Serializable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implements on a new line
} | ||
|
||
public Table getOnlyTableToGenerate() | ||
{ | ||
if (!table.isPresent()) { | ||
if (!Optional.ofNullable(table).isPresent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same. Just check for null.
throw new TpcdsException("table not present"); | ||
} | ||
return table.get(); | ||
return Optional.ofNullable(table).get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -225,8 +280,8 @@ public String getCommandLineArguments() | |||
if (!suffix.equals(DEFAULT_SUFFIX)) { | |||
output.append("--suffix ").append(suffix).append(" "); | |||
} | |||
if (table.isPresent()) { | |||
output.append("--table ").append(table.get().getName()).append(" "); | |||
if (Optional.ofNullable(table).isPresent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just check for null
if (table.isPresent()) { | ||
output.append("--table ").append(table.get().getName()).append(" "); | ||
if (Optional.ofNullable(table).isPresent()) { | ||
output.append("--table ").append(Optional.ofNullable(table).get().getName()).append(" "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just do table.getName()
this.scaling = new Scaling(scale); | ||
this.targetDirectory = targetDirectory; | ||
this.suffix = suffix; | ||
this.table = table; | ||
this.table = table.isPresent() ? table.get() : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while you're here, it would be great to add requireNonNull()
checks for the fields that shouldn't be null.
serializable