{"action":"created","comment":{"url":"https://api.github.com/repos/graphframes/graphframes/pulls/comments/239701437","pull_request_review_id":182553904,"id":239701437,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzOTcwMTQzNw==","diff_hunk":"@@ -0,0 +1,236 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements.  See the NOTICE file distributed with\n+ * this work for additional information regarding copyright ownership.\n+ * The ASF licenses this file to You under the Apache License, Version 2.0\n+ * (the \"License\"); you may not use this file except in compliance with\n+ * the License.  You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.graphframes\n+\n+import org.apache.spark.sql.{Column, DataFrame}\n+import org.apache.spark.sql.functions.{array, col, explode, struct, when}\n+\n+/**\n+ * This class implement pregel on GraphFrame.\n+ *\n+ * We can get the Pregel instance by `graphFrame.pregel`, or construct it via a `graph`\n+ * argument. and call a series of methods, then call method `run` to start pregel.\n+ * It will return a DataFrame which is the vertices dataframe generated in the last round.\n+ *\n+ * When pregel `run` start, first, it will initialize some columns in vertices dataframe,\n+ * which defined by `withVertexColumn` (user can call it multiple times),\n+ * and then start iteration.\n+ *\n+ * Once the iteration start, in each supersteps of pregel, include 3 phases:\n+ * phase-1) generate the `triplets` dataframe, and generate the “msg” to send.\n+ * The target vertex to send and the msg is set via `sendMsg` method.\n+ * phase-2) Do msg aggregation. It will use the aggregation column which is set via\n+ * `aggMsgs` method. Each vertex aggregates those messages which it receives.\n+ * Now vertices dataframe owns a new column which value is the aggregated msgs\n+ * (received by each vertex). Now update vertex property columns, the update expressions\n+ * is set by `updateVertexColumn` method and return the new vertices dataframe.\n+ *\n+ * The pregel iteration will run `maxIter` time, which can be set via `setMaxIter` method.\n+ *\n+ * @param graph The graph which pregel will run on.\n+ */\n+class Pregel(val graph: GraphFrame) {\n+\n+  private val withVertexColumnList = collection.mutable.ListBuffer.empty[(String, Column, Column)]\n+\n+  private var maxIter: Int = 100\n+  private var checkpointInterval = 2\n+\n+  private var sendMsgs = collection.mutable.ListBuffer.empty[(Column, Column)]\n+  private var aggMsgsCol: Column = null\n+\n+  private val CHECKPOINT_NAME_PREFIX = \"pregel\"\n+\n+  /** Set max iteration number for the pregel running. Default value is 100 */\n+  def setMaxIter(value: Int): this.type = {\n+    maxIter = value\n+    this\n+  }\n+\n+  /**\n+   * Set the period to do the checkpoint when running pregel.\n+   * If set to zero or negative value, then do not checkpoint.\n+   * Default value is 2\n+   */\n+  def setCheckpointInterval(value: Int): this.type = {\n+    checkpointInterval = value\n+    this\n+  }\n+\n+  /**\n+   * Use this method to set those vertex columns which will be initialized before\n+   * pregel rounds start, and these columns will be updated after vertex receive\n+   * aggregated messages in each round.\n+   *\n+   * @param colName the column name of initialized column in vertex Dataframe\n+   * @param initialExpr The column expression used to initialize the column.\n+   * @param updateAfterAggMsgsExpr The column expression used to update the column.\n+   *                               Note that this sql expression can reference all\n+   *                               vertex columns and an extra message column\n+   *                               `Pregel.msgCol`.\n+   */\n+  def withVertexColumn(colName: String, initialExpr: Column,\n+                       updateAfterAggMsgsExpr: Column): this.type = {\n+    withVertexColumnList += Tuple3(colName, initialExpr, updateAfterAggMsgsExpr)\n+    this\n+  }\n+\n+  /**\n+   * Set the message column. In each round of pregel, each triplet\n+   * (src-edge-dst) will generate zero or one message and the message will\n+   * be sent to the src vertex of this triplet.\n+   *\n+   * @param msgExpr The message expression. It is a sql expression and it\n+   *                can reference all propertis in the triplet, in the way\n+   *                `Pregel.src(\"src_col_name)`, `Pregel.edge(\"edge_col_name)`,\n+   *                `Pregel.dst(\"dst_col_name)`\n+   */\n+  def sendMsgToSrc(msgExpr: Column): this.type = {","path":"src/main/scala/org/graphframes/Pregel.scala","position":103,"original_position":103,"commit_id":"1b7587adef5583c4f25633de0a59e7151f0d647a","original_commit_id":"1b7587adef5583c4f25633de0a59e7151f0d647a","user":{"login":"mengxr","id":829644,"node_id":"MDQ6VXNlcjgyOTY0NA==","avatar_url":"https://avatars2.githubusercontent.com/u/829644?v=4","gravatar_id":"","url":"https://api.github.com/users/mengxr","html_url":"https://github.com/mengxr","followers_url":"https://api.github.com/users/mengxr/followers","following_url":"https://api.github.com/users/mengxr/following{/other_user}","gists_url":"https://api.github.com/users/mengxr/gists{/gist_id}","starred_url":"https://api.github.com/users/mengxr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mengxr/subscriptions","organizations_url":"https://api.github.com/users/mengxr/orgs","repos_url":"https://api.github.com/users/mengxr/repos","events_url":"https://api.github.com/users/mengxr/events{/privacy}","received_events_url":"https://api.github.com/users/mengxr/received_events","type":"User","site_admin":false},"body":"Mention `null` value.","created_at":"2018-12-07T05:53:05Z","updated_at":"2018-12-07T05:53:15Z","html_url":"https://github.com/graphframes/graphframes/pull/304#discussion_r239701437","pull_request_url":"https://api.github.com/repos/graphframes/graphframes/pulls/304","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/graphframes/graphframes/pulls/comments/239701437"},"html":{"href":"https://github.com/graphframes/graphframes/pull/304#discussion_r239701437"},"pull_request":{"href":"https://api.github.com/repos/graphframes/graphframes/pulls/304"}}},"pull_request":{"url":"https://api.github.com/repos/graphframes/graphframes/pulls/304","id":235764150,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM1NzY0MTUw","html_url":"https://github.com/graphframes/graphframes/pull/304","diff_url":"https://github.com/graphframes/graphframes/pull/304.diff","patch_url":"https://github.com/graphframes/graphframes/pull/304.patch","issue_url":"https://api.github.com/repos/graphframes/graphframes/issues/304","number":304,"state":"open","locked":false,"title":"pregel support","user":{"login":"WeichenXu123","id":19235986,"node_id":"MDQ6VXNlcjE5MjM1OTg2","avatar_url":"https://avatars0.githubusercontent.com/u/19235986?v=4","gravatar_id":"","url":"https://api.github.com/users/WeichenXu123","html_url":"https://github.com/WeichenXu123","followers_url":"https://api.github.com/users/WeichenXu123/followers","following_url":"https://api.github.com/users/WeichenXu123/following{/other_user}","gists_url":"https://api.github.com/users/WeichenXu123/gists{/gist_id}","starred_url":"https://api.github.com/users/WeichenXu123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeichenXu123/subscriptions","organizations_url":"https://api.github.com/users/WeichenXu123/orgs","repos_url":"https://api.github.com/users/WeichenXu123/repos","events_url":"https://api.github.com/users/WeichenXu123/events{/privacy}","received_events_url":"https://api.github.com/users/WeichenXu123/received_events","type":"User","site_admin":false},"body":"Add Pregel interface to GraphFrames.","created_at":"2018-12-04T10:57:52Z","updated_at":"2018-12-07T05:53:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"990f9aa5506cc226ad1ede31fb67cac8322f5b8f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/graphframes/graphframes/pulls/304/commits","review_comments_url":"https://api.github.com/repos/graphframes/graphframes/pulls/304/comments","review_comment_url":"https://api.github.com/repos/graphframes/graphframes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/graphframes/graphframes/issues/304/comments","statuses_url":"https://api.github.com/repos/graphframes/graphframes/statuses/1b7587adef5583c4f25633de0a59e7151f0d647a","head":{"label":"WeichenXu123:pregel","ref":"pregel","sha":"1b7587adef5583c4f25633de0a59e7151f0d647a","user":{"login":"WeichenXu123","id":19235986,"node_id":"MDQ6VXNlcjE5MjM1OTg2","avatar_url":"https://avatars0.githubusercontent.com/u/19235986?v=4","gravatar_id":"","url":"https://api.github.com/users/WeichenXu123","html_url":"https://github.com/WeichenXu123","followers_url":"https://api.github.com/users/WeichenXu123/followers","following_url":"https://api.github.com/users/WeichenXu123/following{/other_user}","gists_url":"https://api.github.com/users/WeichenXu123/gists{/gist_id}","starred_url":"https://api.github.com/users/WeichenXu123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeichenXu123/subscriptions","organizations_url":"https://api.github.com/users/WeichenXu123/orgs","repos_url":"https://api.github.com/users/WeichenXu123/repos","events_url":"https://api.github.com/users/WeichenXu123/events{/privacy}","received_events_url":"https://api.github.com/users/WeichenXu123/received_events","type":"User","site_admin":false},"repo":{"id":60845470,"node_id":"MDEwOlJlcG9zaXRvcnk2MDg0NTQ3MA==","name":"graphframes","full_name":"WeichenXu123/graphframes","private":false,"owner":{"login":"WeichenXu123","id":19235986,"node_id":"MDQ6VXNlcjE5MjM1OTg2","avatar_url":"https://avatars0.githubusercontent.com/u/19235986?v=4","gravatar_id":"","url":"https://api.github.com/users/WeichenXu123","html_url":"https://github.com/WeichenXu123","followers_url":"https://api.github.com/users/WeichenXu123/followers","following_url":"https://api.github.com/users/WeichenXu123/following{/other_user}","gists_url":"https://api.github.com/users/WeichenXu123/gists{/gist_id}","starred_url":"https://api.github.com/users/WeichenXu123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeichenXu123/subscriptions","organizations_url":"https://api.github.com/users/WeichenXu123/orgs","repos_url":"https://api.github.com/users/WeichenXu123/repos","events_url":"https://api.github.com/users/WeichenXu123/events{/privacy}","received_events_url":"https://api.github.com/users/WeichenXu123/received_events","type":"User","site_admin":false},"html_url":"https://github.com/WeichenXu123/graphframes","description":null,"fork":true,"url":"https://api.github.com/repos/WeichenXu123/graphframes","forks_url":"https://api.github.com/repos/WeichenXu123/graphframes/forks","keys_url":"https://api.github.com/repos/WeichenXu123/graphframes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WeichenXu123/graphframes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WeichenXu123/graphframes/teams","hooks_url":"https://api.github.com/repos/WeichenXu123/graphframes/hooks","issue_events_url":"https://api.github.com/repos/WeichenXu123/graphframes/issues/events{/number}","events_url":"https://api.github.com/repos/WeichenXu123/graphframes/events","assignees_url":"https://api.github.com/repos/WeichenXu123/graphframes/assignees{/user}","branches_url":"https://api.github.com/repos/WeichenXu123/graphframes/branches{/branch}","tags_url":"https://api.github.com/repos/WeichenXu123/graphframes/tags","blobs_url":"https://api.github.com/repos/WeichenXu123/graphframes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WeichenXu123/graphframes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WeichenXu123/graphframes/git/refs{/sha}","trees_url":"https://api.github.com/repos/WeichenXu123/graphframes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WeichenXu123/graphframes/statuses/{sha}","languages_url":"https://api.github.com/repos/WeichenXu123/graphframes/languages","stargazers_url":"https://api.github.com/repos/WeichenXu123/graphframes/stargazers","contributors_url":"https://api.github.com/repos/WeichenXu123/graphframes/contributors","subscribers_url":"https://api.github.com/repos/WeichenXu123/graphframes/subscribers","subscription_url":"https://api.github.com/repos/WeichenXu123/graphframes/subscription","commits_url":"https://api.github.com/repos/WeichenXu123/graphframes/commits{/sha}","git_commits_url":"https://api.github.com/repos/WeichenXu123/graphframes/git/commits{/sha}","comments_url":"https://api.github.com/repos/WeichenXu123/graphframes/comments{/number}","issue_comment_url":"https://api.github.com/repos/WeichenXu123/graphframes/issues/comments{/number}","contents_url":"https://api.github.com/repos/WeichenXu123/graphframes/contents/{+path}","compare_url":"https://api.github.com/repos/WeichenXu123/graphframes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WeichenXu123/graphframes/merges","archive_url":"https://api.github.com/repos/WeichenXu123/graphframes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WeichenXu123/graphframes/downloads","issues_url":"https://api.github.com/repos/WeichenXu123/graphframes/issues{/number}","pulls_url":"https://api.github.com/repos/WeichenXu123/graphframes/pulls{/number}","milestones_url":"https://api.github.com/repos/WeichenXu123/graphframes/milestones{/number}","notifications_url":"https://api.github.com/repos/WeichenXu123/graphframes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WeichenXu123/graphframes/labels{/name}","releases_url":"https://api.github.com/repos/WeichenXu123/graphframes/releases{/id}","deployments_url":"https://api.github.com/repos/WeichenXu123/graphframes/deployments","created_at":"2016-06-10T12:16:38Z","updated_at":"2016-06-10T12:16:39Z","pushed_at":"2018-12-06T16:55:38Z","git_url":"git://github.com/WeichenXu123/graphframes.git","ssh_url":"git@github.com:WeichenXu123/graphframes.git","clone_url":"https://github.com/WeichenXu123/graphframes.git","svn_url":"https://github.com/WeichenXu123/graphframes","homepage":"http://graphframes.github.io/","size":857,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"graphframes:master","ref":"master","sha":"dc11c4a7c1b94cfe801f8480e6ea5c64064a8b99","user":{"login":"graphframes","id":16808115,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2ODA4MTE1","avatar_url":"https://avatars0.githubusercontent.com/u/16808115?v=4","gravatar_id":"","url":"https://api.github.com/users/graphframes","html_url":"https://github.com/graphframes","followers_url":"https://api.github.com/users/graphframes/followers","following_url":"https://api.github.com/users/graphframes/following{/other_user}","gists_url":"https://api.github.com/users/graphframes/gists{/gist_id}","starred_url":"https://api.github.com/users/graphframes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graphframes/subscriptions","organizations_url":"https://api.github.com/users/graphframes/orgs","repos_url":"https://api.github.com/users/graphframes/repos","events_url":"https://api.github.com/users/graphframes/events{/privacy}","received_events_url":"https://api.github.com/users/graphframes/received_events","type":"Organization","site_admin":false},"repo":{"id":50067430,"node_id":"MDEwOlJlcG9zaXRvcnk1MDA2NzQzMA==","name":"graphframes","full_name":"graphframes/graphframes","private":false,"owner":{"login":"graphframes","id":16808115,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2ODA4MTE1","avatar_url":"https://avatars0.githubusercontent.com/u/16808115?v=4","gravatar_id":"","url":"https://api.github.com/users/graphframes","html_url":"https://github.com/graphframes","followers_url":"https://api.github.com/users/graphframes/followers","following_url":"https://api.github.com/users/graphframes/following{/other_user}","gists_url":"https://api.github.com/users/graphframes/gists{/gist_id}","starred_url":"https://api.github.com/users/graphframes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graphframes/subscriptions","organizations_url":"https://api.github.com/users/graphframes/orgs","repos_url":"https://api.github.com/users/graphframes/repos","events_url":"https://api.github.com/users/graphframes/events{/privacy}","received_events_url":"https://api.github.com/users/graphframes/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/graphframes/graphframes","description":null,"fork":false,"url":"https://api.github.com/repos/graphframes/graphframes","forks_url":"https://api.github.com/repos/graphframes/graphframes/forks","keys_url":"https://api.github.com/repos/graphframes/graphframes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/graphframes/graphframes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/graphframes/graphframes/teams","hooks_url":"https://api.github.com/repos/graphframes/graphframes/hooks","issue_events_url":"https://api.github.com/repos/graphframes/graphframes/issues/events{/number}","events_url":"https://api.github.com/repos/graphframes/graphframes/events","assignees_url":"https://api.github.com/repos/graphframes/graphframes/assignees{/user}","branches_url":"https://api.github.com/repos/graphframes/graphframes/branches{/branch}","tags_url":"https://api.github.com/repos/graphframes/graphframes/tags","blobs_url":"https://api.github.com/repos/graphframes/graphframes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/graphframes/graphframes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/graphframes/graphframes/git/refs{/sha}","trees_url":"https://api.github.com/repos/graphframes/graphframes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/graphframes/graphframes/statuses/{sha}","languages_url":"https://api.github.com/repos/graphframes/graphframes/languages","stargazers_url":"https://api.github.com/repos/graphframes/graphframes/stargazers","contributors_url":"https://api.github.com/repos/graphframes/graphframes/contributors","subscribers_url":"https://api.github.com/repos/graphframes/graphframes/subscribers","subscription_url":"https://api.github.com/repos/graphframes/graphframes/subscription","commits_url":"https://api.github.com/repos/graphframes/graphframes/commits{/sha}","git_commits_url":"https://api.github.com/repos/graphframes/graphframes/git/commits{/sha}","comments_url":"https://api.github.com/repos/graphframes/graphframes/comments{/number}","issue_comment_url":"https://api.github.com/repos/graphframes/graphframes/issues/comments{/number}","contents_url":"https://api.github.com/repos/graphframes/graphframes/contents/{+path}","compare_url":"https://api.github.com/repos/graphframes/graphframes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/graphframes/graphframes/merges","archive_url":"https://api.github.com/repos/graphframes/graphframes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/graphframes/graphframes/downloads","issues_url":"https://api.github.com/repos/graphframes/graphframes/issues{/number}","pulls_url":"https://api.github.com/repos/graphframes/graphframes/pulls{/number}","milestones_url":"https://api.github.com/repos/graphframes/graphframes/milestones{/number}","notifications_url":"https://api.github.com/repos/graphframes/graphframes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/graphframes/graphframes/labels{/name}","releases_url":"https://api.github.com/repos/graphframes/graphframes/releases{/id}","deployments_url":"https://api.github.com/repos/graphframes/graphframes/deployments","created_at":"2016-01-20T23:17:56Z","updated_at":"2018-12-05T05:46:39Z","pushed_at":"2018-12-06T16:55:40Z","git_url":"git://github.com/graphframes/graphframes.git","ssh_url":"git@github.com:graphframes/graphframes.git","clone_url":"https://github.com/graphframes/graphframes.git","svn_url":"https://github.com/graphframes/graphframes","homepage":"http://graphframes.github.io/","size":840,"stargazers_count":442,"watchers_count":442,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":141,"mirror_url":null,"archived":false,"open_issues_count":98,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":141,"open_issues":98,"watchers":442,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/graphframes/graphframes/pulls/304"},"html":{"href":"https://github.com/graphframes/graphframes/pull/304"},"issue":{"href":"https://api.github.com/repos/graphframes/graphframes/issues/304"},"comments":{"href":"https://api.github.com/repos/graphframes/graphframes/issues/304/comments"},"review_comments":{"href":"https://api.github.com/repos/graphframes/graphframes/pulls/304/comments"},"review_comment":{"href":"https://api.github.com/repos/graphframes/graphframes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/graphframes/graphframes/pulls/304/commits"},"statuses":{"href":"https://api.github.com/repos/graphframes/graphframes/statuses/1b7587adef5583c4f25633de0a59e7151f0d647a"}},"author_association":"NONE"}}
{"actor":{"display_login":"mengxr"}}