Search in sources :

Example 1 with Right

use of org.apache.flink.types.Either.Right in project flink by apache.

the class EitherSerializerTest method testStringValueDoubleValueEither.

@Test
public void testStringValueDoubleValueEither() {
    @SuppressWarnings("unchecked") Either<StringValue, DoubleValue>[] testData = new Either[] { Left(new StringValue("banana")), Left.of(new StringValue("apple")), new Left(new StringValue("")), Right(new DoubleValue(32.0)), Right.of(new DoubleValue(Double.MIN_VALUE)), new Right(new DoubleValue(Double.MAX_VALUE)) };
    EitherTypeInfo<StringValue, DoubleValue> eitherTypeInfo = new EitherTypeInfo<>(ValueTypeInfo.STRING_VALUE_TYPE_INFO, ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO);
    EitherSerializer<StringValue, DoubleValue> eitherSerializer = (EitherSerializer<StringValue, DoubleValue>) eitherTypeInfo.createSerializer(new ExecutionConfig());
    SerializerTestInstance<Either<StringValue, DoubleValue>> testInstance = new EitherSerializerTestInstance<>(eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData);
    testInstance.testAll();
}
Also used : Left(org.apache.flink.types.Either.Left) Right(org.apache.flink.types.Either.Right) EitherTypeInfo(org.apache.flink.api.java.typeutils.EitherTypeInfo) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) DoubleValue(org.apache.flink.types.DoubleValue) Either(org.apache.flink.types.Either) StringValue(org.apache.flink.types.StringValue) Test(org.junit.Test)

Example 2 with Right

use of org.apache.flink.types.Either.Right in project flink by apache.

the class EitherSerializerTest method testEitherWithTupleValues.

@Test
public void testEitherWithTupleValues() {
    @SuppressWarnings("unchecked") Either<Tuple2<LongValue, LongValue>, DoubleValue>[] testData = new Either[] { Left(new Tuple2<>(new LongValue(2L), new LongValue(9L))), new Left<>(new Tuple2<>(new LongValue(Long.MIN_VALUE), new LongValue(Long.MAX_VALUE))), new Right<>(new DoubleValue(32.0)), Right(new DoubleValue(Double.MIN_VALUE)), Right(new DoubleValue(Double.MAX_VALUE)) };
    EitherTypeInfo<Tuple2<LongValue, LongValue>, DoubleValue> eitherTypeInfo = new EitherTypeInfo<>(new TupleTypeInfo<Tuple2<LongValue, LongValue>>(ValueTypeInfo.LONG_VALUE_TYPE_INFO, ValueTypeInfo.LONG_VALUE_TYPE_INFO), ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO);
    EitherSerializer<Tuple2<LongValue, LongValue>, DoubleValue> eitherSerializer = (EitherSerializer<Tuple2<LongValue, LongValue>, DoubleValue>) eitherTypeInfo.createSerializer(new ExecutionConfig());
    SerializerTestInstance<Either<Tuple2<LongValue, LongValue>, DoubleValue>> testInstance = new EitherSerializerTestInstance<>(eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData);
    testInstance.testAll();
}
Also used : Left(org.apache.flink.types.Either.Left) Right(org.apache.flink.types.Either.Right) EitherTypeInfo(org.apache.flink.api.java.typeutils.EitherTypeInfo) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) DoubleValue(org.apache.flink.types.DoubleValue) Tuple2(org.apache.flink.api.java.tuple.Tuple2) LongValue(org.apache.flink.types.LongValue) Either(org.apache.flink.types.Either) Test(org.junit.Test)

Aggregations

ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)2 EitherTypeInfo (org.apache.flink.api.java.typeutils.EitherTypeInfo)2 DoubleValue (org.apache.flink.types.DoubleValue)2 Either (org.apache.flink.types.Either)2 Left (org.apache.flink.types.Either.Left)2 Right (org.apache.flink.types.Either.Right)2 Test (org.junit.Test)2 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1 LongValue (org.apache.flink.types.LongValue)1 StringValue (org.apache.flink.types.StringValue)1