Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jjthomas committed Jun 22, 2016
1 parent 80fee20 commit f7aec9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import org.apache.spark.sql.*;
import org.apache.spark.sql.streaming.StreamingQuery;

import java.util.regex.Pattern;

/**
* Counts words in UTF8 encoded, '\n' delimited text received from the network every second.
*
Expand All @@ -34,7 +32,6 @@
* localhost 9999 <checkpoint dir>`
*/
public final class JavaStructuredNetworkWordCount {
private static final Pattern SPACE = Pattern.compile(" ");

public static void main(String[] args) throws Exception {
if (args.length < 3) {
Expand All @@ -60,11 +57,11 @@ public static void main(String[] args) throws Exception {
.load();

// Split the lines into words
Dataset<String> words = lines.select(
functions.explode(
functions.split(lines.col("value"), " ")
).alias("word")
).as(Encoders.STRING());
Dataset<Row> words = lines.select(
functions.explode(
functions.split(lines.col("value"), " ")
).alias("word")
);

// Generate running word count
Dataset<Row> wordCounts = words.groupBy("word").count();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ object StructuredNetworkWordCount {
val words = lines.select(
explode(
split(lines.col("value"), " ")
).alias("word"))
).alias("word")
)

// Generate running word count
val wordCounts = words.groupBy("word").count()
Expand Down

0 comments on commit f7aec9d

Please sign in to comment.