Search in sources :

Example 1 with IntFormatInfo

use of org.apache.inlong.sort.formats.common.IntFormatInfo 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 2 with IntFormatInfo

use of org.apache.inlong.sort.formats.common.IntFormatInfo 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 3 with IntFormatInfo

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

the class CommonUtilsTest method testBuildAvroRecordSchemaInJsonForRecursiveFields.

@Test
public void testBuildAvroRecordSchemaInJsonForRecursiveFields() throws IOException {
    FieldInfo[] testFieldInfos = new FieldInfo[] { new FieldInfo("f1", new ArrayFormatInfo(new MapFormatInfo(new StringFormatInfo(), new ArrayFormatInfo(new ArrayFormatInfo(new ShortFormatInfo()))))), new FieldInfo("f2", new MapFormatInfo(new StringFormatInfo(), new MapFormatInfo(new StringFormatInfo(), new RowFormatInfo(new String[] { "f21", "f22" }, new FormatInfo[] { new IntFormatInfo(), new ArrayFormatInfo(new ByteFormatInfo()) })))), new FieldInfo("f3", new RowFormatInfo(new String[] { "f31", "f32" }, new FormatInfo[] { new ArrayFormatInfo(new StringFormatInfo()), new RowFormatInfo(new String[] { "f321", "f322" }, new FormatInfo[] { new ArrayFormatInfo(new IntFormatInfo()), new MapFormatInfo(new StringFormatInfo(), new ArrayFormatInfo(new ByteFormatInfo())) }) })) };
    JsonNode expectedJsonNode = objectMapper.readTree("{\n" + "    \"type\":\"record\",\n" + "    \"name\":\"record\",\n" + "    \"fields\":[\n" + "        {\n" + "            \"name\":\"f1\",\n" + "            \"type\":[\n" + "                \"null\",\n" + "                {\n" + "                    \"type\":\"array\",\n" + "                    \"items\":[\n" + "                        \"null\",\n" + "                        {\n" + "                            \"type\":\"map\",\n" + "                            \"values\":[\n" + "                                \"null\",\n" + "                                {\n" + "                                    \"type\":\"array\",\n" + "                                    \"items\":[\n" + "                                        \"null\",\n" + "                                        {\n" + "                                            \"type\":\"array\",\n" + "                                            \"items\":[\n" + "                                                \"null\",\n" + "                                                \"int\"\n" + "                                            ]\n" + "                                        }\n" + "                                    ]\n" + "                                }\n" + "                            ]\n" + "                        }\n" + "                    ]\n" + "                }\n" + "            ],\n" + "            \"default\":null\n" + "        },\n" + "        {\n" + "            \"name\":\"f2\",\n" + "            \"type\":[\n" + "                \"null\",\n" + "                {\n" + "                    \"type\":\"map\",\n" + "                    \"values\":[\n" + "                        \"null\",\n" + "                        {\n" + "                            \"type\":\"map\",\n" + "                            \"values\":[\n" + "                                \"null\",\n" + "                                {\n" + "                                    \"type\":\"record\",\n" + "                                    \"name\":\"record_f2\",\n" + "                                    \"fields\":[\n" + "                                        {\n" + "                                            \"name\":\"f21\",\n" + "                                            \"type\":[\n" + "                                                \"null\",\n" + "                                                \"int\"\n" + "                                            ],\n" + "                                            \"default\":null\n" + "                                        },\n" + "                                        {\n" + "                                            \"name\":\"f22\",\n" + "                                            \"type\":[\n" + "                                                \"null\",\n" + "                                                {\n" + "                                                    \"type\":\"array\",\n" + "                                                    \"items\":[\n" + "                                                        \"null\",\n" + "                                                        \"int\"\n" + "                                                    ]\n" + "                                                }\n" + "                                            ],\n" + "                                            \"default\":null\n" + "                                        }\n" + "                                    ]\n" + "                                }\n" + "                            ]\n" + "                        }\n" + "                    ]\n" + "                }\n" + "            ],\n" + "            \"default\":null\n" + "        },\n" + "        {\n" + "            \"name\":\"f3\",\n" + "            \"type\":[\n" + "                \"null\",\n" + "                {\n" + "                    \"type\":\"record\",\n" + "                    \"name\":\"record_f3\",\n" + "                    \"fields\":[\n" + "                        {\n" + "                            \"name\":\"f31\",\n" + "                            \"type\":[\n" + "                                \"null\",\n" + "                                {\n" + "                                    \"type\":\"array\",\n" + "                                    \"items\":[\n" + "                                        \"null\",\n" + "                                        \"string\"\n" + "                                    ]\n" + "                                }\n" + "                            ],\n" + "                            \"default\":null\n" + "                        },\n" + "                        {\n" + "                            \"name\":\"f32\",\n" + "                            \"type\":[\n" + "                                \"null\",\n" + "                                {\n" + "                                    \"type\":\"record\",\n" + "                                    \"name\":\"record_f3_f32\",\n" + "                                    \"fields\":[\n" + "                                        {\n" + "                                            \"name\":\"f321\",\n" + "                                            \"type\":[\n" + "                                                \"null\",\n" + "                                                {\n" + "                                                    \"type\":\"array\",\n" + "                                                    \"items\":[\n" + "                                                        \"null\",\n" + "                                                        \"int\"\n" + "                                                    ]\n" + "                                                }\n" + "                                            ],\n" + "                                            \"default\":null\n" + "                                        },\n" + "                                        {\n" + "                                            \"name\":\"f322\",\n" + "                                            \"type\":[\n" + "                                                \"null\",\n" + "                                                {\n" + "                                                    \"type\":\"map\",\n" + "                                                    \"values\":[\n" + "                                                        \"null\",\n" + "                                                        {\n" + "                                                            \"type\":\"array\",\n" + "                                                            \"items\":[\n" + "                                                                \"null\",\n" + "                                                                \"int\"\n" + "                                                            ]\n" + "                                                        }\n" + "                                                    ]\n" + "                                                }\n" + "                                            ],\n" + "                                            \"default\":null\n" + "                                        }\n" + "                                    ]\n" + "                                }\n" + "                            ],\n" + "                            \"default\":null\n" + "                        }\n" + "                    ]\n" + "                }\n" + "            ],\n" + "            \"default\":null\n" + "        }\n" + "    ]\n" + "}");
    String actualJson = buildAvroRecordSchemaInJson(testFieldInfos);
    JsonNode actualJsonNode = objectMapper.readTree(actualJson);
    assertEquals(expectedJsonNode, actualJsonNode);
}
Also used : MapFormatInfo(org.apache.inlong.sort.formats.common.MapFormatInfo) ShortFormatInfo(org.apache.inlong.sort.formats.common.ShortFormatInfo) ByteFormatInfo(org.apache.inlong.sort.formats.common.ByteFormatInfo) RowFormatInfo(org.apache.inlong.sort.formats.common.RowFormatInfo) IntFormatInfo(org.apache.inlong.sort.formats.common.IntFormatInfo) ArrayFormatInfo(org.apache.inlong.sort.formats.common.ArrayFormatInfo) JsonNode(org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode) FormatInfo(org.apache.inlong.sort.formats.common.FormatInfo) ShortFormatInfo(org.apache.inlong.sort.formats.common.ShortFormatInfo) StringFormatInfo(org.apache.inlong.sort.formats.common.StringFormatInfo) ArrayFormatInfo(org.apache.inlong.sort.formats.common.ArrayFormatInfo) BooleanFormatInfo(org.apache.inlong.sort.formats.common.BooleanFormatInfo) ByteFormatInfo(org.apache.inlong.sort.formats.common.ByteFormatInfo) RowFormatInfo(org.apache.inlong.sort.formats.common.RowFormatInfo) MapFormatInfo(org.apache.inlong.sort.formats.common.MapFormatInfo) IntFormatInfo(org.apache.inlong.sort.formats.common.IntFormatInfo) StringFormatInfo(org.apache.inlong.sort.formats.common.StringFormatInfo) BuiltInFieldInfo(org.apache.inlong.sort.protocol.BuiltInFieldInfo) FieldInfo(org.apache.inlong.sort.protocol.FieldInfo) Test(org.junit.Test)

