]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: find pipe rules param for specific obj changes
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 19 Nov 2019 18:56:33 +0000 (10:56 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 28 Jan 2020 18:20:39 +0000 (10:20 -0800)
 - reuse RGWObjTags::tag_map_t instead of vector of strings
 - fix the prefix search

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_bucket_sync.cc
src/rgw/rgw_bucket_sync.h

index ba3fbc3518b87c71b1f2e8b2d9f5fe1a8dcc87b3..ec76ef67c94add04cbc9282d953e3474ff91436d 100644 (file)
@@ -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<string>& 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<int> 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;
   }
 
index ceb1c14b90951a171e21ea0d6f361b89d240e71a..63da7836a875ab6301eb59595213e297b5238c23 100644 (file)
@@ -147,7 +147,7 @@ public:
     void insert(const rgw_sync_bucket_pipe& pipe);
 
     bool find_obj_params(const rgw_obj_key& key, 
-                         const vector<string>& tags,
+                         const RGWObjTags::tag_map_t& tags,
                          rgw_sync_pipe_params *params) const;
 
     void scan_prefixes(std::vector<string> *prefixes) const;
@@ -178,7 +178,7 @@ public:
     }
     
     bool find_obj_params(const rgw_obj_key& key,
-                         const std::vector<string>& tags,
+                         const RGWObjTags::tag_map_t& tags,
                          rgw_sync_pipe_params *params) const {
       if (!rules) {
         return false;