beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lc...@apache.org
Subject [1/3] beam git commit: Remove context from size estimate operations.
Date Sun, 07 May 2017 03:34:10 GMT
Repository: beam
Updated Branches:
  refs/heads/master 019d3002b -> dabad1ae5


Remove context from size estimate operations.


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

Branch: refs/heads/master
Commit: 78a99be1c46656996081744e52dac3d619cb4fe7
Parents: 019d300
Author: Robert Bradshaw <robertwb@gmail.com>
Authored: Fri May 5 15:18:52 2017 -0700
Committer: Luke Cwik <lcwik@google.com>
Committed: Sat May 6 19:23:50 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/beam/sdk/coders/Coder.java  | 52 ++++----------------
 1 file changed, 10 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/78a99be1/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/Coder.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/Coder.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/Coder.java
index eeafbd2..d140e89 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/Coder.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/Coder.java
@@ -301,40 +301,10 @@ public abstract class Coder<T> implements Serializable {
    *         unless it is overridden. This is considered expensive.
    */
   public boolean isRegisterByteSizeObserverCheap(T value) {
-    return isRegisterByteSizeObserverCheap(value, Context.NESTED);
-  }
-
-  /**
-   * {@inheritDoc}
-   *
-   * <p>Not intended to be called by user code, but instead by
-   * {@link PipelineRunner}
-   * implementations.
-   *
-   * @return {@code false} unless it is overridden. {@link StructuredCoder#registerByteSizeObserver}
-   *         invokes {@link #getEncodedElementByteSize} which requires re-encoding an element
-   *         unless it is overridden. This is considered expensive.
-   */
-  @Deprecated
-  public boolean isRegisterByteSizeObserverCheap(T value, Context context) {
     return false;
   }
 
   /**
-   * Returns the size in bytes of the encoded value using this coder.
-   */
-  protected long getEncodedElementByteSize(T value, Context context)
-      throws Exception {
-    try (CountingOutputStream os = new CountingOutputStream(ByteStreams.nullOutputStream()))
{
-      encode(value, os, context);
-      return os.getCount();
-    } catch (Exception exn) {
-      throw new IllegalArgumentException(
-          "Unable to encode element '" + value + "' with coder '" + this + "'.", exn);
-    }
-  }
-
-  /**
    * Notifies the {@code ElementByteSizeObserver} about the byte size
    * of the encoded value using this {@code Coder}.
    *
@@ -347,22 +317,20 @@ public abstract class Coder<T> implements Serializable {
    */
   public void registerByteSizeObserver(T value, ElementByteSizeObserver observer)
       throws Exception {
-    registerByteSizeObserver(value, observer, Context.NESTED);
+    observer.update(getEncodedElementByteSize(value));
   }
 
   /**
-   * Notifies the {@code ElementByteSizeObserver} about the byte size
-   * of the encoded value using this {@code Coder}.
-   *
-   * <p>Not intended to be called by user code, but instead by
-   * {@link PipelineRunner}
-   * implementations.
+   * Returns the size in bytes of the encoded value using this coder.
    */
-  @Deprecated
-  public void registerByteSizeObserver(
-      T value, ElementByteSizeObserver observer, Context context)
-      throws Exception {
-    observer.update(getEncodedElementByteSize(value, context));
+  protected long getEncodedElementByteSize(T value) throws Exception {
+    try (CountingOutputStream os = new CountingOutputStream(ByteStreams.nullOutputStream()))
{
+      encode(value, os);
+      return os.getCount();
+    } catch (Exception exn) {
+      throw new IllegalArgumentException(
+          "Unable to encode element '" + value + "' with coder '" + this + "'.", exn);
+    }
   }
 
   /**


Mime
View raw message