phasedb v0.0.2 PhaseDB.Interpolator behaviour
To implement your own interpolator you must implement this behaviour.
To generate a sample you will be provided the timestamp (in usecs) for which the sample is required, and zero or more samples before and after the time depending on the value of sample_distance/0
and series configuration.
Think of the data as a graph of x,y samples where x is the recorded_at
of each sample and y
is the value. The at
argument is the x coordinate of the y value to be generated.
Currently implemented: - Zero Fill; just generates samples with a value of 0. - Nearest Neighbour; uses the value of the sample which is closest on the time axis. - Linear; draws a straight line between the two points and places the sample at the corresponding value on the line.
Future improvements: - Polynomial interpolator. - Spline interpolator.
See also: https://en.wikipedia.org/wiki/Interpolation
Summary
Callbacks
Generate a new sample (Sample
) at the given point in time based on zero or more samples in each direction
The minimum number of samples needed before and after the point before this interpolation function can be applied
Callbacks
Specs
generate_sample(at :: integer, previous :: [%PhaseDB.Sample{actual: term, received_at: term, recorded_at: term, tags: term, value: term}], next :: [%PhaseDB.Sample{actual: term, received_at: term, recorded_at: term, tags: term, value: term}]) :: %PhaseDB.Sample{actual: term, received_at: term, recorded_at: term, tags: term, value: term}
Generate a new sample (Sample
) at the given point in time based on zero or more samples in each direction.