Search in sources :

Example 1 with DeserializationException

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

the class OutputEmitterTest method testWrongKeyClass.

@Test
public void testWrongKeyClass() {
    // Test for IntValue
    @SuppressWarnings({ "unchecked", "rawtypes" }) final TypeComparator<Record> doubleComp = new RecordComparatorFactory(new int[] { 0 }, new Class[] { DoubleValue.class }).createComparator();
    final ChannelSelector<SerializationDelegate<Record>> oe1 = new OutputEmitter<Record>(ShipStrategyType.PARTITION_HASH, doubleComp);
    final SerializationDelegate<Record> delegate = new SerializationDelegate<Record>(new RecordSerializerFactory().getSerializer());
    ;
    Record rec = null;
    try {
        PipedInputStream pipedInput = new PipedInputStream(1024 * 1024);
        DataInputView in = new DataInputViewStreamWrapper(pipedInput);
        DataOutputView out = new DataOutputViewStreamWrapper(new PipedOutputStream(pipedInput));
        rec = new Record(1);
        rec.setField(0, new IntValue());
        rec.write(out);
        rec = new Record();
        rec.read(in);
    } catch (IOException e) {
        fail("Test erroneous");
    }
    try {
        delegate.setInstance(rec);
        oe1.selectChannels(delegate, 100);
    } catch (DeserializationException re) {
        return;
    }
    Assert.fail("Expected a NullKeyFieldException.");
}
Also used : RecordComparatorFactory(org.apache.flink.runtime.testutils.recordutils.RecordComparatorFactory) DataInputView(org.apache.flink.core.memory.DataInputView) RecordSerializerFactory(org.apache.flink.runtime.testutils.recordutils.RecordSerializerFactory) SerializationDelegate(org.apache.flink.runtime.plugable.SerializationDelegate) DataOutputView(org.apache.flink.core.memory.DataOutputView) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) IOException(java.io.IOException) DataInputViewStreamWrapper(org.apache.flink.core.memory.DataInputViewStreamWrapper) DeserializationException(org.apache.flink.types.DeserializationException) OutputEmitter(org.apache.flink.runtime.operators.shipping.OutputEmitter) DataOutputViewStreamWrapper(org.apache.flink.core.memory.DataOutputViewStreamWrapper) DoubleValue(org.apache.flink.types.DoubleValue) Record(org.apache.flink.types.Record) IntValue(org.apache.flink.types.IntValue) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 DataInputView (org.apache.flink.core.memory.DataInputView)1 DataInputViewStreamWrapper (org.apache.flink.core.memory.DataInputViewStreamWrapper)1 DataOutputView (org.apache.flink.core.memory.DataOutputView)1 DataOutputViewStreamWrapper (org.apache.flink.core.memory.DataOutputViewStreamWrapper)1 OutputEmitter (org.apache.flink.runtime.operators.shipping.OutputEmitter)1 SerializationDelegate (org.apache.flink.runtime.plugable.SerializationDelegate)1 RecordComparatorFactory (org.apache.flink.runtime.testutils.recordutils.RecordComparatorFactory)1 RecordSerializerFactory (org.apache.flink.runtime.testutils.recordutils.RecordSerializerFactory)1 DeserializationException (org.apache.flink.types.DeserializationException)1 DoubleValue (org.apache.flink.types.DoubleValue)1 IntValue (org.apache.flink.types.IntValue)1 Record (org.apache.flink.types.Record)1 Test (org.junit.Test)1