This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a commit to branch dev
in repository 
https://gitbox.apache.org/repos/asf/incubator-streampark-quickstart.git


The following commit(s) were added to refs/heads/dev by this push:
     new 143df1f  [Improve] update README
     new 5ed17ad  Merge pull request #29 from wolfboys/readme
143df1f is described below

commit 143df1f81430b81fc1fcc12df13194ccbbd6364d
Author: benjobs <[email protected]>
AuthorDate: Fri Nov 17 00:44:38 2023 +0800

    [Improve] update README
---
 README.md                                          |  92 ++++++++++++++---
 .../quickstart/flink/SocketWindowWordCount.java    | 113 +++++++++++++++++++++
 2 files changed, 190 insertions(+), 15 deletions(-)

diff --git a/README.md b/README.md
index 048e1b3..7e04bde 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,86 @@
-# streampark-quickstart
+<!--
+  ~ 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.
+  ~
+  -->
 
-Apache StreamPark 开发`Flink`的上手示例程序,分为四个模块:
- - `quickstart-apacheflink`
- - `quickstart-datastream`
- - `quickstart-flinksql`
- - `quickstart-connector`
+<h1 align="center">
+   <img src="https://streampark.apache.org/image/logo_name.png"; 
+   alt="StreamPark Logo" title="Apache StreamPark Logo" width="600"/>
+  <br>
+</h1>
 
-## quickstart-apacheflink
+<h3 align="center">A magical framework that makes stream processing 
easier!</h3>
 
-quickstart-apacheflink 是Flink官方的`SocketWindowWordCount`程序, 
其中项目结构,打包规则,开发方式等和Flink官网要求的规范完全一致,
-之所以有这个模块,是因为在`streampark-console`中做了对`标准的Flink程序`(按照官方要求的开发规范开发的Flink程序)的部署支持,后续方便演示使用.
+<div align="center">
 
