Search in sources :

Example 1 with StringFormatInfo

use of org.apache.inlong.sort.formats.common.StringFormatInfo in project incubator-inlong by apache.

the class RecordTransformerTest method testRecordMatchSerializer.

@Test
public void testRecordMatchSerializer() throws Exception {
    final int bufferSize = 1024;
    final RecordTransformer transformer = new RecordTransformer(bufferSize);
    final FieldInfo field1 = new FieldInfo("field1", new LongFormatInfo());
    final FieldInfo field2 = new FieldInfo("field2", new StringFormatInfo());
    final TestingSinkInfo sinkInfo = new TestingSinkInfo(new FieldInfo[] { field1, field2 });
    final DataFlowInfo dataFlowInfo = new DataFlowInfo(1L, new EmptySourceInfo(), sinkInfo);
    transformer.addDataFlow(dataFlowInfo);
    Map<Long, RowSerializer> rowSerializers = transformer.getRowSerializers();
    final Row row = new Row(2);
    row.setField(0, 1024L);
    row.setField(1, "9527");
    final Record record = new Record(1L, System.currentTimeMillis(), row);
    assertSame(record, transformer.matchRecordAndSerializerField(record, rowSerializers.get(1L)));
}
Also used : RowSerializer(org.apache.flink.api.java.typeutils.runtime.RowSerializer) SerializedRecord(org.apache.inlong.sort.flink.SerializedRecord) Record(org.apache.inlong.sort.flink.Record) LongFormatInfo(org.apache.inlong.sort.formats.common.LongFormatInfo) TestingSinkInfo(org.apache.inlong.sort.util.TestingUtils.TestingSinkInfo) Row(org.apache.flink.types.Row) EmptySourceInfo(org.apache.inlong.sort.util.TestingUtils.EmptySourceInfo) StringFormatInfo(org.apache.inlong.sort.formats.common.StringFormatInfo) FieldInfo(org.apache.inlong.sort.protocol.FieldInfo) DataFlowInfo(org.apache.inlong.sort.protocol.DataFlowInfo) Test(org.junit.Test)

Example 2 with StringFormatInfo

use of org.apache.inlong.sort.formats.common.StringFormatInfo in project incubator-inlong by apache.

the class RecordTransformerTest method testRecordNotMatchSerializer.

@Test
public void testRecordNotMatchSerializer() throws Exception {
    final int bufferSize = 1024;
    final RecordTransformer transformer = new RecordTransformer(bufferSize);
    final FieldInfo field1 = new FieldInfo("field1", new LongFormatInfo());
    final FieldInfo field2 = new FieldInfo("field2", new StringFormatInfo());
    final TestingSinkInfo sinkInfo = new TestingSinkInfo(new FieldInfo[] { field1, field2 });
    final DataFlowInfo dataFlowInfo = new DataFlowInfo(1L, new EmptySourceInfo(), sinkInfo);
    transformer.addDataFlow(dataFlowInfo);
    Map<Long, RowSerializer> rowSerializers = transformer.getRowSerializers();
    final Row oneFieldRow = new Row(1);
    oneFieldRow.setField(0, 1024L);
    final Record oneFieldRecord = new Record(1L, System.currentTimeMillis(), oneFieldRow);
    assertEquals(2, transformer.matchRecordAndSerializerField(oneFieldRecord, rowSerializers.get(1L)).getRow().getArity());
    final Row threeFieldRow = new Row(3);
    threeFieldRow.setField(0, 1024L);
    threeFieldRow.setField(1, "9527");
    threeFieldRow.setField(2, 2048);
    final Record threeFieldRecord = new Record(1L, System.currentTimeMillis(), threeFieldRow);
    assertEquals(2, transformer.matchRecordAndSerializerField(threeFieldRecord, rowSerializers.get(1L)).getRow().getArity());
}
Also used : RowSerializer(org.apache.flink.api.java.typeutils.runtime.RowSerializer) SerializedRecord(org.apache.inlong.sort.flink.SerializedRecord) Record(org.apache.inlong.sort.flink.Record) LongFormatInfo(org.apache.inlong.sort.formats.common.LongFormatInfo) TestingSinkInfo(org.apache.inlong.sort.util.TestingUtils.TestingSinkInfo) Row(org.apache.flink.types.Row) EmptySourceInfo(org.apache.inlong.sort.util.TestingUtils.EmptySourceInfo) StringFormatInfo(org.apache.inlong.sort.formats.common.StringFormatInfo) FieldInfo(org.apache.inlong.sort.protocol.FieldInfo) DataFlowInfo(org.apache.inlong.sort.protocol.DataFlowInfo) Test(org.junit.Test)

Example 3 with StringFormatInfo

use of org.apache.inlong.sort.formats.common.StringFormatInfo in project incubator-inlong by apache.

the class RowToDebeziumJsonKafkaSinkTest method prepareData.

