Use the RangeMapFilters

This commit is contained in:
Vishesh Yadav 2023-02-26 12:24:15 -08:00 committed by Jingyu Zhou
parent 9ec9f38a50
commit 3e6e31ad0b
3 changed files with 27 additions and 36 deletions

View File

@ -164,44 +164,21 @@ struct DecodeParams : public ReferenceCounted<DecodeParams> {
}
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<Void> process_file(Reference<IBackupContainer> 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)

View File

@ -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<KeyValueRef> filterLogMutationKVPairs(VectorRef<KeyValueRef> data, const RangeMapFilters& filters) {

View File

@ -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<int> rangeMap;
};