beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lc...@apache.org
Subject [1/2] incubator-beam git commit: Use AutoValue for StepTransformResult
Date Thu, 28 Jul 2016 15:01:00 GMT
Repository: incubator-beam
Updated Branches:
  refs/heads/master ff873f4eb -> a46081eb5


Use AutoValue for StepTransformResult


Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/19de0b8a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/19de0b8a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/19de0b8a

Branch: refs/heads/master
Commit: 19de0b8a6215c57ed5c56668bd61a81f14d813ad
Parents: ff873f4
Author: Thomas Groh <tgroh@google.com>
Authored: Tue Jul 26 09:38:13 2016 -0700
Committer: Luke Cwik <lcwik@google.com>
Committed: Thu Jul 28 10:12:35 2016 -0400

----------------------------------------------------------------------
 .../runners/direct/StepTransformResult.java     | 76 ++++----------------
 1 file changed, 15 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/19de0b8a/runners/direct-java/src/main/java/org/apache/beam/runners/direct/StepTransformResult.java
----------------------------------------------------------------------
diff --git a/runners/direct-java/src/main/java/org/apache/beam/runners/direct/StepTransformResult.java
b/runners/direct-java/src/main/java/org/apache/beam/runners/direct/StepTransformResult.java
index 5706b2a..e2bacbe 100644
--- a/runners/direct-java/src/main/java/org/apache/beam/runners/direct/StepTransformResult.java
+++ b/runners/direct-java/src/main/java/org/apache/beam/runners/direct/StepTransformResult.java
@@ -17,8 +17,6 @@
  */
 package org.apache.beam.runners.direct;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
 import org.apache.beam.runners.direct.DirectRunner.UncommittedBundle;
 import org.apache.beam.runners.direct.WatermarkManager.TimerUpdate;
 import org.apache.beam.sdk.transforms.AppliedPTransform;
@@ -27,7 +25,7 @@ import org.apache.beam.sdk.util.WindowedValue;
 import org.apache.beam.sdk.util.common.CounterSet;
 import org.apache.beam.sdk.util.state.CopyOnAccessInMemoryStateInternals;
 
-import com.google.common.base.MoreObjects;
+import com.google.auto.value.AutoValue;
 import com.google.common.collect.ImmutableList;
 
 import org.joda.time.Instant;
@@ -39,67 +37,30 @@ import javax.annotation.Nullable;
 /**
  * An immutable {@link TransformResult}.
  */
-public class StepTransformResult implements TransformResult {
-  private final AppliedPTransform<?, ?, ?> transform;
-  private final Iterable<? extends UncommittedBundle<?>> bundles;
-  private final Iterable<? extends WindowedValue<?>> unprocessedElements;
-  @Nullable private final CopyOnAccessInMemoryStateInternals<?> state;
-  private final TimerUpdate timerUpdate;
-  @Nullable private final CounterSet counters;
-  private final Instant watermarkHold;
-
-  private StepTransformResult(
-      AppliedPTransform<?, ?, ?> transform,
-      Iterable<? extends UncommittedBundle<?>> outputBundles,
-      Iterable<? extends WindowedValue<?>> unprocessedElements,
-      CopyOnAccessInMemoryStateInternals<?> state,
-      TimerUpdate timerUpdate,
-      CounterSet counters,
-      Instant watermarkHold) {
-    this.transform = checkNotNull(transform);
-    this.bundles = checkNotNull(outputBundles);
-    this.unprocessedElements = checkNotNull(unprocessedElements);
-    this.state = state;
-    this.timerUpdate = checkNotNull(timerUpdate);
-    this.counters = counters;
-    this.watermarkHold = checkNotNull(watermarkHold);
-  }
-
+@AutoValue
+public abstract class StepTransformResult implements TransformResult {
   @Override
-  public Iterable<? extends UncommittedBundle<?>> getOutputBundles() {
-    return bundles;
-  }
+  public abstract AppliedPTransform<?, ?, ?> getTransform();
 
   @Override
-  public Iterable<? extends WindowedValue<?>> getUnprocessedElements() {
-    return unprocessedElements;
-  }
+  public abstract Iterable<? extends UncommittedBundle<?>> getOutputBundles();
 
   @Override
-  public CounterSet getCounters() {
-    return counters;
-  }
+  public abstract Iterable<? extends WindowedValue<?>> getUnprocessedElements();
 
   @Override
-  public AppliedPTransform<?, ?, ?> getTransform() {
-    return transform;
-  }
+  @Nullable
+  public abstract CounterSet getCounters();
 
   @Override
-  public Instant getWatermarkHold() {
-    return watermarkHold;
-  }
+  public abstract Instant getWatermarkHold();
 
   @Nullable
   @Override
-  public CopyOnAccessInMemoryStateInternals<?> getState() {
-    return state;
-  }
+  public abstract CopyOnAccessInMemoryStateInternals<?> getState();
 
   @Override
-  public TimerUpdate getTimerUpdate() {
-    return timerUpdate;
-  }
+  public abstract TimerUpdate getTimerUpdate();
 
   public static Builder withHold(AppliedPTransform<?, ?, ?> transform, Instant watermarkHold)
{
     return new Builder(transform, watermarkHold);
@@ -109,13 +70,6 @@ public class StepTransformResult implements TransformResult {
     return new Builder(transform, BoundedWindow.TIMESTAMP_MAX_VALUE);
   }
 
-  @Override
-  public String toString() {
-    return MoreObjects.toStringHelper(StepTransformResult.class)
-        .add("transform", transform)
-        .toString();
-  }
-
   /**
    * A builder for creating instances of {@link StepTransformResult}.
    */
@@ -137,14 +91,14 @@ public class StepTransformResult implements TransformResult {
     }
 
     public StepTransformResult build() {
-      return new StepTransformResult(
+      return new AutoValue_StepTransformResult(
           transform,
           bundlesBuilder.build(),
           unprocessedElementsBuilder.build(),
-          state,
-          timerUpdate,
           counters,
-          watermarkHold);
+          watermarkHold,
+          state,
+          timerUpdate);
     }
 
     public Builder withCounters(CounterSet counters) {


Mime
View raw message