Example 4 with IntFormatInfo

use of org.apache.inlong.sort.formats.common.IntFormatInfo 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();
}
Also used : NullFormatInfo(org.apache.inlong.sort.formats.common.NullFormatInfo) MapFormatInfo(org.apache.inlong.sort.formats.common.MapFormatInfo) IntFormatInfo(org.apache.inlong.sort.formats.common.IntFormatInfo) RowFormatInfo(org.apache.inlong.sort.formats.common.RowFormatInfo) ArrayFormatInfo(org.apache.inlong.sort.formats.common.ArrayFormatInfo) DoubleFormatInfo(org.apache.inlong.sort.formats.common.DoubleFormatInfo) FormatInfo(org.apache.inlong.sort.formats.common.FormatInfo) DoubleFormatInfo(org.apache.inlong.sort.formats.common.DoubleFormatInfo) BinaryFormatInfo(org.apache.inlong.sort.formats.common.BinaryFormatInfo) StringFormatInfo(org.apache.inlong.sort.formats.common.StringFormatInfo) ArrayFormatInfo(org.apache.inlong.sort.formats.common.ArrayFormatInfo) RowFormatInfo(org.apache.inlong.sort.formats.common.RowFormatInfo) NullFormatInfo(org.apache.inlong.sort.formats.common.NullFormatInfo) MapFormatInfo(org.apache.inlong.sort.formats.common.MapFormatInfo) IntFormatInfo(org.apache.inlong.sort.formats.common.IntFormatInfo) AvroSerializationInfo(org.apache.inlong.sort.protocol.serialization.AvroSerializationInfo) StringFormatInfo(org.apache.inlong.sort.formats.common.StringFormatInfo) FieldInfo(org.apache.inlong.sort.protocol.FieldInfo) BinaryFormatInfo(org.apache.inlong.sort.formats.common.BinaryFormatInfo)

