From 6112294292fbe5700b9b652dea54a8e6c6f1c172 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 24 Jan 2017 17:44:08 -0500 Subject: Fixed behavior of normalizing grouped hierarchal joins Previously, we did not merge grouped hierarchal joins; however, because of the way statements are compiled, we do need to merge OR-d positive hierarchal joins, and ANDed negative hierarchal joins. Also made some whitespace changes. --- lib/filter.cpp | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'lib/filter.cpp') diff --git a/lib/filter.cpp b/lib/filter.cpp index 17309f1..ceb9327 100644 --- a/lib/filter.cpp +++ b/lib/filter.cpp @@ -1283,7 +1283,9 @@ namespace verbly { { filter normalized = child.normalize(context); - // Notably, this does not attempt to merge hierarchal matches. + // Notably, this does not attempt to merge hierarchal matches, + // UNLESS they are positive matches being OR-d, or negative + // matches being ANDed. switch (normalized.getType()) { case type::singleton: @@ -1306,7 +1308,7 @@ namespace verbly { { if (!negativeJoins.count(normalized.singleton_.filterField)) { - negativeJoins[normalized.getField()] = filter(group_.orlogic); + negativeJoins[normalized.getField()] = filter(!group_.orlogic); } negativeJoins.at(normalized.getField()) += std::move(*normalized.singleton_.join); @@ -1314,6 +1316,30 @@ namespace verbly { break; } + case comparison::hierarchally_matches: + { + if (group_.orlogic) + { + positiveJoins[normalized.getField()] |= std::move(*normalized.singleton_.join); + } else { + result += std::move(normalized); + } + + break; + } + + case comparison::does_not_hierarchally_match: + { + if (!group_.orlogic) + { + negativeJoins[normalized.getField()] |= std::move(*normalized.singleton_.join); + } else { + result += std::move(normalized); + } + + break; + } + case comparison::int_equals: case comparison::int_does_not_equal: case comparison::int_is_at_least: @@ -1327,8 +1353,6 @@ namespace verbly { case comparison::string_is_not_like: case comparison::is_null: case comparison::is_not_null: - case comparison::hierarchally_matches: - case comparison::does_not_hierarchally_match: { result += std::move(normalized); -- cgit 1.4.1