-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for StringSet in JetRunner
- Loading branch information
1 parent
e16da38
commit 2dd784b
Showing
2 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
runners/jet/src/main/java/org/apache/beam/runners/jet/metrics/StringSetImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.apache.beam.runners.jet.metrics; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import org.apache.beam.runners.core.metrics.StringSetData; | ||
import org.apache.beam.sdk.metrics.MetricName; | ||
import org.apache.beam.sdk.metrics.StringSet; | ||
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableSet; | ||
|
||
/** Implementation of {@link StringSet}. */ | ||
public class StringSetImpl extends AbstractMetric<StringSetData> implements StringSet { | ||
|
||
private final StringSetData stringSetData = StringSetData.empty(); | ||
|
||
public StringSetImpl(MetricName name) { | ||
super(name); | ||
} | ||
|
||
@Override | ||
StringSetData getValue() { | ||
return stringSetData; | ||
} | ||
|
||
@Override | ||
public void add(String value) { | ||
stringSetData.combine(StringSetData.create(ImmutableSet.of("ab"))); | ||
} | ||
|
||
@Override | ||
public void add(String... values) { | ||
stringSetData.combine(StringSetData.create(new HashSet<>(Arrays.asList(values)))); | ||
} | ||
} |