You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@madlib.apache.org by GitBox <gi...@apache.org> on 2022/06/09 22:49:15 UTC
[GitHub] [madlib] orhankislal opened a new pull request, #582: Utilities: Reuse update plan in GroupIterationController
orhankislal opened a new pull request, #582:
URL: https://github.com/apache/madlib/pull/582
The group iteration controller prepares a plan and executes it during
the update phase. For some modules, this plan does not change between
iterations. With this commit, the plan gets saved and reused as needed.
Co-authored-by: Bhuvnesh Chaudhary <bc...@pivotal.io>
<!--
Thanks for sending a pull request! Here are some tips for you:
1. Refer to this link for contribution guidelines https://cwiki.apache.org/confluence/display/MADLIB/Contribution+Guidelines
2. Please Provide the Module Name, a JIRA Number and a short description about your changes.
-->
- [ ] Add the module name, JIRA# to PR/commit and description.
- [ ] Add tests for the change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@madlib.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [madlib] khannaekta commented on a diff in pull request #582: Utilities: Reuse update plan in GroupIterationController
Posted by GitBox <gi...@apache.org>.
khannaekta commented on code in PR #582:
URL: https://github.com/apache/madlib/pull/582#discussion_r896285007
##########
src/ports/postgres/modules/utilities/in_mem_group_control.py_in:
##########
@@ -549,40 +550,43 @@ class GroupIterationController:
self.iteration = self.iteration + 1
group_param = self.group_param
- run_sql = """
- SELECT
- {_grp_key} AS {col_grp_key},
- {grouping_col},
- {iteration} AS {col_grp_iteration},
- ({newState}) AS {col_grp_state}
- FROM (
- SELECT *,
- array_to_string(ARRAY[{grouping_str}], ',') AS {col_grp_key}
- FROM {rel_source}
- ) AS {as_rel_source}
- JOIN ( {select_rel_state} ) AS {rel_state}
- {using_str}
- JOIN ( {select_n_tuples} ) AS _rel_n_tuples
- {using_str}
- {groupby_str}
- """.format(
- newState=newState,
- iteration=self.iteration,
- using_str=group_param.using_str,
- groupby_str=group_param.groupby_str,
- _grp_key=group_param.grp_key,
- select_rel_state=group_param.select_rel_state,
- select_n_tuples=group_param.select_n_tuples,
- **self.kwargs)
- update_plan = plpy.prepare(run_sql,
- ["text[]", group_param.grouped_state_type,
- "text[]", "integer[]"])
- res_tuples = plpy.execute(update_plan, [self.new_states.keys,
- self.new_states.values,
- self.grp_to_n_tuples.keys(),
- self.grp_to_n_tuples.values()])
+ if self.update_plan is None:
+ run_sql = """
+ SELECT
+ {_grp_key} AS {col_grp_key},
+ {grouping_col},
+ ({newState}) AS {col_grp_state}
+ FROM (
+ SELECT *,
+ array_to_string(ARRAY[{grouping_str}], ',') AS {col_grp_key}
+ FROM {rel_source}
+ ) AS {as_rel_source}
+ JOIN ( {select_rel_state} ) AS {rel_state}
+ {using_str}
+ JOIN ( {select_n_tuples} ) AS _rel_n_tuples
+ {using_str}
+ {groupby_str}
+ """.format(
+ newState=newState,
+ iteration=self.iteration,
+ using_str=group_param.using_str,
+ groupby_str=group_param.groupby_str,
+ _grp_key=group_param.grp_key,
+ select_rel_state=group_param.select_rel_state,
+ select_n_tuples=group_param.select_n_tuples,
+ **self.kwargs)
+
+ self.update_plan = plpy.prepare(run_sql,
Review Comment:
For `plpy.prepare()` statement, don't we want to pass along the `self.iteration` everytime? With initializing it just once for `self.update_plan` will we still be doing that?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@madlib.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [madlib] orhankislal merged pull request #582: Utilities: Reuse update plan in GroupIterationController
Posted by GitBox <gi...@apache.org>.
orhankislal merged PR #582:
URL: https://github.com/apache/madlib/pull/582
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@madlib.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [madlib] orhankislal commented on a diff in pull request #582: Utilities: Reuse update plan in GroupIterationController
Posted by GitBox <gi...@apache.org>.
orhankislal commented on code in PR #582:
URL: https://github.com/apache/madlib/pull/582#discussion_r898577542
##########
src/ports/postgres/modules/utilities/in_mem_group_control.py_in:
##########
@@ -549,40 +550,43 @@ class GroupIterationController:
self.iteration = self.iteration + 1
group_param = self.group_param
- run_sql = """
- SELECT
- {_grp_key} AS {col_grp_key},
- {grouping_col},
- {iteration} AS {col_grp_iteration},
- ({newState}) AS {col_grp_state}
- FROM (
- SELECT *,
- array_to_string(ARRAY[{grouping_str}], ',') AS {col_grp_key}
- FROM {rel_source}
- ) AS {as_rel_source}
- JOIN ( {select_rel_state} ) AS {rel_state}
- {using_str}
- JOIN ( {select_n_tuples} ) AS _rel_n_tuples
- {using_str}
- {groupby_str}
- """.format(
- newState=newState,
- iteration=self.iteration,
- using_str=group_param.using_str,
- groupby_str=group_param.groupby_str,
- _grp_key=group_param.grp_key,
- select_rel_state=group_param.select_rel_state,
- select_n_tuples=group_param.select_n_tuples,
- **self.kwargs)
- update_plan = plpy.prepare(run_sql,
- ["text[]", group_param.grouped_state_type,
- "text[]", "integer[]"])
- res_tuples = plpy.execute(update_plan, [self.new_states.keys,
- self.new_states.values,
- self.grp_to_n_tuples.keys(),
- self.grp_to_n_tuples.values()])
+ if self.update_plan is None:
+ run_sql = """
+ SELECT
+ {_grp_key} AS {col_grp_key},
+ {grouping_col},
+ ({newState}) AS {col_grp_state}
+ FROM (
+ SELECT *,
+ array_to_string(ARRAY[{grouping_str}], ',') AS {col_grp_key}
+ FROM {rel_source}
+ ) AS {as_rel_source}
+ JOIN ( {select_rel_state} ) AS {rel_state}
+ {using_str}
+ JOIN ( {select_n_tuples} ) AS _rel_n_tuples
+ {using_str}
+ {groupby_str}
+ """.format(
+ newState=newState,
+ iteration=self.iteration,
+ using_str=group_param.using_str,
+ groupby_str=group_param.groupby_str,
+ _grp_key=group_param.grp_key,
+ select_rel_state=group_param.select_rel_state,
+ select_n_tuples=group_param.select_n_tuples,
+ **self.kwargs)
+
+ self.update_plan = plpy.prepare(run_sql,
Review Comment:
That is what we used to do. Now, we keep it in memory (instead of the table) attached to the results dictionary on line 589.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@madlib.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org