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

Filter wikimedia canary records, fix NullPointerException #452

Open
wants to merge 2 commits into
base: 7.5.2-post
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ services:


streams-demo:
image: cnfldemos/cp-demo-kstreams:0.0.11
image: cnfldemos/cp-demo-kstreams:0.0.12
restart: always
depends_on:
schemaregistry:
Expand Down
2 changes: 1 addition & 1 deletion kstreams-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
}

group = 'io.confluent'
version = '0.0.11'
version = '0.0.12'
sourceCompatibility = "1.8"
targetCompatibility = "1.8"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ static void createMonitorStream(final StreamsBuilder builder,
builder.<String, GenericRecord>stream(INPUT_TOPIC)
// INPUT_TOPIC has no key so use domain as the key
.map((key, value) -> new KeyValue<>(((GenericRecord)value.get(META)).get(META_DOMAIN).toString(), value))
.filter((key, value) -> !key.equals("canary")) // https://github.com/confluentinc/cp-demo/issues/451 filter canary records
.filter((key, value) -> !(boolean)value.get(BOT))
.groupByKey()
.count()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public void testWikiActivityMonitor() {
metadata1.put("domain", "commons.wikimedia.org");
final GenericRecord metadata2 = new GenericData.Record(KsqlDataSourceSchema_META.SCHEMA$);
metadata2.put("domain", "en.wikipedia.org");
final GenericRecord metadata3 = new GenericData.Record(KsqlDataSourceSchema_META.SCHEMA$);
metadata3.put("domain", "canary");

cloneRecord(testRecord)
.map(c -> with(
Expand All @@ -153,6 +155,9 @@ public void testWikiActivityMonitor() {
cloneRecord(testRecord)
.map(c -> with(c, WikipediaActivityMonitor.META, metadata1))
.ifPresent(inputValues::add);
cloneRecord(testRecord)
.map(c -> with(c, WikipediaActivityMonitor.META, metadata3))
.ifPresent(inputValues::add);

inputTopic.pipeKeyValueList(inputValues
.stream()
Expand All @@ -165,9 +170,7 @@ public void testWikiActivityMonitor() {
.stream().map(kv -> kv.value).collect(Collectors.toList());

assertThat((long)counts.size())
.isEqualTo(inputValues
.stream()
.filter(gr -> !(boolean) gr.get(WikipediaActivityMonitor.BOT)).count());
.isEqualTo(4);

assertThat(counts).extracting("domain", "editCount")
.containsExactly(
Expand Down