use of com.srotya.sidewinder.core.storage.SeriesOutput in project sidewinder by srotya.
the class TestSingleValueAggregators method testMaxFunction.
@Test
public void testMaxFunction() {
MaxFunction f = new MaxFunction();
double[] values = { 2.2, 1.1, 3.3, 4.4 };
List<DataPoint> dps = new ArrayList<>();
long ts = System.currentTimeMillis();
for (double d : values) {
dps.add(MiscUtils.buildDataPoint(ts, d));
}
SeriesOutput series = new SeriesOutput();
series.setDataPoints(dps);
series.setFp(true);
SeriesOutput result = f.apply(series);
assertEquals(4.4, result.getDataPoints().get(0).getValue(), 0);
}
use of com.srotya.sidewinder.core.storage.SeriesOutput in project sidewinder by srotya.
the class TestSingleValueAggregators method testMinFunctionLong.
@Test
public void testMinFunctionLong() {
MinFunction f = new MinFunction();
long[] values = { 2, 1, 3, 4 };
List<DataPoint> dps = new ArrayList<>();
long ts = System.currentTimeMillis();
for (long d : values) {
dps.add(MiscUtils.buildDataPoint(ts, d));
}
SeriesOutput series = new SeriesOutput();
series.setDataPoints(dps);
SeriesOutput result = f.apply(series);
assertEquals(1, result.getDataPoints().get(0).getLongValue());
}
use of com.srotya.sidewinder.core.storage.SeriesOutput in project sidewinder by srotya.
the class TestWindowedFunctions method testWindowedFirst.
@Test
public void testWindowedFirst() throws Exception {
double[] values = { 1.1, 3.3, 2.2, 4.4 };
List<DataPoint> dps = new ArrayList<>();
long ts = 1486617103629L;
for (int i = 0; i < values.length; i++) {
double d = values[i];
ts = ts + (30_000);
dps.add(MiscUtils.buildDataPoint(ts, d));
}
WindowedAggregator rwa = new WindowedFirst();
rwa.init(new Object[] { 70, "smean" });
SeriesOutput series = new SeriesOutput();
series.setDataPoints(dps);
series.setFp(true);
List<DataPoint> result = rwa.apply(series).getDataPoints();
assertEquals(2, result.size());
assertEquals(1.1, result.get(0).getValue(), 0);
assertEquals(3.3, result.get(1).getValue(), 0);
}
use of com.srotya.sidewinder.core.storage.SeriesOutput in project sidewinder by srotya.
the class TestWindowedFunctions method testWindowedMean.
@Test
public void testWindowedMean() throws Exception {
double[] values = { 1.1, 2.2, 3.3, 4.4 };
List<DataPoint> dps = new ArrayList<>();
long ts = 1486617103629L;
for (int i = 0; i < values.length; i++) {
double d = values[i];
ts = ts + (30_000);
dps.add(MiscUtils.buildDataPoint(ts, d));
}
WindowedAggregator rwa = new WindowedMean();
rwa.init(new Object[] { 70, "smean" });
SeriesOutput series = new SeriesOutput();
series.setDataPoints(dps);
series.setFp(true);
List<DataPoint> result = rwa.apply(series).getDataPoints();
assertEquals(2, result.size());
assertEquals(1.1, result.get(0).getValue(), 0);
assertEquals(3.3, result.get(1).getValue(), 0.001);
}
use of com.srotya.sidewinder.core.storage.SeriesOutput in project sidewinder by srotya.
the class TestWindowedFunctions method testDerivativeAggregator2.
@Test
public void testDerivativeAggregator2() throws Exception {
long[] values = { 1, 4, 1, 4, 1 };
List<DataPoint> dps = new ArrayList<>();
long ts = 1486617103629L;
for (int i = 0; i < values.length; i++) {
long d = values[i];
ts = ts + (10_000);
dps.add(MiscUtils.buildDataPoint(ts, d));
}
WindowedAggregator rwa = new DerivativeFunction();
rwa.init(new Object[] { 20, "smean" });
SeriesOutput series = new SeriesOutput();
series.setDataPoints(dps);
series.setFp(false);
SeriesOutput result = rwa.apply(series);
assertEquals(1, result.getDataPoints().size());
assertEquals(false, result.isFp());
assertEquals(0, result.getDataPoints().get(0).getValue() * 1000, 0.01);
System.out.println(result.getDataPoints().get(0).getValue() * 1000 + "\t" + ts);
}
Aggregations