Skip to content

feat(storage): Make PrecomputedChecksumsOption compatible with Options - #16295

Merged
v-pratap merged 8 commits into
googleapis:mainfrom
v-pratap:unify-provided-value-options
Jul 30, 2026
Merged

feat(storage): Make PrecomputedChecksumsOption compatible with Options#16295
v-pratap merged 8 commits into
googleapis:mainfrom
v-pratap:unify-provided-value-options

Conversation

@v-pratap

@v-pratap v-pratap commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This pull request updates the Google Cloud Storage C++ client to fall back to the current context options for Crc32cChecksumValue and MD5HashValue when they are not explicitly provided in the request options. It also introduces a flat PrecomputedChecksums struct and PrecomputedChecksumsOption to cleanly pass multiple precomputed hashes within the unified Options framework.

This enables the same exact conceptual options to be used as both a variadic argument for the synchronous client (e.g. InsertObject(..., MD5HashValue("hash"))) and as a modern option for the asynchronous client (e.g. options.set<PrecomputedChecksumsOption>({..., "hash"})), while avoiding heap allocations and lookups during hash execution.

This avoids needing any deprecations, any new types leaking into public method signatures, or any duplicate upload/download namespace variants. It is perfectly backward-compatible.

By simply adding `using Type = std::string;` to the legacy ComplexOption
structs `MD5HashValue` and `Crc32cChecksumValue`, we instantly make them
compatible with the modern `google::cloud::Options` API.

This enables the exact same type to be used as both a variadic option
for the synchronous client (e.g. `InsertObject(..., MD5HashValue("hash"))`)
and as a modern option for the asynchronous client (e.g.
`options.set<MD5HashValue>("hash")`).

This avoids needing any deprecations, any new types, or any duplicate
upload/download namespace variants. It is perfectly backward-compatible.
@v-pratap
v-pratap requested review from a team as code owners July 30, 2026 09:21
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Jul 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Google Cloud Storage C++ client to fall back to the current context options for Crc32cChecksumValue and MD5HashValue when they are not explicitly provided in the request options. This change affects object writing, hashing functions, REST stub operations, and parallel uploads. The review feedback suggests optimizing the parallel upload implementation by using an immediately-invoked lambda expression (IIFE) to retrieve the current options once instead of calling google::cloud::internal::CurrentOptions() multiple times in the initializer list.

Comment thread google/cloud/storage/parallel_upload.cc Outdated
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.56250% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.30%. Comparing base (d799c3f) to head (1eed8f2).

Files with missing lines Patch % Lines
google/cloud/storage/internal/rest/stub.cc 22.22% 7 Missing ⚠️
google/cloud/storage/client.cc 60.00% 4 Missing ⚠️
google/cloud/storage/parallel_upload.cc 63.63% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16295      +/-   ##
==========================================
- Coverage   92.31%   92.30%   -0.01%     
==========================================
  Files        2223     2223              
  Lines      208086   208141      +55     
==========================================
+ Hits       192086   192123      +37     
- Misses      16000    16018      +18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@v-pratap v-pratap changed the title feat(storage): Make MD5HashValue and Crc32cChecksumValue compatible with Options feat(storage): Make PrecomputedChecksumsOption compatible with Options Jul 30, 2026
…t for performance

Refactored PrecomputedChecksumsOption to use a flat PrecomputedChecksums struct containing crc32c and md5 fields rather than allocating a std::map dynamically on the hot path for every object insertion.
Added unit tests to internal/hash_function_impl_test.cc to verify its behavior and precedence against explicitly provided variadic checksum options.
Comment thread google/cloud/storage/options.h
Comment thread google/cloud/storage/options.h Outdated
Comment thread google/cloud/storage/parallel_upload.cc Outdated
Comment thread google/cloud/storage/internal/rest/stub.cc Outdated
- Removed unused <map> include from options.h
- Extracted PrecomputedChecksumsOption lookups into local variables to avoid redundant get() calls in parallel_upload.cc, client.cc, hash_function.cc, and rest/stub.cc.
@v-pratap
v-pratap enabled auto-merge (squash) July 30, 2026 14:35
@v-pratap
v-pratap merged commit 46d27f8 into googleapis:main Jul 30, 2026
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Sponsor
SponsoredKunjungi sekarang
Promo