[
https://issues.apache.org/jira/browse/BEAM-7996?focusedWorklogId=466541&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-466541
]
ASF GitHub Bot logged work on BEAM-7996:
----------------------------------------
Author: ASF GitHub Bot
Created on: 05/Aug/20 00:23
Start Date: 05/Aug/20 00:23
Worklog Time Spent: 10m
Work Description: robertwb commented on a change in pull request #12426:
URL: https://github.com/apache/beam/pull/12426#discussion_r465401499
##########
File path: sdks/python/apache_beam/coders/coder_impl.py
##########
@@ -530,6 +530,93 @@ def estimate_size(self, unused_value, nested=False):
return 1
+class MapCoderImpl(StreamCoderImpl):
+ """For internal use only; no backwards-compatibility guarantees.
+
+ Note this implementation always uses nested context when encoding keys
+ and values. This differs from Java's MapCoder, which uses
+ nested=False if possible for the last value encoded.
+
+ This difference is acceptable because MapCoder is not standard. It is only
+ used in a standard context by RowCoder which always uses nested context for
+ attribute values.
+
+ A coder for typing.Mapping objects."""
+ def __init__(
+ self,
+ key_coder, # type: CoderImpl
+ value_coder # type: CoderImpl
+ ):
+ self._key_coder = key_coder
+ self._value_coder = value_coder
+
+ def encode_to_stream(self, dict_value, out, nested):
+ size = len(dict_value)
Review comment:
nit: no need to make this a local
----------------------------------------------------------------
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: 466541)
Time Spent: 8h (was: 7h 50m)
> Add support for remaining data types in python RowCoder
> --------------------------------------------------------
>
> Key: BEAM-7996
> URL: https://issues.apache.org/jira/browse/BEAM-7996
> Project: Beam
> Issue Type: New Feature
> Components: sdk-py-core
> Reporter: Brian Hulette
> Assignee: Brian Hulette
> Priority: P2
> Time Spent: 8h
> Remaining Estimate: 0h
>
> In the initial [python RowCoder
> implementation|https://github.com/apache/beam/pull/9188] we only added
> support for the data types that already had coders in the Python SDK. We
> should add support for the remaining data types that are not currently
> supported:
> * INT8 (ByteCoder in Java)
> * INT16 (BigEndianShortCoder in Java)
> * FLOAT (FloatCoder in Java) (Note: doubles are supported, this is
> specifically for single-precision)
> * --BOOLEAN (standard beam:coder:bool:v1, BooleanCoder in Java)--
> * --BYTES (standard beam:coder:bytes:v1, ByteArrayCoder in Java)--
> * Map (MapCoder in Java)
> We might consider making those coders standard so they can be tested
> independently from RowCoder in standard_coders.yaml. Or, if we don't do that
> we should probably add a more robust testing framework for RowCoder itself,
> because it will be challenging to test all of these types as part of the
> RowCoder tests in standard_coders.yaml.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)