From 2d7a94900e518cf1517a07d4e1ec011160099560 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 19 Nov 2019 10:56:33 -0800 Subject: [PATCH] rgw: find pipe rules param for specific obj changes - reuse RGWObjTags::tag_map_t instead of vector of strings - fix the prefix search Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_bucket_sync.cc | 21 +++++++++++++++------ src/rgw/rgw_bucket_sync.h | 4 ++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/rgw/rgw_bucket_sync.cc b/src/rgw/rgw_bucket_sync.cc index ba3fbc3518b..ec76ef67c94 100644 --- a/src/rgw/rgw_bucket_sync.cc +++ b/src/rgw/rgw_bucket_sync.cc @@ -290,22 +290,31 @@ void RGWBucketSyncFlowManager::pipe_rules::insert(const rgw_sync_bucket_pipe& pi #warning add support for tags bool RGWBucketSyncFlowManager::pipe_rules::find_obj_params(const rgw_obj_key& key, - const vector& tags, + const RGWObjTags::tag_map_t& tags, rgw_sync_pipe_params *params) const { - auto iter = prefix_refs.lower_bound(key.name); + if (prefix_refs.empty()) { + return false; + } + + auto iter = prefix_refs.upper_bound(key.name); + if (iter != prefix_refs.begin()) { + --iter; + } if (iter == prefix_refs.end()) { return false; } - auto max = prefix_refs.end(); + auto end = prefix_refs.upper_bound(key.name); + auto max = end; std::optional priority; - for (; iter != prefix_refs.end(); ++iter) { + for (; iter != end; ++iter) { +#warning this is not the most efficient way to do it, need trie maybe auto& prefix = iter->first; if (!boost::starts_with(key.name, prefix)) { - break; + continue; } auto& rule_params = iter->second->params; @@ -321,7 +330,7 @@ bool RGWBucketSyncFlowManager::pipe_rules::find_obj_params(const rgw_obj_key& ke } } - if (max == prefix_refs.end()) { + if (max == end) { return false; } diff --git a/src/rgw/rgw_bucket_sync.h b/src/rgw/rgw_bucket_sync.h index ceb1c14b909..63da7836a87 100644 --- a/src/rgw/rgw_bucket_sync.h +++ b/src/rgw/rgw_bucket_sync.h @@ -147,7 +147,7 @@ public: void insert(const rgw_sync_bucket_pipe& pipe); bool find_obj_params(const rgw_obj_key& key, - const vector& tags, + const RGWObjTags::tag_map_t& tags, rgw_sync_pipe_params *params) const; void scan_prefixes(std::vector *prefixes) const; @@ -178,7 +178,7 @@ public: } bool find_obj_params(const rgw_obj_key& key, - const std::vector& tags, + const RGWObjTags::tag_map_t& tags, rgw_sync_pipe_params *params) const { if (!rules) { return false; -- 2.39.5