hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
main.cpp
Go to the documentation of this file.
1 #include <SphinxTaskReducersManager.h>
2 #include <SphinxTaskReducersStorage.h>
3 #include <SphinxTaskReducerFactory.h>
4 #include <SphinxResultJSONConvertor.h>
5 #include <string>
6 
7 using namespace Poco;
8 using namespace HCE::sphinx;
9 using namespace HCE::sphinx::reduce_task;
10 using namespace std;
11 
12 
13 int main(int argc, char** argv)
14 {
15  SharedPtr<SphinxTaskReducersStorage<> >sphinxTaskReducersStorage(new SphinxTaskReducersStorage<>());
16  SharedPtr<SphinxTaskReducerFactory<> >sphinxTaskReducerFactory(new SphinxTaskReducerFactory<>());
17  SharedPtr<SphinxResultJSONConvertor>sphinxResultJSONConvertor(new SphinxResultJSONConvertor());
18 
19  SphinxTaskReducersManager<> sphinxTaskReducersManager(sphinxTaskReducersStorage, sphinxTaskReducerFactory,
20  sphinxResultJSONConvertor);
21  int itemId = 3;
22  string sphinxResultJSON = "";
23 
24  if (!sphinxTaskReducersManager.isSphinxTaskReducerExist(itemId)){
25  sphinxTaskReducersManager.createSphinxTaskReducer(itemId);
26  }
27 
28  try{
29  sphinxTaskReducersManager.addDataInSphinxTaskReducer(itemId, sphinxResultJSON);
30  }
31  catch(WrongJSONStructureException& e){
32  cout << "WrongJSONStructureException" << endl << sphinxResultJSON << endl;
33  return 1;
34  }
35 
36  try{
37  string reducedJSON = sphinxTaskReducersManager.runReduceTaskForTaskId(itemId);
38  }
39  catch(NotFoundByKeyException &e){
40  cout << "NotFoundSphinxTaskReducerException" << endl;
41  }
42 
43  try{
44  sphinxTaskReducersManager.deleteTaskReducerBy(itemId);
45  }
46  catch(NotFoundByKeyException &e){
47  cout << "NotFoundSphinxTaskReducerException" << endl;
48  }
49 
50  return 0;
51 }