[ 
https://issues.apache.org/jira/browse/BEAM-8355?focusedWorklogId=324504&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-324504
 ]

ASF GitHub Bot logged work on BEAM-8355:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Oct/19 17:13
            Start Date: 07/Oct/19 17:13
    Worklog Time Spent: 10m 
      Work Description: robertwb commented on pull request #9735: [BEAM-8355] 
Add a standard boolean coder
URL: https://github.com/apache/beam/pull/9735#discussion_r332136104
 
 

 ##########
 File path: sdks/python/apache_beam/coders/coder_impl.py
 ##########
 @@ -446,6 +446,28 @@ def decode(self, encoded):
     return encoded
 
 
+class BooleanCoderImpl(CoderImpl):
+  """For internal use only; no backwards-compatibility guarantees.
+
+  A coder for bool objects."""
+
+  def encode_to_stream(self, value, out, nested):
+    out.write_byte(1 if value else 0)
+
+  def decode_from_stream(self, in_stream, nested):
+    return in_stream.read_byte() == 1
 
 Review comment:
   There's a question here of what to do if we encounter something other than 
`0x00` or `0x01`. We could either (1) raise an error, (2) interpret as True, or 
(3) interpret as False. I could go with either (1) or (2) but i think we should 
definitely avoid (3). 
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 324504)
    Time Spent: 1.5h  (was: 1h 20m)

> Make BooleanCoder a standard coder
> ----------------------------------
>
>                 Key: BEAM-8355
>                 URL: https://issues.apache.org/jira/browse/BEAM-8355
>             Project: Beam
>          Issue Type: New Feature
>          Components: beam-model, sdk-java-core, sdk-py-core
>            Reporter: Chad Dombrova
>            Assignee: Chad Dombrova
>            Priority: Major
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> This involves making the current java BooleanCoder a standard coder, and 
> implementing an equivalent coder in python



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to