5 namespace reduce_task {
8 const Poco::SharedPtr<SphinxTaskReducersStorageIf>& sphinxTaskReducersStorage,
9 const Poco::SharedPtr<SphinxTaskReducerFactoryIf>& sphinxTaskReducerFactory,
10 const Poco::SharedPtr<SphinxResultJSONConvertorIf>& sphinxResultJSONConvertor)
12 _sphinxTaskReducersStorage = sphinxTaskReducersStorage;
13 _sphinxTaskReducerFactory = sphinxTaskReducerFactory;
14 _sphinxResultJSONConvertor = sphinxResultJSONConvertor;
22 return types::MessageType::mtSphinx;
28 _sphinxTaskReducersStorage->findByKey(reduceTaskId);
38 Poco::SharedPtr<SphinxTaskReducerIf> sphinxTaskReducer =
39 _sphinxTaskReducerFactory->create();
40 _sphinxTaskReducersStorage->addWithKey(reduceTaskId, sphinxTaskReducer);
44 const std::string& json)
46 Poco::SharedPtr<SphinxResultData> sphinxResult =
47 _sphinxResultJSONConvertor->convertToSphinxResultDataFrom(json);
48 Poco::SharedPtr<SphinxTaskReducerIf> sphinxTaskReducer =
49 _sphinxTaskReducersStorage->findByKey(reduceTaskId);
50 sphinxTaskReducer->addData(*sphinxResult.get());
56 Poco::SharedPtr<SphinxTaskReducerIf> sphinxTaskReducer =
57 _sphinxTaskReducersStorage->findByKey(reduceTaskId);
58 sphinxTaskReducer->reduce(_sphinxTaskReducerFactory->getScheduleStrategy());
59 Poco::SharedPtr<SphinxResultData> reduceResult = sphinxTaskReducer->getResult();
60 return _sphinxResultJSONConvertor->convertToJSONFrom(
61 transformSphinxResultData(reduceResult));
66 _sphinxTaskReducersStorage->deleteByKey(reduceTaskId);
69 Poco::SharedPtr<SphinxResultData> SphinxTaskReducersManager::transformSphinxResultData(
70 Poco::SharedPtr<SphinxResultData>& reduceResult)
73 getSphinxResultTrancater();
74 return sphinxResultTrancater.
trancate(reduceResult);