pabloem commented on a change in pull request #15242:
URL: https://github.com/apache/beam/pull/15242#discussion_r682967218



##########
File path: sdks/python/apache_beam/io/fileio.py
##########
@@ -804,16 +803,17 @@ def finish_bundle(self):
 
 class _RemoveDuplicates(beam.DoFn):
 
-  FILES_STATE = BagStateSpec('files', StrUtf8Coder())
+  COUNT_STATE = CombiningValueStateSpec('count', combine_fn=sum)
+
+  def process(self, element, count_state=beam.DoFn.StateParam(COUNT_STATE)):
 
-  def process(self, element, file_state=beam.DoFn.StateParam(FILES_STATE)):
     path = element[0]
     file_metadata = element[1]
-    bag_content = [x for x in file_state.read()]
+    counter = count_state.read()
 
-    if not bag_content:
-      file_state.add(path)
+    if counter == 0:
+      count_state.add(1)
       _LOGGER.debug('Generated entry for file %s', path)
       yield file_metadata
     else:
-      _LOGGER.debug('File %s was already read', path)
+      _LOGGER.debug("File %s was already read", path)

Review comment:
       Maybe log the number of times it's been seen before?
   LGTM otherwise.




-- 
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]


Reply via email to