Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
a39148af
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,发现更多精彩内容 >>
提交
a39148af
编写于
7月 14, 2014
作者:
G
gyfora
提交者:
Stephan Ewen
8月 18, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[streaming] connectWith fix for different connection types
上级
adfb62aa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
18 deletion
+30
-18
flink-addons/flink-streaming/src/main/java/eu/stratosphere/api/datastream/DataStream.java
.../main/java/eu/stratosphere/api/datastream/DataStream.java
+21
-10
flink-addons/flink-streaming/src/main/java/eu/stratosphere/api/datastream/StreamExecutionEnvironment.java
...ratosphere/api/datastream/StreamExecutionEnvironment.java
+9
-7
flink-addons/flink-streaming/src/test/java/eu/stratosphere/streaming/api/FlatMapTest.java
.../test/java/eu/stratosphere/streaming/api/FlatMapTest.java
+0
-1
未找到文件。
flink-addons/flink-streaming/src/main/java/eu/stratosphere/api/datastream/DataStream.java
浏览文件 @
a39148af
...
...
@@ -19,6 +19,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.Random
;
import
scala.Array
;
import
eu.stratosphere.api.datastream.StreamExecutionEnvironment.ConnectionType
;
import
eu.stratosphere.api.java.functions.FlatMapFunction
;
import
eu.stratosphere.api.java.functions.MapFunction
;
...
...
@@ -32,15 +33,14 @@ public class DataStream<T extends Tuple> {
private
final
Random
random
=
new
Random
();
private
final
String
id
;
List
<
String
>
connectIDs
;
ConnectionType
ctype
=
ConnectionType
.
SHUFFLE
;
int
cparam
=
0
;
List
<
ConnectionType
>
ctypes
;
List
<
Integer
>
cparams
;
protected
DataStream
()
{
// TODO implement
context
=
new
StreamExecutionEnvironment
();
id
=
"source"
;
connectIDs
=
new
ArrayList
<
String
>();
connectIDs
.
add
(
getId
());
initConnections
();
}
protected
DataStream
(
StreamExecutionEnvironment
context
)
{
...
...
@@ -51,8 +51,17 @@ public class DataStream<T extends Tuple> {
// TODO add name based on component number an preferable sequential id
this
.
id
=
Long
.
toHexString
(
random
.
nextLong
())
+
Long
.
toHexString
(
random
.
nextLong
());
this
.
context
=
context
;
initConnections
();
}
private
void
initConnections
()
{
connectIDs
=
new
ArrayList
<
String
>();
connectIDs
.
add
(
getId
());
ctypes
=
new
ArrayList
<
StreamExecutionEnvironment
.
ConnectionType
>();
ctypes
.
add
(
ConnectionType
.
SHUFFLE
);
cparams
=
new
ArrayList
<
Integer
>();
cparams
.
add
(
0
);
}
public
String
getId
()
{
...
...
@@ -60,18 +69,20 @@ public class DataStream<T extends Tuple> {
}
public
DataStream
<
T
>
connectWith
(
DataStream
<
T
>
stream
)
{
connectIDs
.
add
(
stream
.
getId
());
connectIDs
.
addAll
(
stream
.
connectIDs
);
ctypes
.
addAll
(
stream
.
ctypes
);
cparams
.
addAll
(
stream
.
cparams
);
return
this
;
}
public
DataStream
<
T
>
partitionBy
(
int
keyposition
)
{
ctype
=
ConnectionType
.
FIELD
;
cparam
=
keyposition
;
ctype
s
.
set
(
0
,
ConnectionType
.
FIELD
)
;
cparam
s
.
set
(
0
,
keyposition
)
;
return
this
;
}
public
DataStream
<
T
>
broadcast
()
{
ctype
=
ConnectionType
.
BROADCAST
;
ctype
s
.
set
(
0
,
ConnectionType
.
BROADCAST
)
;
return
this
;
}
...
...
@@ -82,12 +93,12 @@ public class DataStream<T extends Tuple> {
public
<
R
extends
Tuple
>
DataStream
<
R
>
map
(
MapFunction
<
T
,
R
>
mapper
)
{
return
context
.
addMapFunction
(
this
,
mapper
);
}
public
DataStream
<
T
>
addSink
(
SinkFunction
<
T
>
sinkFunction
)
{
return
context
.
addSink
(
this
,
sinkFunction
);
}
public
DataStream
<
T
>
addDummySink
()
{
public
DataStream
<
T
>
addDummySink
()
{
return
context
.
addDummySink
(
this
);
}
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/api/datastream/StreamExecutionEnvironment.java
浏览文件 @
a39148af
...
...
@@ -59,9 +59,13 @@ public class StreamExecutionEnvironment {
SHUFFLE
,
BROADCAST
,
FIELD
}
private
void
connectGraph
(
List
<
String
>
inputIDs
,
String
outputID
,
ConnectionType
type
,
int
param
)
{
private
<
T
extends
Tuple
>
void
connectGraph
(
DataStream
<
T
>
inputStream
,
String
outputID
)
{
for
(
int
i
=
0
;
i
<
inputStream
.
connectIDs
.
size
();
i
++)
{
ConnectionType
type
=
inputStream
.
ctypes
.
get
(
i
);
String
input
=
inputStream
.
connectIDs
.
get
(
i
);
int
param
=
inputStream
.
cparams
.
get
(
i
);
for
(
String
input
:
inputIDs
)
{
switch
(
type
)
{
case
SHUFFLE:
jobGraphBuilder
.
shuffleConnect
(
input
,
outputID
);
...
...
@@ -94,8 +98,7 @@ public class StreamExecutionEnvironment {
jobGraphBuilder
.
setTask
(
returnStream
.
getId
(),
new
FlatMapInvokable
<
T
,
R
>(
flatMapper
),
"flatMap"
,
baos
.
toByteArray
());
connectGraph
(
inputStream
.
connectIDs
,
returnStream
.
getId
(),
inputStream
.
ctype
,
inputStream
.
cparam
);
connectGraph
(
inputStream
,
returnStream
.
getId
());
return
returnStream
;
}
...
...
@@ -117,8 +120,7 @@ public class StreamExecutionEnvironment {
jobGraphBuilder
.
setTask
(
returnStream
.
getId
(),
new
MapInvokable
<
T
,
R
>(
mapper
),
"map"
,
baos
.
toByteArray
());
connectGraph
(
inputStream
.
connectIDs
,
returnStream
.
getId
(),
inputStream
.
ctype
,
inputStream
.
cparam
);
connectGraph
(
inputStream
,
returnStream
.
getId
());
return
returnStream
;
}
...
...
@@ -140,7 +142,7 @@ public class StreamExecutionEnvironment {
jobGraphBuilder
.
setSink
(
"sink"
,
new
SinkInvokable
<
T
>(
sinkFunction
),
"sink"
,
baos
.
toByteArray
());
connectGraph
(
inputStream
.
connectIDs
,
"sink"
,
inputStream
.
ctype
,
inputStream
.
cparam
);
connectGraph
(
inputStream
,
"sink"
);
return
returnStream
;
}
...
...
flink-addons/flink-streaming/src/test/java/eu/stratosphere/streaming/api/FlatMapTest.java
浏览文件 @
a39148af
...
...
@@ -55,7 +55,6 @@ public class FlatMapTest {
@Override
public
void
invoke
(
Tuple1
<
String
>
tuple
)
{
// TODO Auto-generated method stub
System
.
out
.
println
(
tuple
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录