liferoad commented on code in PR #27544:
URL: https://github.com/apache/beam/pull/27544#discussion_r1268569431
##########
sdks/python/apache_beam/ml/transforms/handlers.py:
##########
@@ -119,6 +121,59 @@ def expand(
return pcoll | beam.Map(lambda x: x._asdict())
+# Helper methods to compute hash key for elements of PCollections.
+# These are needed to group transformed elements with their appropriate
+# subset of untransformed raw data elements.
+class ComputeAndAttachHashKey(beam.DoFn):
+ def process(self, element):
+ hash_object = hashlib.sha256()
+ for _, value in element.items():
+ # handle the case where value is a list or numpy array
+ if isinstance(value, (list, np.ndarray)):
+ hash_object.update(str(list(value)).encode())
+ else: # assume value is a primitive that can be turned into str
+ hash_object.update(str(value).encode())
+ yield (hash_object.hexdigest(), element)
+
+
+class GetMissingColumnsPColl(beam.DoFn):
Review Comment:
docstring for these classes if they are meant to be public?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]