MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cpp-samples / hashed_name

Function hashed_name

populate-bucket/populate_bucket.cc:144–153  ·  view source on GitHub ↗

Prepend a hash to an object name for better performance in GCS.

Source from the content-addressed store, hash-verified

142
143/// Prepend a hash to an object name for better performance in GCS.
144std::string hashed_name(bool use_hash_prefix, std::string object_name) {
145 if (not use_hash_prefix) return std::move(object_name);
146
147 // Just use the last 32-bits of the hash
148 auto const hash = crc32c::Crc32c(object_name);
149
150 char buf[16];
151 std::snprintf(buf, sizeof(buf), "%08x_", hash);
152 return buf + object_name;
153}
154
155struct work_item {
156 std::string bucket;

Callers 1

process_one_itemFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected