Skip to content

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"

}

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)
{
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,
    ....)

Optional.ofNullable(this.table),
this.nullString,
this.separator,
this.doNotTerminate,
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

return output.toString();
}
}

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?

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)

return output.toString();
}
}

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()) {
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.

if (!Optional.ofNullable(table).isPresent()) {
throw new TpcdsException("table not present");
}
return 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

output.append("--suffix ").append(suffix).append(" ");
}
if (table.isPresent()) {
output.append("--table ").append(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.

just check for null

}
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.

You can just do table.getName()

this.scaling = new Scaling(scale);
this.targetDirectory = targetDirectory;
this.suffix = suffix;
this.table = table;
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