summaryrefslogtreecommitdiffstats
path: root/searchcore/src
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-03-23 10:30:23 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2017-03-27 16:21:01 +0200
commit3656023785d17d513b67f4cbe8686a40141e06d8 (patch)
treed3e26110f82326573c0378d74f8d1dc189b32973 /searchcore/src
parent0cd6a2c04f90ffbdba4d585f1d71a5dd2b4e8311 (diff)
Remove ExpressionNode::CP from interfaces.
Diffstat (limited to 'searchcore/src')
-rw-r--r--searchcore/src/tests/grouping/grouping.cpp171
-rw-r--r--searchcore/src/tests/proton/matching/matching_test.cpp20
2 files changed, 77 insertions, 114 deletions
diff --git a/searchcore/src/tests/grouping/grouping.cpp b/searchcore/src/tests/grouping/grouping.cpp
index 740e1aeb285..2701e697795 100644
--- a/searchcore/src/tests/grouping/grouping.cpp
+++ b/searchcore/src/tests/grouping/grouping.cpp
@@ -172,24 +172,22 @@ TEST("testSessionId") {
EXPECT_EQUAL(id2, id2);
}
+#define MU std::make_unique
+
TEST_F("testGroupingContextInitialization", DoomFixture()) {
vespalib::nbostream os;
Grouping baseRequest = Grouping()
.setRoot(Group()
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr0"))))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr0"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr1"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr2"))))
+ .setExpression(MU<AttributeNode>("attr1"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr2"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr2"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr3"))))
+ .setExpression(MU<AttributeNode>("attr2"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr3"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr3"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr1"))));
+ .setExpression(MU<AttributeNode>("attr3"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr1"))));
vespalib::NBOSerializer nos(os);
nos << (uint32_t)1;
@@ -209,40 +207,31 @@ TEST_F("testGroupingContextUsage", DoomFixture()) {
Grouping request1 = Grouping()
.setFirstLevel(0)
.setLastLevel(0)
- .setRoot(Group()
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr0"))))
+ .setRoot(Group().addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr0"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr1"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr2"))))
+ .setExpression(MU<AttributeNode>("attr1"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr2"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr2"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr3"))))
+ .setExpression(MU<AttributeNode>("attr2"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr3"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr3"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr1"))));
+ .setExpression(MU<AttributeNode>("attr3"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr1"))));
Grouping request2 = Grouping()
.setFirstLevel(0)
.setLastLevel(3)
.setRoot(Group()
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr0"))))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr0"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr1"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr2"))))
+ .setExpression(MU<AttributeNode>("attr1"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr2"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr2"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr3"))))
+ .setExpression(MU<AttributeNode>("attr2"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr3"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr3"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr1"))));
+ .setExpression(MU<AttributeNode>("attr3"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr1"))));
GroupingContext::GroupingPtr r1(new Grouping(request1));
@@ -260,20 +249,16 @@ TEST_F("testGroupingContextUsage", DoomFixture()) {
TEST_F("testGroupingContextSerializing", DoomFixture()) {
Grouping baseRequest = Grouping()
.setRoot(Group()
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr0"))))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr0"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr1"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr2"))))
+ .setExpression(MU<AttributeNode>("attr1"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr2"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr2"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr3"))))
+ .setExpression(MU<AttributeNode>("attr2"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr3"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr3"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr1"))));
+ .setExpression(MU<AttributeNode>("attr3"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr1"))));
vespalib::nbostream os;
vespalib::NBOSerializer nos(os);
@@ -294,17 +279,13 @@ TEST_F("testGroupingManager", DoomFixture()) {
Grouping request1 = Grouping()
.setFirstLevel(0)
.setLastLevel(0)
- .setRoot(Group()
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr0"))))
+ .setRoot(Group().addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr0"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr1"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr2"))))
+ .setExpression(MU<AttributeNode>("attr1"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr2"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr2"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr3"))));
+ .setExpression(MU<AttributeNode>("attr2"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr3"))));
GroupingContext context(f1.clock, f1.timeOfDoom);
GroupingContext::GroupingPtr bp(new Grouping(request1));
@@ -322,30 +303,25 @@ TEST_F("testGroupingSession", DoomFixture()) {
.setFirstLevel(0)
.setLastLevel(0)
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr1"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr2"))))
+ .setExpression(MU<AttributeNode>("attr1"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr2"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr2"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr3"))));
+ .setExpression(MU<AttributeNode>("attr2"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr3"))));
Grouping request2 = Grouping()
.setId(1)
.setFirstLevel(0)
.setLastLevel(3)
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr1"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr2"))))
+ .setExpression(MU<AttributeNode>("attr1"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr2"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr2"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr3"))))
+ .setExpression(MU<AttributeNode>("attr2"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr3"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr3"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr1"))));
+ .setExpression(MU<AttributeNode>("attr3"))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr1"))));
CheckAttributeReferences attrCheck;
@@ -420,13 +396,13 @@ TEST_F("testEmptySessionId", DoomFixture()) {
.setFirstLevel(0)
.setLastLevel(0)
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr1"))
+ .setExpression(MU<AttributeNode>("attr1"))
.addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr2"))))
+ .setExpression(MU<AttributeNode>("attr2"))))
.addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr2"))
+ .setExpression(MU<AttributeNode>("attr2"))
.addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr3"))));
+ .setExpression(MU<AttributeNode>("attr3"))));
GroupingContext::GroupingPtr r1(new Grouping(request1));
GroupingContext initContext(f1.clock, f1.timeOfDoom);
@@ -451,23 +427,22 @@ TEST_F("testSessionManager", DoomFixture()) {
MyWorld world;
world.basicSetup();
vespalib::nbostream os;
- Grouping request1 = Grouping()
- .setId(0)
- .setFirstLevel(0)
- .setLastLevel(0)
- .addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr1"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr2"))
- .setResult(Int64ResultNode(0))))
- .addLevel(GroupingLevel()
- .setExpression(AttributeNode("attr2"))
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr3"))
- .setResult(Int64ResultNode(0))))
- .setRoot(Group()
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr0"))
+ Grouping request1;
+ request1.setId(0)
+ .setFirstLevel(0)
+ .setLastLevel(0)
+ .addLevel(GroupingLevel()
+ .setExpression(MU<AttributeNode>("attr1"))
+ .addResult(SumAggregationResult()
+ .setExpression(MU<AttributeNode>("attr2"))
+ .setResult(Int64ResultNode(0))))
+ .addLevel(GroupingLevel()
+ .setExpression(MU<AttributeNode>("attr2"))
+ .addResult(SumAggregationResult()
+ .setExpression(MU<AttributeNode>("attr3"))
+ .setResult(Int64ResultNode(0))))
+ .setRoot(Group().addResult(SumAggregationResult()
+ .setExpression(MU<AttributeNode>("attr0"))
.setResult(Int64ResultNode(0))));
GroupingContext::GroupingPtr r1(new Grouping(request1));
@@ -522,12 +497,8 @@ TEST_F("test grouping fork/join", DoomFixture()) {
world.basicSetup();
Grouping request = Grouping()
- .setRoot(Group()
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr0"))))
- .addLevel(GroupingLevel()
- .setMaxGroups(3)
- .setExpression(AttributeNode("attr0")))
+ .setRoot(Group().addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr0"))))
+ .addLevel(GroupingLevel().setMaxGroups(3).setExpression(MU<AttributeNode>("attr0")))
.setFirstLevel(0)
.setLastLevel(1);
@@ -554,15 +525,11 @@ TEST_F("test grouping fork/join", DoomFixture()) {
Grouping expect = Grouping()
.setRoot(Group()
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("attr0"))
- .setResult(Int64ResultNode(189)))
+ .addResult(SumAggregationResult().setExpression(MU<AttributeNode>("attr0")).setResult(Int64ResultNode(189)))
.addChild(Group().setId(Int64ResultNode(21)).setRank(40.0))
.addChild(Group().setId(Int64ResultNode(22)).setRank(150.0))
.addChild(Group().setId(Int64ResultNode(32)).setRank(100.0)))
- .addLevel(GroupingLevel()
- .setMaxGroups(3)
- .setExpression(AttributeNode("attr0")))
+ .addLevel(GroupingLevel().setMaxGroups(3).setExpression(MU<AttributeNode>("attr0")))
.setFirstLevel(0)
.setLastLevel(1);
diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp
index ee3cb554615..a1c6538baa7 100644
--- a/searchcore/src/tests/proton/matching/matching_test.cpp
+++ b/searchcore/src/tests/proton/matching/matching_test.cpp
@@ -500,6 +500,7 @@ TEST("require that sortspec can be used (multi-threaded)") {
}
}
+ExpressionNode::UP createAttr() { return std::make_unique<AttributeNode>("a1"); }
TEST("require that grouping is performed (multi-threaded)") {
for (size_t threads = 1; threads <= 16; ++threads) {
MyWorld world;
@@ -511,29 +512,24 @@ TEST("require that grouping is performed (multi-threaded)") {
vespalib::NBOSerializer os(buf);
uint32_t n = 1;
os << n;
- Grouping grequest =
- Grouping()
- .setRoot(Group()
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("a1"))));
+ Grouping grequest;
+ grequest.setRoot(Group().addResult(SumAggregationResult().setExpression(createAttr())));
grequest.serialize(os);
request->groupSpec.assign(buf.c_str(), buf.c_str() + buf.size());
}
SearchReply::UP reply = world.performSearch(request, threads);
{
- vespalib::nbostream buf(&reply->groupResult[0],
- reply->groupResult.size());
+ vespalib::nbostream buf(&reply->groupResult[0], reply->groupResult.size());
vespalib::NBOSerializer is(buf);
uint32_t n;
is >> n;
EXPECT_EQUAL(1u, n);
Grouping gresult;
gresult.deserialize(is);
- Grouping gexpect = Grouping()
- .setRoot(Group()
- .addResult(SumAggregationResult()
- .setExpression(AttributeNode("a1"))
- .setResult(Int64ResultNode(4500))));
+ Grouping gexpect;
+ gexpect.setRoot(Group().addResult(SumAggregationResult()
+ .setExpression(createAttr())
+ .setResult(Int64ResultNode(4500))));
EXPECT_EQUAL(gexpect.root().asString(), gresult.root().asString());
}
EXPECT_GREATER(world.matchingStats.groupingTimeAvg(), 0.0000001);