use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestScale method evaluateFactor1GroupByLong.
@Test
public void evaluateFactor1GroupByLong() throws Exception {
params.add("1");
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.metricNameAsync()).thenReturn(Deferred.fromResult("sys.mem"));
group_bys = new DataPoints[] { dps, dps2 };
query_results.clear();
query_results.add(group_bys);
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(2, results.length);
assertEquals(METRIC, results[0].metricName());
assertEquals("sys.mem", 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 TestScale method evaluateFactor1024GroupBy.
@Test
public void evaluateFactor1024GroupBy() throws Exception {
params.add("1024");
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.metricNameAsync()).thenReturn(Deferred.fromResult("sys.mem"));
group_bys = new DataPoints[] { dps, dps2 };
query_results.clear();
query_results.add(group_bys);
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(2, results.length);
assertEquals(METRIC, results[0].metricName());
assertEquals("sys.mem", results[1].metricName());
long ts = START_TIME;
long v = 1024;
for (DataPoint dp : results[0]) {
assertEquals(ts, dp.timestamp());
assertTrue(dp.isInteger());
assertEquals(v, dp.longValue());
ts += INTERVAL;
v += 1024;
}
ts = START_TIME;
v = 10240;
for (DataPoint dp : results[1]) {
assertEquals(ts, dp.timestamp());
assertTrue(dp.isInteger());
assertEquals(v, dp.longValue());
ts += INTERVAL;
v += 1024;
}
}
use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestScale method evaluateFactor0GroupByLong.
@Test
public void evaluateFactor0GroupByLong() throws Exception {
params.add("0");
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.metricNameAsync()).thenReturn(Deferred.fromResult("sys.mem"));
group_bys = new DataPoints[] { dps, dps2 };
query_results.clear();
query_results.add(group_bys);
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(2, results.length);
assertEquals(METRIC, results[0].metricName());
assertEquals("sys.mem", results[1].metricName());
long ts = START_TIME;
for (DataPoint dp : results[0]) {
assertEquals(ts, dp.timestamp());
assertTrue(dp.isInteger());
assertEquals(0, dp.longValue());
ts += INTERVAL;
}
ts = START_TIME;
for (DataPoint dp : results[1]) {
assertEquals(ts, dp.timestamp());
assertTrue(dp.isInteger());
assertEquals(0, dp.longValue());
ts += INTERVAL;
}
}
use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestScale method evaluateFactor1GroupByDouble.
@Test
public void evaluateFactor1GroupByDouble() throws Exception {
params.add("1");
SeekableView view2 = SeekableViewsForTest.generator(START_TIME, INTERVAL, NUM_POINTS, false, 10, 1.5);
DataPoints dps2 = PowerMockito.mock(DataPoints.class);
when(dps2.iterator()).thenReturn(view2);
when(dps2.metricNameAsync()).thenReturn(Deferred.fromResult("sys.mem"));
group_bys = new DataPoints[] { dps, dps2 };
query_results.clear();
query_results.add(group_bys);
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(2, results.length);
assertEquals(METRIC, results[0].metricName());
assertEquals("sys.mem", results[1].metricName());
long ts = START_TIME;
double v = 1;
for (DataPoint dp : results[0]) {
assertEquals(ts, dp.timestamp());
assertTrue(dp.isInteger());
assertEquals((long) v, dp.longValue());
ts += INTERVAL;
v += 1;
}
ts = START_TIME;
v = 10;
for (DataPoint dp : results[1]) {
assertEquals(ts, dp.timestamp());
assertFalse(dp.isInteger());
assertEquals(v, dp.doubleValue(), 0.001);
ts += INTERVAL;
v += 1.5;
}
}
use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestScale method evaluateFactor1SubQuerySeries.
@Test
public void evaluateFactor1SubQuerySeries() throws Exception {
params.add("1");
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.metricNameAsync()).thenReturn(Deferred.fromResult("sys.mem"));
group_bys = new DataPoints[] { dps, dps2 };
query_results.clear();
query_results.add(group_bys);
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(2, results.length);
assertEquals(METRIC, results[0].metricName());
assertEquals("sys.mem", 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;
}
}
Aggregations