}
};
+static bool is_sys_attr(const std::string& attr_name){
+ static constexpr std::initializer_list<const char*> rgw_sys_attrs = {RGW_ATTR_PG_VER,
+ RGW_ATTR_SOURCE_ZONE,
+ RGW_ATTR_ID_TAG,
+ RGW_ATTR_TEMPURL_KEY1,
+ RGW_ATTR_TEMPURL_KEY2,
+ RGW_ATTR_UNIX1,
+ RGW_ATTR_UNIX_KEY1
+ };
+
+ return std::find(rgw_sys_attrs.begin(), rgw_sys_attrs.end(), attr_name) != rgw_sys_attrs.end();
+}
+
struct es_obj_metadata {
CephContext *cct;
ElasticConfigRef es_conf;
for (auto i : attrs) {
const string& attr_name = i.first;
- string name;
bufferlist& val = i.second;
if (attr_name.compare(0, sizeof(RGW_ATTR_PREFIX) - 1, RGW_ATTR_PREFIX) != 0) {
}
if (attr_name.compare(0, sizeof(RGW_ATTR_META_PREFIX) - 1, RGW_ATTR_META_PREFIX) == 0) {
- name = attr_name.substr(sizeof(RGW_ATTR_META_PREFIX) - 1);
- custom_meta[name] = string(val.c_str(), (val.length() > 0 ? val.length() - 1 : 0));
+ custom_meta.emplace(attr_name.substr(sizeof(RGW_ATTR_META_PREFIX) - 1),
+ string(val.c_str(), (val.length() > 0 ? val.length() - 1 : 0)));
continue;
}
- name = attr_name.substr(sizeof(RGW_ATTR_PREFIX) - 1);
+ if (attr_name.compare(0, sizeof(RGW_ATTR_CRYPT_PREFIX) -1, RGW_ATTR_CRYPT_PREFIX) == 0) {
+ continue;
+ }
- if (name == "acl") {
+ if (attr_name == RGW_ATTR_ACL) {
try {
auto i = val.begin();
::decode(policy, i);
}
}
}
- } else if (name == "x-amz-tagging") {
- auto tags_bl = val.begin();
+ } else if (attr_name == RGW_ATTR_TAGS) {
+ auto tags_bl = val.cbegin();
::decode(obj_tags, tags_bl);
- } else if (name == "compression") {
+ } else if (attr_name == RGW_ATTR_COMPRESSION) {
RGWCompressionInfo cs_info;
- auto vals_bl = val.begin();
+ auto vals_bl = val.cbegin();
::decode(cs_info, vals_bl);
- out_attrs[name] = cs_info.compression_type;
+ out_attrs.emplace("compression",std::move(cs_info.compression_type));
} else {
- if (name != "pg_ver" &&
- name != "source_zone" &&
- name != "idtag") {
- out_attrs[name] = string(val.c_str(), (val.length() > 0 ? val.length() - 1 : 0));
+ if (!is_sys_attr(attr_name)) {
+ out_attrs.emplace(attr_name.substr(sizeof(RGW_ATTR_PREFIX) - 1),
+ std::string(val.c_str(), (val.length() > 0 ? val.length() - 1 : 0)));
}
}
}