ferhatelmas commented on code in PR #688:
URL: https://github.com/apache/iceberg-go/pull/688#discussion_r2712739193


##########
io/blob.go:
##########
@@ -42,26 +42,20 @@ type blobOpenFile struct {
        ctx       context.Context
 }
 
-func (f *blobOpenFile) ReadAt(p []byte, off int64) (int, error) {
-       rdr, err := f.b.Bucket.NewRangeReader(f.ctx, f.key, off, int64(len(p)), 
nil)
-       if err != nil {
-               return 0, err
+func (f *blobOpenFile) ReadAt(p []byte, off int64) (n int, err error) {
+       var rdr io.ReadCloser
+       if f.b.newRangeReader != nil {
+               rdr, err = f.b.newRangeReader(f.ctx, f.key, off, int64(len(p)))
+       } else {
+               rdr, err = f.b.Bucket.NewRangeReader(f.ctx, f.key, off, 
int64(len(p)), nil)
        }
-
-       // ensure the buffer is read, or EOF is reached for this read of this 
"chunk"
-       // given we are using offsets to read this block, it is constrained by 
size of 'p'
-       size, err := io.ReadFull(rdr, p)
        if err != nil {
-               if errors.Is(err, io.EOF) {
-                       return size, err
-               }
-               // check we are at the end of the underlying file
-               if off+int64(size) > f.Size() {
-                       return size, err
-               }
+               return 0, err
        }
+       // not using internal.CheckedClose due to import cycle
+       defer func() { err = errors.Join(err, rdr.Close()) }()
 
-       return size, rdr.Close()
+       return io.ReadFull(rdr, p)

Review Comment:
   yes, because we're creating a new fresh range reader in each call for random 
access. It was already closing in success but shallowing on errors.



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