Machine Learning Library
MysqlDatabase.h
Go to the documentation of this file.
1 #ifndef __MYSQL_DATABASE_H
2 #define __MYSQL_DATABASE_H
3 
4 #include "DatabaseException.h"
5 #include "CDataset.h"
6 #include "CSOM.h"
7 
8 #include <mysql.h>
9 
10 #define LOAD_LABEL 0x01
11 #define LOAD_KEYWORDS 0x02
12 #define LOAD_PROTOTYPES 0x04
13 
14 template<class Type> class CSOM;
15 
16 struct strEqual {
17  bool operator()(const char* pc1, const char* pc2) const {
18  return (strcmp(pc1, pc2) == 0);
19  }
20 };
21 
22 
24 {
25 private:
26  std::string mysql_msg;
27 
28 public:
29  CMysqlDatabaseException(const char* msg, MYSQL* conn, const char* file, int line) :
30  CDatabaseException(msg, file, line), mysql_msg(mysql_error(conn)) {
31  }
32 
33  virtual const std::string getMessage() const {
34  return CDatabaseException::getMessage() + mysql_msg;
35  }
36 };
37 
38 
39 
41 {
42 private:
43  MYSQL *pMysql;
44  bool sparse;
45  string strDatabase;
46 
47 public:
48  CMysqlDatabase(const char* pcHost, const char* pcUser,
49  const char* pcPwd, const char* pcDb, int iPort = 0);
50 
52 
53  void fetchBagOfWords(CDataset<float>& rtDataset,
54  const char* pcQuery, const char* pcTopic=NULL);
55 
56  void fetchBagOfWords(CDataset<float>& rtDataset,
57  char* pcDictQuery, char* pcDocQuery, char* pcTopicTable=NULL,
58  int iUseTfIdf=1);
59 
60  void fetchPyramidOfWords(CDataset<float>& rtDataset,
61  int iNumLevels, int iLow, int iHigh,
62  char *pcWhereDict=NULL, char *pcDocQuery=NULL,
63  char *pcTopicTable=NULL,
64  int iUseTfIdf=1);
65 
66  void loadData(CDataset<float>& rtDataset,
67  char* pcTable, int iInp0, int iInp1, int iOut0, int iOut1);
68 
69  void saveSOM(CSOM<float>& rtSOM, const char* pcName, int iMappingOnly=0);
70  void loadSOM(CSOM<float>& rtSOM, const char* pcName, int iVisible=3, int iMode=6);
71  void loadFlow(CSOM<float>& rtSOM, const char* pcSomName, const char* pcFlowTable);
72 };
73 
74 
75 #endif
void loadFlow(CSOM< float > &rtSOM, const char *pcSomName, const char *pcFlowTable)
CMysqlDatabase(const char *pcHost, const char *pcUser, const char *pcPwd, const char *pcDb, int iPort=0)
Definition: DatabaseException.h:8
virtual const std::string getMessage() const
Definition: MysqlDatabase.h:33
Definition: MysqlDatabase.h:40
void loadData(CDataset< float > &rtDataset, char *pcTable, int iInp0, int iInp1, int iOut0, int iOut1)
CMysqlDatabaseException(const char *msg, MYSQL *conn, const char *file, int line)
Definition: MysqlDatabase.h:29
void fetchBagOfWords(CDataset< float > &rtDataset, const char *pcQuery, const char *pcTopic=NULL)
void loadSOM(CSOM< float > &rtSOM, const char *pcName, int iVisible=3, int iMode=6)
SOM class for Self Organizing Maps with arbitrary topology.
Definition: MysqlDatabase.h:14
void saveSOM(CSOM< float > &rtSOM, const char *pcName, int iMappingOnly=0)
bool operator()(const char *pc1, const char *pc2) const
Definition: MysqlDatabase.h:17
virtual const std::string getMessage() const
Definition: DatabaseException.h:21
void fetchPyramidOfWords(CDataset< float > &rtDataset, int iNumLevels, int iLow, int iHigh, char *pcWhereDict=NULL, char *pcDocQuery=NULL, char *pcTopicTable=NULL, int iUseTfIdf=1)
Definition: MysqlDatabase.h:23
Definition: MysqlDatabase.h:16