This is an automated email from the ASF dual-hosted git repository.

goenka pushed a commit to branch revert-6956-no-is-pair-like
in repository https://gitbox.apache.org/repos/asf/beam.git

commit 6e8e10848f4e05e3024ac5f2140eeed22a33f156
Author: Ankur <angoe...@users.noreply.github.com>
AuthorDate: Tue Nov 13 11:14:40 2018 -0800

    Revert "Remove unused is_pair_like hack."
---
 sdks/python/apache_beam/coders/coders.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/sdks/python/apache_beam/coders/coders.py 
b/sdks/python/apache_beam/coders/coders.py
index 4867ad2b..a17bb08 100644
--- a/sdks/python/apache_beam/coders/coders.py
+++ b/sdks/python/apache_beam/coders/coders.py
@@ -516,6 +516,21 @@ class _PickleCoderBase(FastCoder):
     # GroupByKey operations.
     return False
 
+  def as_cloud_object(self, is_pair_like=True):
+    value = super(_PickleCoderBase, self).as_cloud_object()
+    # We currently use this coder in places where we cannot infer the coder to
+    # use for the value type in a more granular way.  In places where the
+    # service expects a pair, it checks for the "is_pair_like" key, in which
+    # case we would fail without the hack below.
+    if is_pair_like:
+      value['is_pair_like'] = True
+      value['component_encodings'] = [
+          self.as_cloud_object(is_pair_like=False),
+          self.as_cloud_object(is_pair_like=False)
+      ]
+
+    return value
+
   # We allow .key_coder() and .value_coder() to be called on PickleCoder since
   # we can't always infer the return values of lambdas in ParDo operations, the
   # result of which may be used in a GroupBykey.
@@ -600,6 +615,21 @@ class FastPrimitivesCoder(FastCoder):
     else:
       return DeterministicFastPrimitivesCoder(self, step_label)
 
+  def as_cloud_object(self, is_pair_like=True):
+    value = super(FastCoder, self).as_cloud_object()
+    # We currently use this coder in places where we cannot infer the coder to
+    # use for the value type in a more granular way.  In places where the
+    # service expects a pair, it checks for the "is_pair_like" key, in which
+    # case we would fail without the hack below.
+    if is_pair_like:
+      value['is_pair_like'] = True
+      value['component_encodings'] = [
+          self.as_cloud_object(is_pair_like=False),
+          self.as_cloud_object(is_pair_like=False)
+      ]
+
+    return value
+
   # We allow .key_coder() and .value_coder() to be called on 
FastPrimitivesCoder
   # since we can't always infer the return values of lambdas in ParDo
   # operations, the result of which may be used in a GroupBykey.

Reply via email to