diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 6ccc7e7b62..6609a184fb 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -164,44 +164,21 @@ struct DecodeParams : public ReferenceCounted { } bool matchFilters(KeyValueRef kv) { - bool match = false; - auto ranges = rangeMap.intersectingRanges(singleKeyRange(kv.key)); - for ([[maybe_unused]] const auto r : ranges) { - if (r.cvalue() == 1) { - match = true; - break; - } + bool match = filters.match(kv); + + if (!validate_filters) { + return match; } - for (const auto& prefix : prefixes) { - if (kv.key.startsWith(StringRef(prefix))) { - ASSERT(match); - return true; - } - } + for (const auto& prefix : prefixes) { + if (kv.key.startsWith(StringRef(prefix))) { + ASSERT(match); + return true; + } + } - return match; - } - - bool matchFilters(MutationRef m) { - for (const auto& prefix : prefixes) { - if (isSingleKeyMutation((MutationRef::Type)m.type)) { - if (m.param1.startsWith(StringRef(prefix))) { - return true; - } - } else if (m.type == MutationRef::ClearRange) { - KeyRange range(KeyRangeRef(m.param1, m.param2)); - KeyRange range2 = prefixRange(StringRef(prefix)); - if (range.intersects(range2)) { - return true; - } - } else { - ASSERT(false); - } - } - ASSERT(!match); - return false; - } + return match; + } std::string toString() { std::string s; @@ -838,7 +815,6 @@ ACTOR Future process_file(Reference container, if (!print) { print = params->matchFilters(m); - print = params->matchFilters(m); } if (print) { TraceEvent(SevVerbose, format("Mutation_%llu_%d", vms.version, sub).c_str(), uid) diff --git a/fdbclient/FileBackupAgent.actor.cpp b/fdbclient/FileBackupAgent.actor.cpp index 17b1e146c4..b57fa75827 100644 --- a/fdbclient/FileBackupAgent.actor.cpp +++ b/fdbclient/FileBackupAgent.actor.cpp @@ -4041,6 +4041,18 @@ bool RangeMapFilters::match(const MutationRef& m) const { return false; } +bool RangeMapFilters::match(const KeyValueRef& kv) const { + auto ranges = rangeMap.intersectingRanges(singleKeyRange(kv.key)); + for (const auto& r : ranges) { + if (r.cvalue() == 1) { + return true; + } + } + + return false; +} + + // Returns a vector of filtered KV refs from data which are either part of incomplete mutation groups OR complete // and have data relevant to one of the KV ranges in ranges std::vector filterLogMutationKVPairs(VectorRef data, const RangeMapFilters& filters) { diff --git a/fdbclient/include/fdbclient/BackupContainer.h b/fdbclient/include/fdbclient/BackupContainer.h index e4e231ad30..a81a13c0f2 100644 --- a/fdbclient/include/fdbclient/BackupContainer.h +++ b/fdbclient/include/fdbclient/BackupContainer.h @@ -341,6 +341,9 @@ public: // Returns if the mutation matches any filter ranges. bool match(const MutationRef& m) const; + // Returns if the key-value pair matches any filter ranges. + bool match(const KeyValueRef& kv) const; + private: KeyRangeMap rangeMap; };