Skip to content

Commit

Permalink
Explicitly return when an empty line is encountered
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 523492923
  • Loading branch information
cloud-teleport committed Apr 11, 2023
1 parent dd18fff commit 6d2264c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
category = TemplateCategory.GET_STARTED,
displayName = "Word Count",
description =
"Batch pipeline. Reads text from Cloud Storage, tokenizes text lines into individual words, and performs frequency count on each of the words.",
"Batch pipeline. Reads text from Cloud Storage, tokenizes text lines into individual words,"
+ " and performs frequency count on each of the words.",
optionsClass = WordCountOptions.class,
contactInformation = "https://cloud.google.com/support")
public class WordCount {
Expand All @@ -57,8 +58,10 @@ static class ExtractWordsFn extends DoFn<String, String> {

@ProcessElement
public void processElement(ProcessContext c) {
// Check if the line is empty.
if (c.element().trim().isEmpty()) {
emptyLines.inc();
return;
}

// Split the line into words.
Expand Down

0 comments on commit 6d2264c

Please sign in to comment.