Repository: flink-web
Updated Branches:
  refs/heads/asf-site a283d1701 -> 7491f2a53


[FLINK-4593] Fix PageRank algorithm example

This closes #35


Project: http://git-wip-us.apache.org/repos/asf/flink-web/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink-web/commit/86d7ae0d
Tree: http://git-wip-us.apache.org/repos/asf/flink-web/tree/86d7ae0d
Diff: http://git-wip-us.apache.org/repos/asf/flink-web/diff/86d7ae0d

Branch: refs/heads/asf-site
Commit: 86d7ae0de1369fa75f17e84db62cf1f2f859d1c9
Parents: a283d17
Author: Alexander Pivovarov <apivova...@gmail.com>
Authored: Wed Sep 7 11:52:04 2016 -0700
Committer: Greg Hogan <g...@apache.org>
Committed: Fri Oct 14 14:17:52 2016 -0400

----------------------------------------------------------------------
 features.md | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink-web/blob/86d7ae0d/features.md
----------------------------------------------------------------------
diff --git a/features.md b/features.md
index a990a77..e4b2516 100644
--- a/features.md
+++ b/features.md
@@ -244,7 +244,7 @@ case class Word(word: String, freq: Long)
 val texts: DataStream[String] = ...
 
 val counts = text
-  .flatMap { line => line.split("\\W+") } 
+  .flatMap { line => line.split("\\W+") }
   .map { token => Word(token, 1) }
   .keyBy("word")
   .timeWindow(Time.seconds(5), Time.seconds(1))
@@ -272,13 +272,14 @@ case class Page(pageId: Long, rank: Double)
 case class Adjacency(id: Long, neighbors: Array[Long])
 
 val result = initialRanks.iterate(30) { pages =>
-  pages.join(adjacency).where("pageId").equalTo("pageId") {
+  pages.join(adjacency).where("pageId").equalTo("id") {
 
-    (page, adj, out : Collector[Page]) => {
-      out.collect(Page(page.id, 0.15 / numPages))
-        
+    (page, adj, out: Collector[Page]) => {
+      out.collect(Page(page.pageId, 0.15 / numPages))
+
+      val nLen = adj.neighbors.length
       for (n <- adj.neighbors) {
-        out.collect(Page(n, 0.85*page.rank/adj.neighbors.length))
+        out.collect(Page(n, 0.85 * page.rank / nLen))
       }
     }
   }
@@ -335,4 +336,3 @@ val result = initialRanks.iterate(30) { pages =>
     <img src="{{ site.baseurl }}/img/features/ecosystem_logos.png" alt="Other 
projects that Flink is integrated with" style="width:75%" />
   </div>
 </div>
-

Reply via email to