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