Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
e2ef74ea
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,发现更多精彩内容 >>
提交
e2ef74ea
编写于
7月 14, 2016
作者:
G
Greg Hogan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-4213] [gelly] Provide CombineHint in Gelly algorithms
This closes #2248
上级
54f02ec7
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
38 addition
and
16 deletion
+38
-16
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/degree/annotate/directed/VertexDegrees.java
...ink/graph/asm/degree/annotate/directed/VertexDegrees.java
+17
-7
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/degree/annotate/directed/VertexInDegree.java
...nk/graph/asm/degree/annotate/directed/VertexInDegree.java
+2
-0
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/degree/annotate/directed/VertexOutDegree.java
...k/graph/asm/degree/annotate/directed/VertexOutDegree.java
+2
-0
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/degree/annotate/undirected/VertexDegree.java
...nk/graph/asm/degree/annotate/undirected/VertexDegree.java
+2
-0
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/generator/GraphGeneratorUtils.java
...org/apache/flink/graph/generator/GraphGeneratorUtils.java
+5
-9
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/clustering/directed/LocalClusteringCoefficient.java
...brary/clustering/directed/LocalClusteringCoefficient.java
+2
-0
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/clustering/undirected/LocalClusteringCoefficient.java
...ary/clustering/undirected/LocalClusteringCoefficient.java
+2
-0
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/link_analysis/HITS.java
...va/org/apache/flink/graph/library/link_analysis/HITS.java
+6
-0
未找到文件。
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/degree/annotate/directed/VertexDegrees.java
浏览文件 @
e2ef74ea
...
...
@@ -21,9 +21,9 @@ package org.apache.flink.graph.asm.degree.annotate.directed;
import
org.apache.flink.api.common.functions.FlatMapFunction
;
import
org.apache.flink.api.common.functions.GroupReduceFunction
;
import
org.apache.flink.api.common.functions.JoinFunction
;
import
org.apache.flink.api.common.functions.ReduceFunction
;
import
org.apache.flink.api.common.operators.Order
;
import
org.apache.flink.api.java.DataSet
;
import
org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFields
;
import
org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFieldsFirst
;
import
org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFieldsSecond
;
import
org.apache.flink.api.java.tuple.Tuple3
;
...
...
@@ -122,7 +122,7 @@ extends GraphAlgorithmDelegatingDataSet<K, VV, EV, Vertex<K, Degrees>> {
.
setParallelism
(
parallelism
)
.
name
(
"Emit and flip edge"
)
.
groupBy
(
0
,
1
)
.
reduce
(
new
ReduceBitmask
<
K
>())
.
reduceGroup
(
new
ReduceBitmask
<
K
>())
.
setParallelism
(
parallelism
)
.
name
(
"Reduce bitmask"
);
...
...
@@ -177,13 +177,23 @@ extends GraphAlgorithmDelegatingDataSet<K, VV, EV, Vertex<K, Degrees>> {
*
* @param <T> ID type
*/
private
static
class
ReduceBitmask
<
T
>
implements
ReduceFunction
<
Tuple3
<
T
,
T
,
ByteValue
>>
{
@ForwardedFields
(
"0; 1"
)
private
static
final
class
ReduceBitmask
<
T
>
implements
GroupReduceFunction
<
Tuple3
<
T
,
T
,
ByteValue
>,
Tuple3
<
T
,
T
,
ByteValue
>>
{
@Override
public
Tuple3
<
T
,
T
,
ByteValue
>
reduce
(
Tuple3
<
T
,
T
,
ByteValue
>
left
,
Tuple3
<
T
,
T
,
ByteValue
>
righ
t
)
public
void
reduce
(
Iterable
<
Tuple3
<
T
,
T
,
ByteValue
>>
values
,
Collector
<
Tuple3
<
T
,
T
,
ByteValue
>>
ou
t
)
throws
Exception
{
left
.
f2
.
setValue
((
byte
)(
left
.
f2
.
getValue
()
|
right
.
f2
.
getValue
()));
return
left
;
Tuple3
<
T
,
T
,
ByteValue
>
output
=
null
;
byte
bitmask
=
0
;
for
(
Tuple3
<
T
,
T
,
ByteValue
>
value:
values
)
{
output
=
value
;
bitmask
|=
value
.
f2
.
getValue
();
}
output
.
f2
.
setValue
(
bitmask
);
out
.
collect
(
output
);
}
}
...
...
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/degree/annotate/directed/VertexInDegree.java
浏览文件 @
e2ef74ea
...
...
@@ -18,6 +18,7 @@
package
org.apache.flink.graph.asm.degree.annotate.directed
;
import
org.apache.flink.api.common.operators.base.ReduceOperatorBase.CombineHint
;
import
org.apache.flink.api.java.DataSet
;
import
org.apache.flink.graph.Graph
;
import
org.apache.flink.graph.Vertex
;
...
...
@@ -119,6 +120,7 @@ extends GraphAlgorithmDelegatingDataSet<K, VV, EV, Vertex<K, LongValue>> {
DataSet
<
Vertex
<
K
,
LongValue
>>
targetDegree
=
targetIds
.
groupBy
(
0
)
.
reduce
(
new
DegreeCount
<
K
>())
.
setCombineHint
(
CombineHint
.
HASH
)
.
setParallelism
(
parallelism
)
.
name
(
"Degree count"
);
...
...
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/degree/annotate/directed/VertexOutDegree.java
浏览文件 @
e2ef74ea
...
...
@@ -18,6 +18,7 @@
package
org.apache.flink.graph.asm.degree.annotate.directed
;
import
org.apache.flink.api.common.operators.base.ReduceOperatorBase.CombineHint
;
import
org.apache.flink.api.java.DataSet
;
import
org.apache.flink.graph.Graph
;
import
org.apache.flink.graph.Vertex
;
...
...
@@ -119,6 +120,7 @@ extends GraphAlgorithmDelegatingDataSet<K, VV, EV, Vertex<K, LongValue>> {
DataSet
<
Vertex
<
K
,
LongValue
>>
sourceDegree
=
sourceIds
.
groupBy
(
0
)
.
reduce
(
new
DegreeCount
<
K
>())
.
setCombineHint
(
CombineHint
.
HASH
)
.
setParallelism
(
parallelism
)
.
name
(
"Degree count"
);
...
...
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/degree/annotate/undirected/VertexDegree.java
浏览文件 @
e2ef74ea
...
...
@@ -19,6 +19,7 @@
package
org.apache.flink.graph.asm.degree.annotate.undirected
;
import
org.apache.flink.api.common.functions.MapFunction
;
import
org.apache.flink.api.common.operators.base.ReduceOperatorBase.CombineHint
;
import
org.apache.flink.api.java.DataSet
;
import
org.apache.flink.graph.utils.proxy.GraphAlgorithmDelegatingDataSet
;
import
org.apache.flink.graph.Edge
;
...
...
@@ -143,6 +144,7 @@ extends GraphAlgorithmDelegatingDataSet<K, VV, EV, Vertex<K, LongValue>> {
DataSet
<
Vertex
<
K
,
LongValue
>>
degree
=
vertexIds
.
groupBy
(
0
)
.
reduce
(
new
DegreeCount
<
K
>())
.
setCombineHint
(
CombineHint
.
HASH
)
.
setParallelism
(
parallelism
)
.
name
(
"Degree count"
);
...
...
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/generator/GraphGeneratorUtils.java
浏览文件 @
e2ef74ea
...
...
@@ -50,12 +50,10 @@ public class GraphGeneratorUtils {
.
setParallelism
(
parallelism
)
.
name
(
"Vertex iterators"
);
DataSet
<
Vertex
<
LongValue
,
NullValue
>>
vertexSequence
=
vertexLabels
return
vertexLabels
.
map
(
new
CreateVertex
())
.
setParallelism
(
parallelism
)
.
name
(
"Vertex sequence"
);
return
vertexSequence
;
}
@ForwardedFields
(
"*->f0"
)
...
...
@@ -73,7 +71,7 @@ public class GraphGeneratorUtils {
}
}
/
**************************************************************************/
/
/ --------------------------------------------------------------------------------------------
/**
* Generates {@link Vertex Vertices} present in the given set of {@link Edge}s.
...
...
@@ -84,7 +82,7 @@ public class GraphGeneratorUtils {
* @param <EV> edge value type
* @return {@link DataSet} of discovered {@link Vertex Vertices}
*
* @see
{@link Graph#fromDataSet(DataSet, DataSet, ExecutionEnvironment)}
* @see
Graph#fromDataSet(DataSet, DataSet, ExecutionEnvironment)
*/
public
static
<
K
,
EV
>
DataSet
<
Vertex
<
K
,
NullValue
>>
vertexSet
(
DataSet
<
Edge
<
K
,
EV
>>
edges
,
int
parallelism
)
{
DataSet
<
Vertex
<
K
,
NullValue
>>
vertexSet
=
edges
...
...
@@ -92,16 +90,14 @@ public class GraphGeneratorUtils {
.
setParallelism
(
parallelism
)
.
name
(
"Emit source and target labels"
);
DataSet
<
Vertex
<
K
,
NullValue
>>
distinctVertexSet
=
vertexSet
return
vertexSet
.
distinct
()
.
setParallelism
(
parallelism
)
.
name
(
"Emit vertex labels"
);
return
distinctVertexSet
;
}
/**
* @see
{@link Graph.EmitSrcAndTarget}
* @see
Graph.EmitSrcAndTarget
*/
private
static
final
class
EmitSrcAndTarget
<
K
,
EV
>
implements
FlatMapFunction
<
Edge
<
K
,
EV
>,
Vertex
<
K
,
NullValue
>>
{
...
...
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/clustering/directed/LocalClusteringCoefficient.java
浏览文件 @
e2ef74ea
...
...
@@ -21,6 +21,7 @@ package org.apache.flink.graph.library.clustering.directed;
import
org.apache.flink.api.common.functions.FlatMapFunction
;
import
org.apache.flink.api.common.functions.JoinFunction
;
import
org.apache.flink.api.common.functions.ReduceFunction
;
import
org.apache.flink.api.common.operators.base.ReduceOperatorBase.CombineHint
;
import
org.apache.flink.api.java.DataSet
;
import
org.apache.flink.api.java.functions.FunctionAnnotation
;
import
org.apache.flink.api.java.tuple.Tuple2
;
...
...
@@ -121,6 +122,7 @@ extends GraphAlgorithmDelegatingDataSet<K, VV, EV, Result<K>> {
DataSet
<
Tuple2
<
K
,
LongValue
>>
vertexTriangleCount
=
triangleVertices
.
groupBy
(
0
)
.
reduce
(
new
CountTriangles
<
K
>())
.
setCombineHint
(
CombineHint
.
HASH
)
.
name
(
"Count triangles"
);
// u, deg(u)
...
...
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/clustering/undirected/LocalClusteringCoefficient.java
浏览文件 @
e2ef74ea
...
...
@@ -21,6 +21,7 @@ package org.apache.flink.graph.library.clustering.undirected;
import
org.apache.flink.api.common.functions.FlatMapFunction
;
import
org.apache.flink.api.common.functions.JoinFunction
;
import
org.apache.flink.api.common.functions.ReduceFunction
;
import
org.apache.flink.api.common.operators.base.ReduceOperatorBase.CombineHint
;
import
org.apache.flink.api.java.DataSet
;
import
org.apache.flink.api.java.functions.FunctionAnnotation
;
import
org.apache.flink.api.java.tuple.Tuple2
;
...
...
@@ -122,6 +123,7 @@ extends GraphAlgorithmDelegatingDataSet<K, VV, EV, Result<K>> {
DataSet
<
Tuple2
<
K
,
LongValue
>>
vertexTriangleCount
=
triangleVertices
.
groupBy
(
0
)
.
reduce
(
new
CountTriangles
<
K
>())
.
setCombineHint
(
CombineHint
.
HASH
)
.
name
(
"Count triangles"
);
// u, deg(u)
...
...
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/link_analysis/HITS.java
浏览文件 @
e2ef74ea
...
...
@@ -26,6 +26,7 @@ import org.apache.flink.api.common.functions.MapFunction;
import
org.apache.flink.api.common.functions.ReduceFunction
;
import
org.apache.flink.api.common.functions.RichJoinFunction
;
import
org.apache.flink.api.common.operators.base.JoinOperatorBase.JoinHint
;
import
org.apache.flink.api.common.operators.base.ReduceOperatorBase.CombineHint
;
import
org.apache.flink.api.java.DataSet
;
import
org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFields
;
import
org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFieldsFirst
;
...
...
@@ -169,6 +170,7 @@ extends GraphAlgorithmDelegatingDataSet<K, VV, EV, Result<K>> {
.
name
(
"Initial scores"
)
.
groupBy
(
0
)
.
reduce
(
new
SumScores
<
K
>())
.
setCombineHint
(
CombineHint
.
HASH
)
.
setParallelism
(
parallelism
)
.
name
(
"Sum"
);
...
...
@@ -185,6 +187,7 @@ extends GraphAlgorithmDelegatingDataSet<K, VV, EV, Result<K>> {
.
name
(
"Hub"
)
.
groupBy
(
0
)
.
reduce
(
new
SumScore
<
K
>())
.
setCombineHint
(
CombineHint
.
HASH
)
.
setParallelism
(
parallelism
)
.
name
(
"Sum"
);
...
...
@@ -194,6 +197,7 @@ extends GraphAlgorithmDelegatingDataSet<K, VV, EV, Result<K>> {
.
setParallelism
(
parallelism
)
.
name
(
"Square"
)
.
reduce
(
new
Sum
())
.
setCombineHint
(
CombineHint
.
HASH
)
.
setParallelism
(
parallelism
)
.
name
(
"Sum"
);
...
...
@@ -207,6 +211,7 @@ extends GraphAlgorithmDelegatingDataSet<K, VV, EV, Result<K>> {
.
name
(
"Authority"
)
.
groupBy
(
0
)
.
reduce
(
new
SumScore
<
K
>())
.
setCombineHint
(
CombineHint
.
HASH
)
.
setParallelism
(
parallelism
)
.
name
(
"Sum"
);
...
...
@@ -216,6 +221,7 @@ extends GraphAlgorithmDelegatingDataSet<K, VV, EV, Result<K>> {
.
setParallelism
(
parallelism
)
.
name
(
"Square"
)
.
reduce
(
new
Sum
())
.
setCombineHint
(
CombineHint
.
HASH
)
.
setParallelism
(
parallelism
)
.
name
(
"Sum"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录