From c5893284431f76df239ddd2d7c2d18fa4c1cc3dd Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 13 Jul 2015 12:11:38 -0400 Subject: [PATCH] os/LFNIndex: return vector from list_subdirs We'll need this later when we sort the subdirs bitwise instead of nibblewise. Signed-off-by: Sage Weil --- src/os/HashIndex.cc | 26 +++++++++++++++----------- src/os/LFNIndex.cc | 4 ++-- src/os/LFNIndex.h | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/os/HashIndex.cc b/src/os/HashIndex.cc index 6c451eb224db1..b70912f0f2a0d 100644 --- a/src/os/HashIndex.cc +++ b/src/os/HashIndex.cc @@ -71,7 +71,7 @@ int HashIndex::reset_attr( if (!exists) return 0; map objects; - set subdirs; + vector subdirs; r = list_objects(path, 0, 0, &objects); if (r < 0) return r; @@ -98,7 +98,7 @@ int HashIndex::col_split_level( * bits of the hash represented by the subdir path with inbits, match passed * in. */ - set subdirs; + vector subdirs; int r = from.list_subdirs(path, &subdirs); if (r < 0) return r; @@ -108,7 +108,7 @@ int HashIndex::col_split_level( return r; set to_move; - for (set::iterator i = subdirs.begin(); + for (vector::iterator i = subdirs.begin(); i != subdirs.end(); ++i) { uint32_t bits = 0; @@ -442,7 +442,7 @@ int HashIndex::pre_split_folder(uint32_t pg_num, uint64_t expected_num_objs) int HashIndex::init_split_folder(vector &path, uint32_t hash_level) { // Get the number of sub directories for the current path - set subdirs; + vector subdirs; int ret = list_subdirs(path, &subdirs); if (ret < 0) return ret; @@ -457,7 +457,7 @@ int HashIndex::init_split_folder(vector &path, uint32_t hash_level) return ret; // Do the same for subdirs - set::const_iterator iter; + vector::const_iterator iter; for (iter = subdirs.begin(); iter != subdirs.end(); ++iter) { path.push_back(*iter); ret = init_split_folder(path, hash_level + 1); @@ -486,7 +486,7 @@ int HashIndex::recursive_create_path(vector& path, int level) } int HashIndex::recursive_remove(const vector &path) { - set subdirs; + vector subdirs; int r = list_subdirs(path, &subdirs); if (r < 0) return r; @@ -497,7 +497,7 @@ int HashIndex::recursive_remove(const vector &path) { if (!objects.empty()) return -ENOTEMPTY; vector subdir(path); - for (set::iterator i = subdirs.begin(); + for (vector::iterator i = subdirs.begin(); i != subdirs.end(); ++i) { subdir.push_back(*i); @@ -628,10 +628,12 @@ int HashIndex::complete_split(const vector &path, subdir_info_s info) { r = list_objects(path, 0, 0, &objects); if (r < 0) return r; - set subdirs; - r = list_subdirs(path, &subdirs); + vector subdirs_vec; + r = list_subdirs(path, &subdirs_vec); if (r < 0) return r; + set subdirs; + subdirs.insert(subdirs_vec.begin(), subdirs_vec.end()); map > mapped; map moved; int num_moved = 0; @@ -764,7 +766,7 @@ int HashIndex::get_path_contents_by_hash(const vector &path, const ghobject_t *next_object, set *hash_prefixes, set > *objects) { - set subdirs; + vector subdirs_vec; map rev_objects; int r; string cur_prefix; @@ -785,9 +787,11 @@ int HashIndex::get_path_contents_by_hash(const vector &path, hash_prefixes->insert(hash_prefix); objects->insert(pair(hash_prefix, i->second)); } - r = list_subdirs(path, &subdirs); + r = list_subdirs(path, &subdirs_vec); if (r < 0) return r; + set subdirs; + subdirs.insert(subdirs_vec.begin(), subdirs_vec.end()); for (set::iterator i = subdirs.begin(); i != subdirs.end(); ++i) { diff --git a/src/os/LFNIndex.cc b/src/os/LFNIndex.cc index beb8756d311e4..86d140d519503 100644 --- a/src/os/LFNIndex.cc +++ b/src/os/LFNIndex.cc @@ -451,7 +451,7 @@ int LFNIndex::list_objects(const vector &to_list, int max_objs, } int LFNIndex::list_subdirs(const vector &to_list, - set *out) + vector *out) { string to_list_path = get_full_path_subdir(to_list); DIR *dir = ::opendir(to_list_path.c_str()); @@ -468,7 +468,7 @@ int LFNIndex::list_subdirs(const vector &to_list, string demangled_name; ghobject_t obj; if (lfn_is_subdir(short_name, &demangled_name)) { - out->insert(demangled_name); + out->push_back(demangled_name); } } diff --git a/src/os/LFNIndex.h b/src/os/LFNIndex.h index 5dd512115516c..284e4c2ad0d16 100644 --- a/src/os/LFNIndex.h +++ b/src/os/LFNIndex.h @@ -363,7 +363,7 @@ protected: /// Lists subdirectories. int list_subdirs( const vector &to_list, ///< [in] Directory to list. - set *out ///< [out] Subdirectories listed. + vector *out ///< [out] Subdirectories listed. ); /// Create subdirectory. -- 2.39.5