From a46b73c4019ec16302ee80b8e4c19f305a8a0166 Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Mon, 10 Jul 2017 14:29:35 -0300 Subject: [PATCH] lcs: simplify code to get candidates for higher levels get rid of unneeded loop for dealing with suspect sstables and std::advance because vector allows random access. Signed-off-by: Raphael S. Carvalho --- sstables/leveled_manifest.hh | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/sstables/leveled_manifest.hh b/sstables/leveled_manifest.hh index ff69a27fe1..7ab28ab96c 100644 --- a/sstables/leveled_manifest.hh +++ b/sstables/leveled_manifest.hh @@ -488,29 +488,11 @@ public: int start = sstable_index_based_on_last_compacted_key(sstables, level, s, last_compacted_keys); - // look for a non-suspect keyspace to compact with, starting with where we left off last time, - // and wrapping back to the beginning of the generation if necessary - for (auto i = 0U; i < sstables.size(); i++) { - // get an iterator to the element of position pos from the list get_level(level). - auto pos = (start + i) % sstables.size(); - auto it = sstables.begin(); - std::advance(it, pos); + auto pos = start % sstables.size(); + auto candidates = overlapping(*_schema, sstables.at(pos), get_level(level + 1)); + candidates.push_back(sstables.at(pos)); - auto& sstable = *it; - auto candidates = overlapping(*_schema, sstable, get_level(level + 1)); - - candidates.push_back(sstable); -#if 0 - if (Iterables.any(candidates, suspectP)) - continue; - if (Sets.intersection(candidates, compacting).isEmpty()) - return candidates; -#endif - return { candidates, true }; - } - - // all the sstables were suspect or overlapped with something suspect - return {}; + return { candidates, true }; } void sort_sstables_by_age(std::vector& candidates) {