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)));
}
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());
}
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();
}
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();
}
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));
}
Aggregations