java.lang.Object
eu.bengreen.data.utility.DownSampleImpl
- All Implemented Interfaces:
DownSampler
- Direct Known Subclasses:
LargestTriangleThreeBuckets, LargestTriangleThreeBucketsTime
Naive implementation of down sample with simple array input Largest-Triangle-Three-Buckets, from Sveinn Steinarsson's thesis, section 4.2..
Nested Class Summary
Nested classes/interfaces inherited from interface DownSampler
DownSampler.DataSetModifier and TypeInterfaceDescriptionstatic classRepresents a dataset containing timestamps and corresponding values.Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intNumber of data points to downsample to.Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDownSampleImpl(int threshold) Number of data points to downsample to.Method Summary
Modifier and TypeMethodDescriptiondownsize(long[] timestamps, double[] values) Downsample the given data.protected abstract DownSampler.DataSetdownsizeImpl(DownSampler.DataSet sampled, long[] timestamps, double[] values) Reduces the source series into the pre-allocated output set.protected voidsetDataSetLine(DownSampler.DataSet sampled, int rank, long timestamp, double value) Populate a single element in the downsampled data set.
Field Details
threshold
protected final int thresholdNumber of data points to downsample to.
Constructor Details
DownSampleImpl
protected DownSampleImpl(int threshold) Number of data points to downsample to.- Parameters:
threshold- number of data points to downsample to
Method Details
setDataSetLine
Populate a single element in the downsampled data set.- Parameters:
sampled- the data set receiving the timestamp and value at this rankrank- the position within the downsampled data set to writetimestamp- the source timestamp, in seconds since the epochvalue- the source value retained for this rank
downsize
Description copied from interface:DownSamplerDownsample the given data.- Specified by:
downsizein interfaceDownSampler- Parameters:
timestamps- the timestamps, parallel to valuesvalues- the values, parallel to timestamps- Returns:
- the downsampled data set
downsizeImpl
protected abstract DownSampler.DataSet downsizeImpl(DownSampler.DataSet sampled, long[] timestamps, double[] values) Reduces the source series into the pre-allocated output set. Implementations pick the ranks to keep, write them one slot at a time withsetDataSetLine(DownSampler.DataSet, int, long, double), and return that same set;downsize(long[], double[])has already rejected inputs shorter than the output and mismatched array lengths.- Parameters:
sampled- the empty output set allocated bydownsize(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