Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5DE84200C62 for ; Wed, 12 Apr 2017 02:06:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5CA5E160BA3; Wed, 12 Apr 2017 00:06:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AC202160B9B for ; Wed, 12 Apr 2017 02:06:51 +0200 (CEST) Received: (qmail 79641 invoked by uid 500); 12 Apr 2017 00:06:50 -0000 Mailing-List: contact dev-help@madlib.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@madlib.incubator.apache.org Delivered-To: mailing list dev@madlib.incubator.apache.org Received: (qmail 79620 invoked by uid 99); 12 Apr 2017 00:06:50 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Apr 2017 00:06:50 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 17A42CA91D for ; Wed, 12 Apr 2017 00:06:50 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.021 X-Spam-Level: X-Spam-Status: No, score=-4.021 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id H9mCqh7WRvSS for ; Wed, 12 Apr 2017 00:06:49 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 885CB60DA1 for ; Wed, 12 Apr 2017 00:06:48 +0000 (UTC) Received: (qmail 79609 invoked by uid 99); 12 Apr 2017 00:06:47 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Apr 2017 00:06:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7D9B2DF965; Wed, 12 Apr 2017 00:06:47 +0000 (UTC) From: orhankislal To: dev@madlib.incubator.apache.org Reply-To: dev@madlib.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-madlib pull request #112: Feautre: Add grouping support for PageRa... Content-Type: text/plain Message-Id: <20170412000647.7D9B2DF965@git1-us-west.apache.org> Date: Wed, 12 Apr 2017 00:06:47 +0000 (UTC) archived-at: Wed, 12 Apr 2017 00:06:52 -0000 Github user orhankislal commented on a diff in the pull request: https://github.com/apache/incubator-madlib/pull/112#discussion_r111033008 --- Diff: src/ports/postgres/modules/graph/pagerank.py_in --- @@ -158,44 +313,198 @@ def pagerank(schema_madlib, vertex_table, vertex_id, edge_table, edge_args, # https://en.wikipedia.org/wiki/PageRank#Damping_factor # The query below computes the PageRank of each node using the above formula. + # A small explanatory note on ignore_group_clause: + # This is used only when grouping is set. This essentially will have + # the condition that will help skip the PageRank computation on groups + # that have converged. plpy.execute(""" CREATE TABLE {message} AS - SELECT {edge_temp_table}.{dest} AS {vertex_id}, - SUM({v1}.pagerank/{out_cnts}.{out_cnts_cnt})*{damping_factor}+{random_prob} AS pagerank + SELECT {grouping_cols_select} {edge_temp_table}.{dest} AS {vertex_id}, + SUM({v1}.pagerank/{out_cnts}.{out_cnts_cnt})*{damping_factor}+{random_jump_prob} AS pagerank FROM {edge_temp_table} - INNER JOIN {cur} ON {edge_temp_table}.{dest}={cur}.{vertex_id} - INNER JOIN {out_cnts} ON {out_cnts}.{vertex_id}={edge_temp_table}.{src} - INNER JOIN {cur} AS {v1} ON {v1}.{vertex_id}={edge_temp_table}.{src} - GROUP BY {edge_temp_table}.{dest} - """.format(**locals())) + INNER JOIN {cur} ON {cur_join_clause} + INNER JOIN {out_cnts} ON {out_cnts_join_clause} + INNER JOIN {cur} AS {v1} ON {v1_join_clause} + {vertices_per_group_inner_join} + {ignore_group_clause} + GROUP BY {grouping_cols_select} {edge_temp_table}.{dest} + """.format(grouping_cols_select=edge_grouping_cols_select+', ' --- End diff -- You might want to move these grouping_cols if checks out of the loop. You can initialize them to empty strings (similar to lines 122 - 127) and overwrite them when you have grouping (similar to lines 169 - 184). I am sure a C compiler can take care of it automatically but I am not sure about python. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---