MCPcopy Create free account
hub / github.com/apache/arrow / ToObjectMetadata

Function ToObjectMetadata

cpp/src/arrow/filesystem/gcsfs_internal.cc:164–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164Result<gcs::WithObjectMetadata> ToObjectMetadata(
165 const std::shared_ptr<const KeyValueMetadata>& metadata) {
166 if (!metadata) {
167 return gcs::WithObjectMetadata{};
168 }
169
170 static const auto setters = [] {
171 using setter = std::function<Status(gcs::ObjectMetadata&, const std::string&)>;
172 return std::unordered_map<std::string, setter>{
173 {"Cache-Control",
174 [](gcs::ObjectMetadata& m, const std::string& v) {
175 m.set_cache_control(v);
176 return Status::OK();
177 }},
178 {"Content-Disposition",
179 [](gcs::ObjectMetadata& m, const std::string& v) {
180 m.set_content_disposition(v);
181 return Status::OK();
182 }},
183 {"Content-Encoding",
184 [](gcs::ObjectMetadata& m, const std::string& v) {
185 m.set_content_encoding(v);
186 return Status::OK();
187 }},
188 {"Content-Language",
189 [](gcs::ObjectMetadata& m, const std::string& v) {
190 m.set_content_language(v);
191 return Status::OK();
192 }},
193 {"Content-Type",
194 [](gcs::ObjectMetadata& m, const std::string& v) {
195 m.set_content_type(v);
196 return Status::OK();
197 }},
198 {"customTime",
199 [](gcs::ObjectMetadata& m, const std::string& v) {
200 std::string err;
201 absl::Time t;
202 if (!absl::ParseTime(absl::RFC3339_full, v, &t, &err)) {
203 return Status::Invalid("Error parsing RFC-3339 timestamp: '", v, "': ", err);
204 }
205 m.set_custom_time(absl::ToChronoTime(t));
206 return Status::OK();
207 }},
208 {"storageClass",
209 [](gcs::ObjectMetadata& m, const std::string& v) {
210 m.set_storage_class(v);
211 return Status::OK();
212 }},
213 {"predefinedAcl",
214 [](gcs::ObjectMetadata&, const std::string&) { return Status::OK(); }},
215 {"encryptionKeyBase64",
216 [](gcs::ObjectMetadata&, const std::string&) { return Status::OK(); }},
217 {"kmsKeyName",
218 [](gcs::ObjectMetadata&, const std::string&) { return Status::OK(); }},
219 };
220 }();
221

Callers 2

TESTFunction · 0.85
OpenOutputStreamMethod · 0.85

Calls 9

secondMethod · 0.80
OKFunction · 0.50
InvalidFunction · 0.50
keysMethod · 0.45
valuesMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
okMethod · 0.45

Tested by 1

TESTFunction · 0.68