Search in sources :

Example 1 with FloatValue

use of org.apache.flink.types.FloatValue in project flink by apache.

the class FloatValueComparator method compareToReference.

@Override
public int compareToReference(TypeComparator<FloatValue> referencedComparator) {
    FloatValue otherRef = ((FloatValueComparator) referencedComparator).reference;
    int comp = otherRef.compareTo(reference);
    return ascendingComparison ? comp : -comp;
}
Also used : FloatValue(org.apache.flink.types.FloatValue)

Example 2 with FloatValue

use of org.apache.flink.types.FloatValue in project flink by apache.

the class FloatValueComparatorTest method getSortedTestData.

@Override
protected FloatValue[] getSortedTestData() {
    Random rnd = new Random(874597969123412338L);
    float rndFloat = rnd.nextFloat();
    if (rndFloat < 0) {
        rndFloat = -rndFloat;
    }
    if (rndFloat == Float.MAX_VALUE) {
        rndFloat -= 3;
    }
    if (rndFloat <= 2) {
        rndFloat += 3;
    }
    return new FloatValue[] { new FloatValue(-rndFloat), new FloatValue(-1.0F), new FloatValue(0.0F), new FloatValue(2.0F), new FloatValue(rndFloat), new FloatValue(Float.MAX_VALUE) };
}
Also used : Random(java.util.Random) FloatValue(org.apache.flink.types.FloatValue)

Example 3 with FloatValue

use of org.apache.flink.types.FloatValue in project flink by apache.

the class FloatValueSerializerTest method getTestData.

@Override
protected FloatValue[] getTestData() {
    Random rnd = new Random(874597969123412341L);
    float rndFloat = rnd.nextFloat() * Float.MAX_VALUE;
    return new FloatValue[] { new FloatValue(0), new FloatValue(1), new FloatValue(-1), new FloatValue(Float.MAX_VALUE), new FloatValue(Float.MIN_VALUE), new FloatValue(rndFloat), new FloatValue(-rndFloat), new FloatValue(Float.NaN), new FloatValue(Float.NEGATIVE_INFINITY), new FloatValue(Float.POSITIVE_INFINITY) };
}
Also used : Random(java.util.Random) FloatValue(org.apache.flink.types.FloatValue)

Example 4 with FloatValue

use of org.apache.flink.types.FloatValue in project flink by apache.

the class ToNullValueTest method testTranslation.

@Test
public void testTranslation() throws Exception {
    NullValue reuse = NullValue.getInstance();
    assertEquals(NullValue.getInstance(), new ToNullValue<>().translate(new DoubleValue(), reuse));
    assertEquals(NullValue.getInstance(), new ToNullValue<>().translate(new FloatValue(), reuse));
    assertEquals(NullValue.getInstance(), new ToNullValue<>().translate(new IntValue(), reuse));
    assertEquals(NullValue.getInstance(), new ToNullValue<>().translate(new LongValue(), reuse));
    assertEquals(NullValue.getInstance(), new ToNullValue<>().translate(new StringValue(), reuse));
}
Also used : NullValue(org.apache.flink.types.NullValue) DoubleValue(org.apache.flink.types.DoubleValue) LongValue(org.apache.flink.types.LongValue) FloatValue(org.apache.flink.types.FloatValue) StringValue(org.apache.flink.types.StringValue) IntValue(org.apache.flink.types.IntValue) Test(org.junit.Test)

Aggregations

FloatValue (org.apache.flink.types.FloatValue)4 Random (java.util.Random)2 DoubleValue (org.apache.flink.types.DoubleValue)1 IntValue (org.apache.flink.types.IntValue)1 LongValue (org.apache.flink.types.LongValue)1 NullValue (org.apache.flink.types.NullValue)1 StringValue (org.apache.flink.types.StringValue)1 Test (org.junit.Test)1