InigoSJ commented on a change in pull request #15106:
URL: https://github.com/apache/beam/pull/15106#discussion_r661775715
##########
File path: sdks/python/apache_beam/io/fileio.py
##########
@@ -243,6 +249,57 @@ def process(
yield ReadableFile(metadata, self._compression)
+@experimental()
+class MatchContinuously(beam.PTransform):
+ """Checks for new files for a given pattern every interval.
+
+ This ``PTransform`` returns a ``PCollection`` of matching files in the form
+ of ``FileMetadata`` objects.
+ """
+ def __init__(
+ self,
+ file_pattern,
+ interval=360.0,
+ has_deduplication=True,
+ start_timestamp=Timestamp.now(),
+ stop_timestamp=MAX_TIMESTAMP):
+ """Initializes a MatchContinuously transform.
+
+ Args:
+ file_pattern: The file path to read from.
+ interval: Interval at which to check for files.
Review comment:
Ack
##########
File path: sdks/python/apache_beam/io/fileio.py
##########
@@ -743,3 +800,20 @@ def finish_bundle(self):
timestamp=key[1].start,
windows=[key[1]] # TODO(pabloem) HOW DO WE GET THE PANE
))
+
+
+class _RemoveDuplicates(beam.DoFn):
+
+ FILES_STATE = BagStateSpec('files', StrUtf8Coder())
+
+ 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()]
+
+ if not bag_content:
+ file_state.add(path)
+ _LOGGER.info('Generated entry for file %s', path)
Review comment:
Acl
##########
File path: sdks/python/apache_beam/io/fileio.py
##########
@@ -743,3 +800,20 @@ def finish_bundle(self):
timestamp=key[1].start,
windows=[key[1]] # TODO(pabloem) HOW DO WE GET THE PANE
))
+
+
+class _RemoveDuplicates(beam.DoFn):
+
+ FILES_STATE = BagStateSpec('files', StrUtf8Coder())
+
+ 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()]
+
+ if not bag_content:
+ file_state.add(path)
+ _LOGGER.info('Generated entry for file %s', path)
Review comment:
Ack
--
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]