Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions google/cloud/storage/benchmarks/throughput_experiment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,14 @@ class ResumableUpload : public ThroughputExperiment {
auto const start = std::chrono::system_clock::now();
auto timer = Timer::PerThread();
auto writer =
client_.WriteObject(bucket_name, object_name,
gcs::DisableCrc32cChecksum(!config.enable_crc32c),
gcs::DisableMD5Hash(!config.enable_md5));
client_.WriteObject(
bucket_name, object_name,
google::cloud::Options{}.set<gcs::UploadChecksumValidationOption>(
config.enable_crc32c
? (config.enable_md5 ? gcs::ChecksumAlgorithm::kCrc32cAndMD5
: gcs::ChecksumAlgorithm::kCrc32c)
: (config.enable_md5 ? gcs::ChecksumAlgorithm::kMD5
: gcs::ChecksumAlgorithm::kNone)));
auto upload_id = ExtractUploadId(writer.resumable_session_id());
for (std::int64_t offset = 0; offset < config.object_size;
offset += config.app_buffer_size) {
Expand Down Expand Up @@ -152,9 +157,14 @@ class SimpleUpload : public ThroughputExperiment {
auto data = absl::string_view{*random_data_}.substr(
0, static_cast<std::size_t>(config.object_size));
auto object_metadata =
client_.InsertObject(bucket_name, object_name, data,
gcs::DisableCrc32cChecksum(!config.enable_crc32c),
gcs::DisableMD5Hash(!config.enable_md5));
client_.InsertObject(
bucket_name, object_name, data,
google::cloud::Options{}.set<gcs::UploadChecksumValidationOption>(
config.enable_crc32c
? (config.enable_md5 ? gcs::ChecksumAlgorithm::kCrc32cAndMD5
: gcs::ChecksumAlgorithm::kCrc32c)
: (config.enable_md5 ? gcs::ChecksumAlgorithm::kMD5
: gcs::ChecksumAlgorithm::kNone)));
auto const usage = timer.Sample();
auto generation = object_metadata
? std::to_string(object_metadata->generation())
Expand Down Expand Up @@ -210,9 +220,14 @@ class DownloadObject : public ThroughputExperiment {
? gcs::ReadRange(offset, offset + config.read_range->second)
: gcs::ReadRange();
auto reader =
client_.ReadObject(bucket_name, object_name, read_range,
gcs::DisableCrc32cChecksum(!config.enable_crc32c),
gcs::DisableMD5Hash(!config.enable_md5));
client_.ReadObject(
bucket_name, object_name, read_range,
google::cloud::Options{}.set<gcs::DownloadChecksumValidationOption>(
config.enable_crc32c
? (config.enable_md5 ? gcs::ChecksumAlgorithm::kCrc32cAndMD5
: gcs::ChecksumAlgorithm::kCrc32c)
: (config.enable_md5 ? gcs::ChecksumAlgorithm::kMD5
: gcs::ChecksumAlgorithm::kNone)));
std::int64_t transfer_size = 0;
while (!reader.eof() && !reader.bad()) {
reader.read(buffer.data(), buffer.size());
Expand Down
12 changes: 6 additions & 6 deletions google/cloud/storage/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,8 @@ class Client {
* @param contents the contents (media) for the new object.
* @param options a list of optional query parameters and/or request headers.
* Valid types for this operation include `ContentEncoding`,
* `ContentType`, `Crc32cChecksumValue`, `DisableCrc32cChecksum`,
* `DisableMD5Hash`, `EncryptionKey`, `IfGenerationMatch`,
* `ContentType`, `Crc32cChecksumValue`,
* `UploadChecksumValidationOption`, `EncryptionKey`, `IfGenerationMatch`,
* `IfGenerationNotMatch`, `IfMetagenerationMatch`,
* `IfMetagenerationNotMatch`, `KmsKeyName`, `MD5HashValue`,
* `PredefinedAcl`, `Projection`, `UserProject`, and `WithObjectMetadata`.
Expand Down Expand Up @@ -1176,8 +1176,8 @@ class Client {
* @param bucket_name the name of the bucket that contains the object.
* @param object_name the name of the object to be read.
* @param options a list of optional query parameters and/or request headers.
* Valid types for this operation include `DisableCrc32cChecksum`,
* `DisableMD5Hash`, `EncryptionKey`, `Generation`, `IfGenerationMatch`,
* Valid types for this operation include `DownloadChecksumValidationOption`,
* `EncryptionKey`, `Generation`, `IfGenerationMatch`,
* `IfGenerationNotMatch`, `IfMetagenerationMatch`,
* `IfMetagenerationNotMatch`, `ReadFromOffset`, `ReadRange`, `ReadLast`,
* `UserProject`, and `AcceptEncoding`.
Expand Down Expand Up @@ -1240,7 +1240,7 @@ class Client {
* @param object_name the name of the object to be read.
* @param options a list of optional query parameters and/or request headers.
* Valid types for this operation include `ContentEncoding`, `ContentType`,
* `Crc32cChecksumValue`, `DisableCrc32cChecksum`, `DisableMD5Hash`,
* `Crc32cChecksumValue`, `UploadChecksumValidationOption`,
* `EncryptionKey`, `IfGenerationMatch`, `IfGenerationNotMatch`,
* `IfMetagenerationMatch`, `IfMetagenerationNotMatch`, `KmsKeyName`,
* `MD5HashValue`, `PredefinedAcl`, `Projection`,
Expand Down Expand Up @@ -1295,7 +1295,7 @@ class Client {
* @param object_name the name of the object to be read.
* @param options a list of optional query parameters and/or request headers.
* Valid types for this operation include `ContentEncoding`, `ContentType`,
* `Crc32cChecksumValue`, `DisableCrc32cChecksum`, `DisableMD5Hash`,
* `Crc32cChecksumValue`, `UploadChecksumValidationOption`,
* `EncryptionKey`, `IfGenerationMatch`, `IfGenerationNotMatch`,
* `IfMetagenerationMatch`, `IfMetagenerationNotMatch`, `KmsKeyName`,
* `MD5HashValue`, `PredefinedAcl`, `Projection`, `UserProject`,
Expand Down
19 changes: 11 additions & 8 deletions google/cloud/storage/parallel_upload.h
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,9 @@ NonResumableParallelUploadState::Create(Client client,

auto upload_options = StaticTupleFilter<
Among<ContentEncoding, ContentType, DisableCrc32cChecksum, DisableMD5Hash,
EncryptionKey, KmsKeyName, PredefinedAcl, UserProject,
WithObjectMetadata>::TPred>(std::move(options));
UploadChecksumValidationOption, EncryptionKey, KmsKeyName,
PredefinedAcl, UserProject, WithObjectMetadata>::TPred>(
std::move(options));
for (std::size_t i = 0; i < num_shards; ++i) {
ResumableUploadRequest request(
bucket_name, prefix + ".upload_shard_" + std::to_string(i));
Expand Down Expand Up @@ -806,8 +807,9 @@ StatusOr<ResumableParallelUploadState> ResumableParallelUploadState::CreateNew(
auto upload_options = std::tuple_cat(
StaticTupleFilter<
Among<ContentEncoding, ContentType, DisableCrc32cChecksum,
DisableMD5Hash, EncryptionKey, KmsKeyName, PredefinedAcl,
UserProject, WithObjectMetadata>::TPred>(options),
DisableMD5Hash, UploadChecksumValidationOption, EncryptionKey,
KmsKeyName, PredefinedAcl, UserProject,
WithObjectMetadata>::TPred>(options),
std::make_tuple(UseResumableUploadSession("")));
for (std::size_t i = 0; i < num_shards; ++i) {
ResumableUploadRequest request(
Expand Down Expand Up @@ -864,8 +866,8 @@ StatusOr<ResumableParallelUploadState> ResumableParallelUploadState::Resume(

auto read_options = std::tuple_cat(
StaticTupleFilter<Among<DisableCrc32cChecksum, DisableMD5Hash,
EncryptionKey, Generation, UserProject>::TPred>(
options),
UploadChecksumValidationOption, EncryptionKey,
Generation, UserProject>::TPred>(options),
std::make_tuple(IfGenerationMatch(state_and_gen->second)));

auto state_stream = google::cloud::internal::apply(
Expand Down Expand Up @@ -915,8 +917,9 @@ StatusOr<ResumableParallelUploadState> ResumableParallelUploadState::Resume(

auto upload_options = StaticTupleFilter<
Among<ContentEncoding, ContentType, DisableCrc32cChecksum, DisableMD5Hash,
EncryptionKey, KmsKeyName, PredefinedAcl, UserProject,
WithObjectMetadata>::TPred>(std::move(options));
UploadChecksumValidationOption, EncryptionKey, KmsKeyName,
PredefinedAcl, UserProject, WithObjectMetadata>::TPred>(
std::move(options));
for (auto& stream_desc : persistent_state->streams) {
ResumableUploadRequest request(bucket_name,
std::move(stream_desc.object_name));
Expand Down
Loading