From b3edcf099caeb1d8ddde9483553571871663855e Mon Sep 17 00:00:00 2001 From: PengFei Li Date: Fri, 1 Mar 2024 16:26:37 +0800 Subject: [PATCH] [Examples] Use type DefaultStarRocksRowData to reduce serialize cost in multiple tables example (#342) Signed-off-by: PengFei Li --- .../flink/examples/datastream/WriteMultipleTables.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/src/main/java/com/starrocks/connector/flink/examples/datastream/WriteMultipleTables.java b/examples/src/main/java/com/starrocks/connector/flink/examples/datastream/WriteMultipleTables.java index 798bffe2..d9322a56 100644 --- a/examples/src/main/java/com/starrocks/connector/flink/examples/datastream/WriteMultipleTables.java +++ b/examples/src/main/java/com/starrocks/connector/flink/examples/datastream/WriteMultipleTables.java @@ -82,8 +82,8 @@ public static void main(String[] args) throws Exception { // the structure StarRocksRowData. A StarRocksRowData includes the meta (which db and table) // and data. The data is a json-format string whose fields correspond to partial or all columns // of the table. - StarRocksRowData[] records = - new StarRocksRowData[]{ + DefaultStarRocksRowData[] records = + new DefaultStarRocksRowData[]{ // write full columns of `test`.`tbl1`: `id`, `name` and `score` buildRow("test", "tbl1", "{\"id\":1, \"name\":\"starrocks-json\", \"score\":100}"), // write partial columns of `test`.`tbl1`: `id`, `name` @@ -93,7 +93,7 @@ public static void main(String[] args) throws Exception { // write partial columns of `test`.`tbl2`: `order_id`, `order_state` buildRow("test", "tbl2", "{\"order_id\":2, \"order_state\":2}"), }; - DataStream source = env.fromElements(records); + DataStream source = env.fromElements(records); // Configure the connector with the required properties, and you also need to add properties // "sink.properties.format" and "sink.properties.strip_outer_array" to tell the connector the @@ -127,13 +127,13 @@ public static void main(String[] args) throws Exception { options.addTableProperties(tbl2Properties); // Create the sink with the options - SinkFunction starRockSink = SinkFunctionFactory.createSinkFunction(options); + SinkFunction starRockSink = SinkFunctionFactory.createSinkFunction(options); source.addSink(starRockSink); env.execute("WriteMultipleTables"); } - private static StarRocksRowData buildRow(String db, String table, String data) { + private static DefaultStarRocksRowData buildRow(String db, String table, String data) { return new DefaultStarRocksRowData(null, db, table, data); } }