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


##########
python/pyiceberg/avro/decoder.py:
##########
@@ -48,13 +48,18 @@ def read(self, n: int) -> bytes:
         """
         if n < 0:
             raise ValueError(f"Requested {n} bytes to read, expected positive 
integer.")
-        read_bytes = self._input_stream.read(n)
-        read_len = len(read_bytes)
-        if read_len <= 0:
-            raise EOFError
-        elif read_len != n:
-            raise ValueError(f"Read {len(read_bytes)} bytes, expected {n} 
bytes")
-        return read_bytes
+        data = b""
+
+        n_remaining = n
+        while n_remaining > 0:
+            data_read = self._input_stream.read(n_remaining)
+            read_len = len(data_read)
+            if read_len <= 0:
+                raise EOFError(f"Got negative length: {read_len}")

Review Comment:
   This isn't necessarily negative. Most likely, it is going to be 0, so this 
would look strange. How about `f"EOF: read {read_len} bytes"`



##########
python/pyiceberg/avro/decoder.py:
##########
@@ -48,13 +48,18 @@ def read(self, n: int) -> bytes:
         """
         if n < 0:
             raise ValueError(f"Requested {n} bytes to read, expected positive 
integer.")
-        read_bytes = self._input_stream.read(n)
-        read_len = len(read_bytes)
-        if read_len <= 0:
-            raise EOFError
-        elif read_len != n:
-            raise ValueError(f"Read {len(read_bytes)} bytes, expected {n} 
bytes")
-        return read_bytes
+        data = b""
+
+        n_remaining = n
+        while n_remaining > 0:
+            data_read = self._input_stream.read(n_remaining)
+            read_len = len(data_read)
+            if read_len <= 0:
+                raise EOFError(f"Got negative length: {read_len}")

Review Comment:
   This isn't necessarily negative. Most likely, it is going to be 0, so this 
would look strange. How about `f"EOF: read {read_len} bytes"`?



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