guozhangwang commented on code in PR #12135:
URL: https://github.com/apache/kafka/pull/12135#discussion_r872593623
##########
streams/src/main/java/org/apache/kafka/streams/kstream/EmitStrategy.java:
##########
@@ -19,15 +19,52 @@
import org.apache.kafka.streams.kstream.internals.UnlimitedWindow;
import
org.apache.kafka.streams.kstream.internals.emitstrategy.WindowCloseStrategy;
import
org.apache.kafka.streams.kstream.internals.emitstrategy.WindowUpdateStrategy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
/**
* This interface controls the strategy that can be used to control how we
emit results in a processor.
*/
public interface EmitStrategy {
+ Logger log = LoggerFactory.getLogger(EmitStrategy.class);
+
enum StrategyType {
- ON_WINDOW_CLOSE,
- ON_WINDOW_UPDATE
+ ON_WINDOW_UPDATE(0, new WindowUpdateStrategy()),
+ ON_WINDOW_CLOSE(1, new WindowCloseStrategy());
+
+ private final short code;
+ private final EmitStrategy strategy;
+
+ private short code() {
+ return this.code;
+ }
+
+ private EmitStrategy strategy() {
+ return this.strategy;
+ }
+
+ StrategyType(final int code, final EmitStrategy strategy) {
+ this.code = (short) code;
+ this.strategy = strategy;
+ }
+
+ private final static Map<Short, EmitStrategy> TYPE_TO_STRATEGY = new
HashMap<>();
+
+ static {
+ for (final StrategyType type : StrategyType.values()) {
+ if (TYPE_TO_STRATEGY.put(type.code(), type.strategy()) != null)
+ throw new IllegalStateException("Code " + type.code() + "
for type " +
Review Comment:
I was following the enum `Errors` as well to add this guard.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]