DataCondenser.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef DATAINTERFACE_DATACONDENSER_H
  2. #define DATAINTERFACE_DATACONDENSER_H
  3. #include "DataType.h"
  4. #include "RRA.h"
  5. #include <MySQLClient.h>
  6. #include <string>
  7. #include <vector>
  8. namespace DataStorageInterface {
  9. namespace DataInterface {
  10. class DataCondenser
  11. {
  12. public:
  13. DataCondenser(MySQL::MySQLClient* pMySQLClient);
  14. void CondenseData();
  15. private:
  16. int GetPeriodStamp(int timestamp, const RRA::type& rra);
  17. std::vector<int> GetDeviceIDs();
  18. int GetNewestPeriodStamp(const std::string& sourceTable, int deviceId, int dataId);
  19. MySQL::MySQLResultSet GetRawData(const std::string& sourceTable, int deviceId, int dataId, int newestPeriodStamp);
  20. MySQL::MySQLResultSet GetReducedData(const std::string& sourceTable, int deviceId, int dataId, int newestPeriodStamp);
  21. int GetMaximumMySQLPacketSize();
  22. DataType::type GetDataType(int deviceId, int dataId);
  23. std::string GetSourceTable(const RRA::type& rra);
  24. std::string GetDestinationTable(const RRA::type& rra);
  25. int StringStreamSize(std::stringstream& ss);
  26. void InitializeInsertQuery(std::stringstream& query, const std::string& table);
  27. void ExecuteInsertQuery(std::stringstream& query);
  28. void WriteReducedFloatData(int deviceId, int dataId, const RRA::type& rra);
  29. void WriteReducedStringData(int deviceId, int dataId, const RRA::type& rra);
  30. void WriteReducedData(int deviceId, int dataId, const RRA::type& rra);
  31. void CleanData();
  32. void CleanData(const RRA::type& rra);
  33. private:
  34. MySQL::MySQLClient* m_pMySQLClient;
  35. };
  36. } // namespace DataInterface
  37. } // namespace DataStorageInterface
  38. #endif // DATAINTERFACE_DATACONDENSER_H