HCE project C++ developers source code library  1.1.1
HCE project developer library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SphinxTaskReducer.cpp
Go to the documentation of this file.
1 #include "SphinxTaskReducer.hpp"
2 
3 namespace HCE{
4 namespace sphinx{
5 namespace reduce_task{
6 
7 SphinxTaskReducer::SphinxTaskReducer(SphinxResultBuilderIf& sphinxResultBuilder,
8  SphinxReduceJobBuilderIf& reduceJobBuilder,
9  SphinxResultDataAccumulatorFactoryIf& sphinxResultDataAccumulatorFactory):
10  _sphinxResultBuilder(sphinxResultBuilder)
11 {
12  _reduceJob = reduceJobBuilder.build();
13  Poco::SharedPtr<SphinxReduceDataStorage> dataStorage =
14  _reduceJob->getDataStorage().unsafeCast<SphinxReduceDataStorage>();
15  _sphinxResultDataAccumulator = sphinxResultDataAccumulatorFactory.build(dataStorage);
16 }
17 
19 
21 {
22  _sphinxResultDataAccumulator->accumulate(sphinxResultData);
23 }
24 
26 {
27  scheduleStrategy.executeJob(_reduceJob);
28 }
29 
30 Poco::SharedPtr<SphinxResultData> SphinxTaskReducer::getResult()
31 {
32  Poco::SharedPtr<HCE::reduce::core::ReduceResultIf> reduceResult =
33  _reduceJob->getReduceResult();
34  Poco::SharedPtr<SphinxReduceDataStorage> dataStorage =
35  _sphinxResultDataAccumulator->getSphinxDataStorage();
36 
37  std::vector<SphinxRequestInfo>& requestInfo =
38  _sphinxResultDataAccumulator->getAllSphinxRequestInfo();
39 
40  Poco::SharedPtr<SphinxResultData> reduceDataResult = _sphinxResultBuilder.build(
41  dataStorage, reduceResult, requestInfo);
42  return reduceDataResult;
43 }
44 
45 }
46 }
47 }