You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "Fokko (via GitHub)" <gi...@apache.org> on 2023/07/05 07:25:05 UTC

[GitHub] [iceberg] Fokko commented on a diff in pull request #7984: Python: Add gzip metadata support

Fokko commented on code in PR #7984:
URL: https://github.com/apache/iceberg/pull/7984#discussion_r1252662748


##########
python/pyiceberg/serializers.py:
##########
@@ -14,27 +14,72 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+from __future__ import annotations
 
 import codecs
+import gzip
 import json
+from abc import ABC, abstractmethod
+from typing import Callable
 
 from pyiceberg.io import InputFile, InputStream, OutputFile
 from pyiceberg.table.metadata import TableMetadata, TableMetadataUtil
 
+GZIP = "gzip"
+
+
+class Compressor(ABC):
+    @staticmethod
+    def get_compressor(location: str) -> Compressor:
+        return GzipCompressor() if location.endswith(".gz.metadata.json") else NOOP_COMPRESSOR
+
+    @abstractmethod
+    def get_stream_decompressor(self, inp: InputStream) -> InputStream:
+        return inp
+
+    @abstractmethod
+    def get_bytes_compressor(self) -> Callable[[bytes], bytes]:
+        pass
+
+
+class NoopCompressor(Compressor):
+    def get_stream_decompressor(self, inp: InputStream) -> InputStream:
+        return inp
+
+    def get_bytes_compressor(self) -> Callable[[bytes], bytes]:

Review Comment:
   Thanks, for of habit!



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org