aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/predicate/predicate_tree_annotator_test.cpp
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-08-11 10:03:29 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-08-11 10:03:29 +0000
commit09eead438851dcc4b88f1bd5269f72a311b6b3a0 (patch)
tree5ab0aa694f8b5296699c103a5d809fec686f7f5a /searchlib/src/tests/predicate/predicate_tree_annotator_test.cpp
parentdebfe5b96901a1fa2c30a5a284733817af45727f (diff)
Add unit test with comment of what is incorrect with hashed partiotion edges and feature generation.
Diffstat (limited to 'searchlib/src/tests/predicate/predicate_tree_annotator_test.cpp')
-rw-r--r--searchlib/src/tests/predicate/predicate_tree_annotator_test.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/searchlib/src/tests/predicate/predicate_tree_annotator_test.cpp b/searchlib/src/tests/predicate/predicate_tree_annotator_test.cpp
index 96e1c18459d..f4c49b36251 100644
--- a/searchlib/src/tests/predicate/predicate_tree_annotator_test.cpp
+++ b/searchlib/src/tests/predicate/predicate_tree_annotator_test.cpp
@@ -216,11 +216,36 @@ TEST("show different types of NOT-intervals") {
checkInterval(result, "key=C", {0x00010005});
checkInterval(result, "key=D", {0x00070007});
checkInterval(result, Constants::z_star_compressed_attribute_name,
- {0x00010000, 0x00070002, 0x00050000,
- 0x00070006});
+ {0x00010000, 0x00070002, 0x00050000,0x00070006});
}
+TEST("require short edge_partitions to get correct intervals and features") {
+ Slime slime;
+ Cursor &children = makeAndNode(slime.setObject());
+ makeHashedFeatureRange(children.addObject(), "key",{}, {{0, 5, -1}, {30, 0, 3}});
+ makeHashedFeatureRange(children.addObject(), "foo",{}, {{0, 5, -1}, {30, 0, 3}});
+
+ PredicateTreeAnnotations result;
+ PredicateTreeAnnotator::annotate(slime.get(), result);
+
+ EXPECT_EQUAL(2u, result.min_feature);
+ EXPECT_EQUAL(2u, result.interval_range);
+ EXPECT_EQUAL(0u, result.interval_map.size());
+ EXPECT_EQUAL(4u, result.bounds_map.size());
+ EXPECT_EQUAL(4u, result.features.size());
+ EXPECT_EQUAL(0u, result.range_features.size());
+
+ EXPECT_EQUAL(0ul, result.features[0]); //This is incorrect
+ EXPECT_EQUAL(0ul, result.features[1]); //This is incorrect
+ EXPECT_EQUAL(0ul, result.features[2]); //This is incorrect
+ EXPECT_EQUAL(0ul, result.features[3]); //This is incorrect
+ checkBounds(result, "key=0", {{0x00010001, 0xffffffff}});
+ checkBounds(result, "key=30", {{0x00010001, 3}});
+ checkBounds(result, "foo=0", {{0x00020002, 0xffffffff}});
+ checkBounds(result, "foo=30", {{0x00020002, 3}});
+}
+
TEST("require that hashed ranges get correct intervals") {
Slime slime;
Cursor &children = makeAndNode(slime.setObject());
@@ -238,6 +263,9 @@ TEST("require that hashed ranges get correct intervals") {
EXPECT_EQUAL(2u, result.interval_range);
EXPECT_EQUAL(4u, result.interval_map.size());
EXPECT_EQUAL(4u, result.bounds_map.size());
+ EXPECT_EQUAL(0u, result.features.size());
+ EXPECT_EQUAL(2u, result.range_features.size());
+
checkInterval(result, "key=10-19", {0x00010001});
checkInterval(result, "key=20-29", {0x00010001});
checkBounds(result, "key=0", {{0x00010001, 0xffffffff}});