@Override
protected void prepareData() throws IOException, ClassNotFoundException {
    topic = "test_kafka_row_to_debezium";
    fieldInfos = new FieldInfo[] { new FieldInfo("f1", new StringFormatInfo()), new FieldInfo("f2", new IntFormatInfo()) };
    serializationSchema = SerializationSchemaFactory.build(fieldInfos, new DebeziumSerializationInfo("sql", "literal", "null", true));
    prepareTestData();
}
Also used : DebeziumSerializationInfo(org.apache.inlong.sort.protocol.serialization.DebeziumSerializationInfo) IntFormatInfo(org.apache.inlong.sort.formats.common.IntFormatInfo) StringFormatInfo(org.apache.inlong.sort.formats.common.StringFormatInfo) FieldInfo(org.apache.inlong.sort.protocol.FieldInfo)

Example 4 with StringFormatInfo

use of org.apache.inlong.sort.formats.common.StringFormatInfo in project incubator-inlong by apache.

the class RowToJsonKafkaSinkTest method prepareData.

@Override
protected void prepareData() throws IOException, ClassNotFoundException {
    topic = "test_kafka_row_to_json";
    serializationSchema = SerializationSchemaFactory.build(new FieldInfo[] { new FieldInfo("f1", new StringFormatInfo()), new FieldInfo("f2", new MapFormatInfo(new StringFormatInfo(), new DoubleFormatInfo())), new FieldInfo("f3", new ArrayFormatInfo(new IntFormatInfo())) }, new JsonSerializationInfo());
    prepareTestRows();
}
Also used : MapFormatInfo(org.apache.inlong.sort.formats.common.MapFormatInfo) IntFormatInfo(org.apache.inlong.sort.formats.common.IntFormatInfo) ArrayFormatInfo(org.apache.inlong.sort.formats.common.ArrayFormatInfo) DoubleFormatInfo(org.apache.inlong.sort.formats.common.DoubleFormatInfo) JsonSerializationInfo(org.apache.inlong.sort.protocol.serialization.JsonSerializationInfo) StringFormatInfo(org.apache.inlong.sort.formats.common.StringFormatInfo) FieldInfo(org.apache.inlong.sort.protocol.FieldInfo)

Example 5 with StringFormatInfo

use of org.apache.inlong.sort.formats.common.StringFormatInfo in project incubator-inlong by apache.

the class RowToStringKafkaSinkTest method prepareData.

@Override
protected void prepareData() throws IOException, ClassNotFoundException {
    topic = "test_kafka_row_to_string";
    serializationSchema = SerializationSchemaFactory.build(new FieldInfo[] { new FieldInfo("f1", new StringFormatInfo()), new FieldInfo("f2", new DoubleFormatInfo()) }, null);
    testRows = new ArrayList<>();
    testRows.add(Row.of("f1", 12.0));
    testRows.add(Row.of("f2", 12.1));
    testRows.add(Row.of("f3", 12.3));
}
Also used : DoubleFormatInfo(org.apache.inlong.sort.formats.common.DoubleFormatInfo) StringFormatInfo(org.apache.inlong.sort.formats.common.StringFormatInfo) FieldInfo(org.apache.inlong.sort.protocol.FieldInfo)

Aggregations

StringFormatInfo (org.apache.inlong.sort.formats.common.StringFormatInfo)17 FieldInfo (org.apache.inlong.sort.protocol.FieldInfo)16 Test (org.junit.Test)10 IntFormatInfo (org.apache.inlong.sort.formats.common.IntFormatInfo)7 LongFormatInfo (org.apache.inlong.sort.formats.common.LongFormatInfo)7 Row (org.apache.flink.types.Row)6 Record (org.apache.inlong.sort.flink.Record)6 DataFlowInfo (org.apache.inlong.sort.protocol.DataFlowInfo)6 BuiltInFieldInfo (org.apache.inlong.sort.protocol.BuiltInFieldInfo)5 TestingSinkInfo (org.apache.inlong.sort.util.TestingUtils.TestingSinkInfo)5 SerializedRecord (org.apache.inlong.sort.flink.SerializedRecord)4 ArrayFormatInfo (org.apache.inlong.sort.formats.common.ArrayFormatInfo)4 DoubleFormatInfo (org.apache.inlong.sort.formats.common.DoubleFormatInfo)4 MapFormatInfo (org.apache.inlong.sort.formats.common.MapFormatInfo)4 EmptySourceInfo (org.apache.inlong.sort.util.TestingUtils.EmptySourceInfo)4 ByteFormatInfo (org.apache.inlong.sort.formats.common.ByteFormatInfo)3 FormatInfo (org.apache.inlong.sort.formats.common.FormatInfo)3 RowFormatInfo (org.apache.inlong.sort.formats.common.RowFormatInfo)3 Timestamp (java.sql.Timestamp)2 HashMap (java.util.HashMap)2