You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by GitBox <gi...@apache.org> on 2018/12/18 18:42:28 UTC

[GitHub] nlu90 commented on a change in pull request #3123: Refactor window operations to avoid WindowConfigImpl cast

nlu90 commented on a change in pull request #3123: Refactor window operations to avoid WindowConfigImpl cast
URL: https://github.com/apache/incubator-heron/pull/3123#discussion_r242657195
 
 

 ##########
 File path: heron/api/src/java/org/apache/heron/streamlet/impl/WindowConfigImpl.java
 ##########
 @@ -19,59 +19,12 @@
 
 package org.apache.heron.streamlet.impl;
 
-import java.time.Duration;
-
 import org.apache.heron.api.bolt.BaseWindowedBolt;
-import org.apache.heron.api.tuple.Tuple;
-import org.apache.heron.api.windowing.EvictionPolicy;
-import org.apache.heron.api.windowing.TriggerPolicy;
 import org.apache.heron.streamlet.WindowConfig;
 
 /**
  * WindowConfigImpl implements the WindowConfig interface.
  */
-public final class WindowConfigImpl implements WindowConfig {
-  private enum WindowType { TIME, COUNT, CUSTOM }
-  private WindowType windowType;
-  private int windowSize;
-  private int slideInterval;
-  private Duration windowDuration;
-  private Duration slidingIntervalDuration;
-  private TriggerPolicy<Tuple, ?> triggerPolicy;
-  private EvictionPolicy<Tuple, ?> evictionPolicy;
-
-  public WindowConfigImpl(Duration windowDuration, Duration slidingIntervalDuration) {
-    this.windowType = WindowType.TIME;
-    this.windowDuration = windowDuration;
-    this.slidingIntervalDuration = slidingIntervalDuration;
-  }
-  public WindowConfigImpl(int windowSize, int slideInterval) {
-    this.windowType = WindowType.COUNT;
-    this.windowSize = windowSize;
-    this.slideInterval = slideInterval;
-  }
-  public WindowConfigImpl(TriggerPolicy<Tuple, ?> triggerPolicy,
-                          EvictionPolicy<Tuple, ?> evictionPolicy) {
-    this.windowType = WindowType.CUSTOM;
-    this.triggerPolicy = triggerPolicy;
-    this.evictionPolicy = evictionPolicy;
-  }
-
-  public void attachWindowConfig(BaseWindowedBolt bolt) {
-    switch(windowType) {
-      case COUNT:
-        bolt.withWindow(BaseWindowedBolt.Count.of(windowSize),
-                        BaseWindowedBolt.Count.of(slideInterval));
-        break;
-      case TIME:
-        bolt.withWindow(windowDuration, slidingIntervalDuration);
-        break;
-      case CUSTOM:
-        bolt.withCustomEvictor(evictionPolicy);
-        bolt.withCustomTrigger(triggerPolicy);
-        break;
-      default:
-        throw new RuntimeException("Unknown windowType " + String.valueOf(windowType));
-    }
-  }
+public abstract class WindowConfigImpl implements WindowConfig {
 
 Review comment:
   +1 for reducing the redundancy.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services