java.lang.Object
eu.bengreen.data.utility.DownSampleImpl
eu.bengreen.data.utility.LargestTriangleThreeBuckets
- All Implemented Interfaces:
DownSampler
First implementation of Largest-Triangle-Three-Buckets.
Modified by Fabrice Bacchella for NaN support.
Nested Class Summary
Nested classes/interfaces inherited from interface DownSampler
DownSampler.DataSetModifier and TypeInterfaceDescriptionstatic classRepresents a dataset containing timestamps and corresponding values.Field Summary
Fields inherited from class DownSampleImpl
thresholdModifier and TypeFieldDescriptionprotected final intNumber of data points to downsample to.Constructor Summary
ConstructorsConstructorDescriptionLargestTriangleThreeBuckets(int threshold) Create a downsampler that reduces a series to at most this many points, choosing each point by the largest-triangle-three-buckets rule.Method Summary
All MethodsModifier and TypeMethodDescriptiondownsizeImpl(DownSampler.DataSet sampled, long[] timestamps, double[] values) Reduces the source series into the pre-allocated output set.Methods inherited from class DownSampleImpl
downsize, setDataSetLineModifier and TypeMethodDescriptiondownsize(long[] timestamps, double[] values) Downsample the given data.protected voidsetDataSetLine(DownSampler.DataSet sampled, int rank, long timestamp, double value) Populate a single element in the downsampled data set.
Constructor Details
LargestTriangleThreeBuckets
public LargestTriangleThreeBuckets(int threshold) Create a downsampler that reduces a series to at most this many points, choosing each point by the largest-triangle-three-buckets rule.- Parameters:
threshold- the number of buckets to downsample to
Method Details
downsizeImpl
public DownSampler.DataSet downsizeImpl(DownSampler.DataSet sampled, long[] timestamps, double[] values) Description copied from class:DownSampleImplReduces the source series into the pre-allocated output set. Implementations pick the ranks to keep, write them one slot at a time withDownSampleImpl.setDataSetLine(DownSampler.DataSet, int, long, double), and return that same set;DownSampleImpl.downsize(long[], double[])has already rejected inputs shorter than the output and mismatched array lengths.- Specified by:
downsizeImplin classDownSampleImpl- Parameters:
sampled- the empty output set allocated byDownSampleImpl.downsize(long[], double[]), holding exactly threshold timestamp and value slots to filltimestamps- the full source timestamps in seconds since the epoch, more than threshold in numbervalues- the full source values, the same length as timestamps- Returns:
- the same sampled set, with the threshold chosen ranks written into it