Skip to content

cleanup(storage): use Disable{MD5*,Crc32c*} consistently#7034

Merged
coryan merged 1 commit intogoogleapis:mainfrom
coryan:cleanup-storage-hashing-options-usage
Jul 20, 2021
Merged

cleanup(storage): use Disable{MD5*,Crc32c*} consistently#7034
coryan merged 1 commit intogoogleapis:mainfrom
coryan:cleanup-storage-hashing-options-usage

Conversation

@coryan
Copy link
Copy Markdown
Contributor

@coryan coryan commented Jul 20, 2021

All GCS options are implemented as an absl::optional<T>, in the case
of DisableMD5Hash and DisableCrc32cChecksum this is
absl::optional<bool>. The MD5 hashes are disabled by default, this is
achieved by having the default constructor for DisableMD5Hash
initialize the option to true. CRC32C checksums are enabled by
default, the default constructor initializes the optional to
absl::nullopt (this is consistent with all the other options).

After this change we always use these options by doing:

auto value = request.GetOption<Disable*>().value_or(false);

This makes the usage consistent, and only the constructor encodes
what the default is.

Fixes #7029


This change is Reviewable

All GCS options are implemented as an `absl::optional<T>`, in the case
of `DisableMD5Hash` and `DisableCrc32cChecksum` this is
`absl::optional<bool>`. The MD5 hashes are disabled by default, this is
achieved by having the default constructor for `DisableMD5Hash`
initialize the option to `true`. CRC32C checksums are enabled by
default, the default constructor initializes the optional to
`absl::nullopt` (this is consistent with all the other options).

After this change we always use these options by doing:

```cc
auto value = request.GetOption<Disable*>().value_or(false);
```

This makes the usage consistent, and only the constructor encodes
what the default is.
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Jul 20, 2021
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 20, 2021
@google-cloud-cpp-bot
Copy link
Copy Markdown
Contributor

Google Cloud Build Logs
For commit: 3caecdd4df163319ac98f8375931344bd274413a

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 20, 2021

Codecov Report

Merging #7034 (3caecdd) into main (a2d23a6) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7034      +/-   ##
==========================================
- Coverage   94.47%   94.47%   -0.01%     
==========================================
  Files        1305     1305              
  Lines      113414   113412       -2     
==========================================
- Hits       107148   107144       -4     
- Misses       6266     6268       +2     
Impacted Files Coverage Δ
google/cloud/storage/internal/curl_client.cc 98.13% <100.00%> (ø)
google/cloud/storage/internal/hash_function.cc 100.00% <100.00%> (ø)
google/cloud/storage/internal/hash_validator.cc 100.00% <100.00%> (ø)
...bigtable/examples/bigtable_hello_instance_admin.cc 81.31% <0.00%> (-2.20%) ⬇️
google/cloud/pubsub/samples/samples.cc 91.67% <0.00%> (-0.24%) ⬇️
...sub/internal/batching_publisher_connection_test.cc 97.60% <0.00%> (-0.21%) ⬇️
google/cloud/completion_queue_test.cc 97.14% <0.00%> (+0.19%) ⬆️
...le/cloud/storage/internal/curl_download_request.cc 81.65% <0.00%> (+0.43%) ⬆️
...cloud/pubsub/internal/subscription_session_test.cc 98.27% <0.00%> (+0.49%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2d23a6...3caecdd. Read the comment docs.

@coryan coryan marked this pull request as ready for review July 20, 2021 18:59
@coryan coryan requested a review from a team July 20, 2021 18:59
Copy link
Copy Markdown
Contributor

@devjgm devjgm left a comment

Choose a reason for hiding this comment

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

Thanks. Just one question.

Comment thread google/cloud/storage/internal/hash_function.cc
@coryan coryan merged commit 69cc6a8 into googleapis:main Jul 20, 2021
@coryan coryan deleted the cleanup-storage-hashing-options-usage branch July 20, 2021 21:10
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. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleanup uses of Disable{MD5Hash,Crc32Checksum}

4 participants