-
Notifications
You must be signed in to change notification settings - Fork 471
Cherry pick initial read ranges in AsyncClient support #16537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/storage-experimental-metrics
Are you sure you want to change the base?
Changes from all commits
f47af17
d9c09be
75869a7
6b3b430
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,9 @@ | |
| #include "google/cloud/storage/internal/async/object_descriptor_impl.h" | ||
| #include "google/cloud/storage/internal/async/open_object.h" | ||
| #include "google/cloud/storage/internal/async/open_stream.h" | ||
| #include "google/cloud/storage/internal/async/options.h" | ||
| #include "google/cloud/storage/internal/async/read_payload_impl.h" | ||
| #include "google/cloud/storage/internal/async/read_range.h" | ||
| #include "google/cloud/storage/internal/async/reader_connection_impl.h" | ||
| #include "google/cloud/storage/internal/async/reader_connection_resume.h" | ||
| #include "google/cloud/storage/internal/async/rewriter_connection_impl.h" | ||
|
|
@@ -58,6 +60,7 @@ | |
| #include "google/cloud/internal/make_status.h" | ||
| #include <grpcpp/grpcpp.h> | ||
| #include <memory> | ||
| #include <set> | ||
| #include <utility> | ||
|
|
||
| namespace google { | ||
|
|
@@ -220,6 +223,18 @@ AsyncConnectionImpl::Open(OpenParams p) { | |
| auto initial_request = google::storage::v2::BidiReadObjectRequest{}; | ||
| *initial_request.mutable_read_object_spec() = p.read_spec; | ||
| auto current = internal::MakeImmutableOptions(p.options); | ||
| // If pre-warmed ranges are configured, populate the initial request | ||
| // with these ranges to start downloading them as soon as the stream opens. | ||
| if (current->has<ReadRangesOption>()) { | ||
| auto const& ranges = current->get<ReadRangesOption>(); | ||
| for (auto const& r : DeduplicateRanges(ranges)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using for (DedupedReadRange const& r : DeduplicateRanges(ranges)) {References
|
||
| auto* proto_range = initial_request.add_read_ranges(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using google::storage::v2::ReadRange* proto_range =
initial_request.add_read_ranges();References
|
||
| proto_range->set_read_offset(r.config.offset); | ||
| proto_range->set_read_length(r.config.length); | ||
| // Generate sequential IDs starting at 1. The receiver must match these. | ||
| proto_range->set_read_id(r.read_id); | ||
| } | ||
| } | ||
| // Get the policy factory and immediately create a policy. | ||
| auto resume_policy = current->get<storage::ResumePolicyOption>()(); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a function returns a reference to a container or a large object, use
auto const&instead ofautoto avoid unnecessary and inefficient copies.References