6 #ifndef RESAMPLE_INTERPOLATE_VALUE_H 7 #define RESAMPLE_INTERPOLATE_VALUE_H 9 #include <core/data/flexible_type/flexible_type.hpp> 12 namespace timeseries {
55 return set_input_type(types[0]);
61 virtual std::string
name()
const = 0;
85 std::string
name()
const {
86 return std::string(
"zero");
119 std::string
name()
const {
120 return std::string(
"ffill");
126 return t1 <= t2 ? v1 : v2;
138 std::string
name()
const {
139 return std::string(
"nearest");
149 return (del_t1 <= del_t2) ? v1 : v2;
161 std::string
name()
const {
162 return std::string(
"bfill");
168 return (t2 >= t1) ? v2 : v1;
180 std::string
name()
const {
181 return std::string(
"none");
201 std::string
name()
const {
202 return std::string(
"linear");
221 return (dt_21 == 0) ? v1: scale * (v2 - v1) + v1;
223 return (dt_21 == 0) ? v1: v1 + (v2 - v1) * scale;
244 EXPORT
inline std::shared_ptr<interpolator_value> get_builtin_interpolator(
const 245 std::string& fill_method) {
246 std::shared_ptr<interpolator_value> interpolation_fn;
247 if (fill_method ==
"__builtin__zero__") {
248 interpolation_fn.reset(
new zero_fill());
249 }
else if (fill_method ==
"__builtin__nearest__") {
250 interpolation_fn.reset(
new nearest());
251 }
else if (fill_method ==
"__builtin__ffill__") {
252 interpolation_fn.reset(
new forward_fill());
253 }
else if (fill_method ==
"__builtin__bfill__") {
254 interpolation_fn.reset(
new backward_fill());
255 }
else if (fill_method ==
"__builtin__none__") {
256 interpolation_fn.reset(
new none_fill());
257 }
else if (fill_method ==
"__builtin__linear__") {
258 interpolation_fn.reset(
new linear_interpolation());
260 log_and_throw(
"Internal error. Undefined interpolation method.");
262 return interpolation_fn;
std::vector< double > flex_vec
virtual flex_type_enum set_input_types(const std::vector< flex_type_enum > &types)
int64_t posix_timestamp() const
virtual std::string name() const =0
flex_type_enum get_type() const
virtual flexible_type interpolate(const flexible_type &t, const flexible_type &t1, const flexible_type &t2, const flexible_type &v1, const flexible_type &v2) const =0
virtual bool support_type(flex_type_enum type) const =0
static flexible_type FLEX_UNDEFINED
#define DASSERT_TRUE(cond)