#pragma once /** * @file approximate_data.h * @brief 存储大概分布的类 * @author Cat (null.null.null@qq.com) * @version 0.1 * @date 2021-08-24 * * Copyright: Baosight Co. Ltd. * DO NOT COPY/USE WITHOUT PERMISSION * */ #include #include #include #include #include #include #include #include #include #include "mix_cc/type/range.h" #include "mix_cc/sql.h" #include "mix_cc/sql/database/db2_t.h" #include #include #include namespace data_handler { namespace policy { using std::string; using namespace mix_cc; using namespace mix_cc::sql; /** * @brief 大约数据分布 * @tparam dims */ struct FlattenData : public Base { struct RS { public: TimePoint sample_date; double avg; double stddev; double skewness; double ex_kurtosis; double min; double max; }; using TmpRS = dlib::running_stats; ///< 数据类型 using Dim1Table = T_RULE_SAMPLE_1D_FLATTEN; using InData = SampleWindow; using DumpedMetaData = RS; ///< 导出的元数据类型 using DumpedData = std::map; ///< 导出的数据类型 using OutData = DumpedData; protected: std::chrono::system_clock::duration storage_interval_; InData tmp_data_; DumpedData dumped_data_; bool is_first_sampling_ = true; std::unique_ptr gb_logger_; public: FlattenData(const std::string& ruleId, size_t dims); int first_sampling_batch(const InData& first_runing_info, TimePoint Tp); /** * @brief 与approximate_data一致,保证编译通过 * @param first_runing_infoMy Param doc * @param Tp My Param doc * @param running_state My Param doc * @return int */ int first_sampling_batch(const InData& first_runing_info, TimePoint Tp, Rs running_state) { return 0; } /** * @brief * 是否是第一次采样 * @return true * @return false */ bool is_first_sampling() { return this->is_first_sampling_; } int load(); int store(const SamplePoint& i_value); int commit(); SampleWindow extract(); /** * @brief 获取采样数据的大小 * @return size_t */ size_t get_sampling_size() { return this->sampling_size_; } // 均值方差 2021-11-29 没有意义,为了编译 int put_data_to_rs(const SampleWindow& input_data); vector get_rs_means(); vector get_rs_variances(); vector get_rs_stddev(); vector get_rs_skewness(); vector get_rs_kurtosis(); vector get_rs_max(); vector get_rs_min(); }; } // namespace policy } // namespace data_handler