Search in sources :

Example 21 with SeekableView

use of net.opentsdb.core.SeekableView in project opentsdb by OpenTSDB.

the class TestHighestMax method evaluateTopN100with2SeriesLong.

@Test
public void evaluateTopN100with2SeriesLong() throws Exception {
    params.add("100");
    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"));
    DataPoints[] group_bys2 = new DataPoints[] { dps2 };
    query_results.add(group_bys2);
    final DataPoints[] results = func.evaluate(data_query, query_results, params);
    assertEquals(2, results.length);
    assertEquals("sys.mem", results[0].metricName());
    assertEquals(METRIC, results[1].metricName());
    long ts = START_TIME;
    long v = 10;
    for (DataPoint dp : results[0]) {
        assertEquals(ts, dp.timestamp());
        assertTrue(dp.isInteger());
        assertEquals(v, dp.longValue());
        ts += INTERVAL;
        v += 1;
    }
    ts = START_TIME;
    v = 1;
    for (DataPoint dp : results[1]) {
        assertEquals(ts, dp.timestamp());
        assertTrue(dp.isInteger());
        assertEquals(v, dp.longValue());
        ts += INTERVAL;
        v += 1;
    }
}
Also used : DataPoint(net.opentsdb.core.DataPoint) SeekableView(net.opentsdb.core.SeekableView) DataPoints(net.opentsdb.core.DataPoints) Test(org.junit.Test) SeekableViewsForTest(net.opentsdb.core.SeekableViewsForTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 22 with SeekableView

use of net.opentsdb.core.SeekableView in project opentsdb by OpenTSDB.

the class TestScale method evaluateFactorNegative1GroupByLong.

@Test
public void evaluateFactorNegative1GroupByLong() 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;
    }
}
Also used : DataPoint(net.opentsdb.core.DataPoint) SeekableView(net.opentsdb.core.SeekableView) DataPoints(net.opentsdb.core.DataPoints) Test(org.junit.Test) SeekableViewsForTest(net.opentsdb.core.SeekableViewsForTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 23 with SeekableView

use of net.opentsdb.core.SeekableView 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;
    }
}
Also used : DataPoint(net.opentsdb.core.DataPoint) SeekableView(net.opentsdb.core.SeekableView) DataPoints(net.opentsdb.core.DataPoints) Test(org.junit.Test) SeekableViewsForTest(net.opentsdb.core.SeekableViewsForTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 24 with SeekableView

use of net.opentsdb.core.SeekableView 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;
    }
}
Also used : DataPoint(net.opentsdb.core.DataPoint) SeekableView(net.opentsdb.core.SeekableView) DataPoints(net.opentsdb.core.DataPoints) Test(org.junit.Test) SeekableViewsForTest(net.opentsdb.core.SeekableViewsForTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 25 with SeekableView

use of net.opentsdb.core.SeekableView 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;
    }
}
Also used : DataPoint(net.opentsdb.core.DataPoint) SeekableView(net.opentsdb.core.SeekableView) DataPoints(net.opentsdb.core.DataPoints) Test(org.junit.Test) SeekableViewsForTest(net.opentsdb.core.SeekableViewsForTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

SeekableView (net.opentsdb.core.SeekableView)54 DataPoint (net.opentsdb.core.DataPoint)50 DataPoints (net.opentsdb.core.DataPoints)50 Test (org.junit.Test)47 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)47 SeekableViewsForTest (net.opentsdb.core.SeekableViewsForTest)45 ArrayList (java.util.ArrayList)7 MutableDataPoint (net.opentsdb.core.MutableDataPoint)7 AggregationIterator (net.opentsdb.core.AggregationIterator)3 NoSuchElementException (java.util.NoSuchElementException)2 Callback (com.stumbleupon.async.Callback)1 Deferred (com.stumbleupon.async.Deferred)1 IOException (java.io.IOException)1 Map (java.util.Map)1 Aggregator (net.opentsdb.core.Aggregator)1 Query (net.opentsdb.core.Query)1 TSDB (net.opentsdb.core.TSDB)1 TSQuery (net.opentsdb.core.TSQuery)1 TSSubQuery (net.opentsdb.core.TSSubQuery)1 TopNSortingEntry (net.opentsdb.query.expression.HighestMax.TopNSortingEntry)1