8 #include <gtest/gtest.h>
13 using namespace HCE::sphinx;
14 using namespace HCE::sphinx::reduce_task;
21 sphinxReduceDataStorage.
reset();
22 ASSERT_TRUE(sphinxReduceDataStorage.
hasNext() ==
false);
42 resources.push_back(sphinxMatchInfo1);
43 resources.push_back(sphinxMatchInfo2);
44 resources.push_back(sphinxMatchInfo3);
46 expectIdsWeights.push_back(make_pair(to_string(14LLU),
toHexString(12345LLU)));
47 expectIdsWeights.push_back(make_pair(to_string(7LLU),
toHexString(256789LLU)));
48 expectIdsWeights.push_back(make_pair(to_string(21LLU),
toHexString(1122334LLU)));
53 if (expectDocId == expectIdsWeights[
index].first &&
54 expectWeight == expectIdsWeights[
index].second){
73 sphinxReduceDataStorage.
addData(resources[index]);
75 sphinxReduceDataStorage.
reset();
76 ASSERT_TRUE(sphinxReduceDataStorage.
hasNext());
77 sphinxReduceDataStorage.
getNext(expectDocId, expectWeight);
78 EXPECT_EQ(expectDocId, expectIdsWeights[index].first);
79 EXPECT_EQ(expectWeight, expectIdsWeights[index].second);
89 sphinxReduceDataStorage.
addData(resources[index]);
91 string expectComplexKey = expectIdsWeights[
index].first + expectIdsWeights[
index].second;
93 storageDataIter = sphinxReduceDataStorage.
getData(expectComplexKey);
95 ASSERT_TRUE(storageDataIter.first != storageDataIter.second);
96 EXPECT_EQ(storageDataIter.first->second.getDocId(), resources[
index].getDocId());
97 EXPECT_EQ(storageDataIter.first->second.getWeight(), resources[
index].getWeight());
109 unsigned int docsNumber = 0;
110 sphinxReduceDataStorage.
reset();
111 while(sphinxReduceDataStorage.
hasNext()){
112 sphinxReduceDataStorage.
getNext(expectDocId, expectWeight);
113 EXPECT_TRUE(isFindExpectData(expectDocId, expectWeight));
116 ASSERT_EQ(docsNumber, expectIdsWeights.size());
132 resources.push_back(sphinxMatchInfo4);
138 string expectComplexKey = expectIdsWeights[doubleIndex].first + expectIdsWeights[doubleIndex].second;
139 storageDataIter = sphinxReduceDataStorage.
getData(expectComplexKey);
141 ASSERT_EQ(storageDataIter.first->second.getAttributes().size(), 0U);
142 storageDataIter.first++;
143 ASSERT_EQ(storageDataIter.first->second.getAttributes().size(), 1U);
144 storageDataIter.first++;
145 ASSERT_TRUE(storageDataIter.first == storageDataIter.second);