eis/eqpalg/.do_not_use/data_handler/flatten_data.h000

130 lines
2.8 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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 <dlib/statistics.h>
#include <eqpalg/table_struct/t_rule_sample_1d_flatten.h>
#include <array>
#include <vector>
#include <type_traits>
#include <string>
#include <map>
#include <utility>
#include <random>
#include "mix_cc/type/range.h"
#include "mix_cc/sql.h"
#include "mix_cc/sql/database/db2_t.h"
#include <eqpalg/data_handler/base.h>
#include <eqpalg/gb_logger.h>
#include <eqpalg/define/dlib.h>
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<double>; ///< 数据类型
using Dim1Table = T_RULE_SAMPLE_1D_FLATTEN;
using InData = SampleWindow;
using DumpedMetaData = RS; ///< 导出的元数据类型
using DumpedData = std::map<TimePoint, DumpedMetaData>; ///< 导出的数据类型
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<GbLogger> 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<double> get_rs_means();
vector<double> get_rs_variances();
vector<double> get_rs_stddev();
vector<double> get_rs_skewness();
vector<double> get_rs_kurtosis();
vector<double> get_rs_max();
vector<double> get_rs_min();
};
} // namespace policy
} // namespace data_handler