Repository navigation
Add Reader::NewReader(initial_pos, length_hint), and let GcsReader bound the request to the hinted range. - #45
Merged
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
copybara-service
Bot
force-pushed
the
test_1009577927
branch
2 times, most recently
from
October 30, 2026 23:04
1f7f712 to
5104549
Compare
copybara-service
Bot
force-pushed
the
test_1009577927
branch
2 times, most recently
from
November 17, 2026 16:00
1c40a3a to
d5b0459
Compare
…bound the request to the hinted range. Random single-record reads of ArrayRecord files on GCS create a child reader with `NewReader(offset)` and read one chunk. `GcsReader` sent an open-ended request (`Range: bytes=offset-`), and the request was cancelled when the reader was destroyed after the chunk was read. The caller knows how much it will read, but `NewReader(Position)` cannot express it. `NewReader(initial_pos, length_hint)` is like `NewReader(initial_pos)`, but hints that about `length_hint` bytes will be read from `initial_pos`. Reading beyond the hinted range is supported. By default the hint is ignored, by the new virtual `NewReaderWithLengthHintImpl()` calling `NewReaderImpl()`. `GcsReader` overrides it: if the hinted range ends before the object (or the range given to the constructor) does, the request is `ReadRange(pos, pos + length_hint)`, so it completes normally and the connection is reused. The request is sent when the reader is created, as for `NewReader(initial_pos)`, so request failures and metadata are reported the same way. A read which needs more than what is left of the range continues with an open-ended request from the current position. A hint reaching the end of the object sends the same request as `NewReader(initial_pos)`; in particular a read of the whole object from offset 0 still sends no `Range` header and keeps checksum validation. All other requests are unchanged. ArrayRecord passes the chunk length in a follow-up change. PiperOrigin-RevId: 1023749871
copybara-service
Bot
force-pushed
the
test_1009577927
branch
from
November 17, 2026 16:11
d5b0459 to
64d553d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
Reader::NewReader(initial_pos, length_hint), and let GcsReader bound the request to the hinted range.Random single-record reads of ArrayRecord files on GCS create a child reader
with
NewReader(offset)and read one chunk.GcsReadersent an open-endedrequest (
Range: bytes=offset-), and the request was cancelled when the readerwas destroyed after the chunk was read. The caller knows how much it will read,
but
NewReader(Position)cannot express it.NewReader(initial_pos, length_hint)is likeNewReader(initial_pos), buthints that about
length_hintbytes will be read frominitial_pos. Readingbeyond the hinted range is supported. By default the hint is ignored, by the
new virtual
NewReaderWithLengthHintImpl()callingNewReaderImpl().GcsReaderoverrides it: if the hinted range ends before the object (or therange given to the constructor) does, the request is
ReadRange(pos, pos + length_hint), so it completes normally and the connection is reused. Therequest is sent when the reader is created, as for
NewReader(initial_pos), sorequest failures and metadata are reported the same way. A read which needs
more than what is left of the range continues with an open-ended request from
the current position. A hint reaching the end of the object sends the same
request as
NewReader(initial_pos); in particular a read of the whole objectfrom offset 0 still sends no
Rangeheader and keeps checksum validation.All other requests are unchanged.
ArrayRecord passes the chunk length in a follow-up change.