Search in sources :

Example 16 with TestingTicker

use of io.airlift.testing.TestingTicker in project airlift by airlift.

the class TestQuantileDigest method testDecayedCountsWithClockIncrementSmallerThanRescaleThreshold.

@Test
public void testDecayedCountsWithClockIncrementSmallerThanRescaleThreshold() throws Exception {
    int targetAgeInSeconds = (int) (QuantileDigest.RESCALE_THRESHOLD_SECONDS - 1);
    TestingTicker ticker = new TestingTicker();
    QuantileDigest digest = new QuantileDigest(1, ExponentialDecay.computeAlpha(0.5, targetAgeInSeconds), ticker);
    addAll(digest, asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
    ticker.increment(targetAgeInSeconds, TimeUnit.SECONDS);
    addAll(digest, asList(10, 11, 12, 13, 14, 15, 16, 17, 18, 19));
    assertEquals(digest.getCount(), 15.0);
}
Also used : TestingTicker(io.airlift.testing.TestingTicker) Test(org.testng.annotations.Test)

Example 17 with TestingTicker

use of io.airlift.testing.TestingTicker in project airlift by airlift.

the class TestQuantileDigest method testDecayedCounts.

@Test
public void testDecayedCounts() throws Exception {
    TestingTicker ticker = new TestingTicker();
    QuantileDigest digest = new QuantileDigest(1, ExponentialDecay.computeAlpha(0.5, 60), ticker);
    addAll(digest, asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
    // should have no compressions with so few values and the allowed error
    assertEquals(digest.getConfidenceFactor(), 0.0);
    ticker.increment(60, TimeUnit.SECONDS);
    addAll(digest, asList(10, 11, 12, 13, 14, 15, 16, 17, 18, 19));
    assertEquals(digest.getCount(), 15.0);
}
Also used : TestingTicker(io.airlift.testing.TestingTicker) Test(org.testng.annotations.Test)

Aggregations

TestingTicker (io.airlift.testing.TestingTicker)17 Test (org.testng.annotations.Test)17 Duration (io.airlift.units.Duration)3 PRESTO_PAGES (com.facebook.presto.PrestoMediaTypes.PRESTO_PAGES)1 TaskHandle (com.facebook.presto.execution.TaskExecutor.TaskHandle)1 PagesSerde (com.facebook.presto.execution.buffer.PagesSerde)1 SerializedPage (com.facebook.presto.execution.buffer.SerializedPage)1 TestingPagesSerdeFactory.testingPagesSerde (com.facebook.presto.execution.buffer.TestingPagesSerdeFactory.testingPagesSerde)1 ClientCallback (com.facebook.presto.operator.HttpPageBufferClient.ClientCallback)1 Page (com.facebook.presto.spi.Page)1 PAGE_TOO_LARGE (com.facebook.presto.spi.StandardErrorCode.PAGE_TOO_LARGE)1 PAGE_TRANSPORT_ERROR (com.facebook.presto.spi.StandardErrorCode.PAGE_TRANSPORT_ERROR)1 PAGE_TRANSPORT_TIMEOUT (com.facebook.presto.spi.StandardErrorCode.PAGE_TRANSPORT_TIMEOUT)1 WORKER_NODE_ERROR (com.facebook.presto.util.Failures.WORKER_NODE_ERROR)1 Throwables (com.google.common.base.Throwables)1 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 CONTENT_TYPE (com.google.common.net.HttpHeaders.CONTENT_TYPE)1 Threads.daemonThreadsNamed (io.airlift.concurrent.Threads.daemonThreadsNamed)1 HttpStatus (io.airlift.http.client.HttpStatus)1 Request (io.airlift.http.client.Request)1