Search in sources :

Example 1 with MultiplicationTransform

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

the class MultiplicationTransformTest method test.

/**
   * Tests that multiplication for three columns (one int, one float and one double)
   * are as expected.
   */
@Test
public void test() {
    long seed = System.nanoTime();
    Random random = new Random(seed);
    double[] input1 = new double[NUM_ROWS];
    double[] input2 = new double[NUM_ROWS];
    double[] input3 = new double[NUM_ROWS];
    double[] expected = new double[NUM_ROWS];
    for (int i = 0; i < NUM_ROWS; i++) {
        input1[i] = random.nextInt(1000);
        input2[i] = random.nextFloat();
        input3[i] = random.nextDouble();
        expected[i] = input1[i] * input2[i] * input3[i];
    }
    TransformFunction function = new MultiplicationTransform();
    double[] actual = function.transform(NUM_ROWS, new TransformTestUtils.TestBlockValSet(input1, NUM_ROWS), new TransformTestUtils.TestBlockValSet(input2, NUM_ROWS), new TransformTestUtils.TestBlockValSet(input3, NUM_ROWS));
    for (int i = 0; i < NUM_ROWS; i++) {
        Assert.assertEquals(actual[i], expected[i], EPSILON, ("Random seed: " + seed));
    }
}
Also used : Random(java.util.Random) TransformFunction(com.linkedin.pinot.core.operator.transform.function.TransformFunction) MultiplicationTransform(com.linkedin.pinot.core.operator.transform.function.MultiplicationTransform) Test(org.testng.annotations.Test)

Aggregations

MultiplicationTransform (com.linkedin.pinot.core.operator.transform.function.MultiplicationTransform)1 TransformFunction (com.linkedin.pinot.core.operator.transform.function.TransformFunction)1 Random (java.util.Random)1 Test (org.testng.annotations.Test)1