use of com.srotya.sidewinder.core.storage.Series in project sidewinder by srotya.
the class TestTransformFunctions method testCeil.
@Test
public void testCeil() {
Function f = new CeilFunction();
List<Series> series = new ArrayList<>();
Series s = new Series(Arrays.asList(new DataPoint(1L, 3.2), new DataPoint(1L, 4.7)));
series.add(s);
List<Series> apply = f.apply(series);
assertEquals(2, apply.get(0).getDataPoints().size());
assertEquals(3.2, apply.get(0).getDataPoints().get(0).getValue(), 0.1);
assertEquals(4.7, apply.get(0).getDataPoints().get(1).getValue(), 0.1);
}
use of com.srotya.sidewinder.core.storage.Series 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.storage.Series 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.storage.Series 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.storage.Series in project sidewinder by srotya.
the class TestGRPWriterServiceImpl method testSingleDataPointWrites.
// @Test
public void testSingleDataPointWrites() throws Exception {
WriterServiceBlockingStub client = WriterServiceGrpc.newBlockingStub(channel);
long sts = 1497720452566L;
Point point = Point.newBuilder().setDbName("test").setFp(false).setMeasurementName("cpu").addTags("host=1").setTimestamp(sts).setValue(1L).setValueFieldName("usage").build();
client.writeSingleDataPoint(SingleData.newBuilder().setMessageId(point.getTimestamp()).setPoint(point).build());
assertTrue(engine.checkIfExists("test"));
assertTrue(engine.checkIfExists("test", "cpu"));
assertEquals("host=1", engine.getTagKeysForMeasurement("test", "cpu").iterator().next());
List<Series> result = engine.queryDataPoints("test", "cpu", "usage", sts, sts + 1, null);
assertEquals(1, result.size());
assertEquals(1, result.iterator().next().getDataPoints().size());
assertEquals(1L, result.iterator().next().getDataPoints().iterator().next().getLongValue());
}
Aggregations