hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SphinxMultiIndexTest.hpp
Go to the documentation of this file.
1 #ifndef SPHINX_MULTI_INDEX_TEST_HPP
2 #define SPHINX_MULTI_INDEX_TEST_HPP
3 
4 #include <Poco/Task.h>
5 #include <Poco/TaskManager.h>
6 #include <Poco/TaskNotification.h>
7 #include <Poco/Observer.h>
8 #include <Poco/Mutex.h>
9 
10 #include <iostream>
12 #include <string>
13 
14 namespace HCE
15 {
16 namespace sphinx
17 {
18 namespace tests
19 {
20 //-----------------------------------------------------------------------------
21 class SearchTask : public Poco::Task
22 {
23 public:
24  SearchTask(const std::string& indexName, std::vector<std::string>& queries, bool start=true, bool stop=true);
25  void runTask(void);
26 
27  float getFps(void) const {return fps;}
28  bool stopSearchd(void) { return fObj.stopSearchd();}
29 private:
30  std::string indexName;
31  std::vector<std::string> queries;
33 
34  float fps;
35  typedef Poco::Task inherited;
36 };
37 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 {
41 public:
42  SearchProgressHandler(void) : fps(0), mutex() {}
43  void onProgress(Poco::TaskProgressNotification* pNf);
44  void onFinished(Poco::TaskFinishedNotification* pNf);
45 
46  float getFps(void);
47 private:
48  float fps;
49  Poco::Mutex mutex;
50 };
51 //-----------------------------------------------------------------------------
52 //-----------------------------------------------------------------------------
54 {
55  struct IndexProperty
56  {
57  std::string path;
58  std::string listen;
59  };
60  friend class CreateTask;
61  static void printSuccess(const std::string& msg, std::ostream& os=std::cout);
62  static void printWarning(const std::string& msg, std::ostream& os=std::cout);
63 
64  static void setIndexProperty(const std::string& homeDir, const std::string& indexName, const IndexProperty& property) throw (Poco::Exception);
65  static void getIndexProperty(const std::string& homeDir, const std::string& indexName, IndexProperty& property) throw (Poco::Exception);
66 public:
67  static void testCreateIndex(SphinxFunctionalObject& fObj, const std::string& indexName, const std::string& dataContent);
68  static unsigned int testSearchIndex(SphinxFunctionalObject& fObj, const std::string& indexName, const std::string& query);
69 
70  static void makeIndexNames(size_t count, std::vector<std::string>& names);
71 
72  static void testCreateIndexes(const std::string& homeDir, size_t count, const std::string& dataFileName, std::vector<std::string>& names);
73  static float testSearchIndexes(std::vector<std::string>& names, std::vector<std::string> queries); // return accumulate fps all indexes
74  static float testSearchIndexes(const std::string& homeDir, std::vector<std::string>& names, std::vector<std::string> queries, const std::string& indexName); // return accumulate fps all indexes
75  static void testRemoveIndexes(const std::string& homeDir, std::vector<std::string>& names);
76 };
77 //-----------------------------------------------------------------------------
78 //-----------------------------------------------------------------------------
79 } // end namespace tests
80 } // namespace sphinx
81 } // namespace HCE
82 
83 #endif // SPHINX_MULTI_INDEX_TEST_HPP