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

MINOR: Account for extra whitespaces in WordCountDemo #10229

Merged
merged 1 commit into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void init(final ProcessorContext<String, String> context) {

@Override
public void process(final Record<String, String> record) {
final String[] words = record.value().toLowerCase(Locale.getDefault()).split(" ");
final String[] words = record.value().toLowerCase(Locale.getDefault()).split("\\W+");

for (final String word : words) {
final Integer oldValue = kvStore.get(word);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void init(final ProcessorContext context) {

@Override
public KeyValue<String, String> transform(final String dummy, final String line) {
final String[] words = line.toLowerCase(Locale.getDefault()).split(" ");
final String[] words = line.toLowerCase(Locale.getDefault()).split("\\W+");

for (final String word : words) {
final Integer oldValue = this.kvStore.get(word);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void test() {
processor.init(context);

// send a record to the processor
processor.process(new Record<>("key", "alpha beta gamma alpha", 0L));
processor.process(new Record<>("key", "alpha beta\tgamma\n\talpha", 0L));

// note that the processor does not forward during process()
assertTrue(context.forwarded().isEmpty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void test() {
transformer.init(context);

// send a record to the transformer
transformer.transform("key", "alpha beta gamma alpha");
transformer.transform("key", "alpha beta\tgamma\n\talpha");

// note that the transformer does not forward during transform()
assertTrue(context.forwarded().isEmpty());
Expand Down