Search in sources :

Example 1 with TimeConversionTransform

use of com.linkedin.pinot.core.operator.transform.function.TimeConversionTransform in project pinot by linkedin.

the class TimeConversionTransformTest method test.

@Test
public void test() {
    long[] input = new long[NUM_ROWS];
    long[] expected = new long[NUM_ROWS];
    long seed = System.currentTimeMillis();
    Random random = new Random(seed);
    for (int i = 0; i < NUM_ROWS; i++) {
        input[i] = random.nextLong() % seed;
        expected[i] = TimeUnit.DAYS.convert(input[i], TimeUnit.MILLISECONDS);
    }
    TransformTestUtils.TestBlockValSet inputTimes = new TransformTestUtils.TestBlockValSet(input, NUM_ROWS);
    ConstantBlockValSet inputTimeUnit = new ConstantBlockValSet("MILLISECONDS", NUM_ROWS);
    ConstantBlockValSet outputTimeUnit = new ConstantBlockValSet("DAYS", NUM_ROWS);
    TimeConversionTransform function = new TimeConversionTransform();
    long[] actual = function.transform(NUM_ROWS, inputTimes, inputTimeUnit, outputTimeUnit);
    for (int i = 0; i < NUM_ROWS; i++) {
        Assert.assertEquals(actual[i], expected[i]);
    }
}
Also used : Random(java.util.Random) TimeConversionTransform(com.linkedin.pinot.core.operator.transform.function.TimeConversionTransform) ConstantBlockValSet(com.linkedin.pinot.core.operator.docvalsets.ConstantBlockValSet) Test(org.testng.annotations.Test)

Aggregations

ConstantBlockValSet (com.linkedin.pinot.core.operator.docvalsets.ConstantBlockValSet)1 TimeConversionTransform (com.linkedin.pinot.core.operator.transform.function.TimeConversionTransform)1 Random (java.util.Random)1 Test (org.testng.annotations.Test)1