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]);
}
}
Aggregations