use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestAlias method evaluateWithTagsJoined.
@Test
public void evaluateWithTagsJoined() throws Exception {
SeekableView view2 = SeekableViewsForTest.generator(START_TIME, INTERVAL, NUM_POINTS, true, 10, 1);
DataPoints dps2 = PowerMockito.mock(DataPoints.class);
when(dps2.iterator()).thenReturn(view2);
when(dps2.metricName()).thenReturn("sys.mem");
when(dps2.getTagsAsync()).thenReturn(Deferred.fromResult(tags));
when(dps2.getTagUids()).thenReturn(tag_uids);
group_bys = new DataPoints[] { dps, dps2 };
query_results.clear();
query_results.add(group_bys);
params.add("My Alias");
params.add("@host");
params.add("@dc");
params.add("@none");
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(2, results.length);
assertEquals("My Alias,web01,lga,@none", results[0].metricName());
assertEquals("My Alias,web01,lga,@none", results[1].metricName());
}
use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestAlias method evaluateSubQuerySeries.
@Test
public void evaluateSubQuerySeries() throws Exception {
SeekableView view2 = SeekableViewsForTest.generator(START_TIME, INTERVAL, NUM_POINTS, true, -10, -1);
DataPoints dps2 = PowerMockito.mock(DataPoints.class);
when(dps2.iterator()).thenReturn(view2);
when(dps2.metricName()).thenReturn("sys.mem");
group_bys = new DataPoints[] { dps, dps2 };
query_results.clear();
query_results.add(group_bys);
params.add("My Alias");
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(2, results.length);
assertEquals("My Alias", results[0].metricName());
assertEquals("My Alias", results[1].metricName());
long ts = START_TIME;
long v = 1;
for (DataPoint dp : results[0]) {
assertEquals(ts, dp.timestamp());
assertTrue(dp.isInteger());
assertEquals(v, dp.longValue());
ts += INTERVAL;
v += 1;
}
ts = START_TIME;
v = 10;
for (DataPoint dp : results[1]) {
assertEquals(ts, dp.timestamp());
assertTrue(dp.isInteger());
assertEquals(v, dp.longValue());
ts += INTERVAL;
v += 1;
}
}
use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestDiffSeries method diffMultipleSeriesEach.
@Test
public void diffMultipleSeriesEach() throws Exception {
oneExtraSameE();
queryAB_Dstar();
query_results.clear();
query_results.add(results.get("1").getValue());
query_results.add(results.get("0").getValue());
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(3, results.length);
double val = 17;
for (int i = 0; i < results.length; i++) {
long ts = 1431561600000l;
final SeekableView it = results[i].iterator();
while (it.hasNext()) {
final DataPoint dp = it.next();
assertEquals(ts, dp.timestamp());
if (i < 2) {
assertEquals(10, dp.toDouble(), 0.0001);
} else {
assertEquals(val++, dp.toDouble(), 0.0001);
}
ts += INTERVAL;
}
}
}
use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestDiffSeries method diffOneSeriesEach.
@Test
public void diffOneSeriesEach() throws Exception {
SeekableView view2 = SeekableViewsForTest.generator(START_TIME, INTERVAL, NUM_POINTS, true, 10, 1);
DataPoints dps2 = PowerMockito.mock(DataPoints.class);
when(dps2.iterator()).thenReturn(view2);
when(dps2.metricName()).thenReturn("sys.mem");
when(dps2.metricUID()).thenReturn(new byte[] { 0, 0, 2 });
group_bys = new DataPoints[] { dps2 };
query_results.add(group_bys);
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(1, results.length);
assertEquals(METRIC_STRING, results[0].metricName());
long ts = START_TIME;
for (DataPoint dp : results[0]) {
assertEquals(ts, dp.timestamp());
assertEquals(-9, dp.toDouble(), 0.001);
ts += INTERVAL;
}
}
use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestDivideSeries method divideMultipleSeriesEach.
@Test
public void divideMultipleSeriesEach() throws Exception {
oneExtraSameE();
queryAB_Dstar();
query_results.clear();
query_results.add(results.get("1").getValue());
query_results.add(results.get("0").getValue());
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(3, results.length);
final int[][] vals = new int[2][];
vals[0] = new int[] { 11, 1 };
vals[1] = new int[] { 14, 4 };
for (int i = 0; i < results.length; i++) {
long ts = 1431561600000l;
final SeekableView it = results[i].iterator();
while (it.hasNext()) {
final DataPoint dp = it.next();
assertEquals(ts, dp.timestamp());
if (i < 2) {
assertEquals(((double) vals[i][0]++ / (double) vals[i][1]++), dp.toDouble(), 0.001);
} else {
assertEquals(0, dp.toDouble(), 0.0001);
}
ts += INTERVAL;
}
}
}
Aggregations