rdblue commented on code in PR #4792:
URL: https://github.com/apache/iceberg/pull/4792#discussion_r885861491


##########
python/src/iceberg/io/boto.py:
##########
@@ -0,0 +1,291 @@
+# 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.
+"""FileIO implementation for reading and writing table files that uses boto3"""
+
+from io import SEEK_CUR, SEEK_END, SEEK_SET
+from typing import Optional, Union
+from urllib.parse import urlparse
+
+from boto3 import Session
+from botocore.exceptions import ClientError
+
+from iceberg.io.base import FileIO, InputFile, InputStream, OutputFile, 
OutputStream
+
+
+class BotoInputStream(InputStream):
+    """A seekable wrapper for reading an S3 Object that abides by the 
InputStream protocol
+
+    Args:
+        s3_object(boto3.resources.factory.s3.Object): An s3 object
+    """
+
+    def __init__(self, s3_object):
+        self._s3_object = s3_object
+        self._position = 0
+
+    def read(self, n: int = -1) -> bytes:
+        """Read the byte content of the s3 object
+
+        This uses the `Range` argument when reading the S3 Object that allows 
setting a range of bytes to the headers of the request to S3.
+
+        Args:
+            n (int, optional): The number of bytes to read. Defaults to -1 
which reads the entire file.
+
+        Returns:
+            bytes: The byte content of the file
+        """
+        if n == -1:  # Read the entire file from the current position

Review Comment:
   Should any negative have this effect? Or should we raise ValueError if n < 
-1?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to