-## quickstart-datastream
+[![License](https://img.shields.io/badge/license-Apache%202-blue.svg?style=for-the-badge&label=license)](https://www.apache.org/licenses/LICENSE-2.0.html)
+[![stars](https://img.shields.io/github/stars/apache/streampark?style=for-the-badge&label=stars)](https://github.com/apache/incubator-streampark/stargazers)
+[![Latest 
release](https://img.shields.io/github/v/release/apache/streampark.svg?style=for-the-badge&label=release)](https://github.com/apache/incubator-streampark/releases)
+[![total 
downloads](https://img.shields.io/github/downloads/apache/streampark/total.svg?style=for-the-badge&label=downloads)](https://streampark.apache.org/download)
+[![Twitter](https://img.shields.io/twitter/follow/ASFStreamPark?label=follow&logo=twitter&style=for-the-badge)](https://twitter.com/ASFStreamPark)
 
-该模块主要演示了如果利用`Apache 
StreamPark`快速开发一个`DataStream`程序,其中有`java`和`scala`两种语言的开发示例,供开发者快速上手学习使用
+**[Website](https://streampark.apache.org)**&nbsp;&nbsp;|&nbsp;&nbsp;
+**[Document](https://streampark.apache.org/docs/intro)**&nbsp;&nbsp;|&nbsp;&nbsp;
+**[FAQ](https://github.com/apache/incubator-streampark/issues/507)**
 
-## quickstart-flinksql
+</div>
 
-该模块主要演示了如果利用`Apache StreamPark`快速开发一个`Flink & 
SQL`程序,其中有`java`和`scala`两种语言的开发示例,供开发者快速上手学习使用
+## 🚀 What is StreamPark?
 
-## quickstart-connector
+<h4>StreamPark is a stream processing development framework and professional 
management platform. </h4>
 
-该模块演示了如何使用`Apache StreamPark`里提供的各种 `Datastream connector` , 里面集合了各种 
`Datastream connector` 的配置和使用示例, 供开发者快速上手学习使用
+> StreamPark is a streaming application development framework. Aimed at ease 
building and managing streaming applications, StreamPark provides development 
framework for writing stream processing application with Apache Flink and 
Apache Spark, More other engines will be supported in the future. Also, 
StreamPark is a professional management platform for streaming application
+, including application development, debugging, interactive query, deployment, 
operation, maintenance, etc. It was initially known as StreamX and renamed to 
StreamPark in August 2022.
+
+## 🚀 What is streampark-quickstart ?
+
+> Apache StreamPark quickstart program for developing `Flink`
+
+## 🎉 Modules
+
+* quickstart-apacheflink
+* quickstart-datastream
+* quickstart-flinksql
+* quickstart-connector
+
+### | quickstart-apacheflink
+> quickstart-apacheflink is an official SocketWindowWordCount program provided 
by Flink. The project structure, packaging rules, development methods, etc. are 
fully consistent with the specifications required by the Flink official 
website. The reason for having this module is to support the deployment of 
standard Flink programs (Flink programs developed according to the official 
development specifications) in streampark-console for subsequent demonstrations 
and ease of use.
+
+### | quickstart-datastream
+> This module demonstrates how to quickly develop a DataStream program using 
Apache StreamPark. It provides development examples in both Java and Scala to 
help developers get started quickly.
+
+### | quickstart-flinksql
+> This module demonstrates how to quickly develop a Flink & SQL program using 
Apache StreamPark. It provides development examples in both Java and Scala to 
help developers get started quickly.
+
+### | quickstart-connector
+> This module demonstrates how to use various Datastream connectors provided 
by Apache StreamPark. It includes configuration and usage examples of various 
Datastream connectors, allowing developers to get started quickly.
+
+## 🔨 How to Build
+
+```shell
+git clone [email protected]:apache/incubator-streampark-quickstart.git
+cd incubator-streampark-quickstart
+mvn clean install -DskipTests
+```
+
+## 💬 Social Media
+
+- [Twitter](https://twitter.com/ASFStreamPark)
+- [Zhihu](https://www.zhihu.com/people/streampark) (in Chinese)
+- [bilibili](https://space.bilibili.com/455330087) (in Chinese)
+- WeChat Official Account (in Chinese, scan the QR code to follow)
+
+<img src="https://streampark.apache.org/image/wx_qr.png"; alt="Join the Group" 
height="350px"><br>
diff --git 
a/quickstart-flink/quickstart-apacheflink/src/main/java/org/apache/streampark/quickstart/flink/SocketWindowWordCount.java
 
b/quickstart-flink/quickstart-apacheflink/src/main/java/org/apache/streampark/quickstart/flink/SocketWindowWordCount.java
new file mode 100644
index 0000000..00253d9
--- /dev/null
+++ 
b/quickstart-flink/quickstart-apacheflink/src/main/java/org/apache/streampark/quickstart/flink/SocketWindowWordCount.java
@@ -0,0 +1,113 @@
+/*
+ * 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.streampark.quickstart.flink;
+
+import org.apache.flink.api.common.functions.FlatMapFunction;
+import org.apache.flink.api.common.typeinfo.Types;
+import org.apache.flink.api.java.utils.ParameterTool;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import 
org.apache.flink.streaming.api.windowing.assigners.TumblingProcessingTimeWindows;
+import org.apache.flink.streaming.api.windowing.time.Time;
+
+/**
+ * Implements a streaming windowed version of the "WordCount" program.
+ *
+ * <p>This program connects to a server socket and reads strings from the 
socket. The easiest way to
+ * try this out is to open a text server (at port 12345) using the 
<i>netcat</i> tool via
+ *
+ * <pre>
+ * nc -l 12345 on Linux or nc -l -p 12345 on Windows
+ * </pre>
+ *
+ * <p>and run this example with the hostname and the port as arguments.
+ */
+public class SocketWindowWordCount {
+
+    public static void main(String[] args) throws Exception {
+
+        // the host and the port to connect to
+        final String hostname;
+        final int port;
+        try {
+            final ParameterTool params = ParameterTool.fromArgs(args);
+            hostname = params.has("hostname") ? params.get("hostname") : 
"localhost";
+            port = params.getInt("port");
+        } catch (Exception e) {
+            System.err.println(
+                    "No port specified. Please run 'SocketWindowWordCount "
+                            + "--hostname <hostname> --port <port>', where 
hostname (localhost by default) "
+                            + "and port is the address of the text server");
+            System.err.println(
+                    "To start a simple text server, run 'netcat -l <port>' and 
"
+                            + "type the input text into the command line");
+            return;
+        }
+
+        // get the execution environment
+        final StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment();
+
+        // get input data by connecting to the socket
+        DataStream<String> text = env.socketTextStream(hostname, port, "\n");
+
+        // parse the data, group it, window it, and aggregate the counts
+        DataStream<WordWithCount> windowCounts =
+                text.flatMap(
+                                (FlatMapFunction<String, WordWithCount>)
+                                        (value, out) -> {
+                                            for (String word : 
value.split("\\s")) {
+                                                out.collect(new 
WordWithCount(word, 1L));
+                                            }
+                                        },
+                                Types.POJO(WordWithCount.class))
+                        .keyBy(value -> value.word)
+                        
.window(TumblingProcessingTimeWindows.of(Time.seconds(5)))
+                        .reduce((a, b) -> new WordWithCount(a.word, a.count + 
b.count))
+                        .returns(WordWithCount.class);
+
+        // print the results with a single thread, rather than in parallel
+        windowCounts.print().setParallelism(1);
+
+        env.execute("Socket Window WordCount");
+    }
+
+    // ------------------------------------------------------------------------
+
+    /**
+     * Data type for words with count.
+     */
+    public static class WordWithCount {
+
+        public String word;
+        public long count;
+
+        @SuppressWarnings("unused")
+        public WordWithCount() {
+        }
+
+        public WordWithCount(String word, long count) {
+            this.word = word;
+            this.count = count;
+        }
+
+        @Override
+        public String toString() {
+            return word + " : " + count;
+        }
+    }
+}

Reply via email to