Fokko commented on code in PR #650: URL: https://github.com/apache/iceberg-python/pull/650#discussion_r1669196117
########## pyiceberg/manifest.py: ########## @@ -770,6 +818,81 @@ def add_entry(self, entry: ManifestEntry) -> ManifestWriter: self._writer.write_block([self.prepare_entry(entry)]) return self + def __len__(self) -> int: + """Return the total number number of bytes written.""" + return len(self._writer) + + +class RollingManifestWriter: + closed: bool + _supplier: Generator[ManifestWriter, None, None] + _manifest_files: list[ManifestFile] + _target_file_size_in_bytes: int + _target_number_of_rows: int + _current_writer: Optional[ManifestWriter] + _current_file_rows: int + + def __init__( + self, supplier: Generator[ManifestWriter, None, None], target_file_size_in_bytes, target_number_of_rows + ) -> None: + self._closed = False + self._manifest_files = [] + self._supplier = supplier + self._target_file_size_in_bytes = target_file_size_in_bytes + self._target_number_of_rows = target_number_of_rows + self._current_writer = None + self._current_file_rows = 0 + + def __enter__(self) -> RollingManifestWriter: + self._get_current_writer().__enter__() + return self + + def __exit__( + self, + exc_type: Optional[Type[BaseException]], + exc_value: Optional[BaseException], + traceback: Optional[TracebackType], + ) -> None: + self.closed = True + if self._current_writer: Review Comment: Why not re-use `_close_current_writer` here? -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org