hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SphinxResultDataAccumulator.hpp
Go to the documentation of this file.
1 
14 #ifndef SPHINXRESULTDATAACCUMULATOR_HPP_
15 #define SPHINXRESULTDATAACCUMULATOR_HPP_
16 
18 
19 namespace HCE{
20 namespace sphinx{
21 namespace reduce_task
22 {
23 
25 public:
26  SphinxResultDataAccumulator(Poco::SharedPtr<SphinxReduceDataStorage>& sphinxDataStorage):
27  _sphinxDataStorage(sphinxDataStorage){
28  }
30 
31  void accumulate(SphinxResultData& sphinxResultData){
32  accumulateSphinxMatchInfo(sphinxResultData);
33  accumulateSphinxRequestInfo(sphinxResultData);
34  }
35 
36  std::vector<SphinxRequestInfo>& getAllSphinxRequestInfo(){
37  return _allSphinxRequestInfo;
38  }
39 
40  Poco::SharedPtr<SphinxReduceDataStorage> getSphinxDataStorage(){
41  return _sphinxDataStorage;
42  }
43 
44 private:
45  Poco::SharedPtr<SphinxReduceDataStorage> _sphinxDataStorage;
46  std::vector<SphinxRequestInfo> _allSphinxRequestInfo;
47 
48  void accumulateSphinxMatchInfo(SphinxResultData& sphinxResultData){
49  size_t totalMatchInfoNumber = sphinxResultData.getMatchInfoCount();
50  for (size_t curMatchInfoIndex = 0; curMatchInfoIndex < totalMatchInfoNumber;
51  ++curMatchInfoIndex){
52  const SphinxMatchInfo &matchInfo = sphinxResultData.getMatchInfoItem(curMatchInfoIndex);
53  _sphinxDataStorage->addData(matchInfo);
54  }
55  }
56 
57  void accumulateSphinxRequestInfo(SphinxResultData& sphinxResultData){
58  size_t totalRequestInfoNumber = sphinxResultData.getRequestInfoCount();
59  for(size_t curRequestInfoIndex = 0; curRequestInfoIndex < totalRequestInfoNumber;
60  ++curRequestInfoIndex){
61  _allSphinxRequestInfo.push_back(sphinxResultData.getRequestInfoItem(curRequestInfoIndex));
62  }
63  }
64 };
65 }
66 }
67 }
68 
69 #endif