org.apache.flink.api.common.typeutils.ComparatorTestBase.TestOutputView Java Examples
The following examples show how to use
org.apache.flink.api.common.typeutils.ComparatorTestBase.TestOutputView.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EitherSerializerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testSerializeIndividually() throws IOException { EitherTypeInfo<LongValue, DoubleValue> eitherTypeInfo = new EitherTypeInfo<>( ValueTypeInfo.LONG_VALUE_TYPE_INFO, ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO); EitherSerializer<LongValue, DoubleValue> eitherSerializer = (EitherSerializer<LongValue, DoubleValue>) eitherTypeInfo.createSerializer(new ExecutionConfig()); LongValue lv = new LongValue(); DoubleValue dv = new DoubleValue(); Either<LongValue, DoubleValue> left = Left(lv); Either<LongValue, DoubleValue> right = Right(dv); TestOutputView out = new TestOutputView(); eitherSerializer.serialize(left, out); eitherSerializer.serialize(right, out); eitherSerializer.serialize(left, out); TestInputView in = out.getInputView(); // the first deserialization creates a new instance of Left Either<LongValue, DoubleValue> copy0 = eitherSerializer.deserialize(right, in); // then the cross-references are used for future copies Either<LongValue, DoubleValue> copy1 = eitherSerializer.deserialize(copy0, in); Either<LongValue, DoubleValue> copy2 = eitherSerializer.deserialize(copy1, in); // validate reference equality assertSame(right, copy1); assertSame(copy0, copy2); // validate reference equality of contained objects assertSame(right.right(), copy1.right()); assertSame(copy0.left(), copy2.left()); }
Example #2
Source File: EitherSerializerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSerializeIndividually() throws IOException { EitherTypeInfo<LongValue, DoubleValue> eitherTypeInfo = new EitherTypeInfo<>( ValueTypeInfo.LONG_VALUE_TYPE_INFO, ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO); EitherSerializer<LongValue, DoubleValue> eitherSerializer = (EitherSerializer<LongValue, DoubleValue>) eitherTypeInfo.createSerializer(new ExecutionConfig()); LongValue lv = new LongValue(); DoubleValue dv = new DoubleValue(); Either<LongValue, DoubleValue> left = Left(lv); Either<LongValue, DoubleValue> right = Right(dv); TestOutputView out = new TestOutputView(); eitherSerializer.serialize(left, out); eitherSerializer.serialize(right, out); eitherSerializer.serialize(left, out); TestInputView in = out.getInputView(); // the first deserialization creates a new instance of Left Either<LongValue, DoubleValue> copy0 = eitherSerializer.deserialize(right, in); // then the cross-references are used for future copies Either<LongValue, DoubleValue> copy1 = eitherSerializer.deserialize(copy0, in); Either<LongValue, DoubleValue> copy2 = eitherSerializer.deserialize(copy1, in); // validate reference equality assertSame(right, copy1); assertSame(copy0, copy2); // validate reference equality of contained objects assertSame(right.right(), copy1.right()); assertSame(copy0.left(), copy2.left()); }
Example #3
Source File: EitherSerializerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSerializeIndividually() throws IOException { EitherTypeInfo<LongValue, DoubleValue> eitherTypeInfo = new EitherTypeInfo<>( ValueTypeInfo.LONG_VALUE_TYPE_INFO, ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO); EitherSerializer<LongValue, DoubleValue> eitherSerializer = (EitherSerializer<LongValue, DoubleValue>) eitherTypeInfo.createSerializer(new ExecutionConfig()); LongValue lv = new LongValue(); DoubleValue dv = new DoubleValue(); Either<LongValue, DoubleValue> left = Left(lv); Either<LongValue, DoubleValue> right = Right(dv); TestOutputView out = new TestOutputView(); eitherSerializer.serialize(left, out); eitherSerializer.serialize(right, out); eitherSerializer.serialize(left, out); TestInputView in = out.getInputView(); // the first deserialization creates a new instance of Left Either<LongValue, DoubleValue> copy0 = eitherSerializer.deserialize(right, in); // then the cross-references are used for future copies Either<LongValue, DoubleValue> copy1 = eitherSerializer.deserialize(copy0, in); Either<LongValue, DoubleValue> copy2 = eitherSerializer.deserialize(copy1, in); // validate reference equality assertSame(right, copy1); assertSame(copy0, copy2); // validate reference equality of contained objects assertSame(right.right(), copy1.right()); assertSame(copy0.left(), copy2.left()); }