7 #include <gtest/gtest.h>
13 using namespace HCE::sphinx;
14 using namespace HCE::sphinx::reduce_task;
15 using namespace HCE::reduce;
26 SharedPtr<SphinxResultData> sphinxResult = sphinxResultBuilder.
build(
27 sphinxReduceDataStorage, sphinxReduceResult, requestInfo);
29 ASSERT_EQ(sphinxResult->getMatchInfoCount(), 0U);
30 ASSERT_EQ(sphinxResult->getRequestInfoCount(), 0U);
50 matchInfo1.addAttrInfo(attrInfo);
51 matchInfo2.addAttrInfo(attrInfo);
52 matchInfo3.addAttrInfo(attrInfo);
53 matchInfo4.addAttrInfo(attrInfo);
55 sphinxRequestInfo.setQuery(
query);
56 sphinxRequestInfo.setTotal(totalRes);
58 sphinxRequestInfo.setTimeMsec(
time);
59 sphinxRequestInfo.addWordInfo(word1);
62 sphinxResultData->addMatchInfo(matchInfo1);
63 sphinxResultData->addMatchInfo(matchInfo2);
64 sphinxResultData->addMatchInfo(matchInfo3);
65 sphinxResultData->addMatchInfo(matchInfo4);
66 sphinxResultData->addRequestInfo(sphinxRequestInfo);
68 expectedSelectResultData.addMatchInfo(matchInfo1);
69 expectedSelectResultData.addMatchInfo(matchInfo4);
70 expectedSelectResultData.addRequestInfo(sphinxRequestInfo);
72 expectedCopyResultData = *sphinxResultData.get();
100 sphinxReduceDataStorage->addData(matchInfo1);
101 sphinxReduceDataStorage->addData(matchInfo2);
102 sphinxReduceDataStorage->addData(matchInfo3);
103 sphinxReduceDataStorage->addData(matchInfo4);
105 sphinxReduceResult->addKeyValue(to_string(matchInfo1.getDocId()), matchInfo1.getWeight());
106 sphinxReduceResult->addKeyValue(to_string(matchInfo2.getDocId()), matchInfo2.getWeight());
107 sphinxReduceResult->addKeyValue(to_string(matchInfo3.getDocId()), matchInfo3.getWeight());
108 sphinxReduceResult->addKeyValue(to_string(matchInfo4.getDocId()), matchInfo4.getWeight());
113 SharedPtr<SphinxResultData> sphinxResult = sphinxResultBuilder.
build(
114 sphinxReduceDataStorage, sphinxReduceResult,
requestInfo);
122 sphinxReduceDataStorage->addData(matchInfo1);
123 sphinxReduceDataStorage->addData(matchInfo2);
125 sphinxReduceResult->addKeyValue(to_string(matchInfo1.getDocId()), matchInfo1.getWeight());
126 sphinxReduceResult->addKeyValue(
"fake key",
"fake weight");
129 ASSERT_THROW(sphinxResultBuilder.
build(sphinxReduceDataStorage, sphinxReduceResult,
requestInfo),
138 sphinxReduceDataStorage->addData(matchInfo1);
139 sphinxReduceDataStorage->addData(matchInfo1Equal);
141 sphinxReduceResult->addKeyValue(to_string(matchInfo1.getDocId()), matchInfo1.getWeight());
144 SharedPtr<SphinxResultData> sphinxResult = sphinxResultBuilder.
build(
145 sphinxReduceDataStorage, sphinxReduceResult,
requestInfo);
147 ASSERT_EQ(sphinxResult->getMatchInfoItem(0).getAttributes().size(), 1U);
153 vector<pair<string, unsigned long long> > weightKeyPairs;
157 sphinxResultData, weightKeyPairs);
159 ASSERT_EQ(sphinxResult->getMatchInfoCount(), 0U);
160 ASSERT_EQ(sphinxResult->getRequestInfoCount(), 1U);
166 vector<pair<string, unsigned long long> > weightKeyPairs;
167 weightKeyPairs.push_back(make_pair(
"111", 7LLU));
168 weightKeyPairs.push_back(make_pair(
"099", 3LLU));
172 sphinxResultData, weightKeyPairs);
180 vector<pair<string, unsigned long long> > weightKeyPairs;
181 weightKeyPairs.push_back(make_pair(
"111", 7LLU));
182 weightKeyPairs.push_back(make_pair(
"222", 9LLU));
183 weightKeyPairs.push_back(make_pair(
"444", 15LLU));
184 weightKeyPairs.push_back(make_pair(
"099", 3LLU));
188 sphinxResultData, weightKeyPairs);