Example 5 with IntFormatInfo

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

the class RowToCanalKafkaSinkTest method prepareData.

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

Aggregations

IntFormatInfo (org.apache.inlong.sort.formats.common.IntFormatInfo)7 StringFormatInfo (org.apache.inlong.sort.formats.common.StringFormatInfo)7 FieldInfo (org.apache.inlong.sort.protocol.FieldInfo)6 ArrayFormatInfo (org.apache.inlong.sort.formats.common.ArrayFormatInfo)4 MapFormatInfo (org.apache.inlong.sort.formats.common.MapFormatInfo)4 DoubleFormatInfo (org.apache.inlong.sort.formats.common.DoubleFormatInfo)3 FormatInfo (org.apache.inlong.sort.formats.common.FormatInfo)3 RowFormatInfo (org.apache.inlong.sort.formats.common.RowFormatInfo)3 BinaryFormatInfo (org.apache.inlong.sort.formats.common.BinaryFormatInfo)2 BooleanFormatInfo (org.apache.inlong.sort.formats.common.BooleanFormatInfo)2 ByteFormatInfo (org.apache.inlong.sort.formats.common.ByteFormatInfo)2 LongFormatInfo (org.apache.inlong.sort.formats.common.LongFormatInfo)2 NullFormatInfo (org.apache.inlong.sort.formats.common.NullFormatInfo)2 ShortFormatInfo (org.apache.inlong.sort.formats.common.ShortFormatInfo)2 JsonNode (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode)1 ArrayType (org.apache.flink.table.types.logical.ArrayType)1 BigIntType (org.apache.flink.table.types.logical.BigIntType)1 BinaryType (org.apache.flink.table.types.logical.BinaryType)1 BooleanType (org.apache.flink.table.types.logical.BooleanType)1 DateType (org.apache.flink.table.types.logical.DateType)1