[
https://issues.apache.org/jira/browse/BEAM-8355?focusedWorklogId=324618&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-324618
]
ASF GitHub Bot logged work on BEAM-8355:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Oct/19 21:22
Start Date: 07/Oct/19 21:22
Worklog Time Spent: 10m
Work Description: chadrik commented on pull request #9735: [BEAM-8355]
Add a standard boolean coder
URL: https://github.com/apache/beam/pull/9735#discussion_r332243001
##########
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:
I follow your logic. e.g. it makes more sense for `0x03` to be `True` than
to be `False`.
That said, I'm just reproducing the behavior of the Java BooleanCoder:
```java
@Override
public void encode(Boolean value, OutputStream os) throws IOException {
BYTE_CODER.encode(value ? (byte) 1 : 0, os);
}
@Override
public Boolean decode(InputStream is) throws IOException {
return BYTE_CODER.decode(is) == 1;
}
```
So I think that changing the behavior of the BooleanCoder is outside of the
scope of this PR.
----------------------------------------------------------------
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: 324618)
Time Spent: 1h 40m (was: 1.5h)
> 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: 1h 40m
> 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)