use of org.apache.inlong.sort.protocol.serialization.AvroSerializationInfo in project incubator-inlong by apache.
the class RowToAvroKafkaSinkTest method prepareData.
@Override
protected void prepareData() throws IOException, ClassNotFoundException {
fieldInfos = new FieldInfo[] { new FieldInfo("f1", new StringFormatInfo()), new FieldInfo("f2", new IntFormatInfo()), new FieldInfo("f3", new NullFormatInfo()), new FieldInfo("f4", new BinaryFormatInfo()), new FieldInfo("f5", new MapFormatInfo(new StringFormatInfo(), new RowFormatInfo(new String[] { "f51", "f52" }, new FormatInfo[] { new IntFormatInfo(), new ArrayFormatInfo(new DoubleFormatInfo()) }))) };
topic = "test_kafka_row_to_avro";
serializationSchema = SerializationSchemaFactory.build(fieldInfos, new AvroSerializationInfo());
prepareTestRows();
}
use of org.apache.inlong.sort.protocol.serialization.AvroSerializationInfo in project incubator-inlong by apache.
the class AvroDeserializationTest method testAvroDeserializationSchema.
@Test
public void testAvroDeserializationSchema() throws IOException, ClassNotFoundException {
SerializationSchema<Row> serializationSchema = SerializationSchemaFactory.build(fieldInfos, new AvroSerializationInfo());
Row expectedRow = generateTestRow();
byte[] bytes = serializationSchema.serialize(expectedRow);
DeserializationSchema<Row> deserializationSchema = DeserializationSchemaFactory.build(fieldInfos, new AvroDeserializationInfo());
Row actualRow = deserializationSchema.deserialize(bytes);
assertEquals(expectedRow, actualRow);
}
use of org.apache.inlong.sort.protocol.serialization.AvroSerializationInfo in project incubator-inlong by apache.
the class SerializationUtils method serializeForKafka.
/**
* Get serialization info for Kafka
*/
private static SerializationInfo serializeForKafka(SourceResponse sourceResponse, KafkaSinkResponse sinkResponse) {
String serializationType = sinkResponse.getSerializationType();
DataTypeEnum dataType = DataTypeEnum.forName(serializationType);
switch(dataType) {
case AVRO:
return new AvroSerializationInfo();
case JSON:
return new JsonSerializationInfo();
case CANAL:
return new CanalSerializationInfo();
case DEBEZIUM_JSON:
Assert.isInstanceOf(BinlogSourceResponse.class, sourceResponse, "Unsupported serializationType for Kafka");
BinlogSourceResponse binlogSource = (BinlogSourceResponse) sourceResponse;
return new DebeziumSerializationInfo(binlogSource.getTimestampFormatStandard(), "FAIL", "", false);
default:
throw new IllegalArgumentException(String.format("Unsupported serializationType for Kafka sink: %s", serializationType));
}
}
Aggregations