summary refs log tree commit diff stats
path: root/lib/filter.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-01-24 17:44:08 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-01-24 17:44:08 -0500
commit6112294292fbe5700b9b652dea54a8e6c6f1c172 (patch)
tree6df053f7e3f0db07ca433bb532b852317f005673 /lib/filter.cpp
parenta5782a2133bae494e6c4ba3b4c2840aedab1da21 (diff)
downloadverbly-6112294292fbe5700b9b652dea54a8e6c6f1c172.tar.gz
verbly-6112294292fbe5700b9b652dea54a8e6c6f1c172.tar.bz2
verbly-6112294292fbe5700b9b652dea54a8e6c6f1c172.zip
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.
Diffstat (limited to 'lib/filter.cpp')
-rw-r--r--lib/filter.cpp32
1 files changed, 28 insertions, 4 deletions
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 {
1283 { 1283 {
1284 filter normalized = child.normalize(context); 1284 filter normalized = child.normalize(context);
1285 1285
1286 // Notably, this does not attempt to merge hierarchal matches. 1286 // Notably, this does not attempt to merge hierarchal matches,
1287 // UNLESS they are positive matches being OR-d, or negative
1288 // matches being ANDed.
1287 switch (normalized.getType()) 1289 switch (normalized.getType())
1288 { 1290 {
1289 case type::singleton: 1291 case type::singleton:
@@ -1306,7 +1308,7 @@ namespace verbly {
1306 { 1308 {
1307 if (!negativeJoins.count(normalized.singleton_.filterField)) 1309 if (!negativeJoins.count(normalized.singleton_.filterField))
1308 { 1310 {
1309 negativeJoins[normalized.getField()] = filter(group_.orlogic); 1311 negativeJoins[normalized.getField()] = filter(!group_.orlogic);
1310 } 1312 }
1311 1313
1312 negativeJoins.at(normalized.getField()) += std::move(*normalized.singleton_.join); 1314 negativeJoins.at(normalized.getField()) += std::move(*normalized.singleton_.join);
@@ -1314,6 +1316,30 @@ namespace verbly {
1314 break; 1316 break;
1315 } 1317 }
1316 1318
1319 case comparison::hierarchally_matches:
1320 {
1321 if (group_.orlogic)
1322 {
1323 positiveJoins[normalized.getField()] |= std::move(*normalized.singleton_.join);
1324 } else {
1325 result += std::move(normalized);
1326 }
1327
1328 break;
1329 }
1330
1331 case comparison::does_not_hierarchally_match:
1332 {
1333 if (!group_.orlogic)
1334 {
1335 negativeJoins[normalized.getField()] |= std::move(*normalized.singleton_.join);
1336 } else {
1337 result += std::move(normalized);
1338 }
1339
1340 break;
1341 }
1342
1317 case comparison::int_equals: 1343 case comparison::int_equals:
1318 case comparison::int_does_not_equal: 1344 case comparison::int_does_not_equal:
1319 case comparison::int_is_at_least: 1345 case comparison::int_is_at_least:
@@ -1327,8 +1353,6 @@ namespace verbly {
1327 case comparison::string_is_not_like: 1353 case comparison::string_is_not_like:
1328 case comparison::is_null: 1354 case comparison::is_null:
1329 case comparison::is_not_null: 1355 case comparison::is_not_null:
1330 case comparison::hierarchally_matches:
1331 case comparison::does_not_hierarchally_match:
1332 { 1356 {
1333 result += std::move(normalized); 1357 result += std::move(normalized);
1334 1358