Search in sources :

Example 1 with TestThriftMessage

use of org.apache.beam.sdk.io.thrift.payloads.TestThriftMessage in project beam by apache.

the class BeamKafkaTableThriftTest method generateEncodedPayload.

@Override
protected byte[] generateEncodedPayload(int i) {
    final TestThriftMessage message = new TestThriftMessage().setFLong(i).setFInt(i).setFDouble(i).setFString("thrift_value" + i);
    message.addToFDoubleArray(i);
    try {
        return new TSerializer(protocolFactory).serialize(message);
    } catch (TException e) {
        throw new RuntimeException(e);
    }
}
Also used : TException(org.apache.thrift.TException) TSerializer(org.apache.thrift.TSerializer) TestThriftMessage(org.apache.beam.sdk.io.thrift.payloads.TestThriftMessage)

Example 2 with TestThriftMessage

use of org.apache.beam.sdk.io.thrift.payloads.TestThriftMessage in project beam by apache.

the class ThriftPayloadSerializerProviderTest method serialize.

@Test
public void serialize() throws Exception {
    byte[] bytes = provider.getSerializer(SHUFFLED_SCHEMA, ImmutableMap.of("thriftClass", TestThriftMessage.class.getName(), "thriftProtocolFactoryClass", TCompactProtocol.Factory.class.getName())).serialize(ROW);
    TestThriftMessage result = new TestThriftMessage();
    new TDeserializer(new TCompactProtocol.Factory()).deserialize(result, bytes);
    assertEquals(MESSAGE, result);
}
Also used : TDeserializer(org.apache.thrift.TDeserializer) TestThriftMessage(org.apache.beam.sdk.io.thrift.payloads.TestThriftMessage) Test(org.junit.Test)

Aggregations

TestThriftMessage (org.apache.beam.sdk.io.thrift.payloads.TestThriftMessage)2 TDeserializer (org.apache.thrift.TDeserializer)1 TException (org.apache.thrift.TException)1 TSerializer (org.apache.thrift.TSerializer)1 Test (org.junit.Test)1