You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/08/23 08:35:55 UTC

[GitHub] [incubator-doris] caoliang-web opened a new pull request #6490: Flink demo

caoliang-web opened a new pull request #6490:
URL: https://github.com/apache/incubator-doris/pull/6490


   Flink Demo example:
   1.Flink consumes Kafka data and uses Stream load to store data (dorisSink method)
   2.Flink reads the file into the library (hdfs file, the format can be text or other), and uses stream load to import
   3.Use flink connector to read doris data to build DataStream for sum analysis


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] github-actions[bot] commented on pull request #6490: Flink reads multiple data sources to doris

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #6490:
URL: https://github.com/apache/incubator-doris/pull/6490#issuecomment-905558732


   PR approved by at least one committer and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] github-actions[bot] commented on pull request #6490: Flink reads multiple data sources to doris

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #6490:
URL: https://github.com/apache/incubator-doris/pull/6490#issuecomment-904320984


   PR approved by anyone and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] hf200012 commented on a change in pull request #6490: Flink reads multiple data sources to doris

Posted by GitBox <gi...@apache.org>.
hf200012 commented on a change in pull request #6490:
URL: https://github.com/apache/incubator-doris/pull/6490#discussion_r693778066



##########
File path: samples/doris-demo/flink-demo/src/main/java/org/apache/doris/demo/flink/analyze/DorisSource.java
##########
@@ -0,0 +1,93 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.doris.demo.flink.analyze;
+
+import org.apache.doris.demo.flink.User;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.streaming.api.functions.source.RichSourceFunction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.*;

Review comment:
       Don't use import *

##########
File path: samples/doris-demo/flink-demo/src/main/java/org/apache/doris/demo/flink/DorisStreamLoad.java
##########
@@ -0,0 +1,157 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.demo.flink;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;

Review comment:
       Don't use import *

##########
File path: samples/doris-demo/flink-demo/src/main/java/org/apache/doris/demo/flink/analyze/FlinkDorisConnectorAnalyze.java
##########
@@ -0,0 +1,79 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.doris.demo.flink.analyze;
+
+import org.apache.doris.demo.flink.User;
+import org.apache.doris.flink.cfg.DorisStreamOptions;
+import org.apache.doris.flink.datastream.DorisSourceFunction;
+import org.apache.flink.api.common.functions.MapFunction;
+import org.apache.flink.api.java.functions.KeySelector;
+import org.apache.flink.streaming.api.datastream.DataStreamSource;
+import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+
+import java.util.ArrayList;
+import java.util.Properties;
+
+
+/**
+ * This example mainly demonstrates the use of Flink connector to read Doris data,
+ * build DataStream for analysis, and sum.
+ * <p>
+ * use flink doris connector
+ */
+public class FlinkDorisConnectorAnalyze {
+
+    public static void main(String[] args) throws Exception {
+        Properties properties = new Properties();
+        properties.put("fenodes", "IP:8030");
+        properties.put("username", "root");
+        properties.put("password", "");
+        properties.put("table.identifier", "test1.doris_test_source_2");
+
+        DorisStreamOptions options = new DorisStreamOptions(properties);
+
+        final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
+        env.setParallelism(2);
+
+        DataStreamSource dataStreamSource = env.addSource(new DorisSourceFunction(options, new User()));
+
+        SingleOutputStreamOperator outputStream = dataStreamSource.map(new MapFunction<Object, User>() {
+            @Override
+            public User map(Object obj) throws Exception {
+                User user = new User();
+                if (obj instanceof ArrayList<?>) {
+                    user.setName(((ArrayList<?>) obj).get(0).toString());
+                    user.setAge(Integer.valueOf(((ArrayList<?>) obj).get(1).toString()));
+                    user.setPrice(((ArrayList<?>) obj).get(2).toString());
+                    user.setSale(((ArrayList<?>) obj).get(3).toString());
+                }
+                return user;
+            }
+        });
+
+        outputStream.keyBy(new KeySelector<User, String>() {
+            @Override
+            public String getKey(User user) throws Exception {
+                return user.getName();
+            }
+        })
+                .sum("age")

Review comment:
       code style




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] yangzhg merged pull request #6490: Flink reads multiple data sources to doris

Posted by GitBox <gi...@apache.org>.
yangzhg merged pull request #6490:
URL: https://github.com/apache/incubator-doris/pull/6490


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org