Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
306ef32f
F
flink
项目概览
doujutun3207
/
flink
与 Fork 源项目一致
从无法访问的项目Fork
通知
24
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flink
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
306ef32f
编写于
7月 14, 2014
作者:
M
Márton Balassi
提交者:
Stephan Ewen
8月 18, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[streaming] WordCount Refactor
上级
cef2a4d0
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
21 addition
and
27 deletion
+21
-27
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/batch/BatchForward.java
...va/eu/stratosphere/streaming/test/batch/BatchForward.java
+2
-2
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/batch/BatchForwardSink.java
...u/stratosphere/streaming/test/batch/BatchForwardSink.java
+1
-1
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/batch/wordcount/BatchWordCount.java
...sphere/streaming/test/batch/wordcount/BatchWordCount.java
+2
-2
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/batch/wordcount/BatchWordCountCounter.java
...streaming/test/batch/wordcount/BatchWordCountCounter.java
+4
-8
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/wordcount/WordCount.java
...a/eu/stratosphere/streaming/test/wordcount/WordCount.java
+2
-2
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/wordcount/WordCountCounter.java
...ratosphere/streaming/test/wordcount/WordCountCounter.java
+3
-3
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/wordcount/WordCountDummySource.java
...sphere/streaming/test/wordcount/WordCountDummySource.java
+1
-3
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/wordcount/WordCountLocal.java
...stratosphere/streaming/test/wordcount/WordCountLocal.java
+2
-2
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/wordcount/WordCountSink.java
.../stratosphere/streaming/test/wordcount/WordCountSink.java
+1
-1
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/wordcount/WordCountSplitter.java
...atosphere/streaming/test/wordcount/WordCountSplitter.java
+3
-3
未找到文件。
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/batch/BatchForward.java
浏览文件 @
306ef32f
...
...
@@ -25,9 +25,9 @@ public class BatchForward extends TestBase2{
public
JobGraph
getJobGraph
()
{
JobGraphBuilder
graphBuilder
=
new
JobGraphBuilder
(
"testGraph"
);
graphBuilder
.
setSource
(
"StreamSource"
,
BatchForwardSource
.
class
);
graphBuilder
.
setSink
(
"StreamSink"
,
BachForwardSink
.
class
);
graphBuilder
.
setSink
(
"StreamSink"
,
Ba
t
chForwardSink
.
class
);
graphBuilder
.
broadcast
Connect
(
"StreamSource"
,
"StreamSink"
);
graphBuilder
.
shuffle
Connect
(
"StreamSource"
,
"StreamSink"
);
return
graphBuilder
.
getJobGraph
();
}
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/batch/BachForwardSink.java
→
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/batch/Ba
t
chForwardSink.java
浏览文件 @
306ef32f
...
...
@@ -19,7 +19,7 @@ import eu.stratosphere.streaming.api.StreamRecord;
import
eu.stratosphere.streaming.api.invokable.UserSinkInvokable
;
import
eu.stratosphere.types.StringValue
;
public
class
BachForwardSink
implements
UserSinkInvokable
{
public
class
Ba
t
chForwardSink
implements
UserSinkInvokable
{
private
StringValue
word
=
new
StringValue
(
""
);
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/batch/wordcount/BatchWordCount.java
浏览文件 @
306ef32f
...
...
@@ -30,10 +30,10 @@ public class BatchWordCount extends TestBase2 {
graphBuilder
.
setTask
(
"BatchWordCountCounter"
,
BatchWordCountCounter
.
class
,
2
);
graphBuilder
.
setSink
(
"BatchWordCountSink"
,
BatchWordCountSink
.
class
);
graphBuilder
.
broadcast
Connect
(
"BatchWordCountSource"
,
"BatchWordCountSplitter"
);
graphBuilder
.
shuffle
Connect
(
"BatchWordCountSource"
,
"BatchWordCountSplitter"
);
graphBuilder
.
fieldsConnect
(
"BatchWordCountSplitter"
,
"BatchWordCountCounter"
,
0
,
StringValue
.
class
);
graphBuilder
.
broadcast
Connect
(
"BatchWordCountCounter"
,
"BatchWordCountSink"
);
graphBuilder
.
shuffle
Connect
(
"BatchWordCountCounter"
,
"BatchWordCountSink"
);
return
graphBuilder
.
getJobGraph
();
}
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/batch/wordcount/BatchWordCountCounter.java
浏览文件 @
306ef32f
...
...
@@ -26,19 +26,18 @@ import eu.stratosphere.types.LongValue;
import
eu.stratosphere.types.StringValue
;
public
class
BatchWordCountCounter
extends
UserTaskInvokable
{
private
Map
<
String
,
Integer
>
wordCounts
=
new
HashMap
<
String
,
Integer
>();
private
StringValue
wordValue
=
new
StringValue
(
""
);
private
IntValue
countValue
=
new
IntValue
(
1
);
private
LongValue
timestamp
=
new
LongValue
(
0
);
private
String
word
=
""
;
private
AtomRecord
outputRecord
=
new
AtomRecord
(
3
);
private
int
count
=
1
;
@Override
public
void
invoke
(
StreamRecord
record
)
throws
Exception
{
wordValue
=
(
StringValue
)
record
.
getField
(
0
,
0
);
timestamp
=
(
LongValue
)
record
.
getField
(
0
,
1
);
wordValue
=
(
StringValue
)
record
.
getField
(
0
,
0
);
timestamp
=
(
LongValue
)
record
.
getField
(
0
,
1
);
if
(
wordCounts
.
containsKey
(
word
))
{
count
=
wordCounts
.
get
(
word
)
+
1
;
...
...
@@ -48,10 +47,7 @@ public class BatchWordCountCounter extends UserTaskInvokable {
wordCounts
.
put
(
word
,
1
);
countValue
.
setValue
(
1
);
}
outputRecord
.
setField
(
0
,
wordValue
);
outputRecord
.
setField
(
1
,
countValue
);
outputRecord
.
setField
(
2
,
timestamp
);
emit
(
new
StreamRecord
(
outputRecord
));
emit
(
new
StreamRecord
(
wordValue
,
countValue
,
timestamp
));
}
}
\ No newline at end of file
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/wordcount/WordCount.java
浏览文件 @
306ef32f
...
...
@@ -30,10 +30,10 @@ public class WordCount extends TestBase2 {
graphBuilder
.
setTask
(
"WordCountCounter"
,
WordCountCounter
.
class
,
2
);
graphBuilder
.
setSink
(
"WordCountSink"
,
WordCountSink
.
class
);
graphBuilder
.
broadcast
Connect
(
"WordCountSource"
,
"WordCountSplitter"
);
graphBuilder
.
shuffle
Connect
(
"WordCountSource"
,
"WordCountSplitter"
);
graphBuilder
.
fieldsConnect
(
"WordCountSplitter"
,
"WordCountCounter"
,
0
,
StringValue
.
class
);
graphBuilder
.
broadcast
Connect
(
"WordCountCounter"
,
"WordCountSink"
);
graphBuilder
.
shuffle
Connect
(
"WordCountCounter"
,
"WordCountSink"
);
return
graphBuilder
.
getJobGraph
();
}
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/wordcount/WordCountCounter.java
浏览文件 @
306ef32f
...
...
@@ -26,9 +26,9 @@ import eu.stratosphere.types.StringValue;
public
class
WordCountCounter
extends
UserTaskInvokable
{
private
Map
<
String
,
Integer
>
wordCounts
=
new
HashMap
<
String
,
Integer
>();
private
StringValue
wordValue
=
new
StringValue
(
""
);
private
IntValue
countValue
=
new
IntValue
(
1
);
private
String
word
=
""
;
private
StringValue
wordValue
=
new
StringValue
();
private
IntValue
countValue
=
new
IntValue
();
private
String
word
=
new
String
()
;
private
int
count
=
1
;
@Override
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/wordcount/WordCountDummySource.java
浏览文件 @
306ef32f
...
...
@@ -9,18 +9,16 @@ public class WordCountDummySource extends UserSourceInvokable {
private
String
line
=
new
String
();
private
StringValue
lineValue
=
new
StringValue
();
private
Value
[]
values
=
new
StringValue
[
1
];
public
WordCountDummySource
()
{
line
=
"first second"
;
lineValue
.
setValue
(
line
);
values
[
0
]
=
lineValue
;
}
@Override
public
void
invoke
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
emit
(
new
StreamRecord
(
values
));
emit
(
new
StreamRecord
(
lineValue
));
System
.
out
.
println
(
"xxxxxxxxx"
);
}
}
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/wordcount/WordCountLocal.java
浏览文件 @
306ef32f
...
...
@@ -110,10 +110,10 @@ public class WordCountLocal {
graphBuilder
.
setTask
(
"WordCountCounter"
,
WordCountCounter
.
class
,
2
);
graphBuilder
.
setSink
(
"WordCountSink"
,
WordCountSink
.
class
);
graphBuilder
.
broadcast
Connect
(
"WordCountSource"
,
"WordCountSplitter"
);
graphBuilder
.
shuffle
Connect
(
"WordCountSource"
,
"WordCountSplitter"
);
graphBuilder
.
fieldsConnect
(
"WordCountSplitter"
,
"WordCountCounter"
,
0
,
StringValue
.
class
);
graphBuilder
.
broadcast
Connect
(
"WordCountCounter"
,
"WordCountSink"
);
graphBuilder
.
shuffle
Connect
(
"WordCountCounter"
,
"WordCountSink"
);
return
graphBuilder
.
getJobGraph
();
}
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/wordcount/WordCountSink.java
浏览文件 @
306ef32f
...
...
@@ -22,7 +22,7 @@ import eu.stratosphere.types.StringValue;
public
class
WordCountSink
implements
UserSinkInvokable
{
private
StringValue
word
=
new
StringValue
(
""
);
private
StringValue
word
=
new
StringValue
();
private
IntValue
count
=
new
IntValue
();
@Override
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/test/wordcount/WordCountSplitter.java
浏览文件 @
306ef32f
...
...
@@ -21,9 +21,9 @@ import eu.stratosphere.types.StringValue;
public
class
WordCountSplitter
extends
UserTaskInvokable
{
private
StringValue
sentence
=
new
StringValue
(
""
);
private
String
[]
words
=
new
String
[
0
]
;
private
StringValue
wordValue
=
new
StringValue
(
""
);
private
StringValue
sentence
=
new
StringValue
();
private
String
[]
words
=
new
String
[
]
{}
;
private
StringValue
wordValue
=
new
StringValue
();
@Override
public
void
invoke
(
StreamRecord
record
)
throws
Exception
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录