Search in sources :

Example 1 with SerializablePair

use of org.apache.druid.collections.SerializablePair in project druid by druid-io.

the class LongLastAggregationTest method testCombine.

@Test
public void testCombine() {
    SerializablePair pair1 = new SerializablePair<>(1467225000L, 64432L);
    SerializablePair pair2 = new SerializablePair<>(1467240000L, 99999L);
    Assert.assertEquals(pair2, longLastAggFactory.combine(pair1, pair2));
}
Also used : SerializablePair(org.apache.druid.collections.SerializablePair) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 2 with SerializablePair

use of org.apache.druid.collections.SerializablePair in project druid by druid-io.

the class FloatLastAggregationTest method testComparatorWithNulls.

@Test
public void testComparatorWithNulls() {
    SerializablePair pair1 = new SerializablePair<>(1467225000L, 3.621f);
    SerializablePair pair2 = new SerializablePair<>(1467240000L, null);
    Comparator comparator = floatLastAggregatorFactory.getComparator();
    Assert.assertEquals(1, comparator.compare(pair1, pair2));
    Assert.assertEquals(0, comparator.compare(pair1, pair1));
    Assert.assertEquals(0, comparator.compare(pair2, pair2));
    Assert.assertEquals(-1, comparator.compare(pair2, pair1));
}
Also used : SerializablePair(org.apache.druid.collections.SerializablePair) Comparator(java.util.Comparator) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 3 with SerializablePair

use of org.apache.druid.collections.SerializablePair in project druid by druid-io.

the class FloatFirstAggregationTest method testCombine.

@Test
public void testCombine() {
    SerializablePair pair1 = new SerializablePair<>(1467225000L, 3.621f);
    SerializablePair pair2 = new SerializablePair<>(1467240000L, 785.4f);
    Assert.assertEquals(pair1, floatFirstAggregatorFactory.combine(pair1, pair2));
}
Also used : SerializablePair(org.apache.druid.collections.SerializablePair) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 4 with SerializablePair

use of org.apache.druid.collections.SerializablePair in project druid by druid-io.

the class DoubleFirstAggregationTest method testComparatorWithNulls.

@Test
public void testComparatorWithNulls() {
    SerializablePair pair1 = new SerializablePair<>(1467225000L, 3.621);
    SerializablePair pair2 = new SerializablePair<>(1467240000L, null);
    Comparator comparator = doubleFirstAggFactory.getComparator();
    Assert.assertEquals(1, comparator.compare(pair1, pair2));
    Assert.assertEquals(0, comparator.compare(pair1, pair1));
    Assert.assertEquals(0, comparator.compare(pair2, pair2));
    Assert.assertEquals(-1, comparator.compare(pair2, pair1));
}
Also used : SerializablePair(org.apache.druid.collections.SerializablePair) Comparator(java.util.Comparator) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 5 with SerializablePair

use of org.apache.druid.collections.SerializablePair in project druid by druid-io.

the class DoubleFirstAggregationTest method testComparator.

@Test
public void testComparator() {
    SerializablePair pair1 = new SerializablePair<>(1467225000L, 3.621);
    SerializablePair pair2 = new SerializablePair<>(1467240000L, 785.4);
    Comparator comparator = doubleFirstAggFactory.getComparator();
    Assert.assertEquals(-1, comparator.compare(pair1, pair2));
    Assert.assertEquals(0, comparator.compare(pair1, pair1));
    Assert.assertEquals(0, comparator.compare(pair2, pair2));
    Assert.assertEquals(1, comparator.compare(pair2, pair1));
}
Also used : SerializablePair(org.apache.druid.collections.SerializablePair) Comparator(java.util.Comparator) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

SerializablePair (org.apache.druid.collections.SerializablePair)13 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)13 Test (org.junit.Test)13 Comparator (java.util.Comparator)7