Skip to content

Commit

Permalink
[BEAM-59] Minor style cleanups to WriteOneWindowPerFile
Browse files Browse the repository at this point in the history
Makes the changes in #2779 more standalone
  • Loading branch information
dhalperi committed May 1, 2017
1 parent 46ca02a commit 1ecc6eb
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
*/
public class WriteOneFilePerWindow extends PTransform<PCollection<String>, PDone> {

private static DateTimeFormatter formatter = ISODateTimeFormat.hourMinute();
private String filenamePrefix;
private static final DateTimeFormatter FORMATTER = ISODateTimeFormat.hourMinute();
private final String filenamePrefix;

public WriteOneFilePerWindow(String filenamePrefix) {
this.filenamePrefix = filenamePrefix;
Expand All @@ -48,7 +48,10 @@ public WriteOneFilePerWindow(String filenamePrefix) {
@Override
public PDone expand(PCollection<String> input) {
return input.apply(
TextIO.Write.to(new PerWindowFiles(filenamePrefix)).withWindowedWrites().withNumShards(3));
TextIO.Write
.to(new PerWindowFiles(filenamePrefix))
.withWindowedWrites()
.withNumShards(3));
}

/**
Expand All @@ -72,7 +75,7 @@ public ValueProvider<String> getBaseOutputFilenameProvider() {

public String filenamePrefixForWindow(IntervalWindow window) {
return String.format(
"%s-%s-%s", output, formatter.print(window.start()), formatter.print(window.end()));
"%s-%s-%s", output, FORMATTER.print(window.start()), FORMATTER.print(window.end()));
}

@Override
Expand Down

0 comments on commit 1ecc6eb

Please sign in to comment.