Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
cb205d3a
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,发现更多精彩内容 >>
提交
cb205d3a
编写于
7月 14, 2014
作者:
G
gyfora
提交者:
Stephan Ewen
8月 18, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[streaming] StreamCollector2 added to streamcomponenthelper with fix
上级
6c2a1b3e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
47 addition
and
28 deletion
+47
-28
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/api/StreamCollector.java
...n/java/eu/stratosphere/streaming/api/StreamCollector.java
+1
-0
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/api/StreamCollector2.java
.../java/eu/stratosphere/streaming/api/StreamCollector2.java
+22
-17
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/api/streamcomponent/StreamComponentHelper.java
.../streaming/api/streamcomponent/StreamComponentHelper.java
+4
-5
flink-addons/flink-streaming/src/test/java/eu/stratosphere/streaming/api/BatchReduceTest.java
...t/java/eu/stratosphere/streaming/api/BatchReduceTest.java
+2
-2
flink-addons/flink-streaming/src/test/java/eu/stratosphere/streaming/api/StreamCollector2Test.java
...a/eu/stratosphere/streaming/api/StreamCollector2Test.java
+18
-4
未找到文件。
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/api/StreamCollector.java
浏览文件 @
cb205d3a
...
...
@@ -53,6 +53,7 @@ public class StreamCollector<T extends Tuple> implements Collector<T> {
// TODO reconsider emitting mechanism at timeout (find a place to timeout)
@Override
public
void
collect
(
T
tuple
)
{
//TODO: move copy to StreamCollector2
streamRecord
.
setTuple
(
counter
,
StreamRecord
.
copyTuple
(
tuple
));
counter
++;
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/api/StreamCollector2.java
浏览文件 @
cb205d3a
...
...
@@ -28,45 +28,50 @@ public class StreamCollector2<T extends Tuple> implements Collector<T> {
ArrayList
<
StreamCollector
<
Tuple
>>
notPartitionedCollectors
;
ArrayList
<
StreamCollector
<
Tuple
>[]>
partitionedCollectors
;
List
<
RecordWriter
<
StreamRecord
>>
partitionedOutputs
;
List
<
RecordWriter
<
StreamRecord
>>
notPartitionedOutputs
;
int
keyPostition
;
// TODO consider channelID
public
StreamCollector2
(
int
[]
batchSizesOfNotPartitioned
,
int
[]
batchSizesOfPartitioned
,
int
[]
parallelismOfOutput
,
int
keyPosition
,
long
batchTimeout
,
int
channelID
,
public
StreamCollector2
(
List
<
Integer
>
batchSizesOfNotPartitioned
,
List
<
Integer
>
batchSizesOfPartitioned
,
List
<
Integer
>
parallelismOfOutput
,
int
keyPosition
,
long
batchTimeout
,
int
channelID
,
SerializationDelegate
<
Tuple
>
serializationDelegate
,
List
<
RecordWriter
<
StreamRecord
>>
outputs
)
{
List
<
RecordWriter
<
StreamRecord
>>
partitionedOutputs
,
List
<
RecordWriter
<
StreamRecord
>>
notPartitionedOutputs
)
{
notPartitionedCollectors
=
new
ArrayList
<
StreamCollector
<
Tuple
>>(
batchSizesOfNotPartitioned
.
length
);
batchSizesOfNotPartitioned
.
size
()
);
partitionedCollectors
=
new
ArrayList
<
StreamCollector
<
Tuple
>[]>(
batchSizesOfPartitioned
.
length
);
batchSizesOfPartitioned
.
size
()
);
this
.
keyPostition
=
keyPosition
;
for
(
int
i
=
0
;
i
<
batchSizesOfNotPartitioned
.
length
;
i
++)
{
notPartitionedCollectors
.
add
(
new
StreamCollector
<
Tuple
>(
batchSizesOfNotPartitioned
[
i
]
,
batchTimeout
,
channelID
,
serializationDelegate
,
o
utputs
));
for
(
int
i
=
0
;
i
<
batchSizesOfNotPartitioned
.
size
()
;
i
++)
{
notPartitionedCollectors
.
add
(
new
StreamCollector
<
Tuple
>(
batchSizesOfNotPartitioned
.
get
(
i
)
,
batchTimeout
,
channelID
,
serializationDelegate
,
notPartitionedO
utputs
));
}
for
(
int
i
=
0
;
i
<
batchSizesOfPartitioned
.
length
;
i
++)
{
StreamCollector
<
Tuple
>[]
collectors
=
new
StreamCollector
[
parallelismOfOutput
[
i
]
];
for
(
int
i
=
0
;
i
<
batchSizesOfPartitioned
.
size
()
;
i
++)
{
StreamCollector
<
Tuple
>[]
collectors
=
new
StreamCollector
[
parallelismOfOutput
.
get
(
i
)
];
for
(
int
j
=
0
;
j
<
collectors
.
length
;
j
++)
{
collectors
[
j
]
=
new
StreamCollector
<
Tuple
>(
batchSizesOfPartitioned
[
i
],
batchTimeout
,
channelID
,
serializationDelegate
,
outputs
);
List
<
RecordWriter
<
StreamRecord
>>
output
=
new
ArrayList
<
RecordWriter
<
StreamRecord
>>();
output
.
add
(
partitionedOutputs
.
get
(
i
));
collectors
[
j
]
=
new
StreamCollector
<
Tuple
>(
batchSizesOfPartitioned
.
get
(
i
),
batchTimeout
,
channelID
,
serializationDelegate
,
output
);
}
partitionedCollectors
.
add
(
collectors
);
}
}
// TODO copy here instead of copying inside every StreamCollector
@Override
public
void
collect
(
T
record
)
{
for
(
StreamCollector
<
Tuple
>
collector
:
notPartitionedCollectors
)
{
collector
.
collect
(
record
);
}
int
partitionHash
=
Math
.
abs
(
record
.
getField
(
keyPostition
).
hashCode
());
for
(
StreamCollector
<
Tuple
>[]
collectors
:
partitionedCollectors
)
{
collectors
[
partitionHash
%
collectors
.
length
].
collect
(
record
);
}
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/api/streamcomponent/StreamComponentHelper.java
浏览文件 @
cb205d3a
...
...
@@ -121,12 +121,11 @@ public final class StreamComponentHelper<T extends AbstractInvokable> {
int
batchSize
=
taskConfiguration
.
getInteger
(
"batchSize"
,
1
);
long
batchTimeout
=
taskConfiguration
.
getLong
(
"batchTimeout"
,
1000
);
collector
=
new
StreamCollector
<
Tuple
>(
batchSize
,
batchTimeout
,
id
,
outSerializationDelegate
,
outputs
);
//
collector = new StreamCollector<Tuple>(batchSize, batchTimeout, id,
//
outSerializationDelegate, outputs);
// collector = new StreamCollector2<Tuple>(batchsizes_s.toArray(),
// batchsizes_f.toArray(),numOfOutputs_f , keyPosition, batchTimeout,
// id, outSerializationDelegate, outputs);
collector
=
new
StreamCollector2
<
Tuple
>(
batchsizes_s
,
batchsizes_f
,
numOfOutputs_f
,
keyPosition
,
batchTimeout
,
id
,
outSerializationDelegate
,
outputs_f
,
outputs_s
);
return
collector
;
}
...
...
flink-addons/flink-streaming/src/test/java/eu/stratosphere/streaming/api/BatchReduceTest.java
浏览文件 @
cb205d3a
...
...
@@ -69,9 +69,9 @@ public class BatchReduceTest {
@Test
public
void
test
()
throws
Exception
{
StreamExecutionEnvironment
context
=
new
StreamExecutionEnvironment
(
4
,
1000
);
StreamExecutionEnvironment
context
=
new
StreamExecutionEnvironment
();
DataStream
<
Tuple1
<
Double
>>
dataStream0
=
context
.
addSource
(
new
MySource
())
.
batchReduce
(
new
MyBatchReduce
()).
addSink
(
new
MySink
());
.
batch
(
4
).
batch
Reduce
(
new
MyBatchReduce
()).
addSink
(
new
MySink
());
context
.
execute
();
}
...
...
flink-addons/flink-streaming/src/test/java/eu/stratosphere/streaming/api/StreamCollector2Test.java
浏览文件 @
cb205d3a
...
...
@@ -15,10 +15,15 @@
package
eu.stratosphere.streaming.api
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.junit.Test
;
import
eu.stratosphere.api.java.tuple.Tuple
;
import
eu.stratosphere.api.java.tuple.Tuple1
;
import
eu.stratosphere.nephele.io.RecordWriter
;
import
eu.stratosphere.streaming.api.streamrecord.StreamRecord
;
public
class
StreamCollector2Test
{
...
...
@@ -26,14 +31,23 @@ public class StreamCollector2Test {
@Test
public
void
testCollect
()
{
int
[]
batchSizesOfNotPartitioned
=
new
int
[]
{};
int
[]
batchSizesOfPartitioned
=
new
int
[]
{
2
,
2
};
int
[]
parallelismOfOutput
=
new
int
[]
{
2
,
1
};
List
<
Integer
>
batchSizesOfNotPartitioned
=
new
ArrayList
<
Integer
>();
List
<
Integer
>
batchSizesOfPartitioned
=
new
ArrayList
<
Integer
>();
batchSizesOfPartitioned
.
add
(
2
);
batchSizesOfPartitioned
.
add
(
2
);
List
<
Integer
>
parallelismOfOutput
=
new
ArrayList
<
Integer
>();
parallelismOfOutput
.
add
(
2
);
parallelismOfOutput
.
add
(
2
);
int
keyPosition
=
0
;
long
batchTimeout
=
1000
;
int
channelID
=
1
;
collector
=
new
StreamCollector2
<
Tuple
>(
batchSizesOfNotPartitioned
,
batchSizesOfPartitioned
,
parallelismOfOutput
,
keyPosition
,
batchTimeout
,
channelID
,
null
,
null
);
List
<
RecordWriter
<
StreamRecord
>>
fOut
=
new
ArrayList
<
RecordWriter
<
StreamRecord
>>();
fOut
.
add
(
null
);
fOut
.
add
(
null
);
collector
=
new
StreamCollector2
<
Tuple
>(
batchSizesOfNotPartitioned
,
batchSizesOfPartitioned
,
parallelismOfOutput
,
keyPosition
,
batchTimeout
,
channelID
,
null
,
fOut
,
fOut
);
Tuple1
<
Integer
>
t
=
new
Tuple1
<
Integer
>();
StreamCollector
<
Tuple
>
sc1
=
new
StreamCollector
<
Tuple
>(
1
,
batchTimeout
,
channelID
,
null
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录