use of com.srotya.sidewinder.core.functions.windowed.ReducingWindowedAggregator in project sidewinder by srotya.
the class TestWindowedFunctions method testIntegralFunction.
@Test
public void testIntegralFunction() 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));
}
ReducingWindowedAggregator rwa = new IntegralFunction();
rwa.init(new Object[] { 70, "smean" });
Series series = new Series();
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(9.9, result.get(1).getValue(), 0);
}
use of com.srotya.sidewinder.core.functions.windowed.ReducingWindowedAggregator in project sidewinder by srotya.
the class TestWindowedFunctions method testWindowedMax.
@Test
public void testWindowedMax() 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));
}
ReducingWindowedAggregator rwa = new WindowedMax();
rwa.init(new Object[] { 70, "smean" });
Series series = new Series();
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(4.4, result.get(1).getValue(), 0);
}
use of com.srotya.sidewinder.core.functions.windowed.ReducingWindowedAggregator in project sidewinder by srotya.
the class TestWindowedFunctions method testWindowedMin.
@Test
public void testWindowedMin() 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));
}
ReducingWindowedAggregator rwa = new WindowedMin();
rwa.init(new Object[] { 70, "smean" });
Series series = new Series();
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(2.2, result.get(1).getValue(), 0);
}
use of com.srotya.sidewinder.core.functions.windowed.ReducingWindowedAggregator in project sidewinder by srotya.
the class TestWindowedFunctions method testWindowedLast.
@Test
public void testWindowedLast() 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));
}
ReducingWindowedAggregator rwa = new WindowedLast();
rwa.init(new Object[] { 70, "smean" });
Series series = new Series();
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(4.4, result.get(1).getValue(), 0);
}
use of com.srotya.sidewinder.core.functions.windowed.ReducingWindowedAggregator in project sidewinder by srotya.
the class TestChainFunction method testSingleFunction.
@Test
public void testSingleFunction() throws Exception {
Series series = new Series("cpu", "test", Arrays.asList(new Tag("t", "1"), new Tag("t", "2")));
List<DataPoint> dps = new ArrayList<>();
long baseTs = 1486617103629L;
for (int i = 0; i < 4; i++) {
dps.add(new DataPoint(baseTs + 30_000 * i, 1));
}
series.setDataPoints(dps);
series.setFp(false);
List<Series> seriesList = Arrays.asList(series);
ChainFunction cf = new ChainFunction();
ReducingWindowedAggregator rwa = new WindowedMean();
rwa.init(new Object[] { 70, "smean" });
cf.init(new Function[] { rwa });
List<Series> apply = cf.apply(seriesList);
List<DataPoint> result = apply.get(0).getDataPoints();
assertEquals(2, result.size());
}
Aggregations