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


##########
python/src/iceberg/avro/file.py:
##########
@@ -0,0 +1,160 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# pylint: disable=W0621
+"""
+Avro reader for reading Avro files
+"""
+from __future__ import annotations
+
+import json
+from dataclasses import dataclass
+from io import SEEK_SET
+
+from iceberg.avro.codec import KNOWN_CODECS, Codec, NullCodec
+from iceberg.avro.decoder import BinaryDecoder
+from iceberg.avro.reader import AvroStruct, ConstructReader
+from iceberg.io.base import InputFile, InputStream
+from iceberg.schema import Schema, visit
+from iceberg.types import (
+    BinaryType,
+    FixedType,
+    MapType,
+    NestedField,
+    StringType,
+    StructType,
+)
+from iceberg.utils.schema_conversion import AvroSchemaConversion
+
+VERSION = 1
+MAGIC = bytes(b"Obj" + bytearray([VERSION]))
+MAGIC_SIZE = len(MAGIC)
+SYNC_SIZE = 16
+META_SCHEMA = StructType(
+    NestedField(name="magic", field_id=100, 
field_type=FixedType(length=MAGIC_SIZE), is_optional=False),
+    NestedField(
+        field_id=200,
+        name="meta",
+        field_type=MapType(key_id=201, key_type=StringType(), value_id=202, 
value_type=BinaryType(), value_is_optional=False),
+        is_optional=False,
+    ),
+    NestedField(field_id=300, name="sync", 
field_type=FixedType(length=SYNC_SIZE), is_optional=False),
+)
+
+
+@dataclass(frozen=True)
+class AvroFileHeader:
+    magic: bytes
+    meta: dict[str, str]
+    sync: bytes
+
+    def get_compression_codec(self) -> type[Codec]:
+        """Get the file's compression codec algorithm from the file's 
metadata."""
+        codec_key = "avro.codec"

Review Comment:
   I've moved it to the file itself.



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

Reply via email to