adding logic to restrict read size
@@ -58,6 +58,8 @@ const maxReadSize = 8 * MB
// Minimum number of seeks before evaluating if the read pattern is random.
const minSeeksForRandom = 2
+const maxSizeToReadFromGCS = 200 * MB
+
// Constants for read types - sequential/random
const sequential = "Sequential"
const random = "Random"
@@ -353,6 +355,10 @@ func (rr *randomReader) startRead(
end = int64(rr.object.Size)
}
+ if end-start > maxSizeToReadFromGCS {
+ end = start + maxSizeToReadFromGCS
+ }
+
// Begin the read.
ctx, cancel := context.WithCancel(context.Background())
rc, err := rr.bucket.NewReader(
