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

Fixes #24 - Teach Table Generator how to write to a HDFS file. #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mcdan
Copy link

@mcdan mcdan commented Aug 30, 2017

  • 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

 * 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
Copy link
Contributor

@rschlussel-zz rschlussel-zz left a 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,
Copy link
Contributor

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,
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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()) {
Copy link
Contributor

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();
Copy link
Contributor

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()) {
Copy link
Contributor

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(" ");
Copy link
Contributor

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;
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants