Repository: incubator-hawq
Updated Branches:
  refs/heads/master b590ed9d4 -> 6dee3cccf


HAWQ-1214. Remove resource_parameters


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/6dee3ccc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/6dee3ccc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/6dee3ccc

Branch: refs/heads/master
Commit: 6dee3cccf00290dfa977027798ce810948cacdce
Parents: b590ed9
Author: Paul Guo <[email protected]>
Authored: Wed Dec 14 12:08:19 2016 +0800
Committer: Paul Guo <[email protected]>
Committed: Thu Dec 15 21:54:20 2016 +0800

----------------------------------------------------------------------
 src/backend/cdb/cdbdatalocality.c    | 73 ++++---------------------------
 src/backend/nodes/copyfuncs.c        | 46 -------------------
 src/backend/optimizer/plan/planner.c |  6 +--
 src/include/cdb/cdbdatalocality.h    | 17 -------
 src/include/executor/execdesc.h      | 16 -------
 src/include/nodes/nodes.h            |  1 -
 src/include/nodes/plannodes.h        |  1 -
 7 files changed, 11 insertions(+), 149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/6dee3ccc/src/backend/cdb/cdbdatalocality.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbdatalocality.c 
b/src/backend/cdb/cdbdatalocality.c
index 6e7ab2f..c2da7a7 100644
--- a/src/backend/cdb/cdbdatalocality.c
+++ b/src/backend/cdb/cdbdatalocality.c
@@ -49,6 +49,7 @@
 #include "nodes/nodes.h"
 #include "nodes/parsenodes.h"
 #include "optimizer/walkers.h"
+#include "optimizer/planmain.h"
 #include "parser/parsetree.h"
 #include "storage/fd.h"
 #include "postmaster/identity.h"
@@ -464,32 +465,6 @@ static int64 
set_maximum_segment_volume_parameter(Relation_Data *rel_data,
                int host_num, double* maxSizePerSegment);
 
 /*
- * saveQueryResourceParameters: save QueryResourceParameters
- * in prepare statement along with query plan so that the query
- * resource can be re-allocated during multiple executions of
- * the plan
- */
-void saveQueryResourceParameters(
-               QueryResourceParameters *resource_parameters,
-               QueryResourceLife       life,
-               int32                   slice_size,
-               int64_t                 iobytes,
-               int                     max_target_segment_num,
-               int                     min_target_segment_num,
-               HostnameVolumeInfo      *vol_info,
-               int                     vol_info_size)
-
-{
-       resource_parameters->life = life;
-       resource_parameters->slice_size = slice_size;
-       resource_parameters->iobytes = iobytes;
-       resource_parameters->max_target_segment_num = max_target_segment_num;
-       resource_parameters->min_target_segment_num = min_target_segment_num;
-       resource_parameters->vol_info = vol_info;
-       resource_parameters->vol_info_size = vol_info_size;
-}
-
-/*
  * Setup /cleanup the memory context for this run
  * of data locality algorithm.
  */
@@ -3433,45 +3408,45 @@ static void 
print_datalocality_overall_log_information(SplitAllocResult *result,
                        if(log_context->minSegmentNumofHost > 0 ){
                                fprintf(fpratio, 
"segmentnumber_perhost_max/min=%.2f\n", 
(double)(log_context->maxSegmentNumofHost / log_context->minSegmentNumofHost));
                        }else{
-                               fprintf(fpratio, 
"segmentnumber_perhost_max/min=%lld\n", INT64_MAX);
+                               fprintf(fpratio, 
"segmentnumber_perhost_max/min=" INT64_FORMAT "\n", INT64_MAX);
                        }
                        if(log_context->avgSegmentNumofHost > 0 ){
                                fprintf(fpratio, 
"segmentnumber_perhost_max/avg=%.2f\n", 
(double)(log_context->maxSegmentNumofHost / log_context->avgSegmentNumofHost));
                        }else{
-                               fprintf(fpratio, 
"segmentnumber_perhost_max/avg=%lld\n", INT64_MAX);
+                               fprintf(fpratio, 
"segmentnumber_perhost_max/avg=" INT64_FORMAT "\n", INT64_MAX);
                        }
 
                        if (log_context->minSizeSegmentOverall > 0){
                                fprintf(fpratio, 
"segments_size_max/min=%.5f\n", (double)log_context->maxSizeSegmentOverall / 
(double)log_context->minSizeSegmentOverall);
                        }else{
-                               fprintf(fpratio, 
"segments_size_max/min=%lld\n", INT64_MAX);
+                               fprintf(fpratio, "segments_size_max/min=" 
INT64_FORMAT "\n", INT64_MAX);
                        }
                        if (log_context->avgSizeOverall > 0){
                                fprintf(fpratio, 
"segments_size_max/avg=%.5f\n", log_context->maxSizeSegmentOverall / 
log_context->avgSizeOverall);
                        }else{
-                               fprintf(fpratio, 
"segments_size_max/avg=%lld\n", INT64_MAX);
+                               fprintf(fpratio, "segments_size_max/avg=" 
INT64_FORMAT "\n", INT64_MAX);
                        }
 
                        if (log_context->minSizeSegmentOverallPenalty > 0){
                                fprintf(fpratio, 
"segments_size_penalty_max/min=%.5f\n",(double)log_context->maxSizeSegmentOverallPenalty
 / (double)log_context->minSizeSegmentOverallPenalty);
                        }else{
-                               fprintf(fpratio, 
"segments_size_penalty_max/min=%lld\n", INT64_MAX);
+                               fprintf(fpratio, 
"segments_size_penalty_max/min=" INT64_FORMAT "\n", INT64_MAX);
                        }
                        if (log_context->avgSizeOverallPenalty > 0){
                                fprintf(fpratio, 
"segments_size_penalty_max/avg=%.5f\n",log_context->maxSizeSegmentOverallPenalty
 / log_context->avgSizeOverallPenalty);
                        }else{
-                               fprintf(fpratio, 
"segments_size_penalty_max/avg=%lld\n", INT64_MAX);
+                               fprintf(fpratio, 
"segments_size_penalty_max/avg=" INT64_FORMAT "\n", INT64_MAX);
                        }
 
                        if (log_context->minContinuityOverall > 0){
                                fprintf(fpratio, 
"continuity_max/min=%.5f\n",log_context->maxContinuityOverall / 
log_context->minContinuityOverall);
                        }else{
-                               fprintf(fpratio, "continuity_max/min=%lld\n", 
INT64_MAX);
+                               fprintf(fpratio, "continuity_max/min=" 
INT64_FORMAT "\n", INT64_MAX);
                        }
                        if (log_context->avgContinuityOverall > 0){
                                fprintf(fpratio, 
"continuity_max/avg=%.5f\n",log_context->maxContinuityOverall / 
log_context->avgContinuityOverall);
                        }else{
-                               fprintf(fpratio, "continuity_max/avg=%lld\n", 
INT64_MAX);
+                               fprintf(fpratio, "continuity_max/avg=" 
INT64_FORMAT "\n", INT64_MAX);
                        }
                        fflush(fpratio);
                        fclose(fpratio);
@@ -4050,7 +4025,6 @@ calculate_planner_segment_num(Query *query, 
QueryResourceLife resourceLife,
                List *fullRangeTable, GpPolicy *intoPolicy, int sliceNum, int 
fixedVsegNum) {
        SplitAllocResult *result = NULL;
        QueryResource *resource = NULL;
-       QueryResourceParameters *resource_parameters = NULL;
 
        List *virtual_segments = NIL;
        List *alloc_result = NIL;
@@ -4060,7 +4034,6 @@ calculate_planner_segment_num(Query *query, 
QueryResourceLife resourceLife,
 
        result = (SplitAllocResult *) palloc(sizeof(SplitAllocResult));
        result->resource = NULL;
-       result->resource_parameters = NULL;
        result->alloc_results = NIL;
        result->relsType = NIL;
        result->planner_segments = 0;
@@ -4078,7 +4051,6 @@ calculate_planner_segment_num(Query *query, 
QueryResourceLife resourceLife,
 
        if (Gp_role != GP_ROLE_DISPATCH) {
                result->resource = NULL;
-               result->resource_parameters = NULL;
                result->alloc_results = NIL;
                result->relsType = NIL;
                result->planner_segments = 0;
@@ -4091,8 +4063,6 @@ calculate_planner_segment_num(Query *query, 
QueryResourceLife resourceLife,
 
                init_datalocality_context(&context);
 
-               resource_parameters = makeNode(QueryResourceParameters);
-
                collect_range_tables(query, fullRangeTable, 
&(context.rtc_context));
 
                bool isTableFunctionExists = false;
@@ -4147,17 +4117,6 @@ calculate_planner_segment_num(Query *query, 
QueryResourceLife resourceLife,
                                resource = AllocateResource(resourceLife, 
sliceNum, 0, 0, 0, NULL, 0);
                        }
 
-                       saveQueryResourceParameters(
-                                                       resource_parameters,  
/* resource_parameters */
-                                                       resourceLife,         
/* life */
-                                                       sliceNum,             
/* slice_size */
-                                                       0,                    
/* iobytes */
-                                                       0,                    
/* max_target_segment_num */
-                                                       0,                    
/* min_target_segment_num */
-                                                       NULL,                 
/* vol_info */
-                                                       0                     
/* vol_info_size */
-                                                       );
-
                        if (resource != NULL) {
                                if ((context.keep_hash)
                                                && 
(list_length(resource->segments) != context.hashSegNum)) {
@@ -4348,18 +4307,6 @@ calculate_planner_segment_num(Query *query, 
QueryResourceLife resourceLife,
                                                                    
context.host_context.hostnameVolInfos,
                                                                    
context.host_context.size);
                                }
-
-                               saveQueryResourceParameters(
-                                                               
resource_parameters,                   /* resource_parameters */
-                                                               QRL_ONCE,       
                       /* life */
-                                                               sliceNum,       
                       /* slice_size */
-                                                               queryCost,      
                       /* iobytes */
-                                                               
maxTargetSegmentNumber,                /* max_target_segment_num */
-                                                               
minTargetSegmentNumber,                /* min_target_segment_num */
-                                                               
context.host_context.hostnameVolInfos, /* vol_info */
-                                                               
context.host_context.size              /* vol_info_size */
-                                                               );
-
                        }
                        /* for explain statement, we doesn't allocate resource 
physically*/
                        else {
@@ -4380,7 +4327,6 @@ calculate_planner_segment_num(Query *query, 
QueryResourceLife resourceLife,
 
                        if (resource == NULL) {
                                result->resource = NULL;
-                               result->resource_parameters = 
resource_parameters;
                                result->alloc_results = NIL;
                                result->relsType = NIL;
                                result->planner_segments = planner_segments;
@@ -4418,7 +4364,6 @@ calculate_planner_segment_num(Query *query, 
QueryResourceLife resourceLife,
                alloc_result = run_allocation_algorithm(result, 
virtual_segments, &resource, &context);
 
                result->resource = resource;
-               result->resource_parameters = resource_parameters;
                result->alloc_results = alloc_result;
                result->planner_segments = list_length(resource->segments);
        }

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/6dee3ccc/src/backend/nodes/copyfuncs.c
----------------------------------------------------------------------
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 7082dac..b16db04 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -169,32 +169,6 @@ CopyLogicalIndexInfo(const LogicalIndexInfo *from, 
LogicalIndexInfo *newnode)
 }
 
 /*
- * _copyQueryResourceParameters
- */
-static QueryResourceParameters *
-_copyQueryResourceParameters(QueryResourceParameters *from)
-{
-       QueryResourceParameters *newnode = makeNode(QueryResourceParameters);
-
-       COPY_SCALAR_FIELD(life);
-       COPY_SCALAR_FIELD(slice_size);
-       COPY_SCALAR_FIELD(iobytes);
-       COPY_SCALAR_FIELD(max_target_segment_num);
-       COPY_SCALAR_FIELD(min_target_segment_num);
-       if (from->vol_info_size > 0)
-       {
-               COPY_POINTER_FIELD(vol_info, sizeof(HostnameVolumeInfo) * 
(from->vol_info_size));
-       }
-       else
-       {
-               newnode->vol_info = NULL;
-       }
-       COPY_SCALAR_FIELD(vol_info_size);
-
-       return newnode;
-}
-
-/*
  * _copyPlannedStmt 
  */
 static PlannedStmt *
@@ -249,22 +223,6 @@ _copyPlannedStmt(PlannedStmt *from)
         * resource in planned statement.
         */
        COPY_SCALAR_FIELD(resource);
-       /*
-        * A (prepared) plan might be executed multiple times. To
-        * prevent memory leakage, here we do a deep copy of query
-        * resource parameters so that its lifetime is exactly the
-        * same as planned statement. Thus, we can re-allocate query
-        * resource for each of the multiple executions of the (prepared)
-        * plan.
-        */
-       if (from->resource_parameters)
-       {
-               newnode->resource_parameters = 
_copyQueryResourceParameters(from->resource_parameters);
-       }
-       else
-       {
-               newnode->resource_parameters = NULL;
-       }
 
        COPY_SCALAR_FIELD(planner_segments);
 
@@ -5212,10 +5170,6 @@ copyObject(void *from)
                        retval = _copyDenyLoginPoint(from);
                        break;
 
-               case T_QueryResourceParameters:
-                       retval = _copyQueryResourceParameters(from);
-                       break;
-
                case T_CaQLSelect:
                        retval = _copyCaQLSelect(from);
                        break;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/6dee3ccc/src/backend/optimizer/plan/planner.c
----------------------------------------------------------------------
diff --git a/src/backend/optimizer/plan/planner.c 
b/src/backend/optimizer/plan/planner.c
index 950943a..2f1fb5d 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -304,7 +304,7 @@ PlannedStmt *refineCachedPlan(PlannedStmt * plannedstmt,
 {
   PlannedStmt *result = plannedstmt;
   ResourceNegotiatorResult *ppResult = (ResourceNegotiatorResult *) 
palloc(sizeof(ResourceNegotiatorResult));
-  SplitAllocResult initResult = {NULL, NULL, NIL, 0, NIL, NULL};
+  SplitAllocResult initResult = {NULL, NIL, 0, NIL, NULL};
   ppResult->saResult = initResult;
   ppResult->stmt = plannedstmt;
   instr_time  starttime, endtime;
@@ -410,7 +410,6 @@ PlannedStmt *refineCachedPlan(PlannedStmt * plannedstmt,
 
   /* add resource and split information to it*/
   result->resource = ppResult->saResult.resource;
-  result->resource_parameters = ppResult->saResult.resource_parameters;
   result->scantable_splits = ppResult->saResult.alloc_results;
   result->planner_segments = ppResult->saResult.planner_segments;
   result->datalocalityInfo = ppResult->saResult.datalocalityInfo;
@@ -446,7 +445,7 @@ planner(Query *parse, int cursorOptions,
        PlannedStmt *result = NULL;
        instr_time      starttime, endtime;
        ResourceNegotiatorResult *ppResult = (ResourceNegotiatorResult *) 
palloc(sizeof(ResourceNegotiatorResult));
-       SplitAllocResult initResult = {NULL, NULL, NIL, 0, NIL, NULL};
+       SplitAllocResult initResult = {NULL, NIL, 0, NIL, NULL};
        ppResult->saResult = initResult;
        ppResult->stmt = NULL;
        static int plannerLevel = 0;
@@ -622,7 +621,6 @@ planner(Query *parse, int cursorOptions,
                SetActiveQueryResource(savedQueryResource);
 
                result->resource = ppResult->saResult.resource;
-               result->resource_parameters = 
ppResult->saResult.resource_parameters;
                result->scantable_splits = ppResult->saResult.alloc_results;
                result->planner_segments = ppResult->saResult.planner_segments;
                result->datalocalityInfo = ppResult->saResult.datalocalityInfo;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/6dee3ccc/src/include/cdb/cdbdatalocality.h
----------------------------------------------------------------------
diff --git a/src/include/cdb/cdbdatalocality.h 
b/src/include/cdb/cdbdatalocality.h
index 21e4c68..c3753ce 100644
--- a/src/include/cdb/cdbdatalocality.h
+++ b/src/include/cdb/cdbdatalocality.h
@@ -40,7 +40,6 @@
 typedef struct SplitAllocResult
 {
   QueryResource *resource;
-  QueryResourceParameters *resource_parameters;
   List *alloc_results;
   int planner_segments;
   List *relsType;// relation type after datalocality changing
@@ -73,22 +72,6 @@ typedef struct VirtualSegmentNode
 } VirtualSegmentNode;
 
 /*
- * saveQueryResourceParameters: save QueryResourceParameters
- * in prepare statement along with query plan so that the query
- * resource can be re-allocated during multiple executions of
- * the plan
- */
-void saveQueryResourceParameters(
-               QueryResourceParameters *resource_parameters,
-               QueryResourceLife       life,
-               int32                   slice_size,
-               int64_t                 iobytes,
-               int                     max_target_segment_num,
-               int                     min_target_segment_num,
-               HostnameVolumeInfo      *vol_info,
-               int                     vol_info_size);
-
-/*
  * calculate_planner_segment_num: based on the parse tree,
  * we calculate the appropriate planner segment_num.
  */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/6dee3ccc/src/include/executor/execdesc.h
----------------------------------------------------------------------
diff --git a/src/include/executor/execdesc.h b/src/include/executor/execdesc.h
index 36d1287..9d91663 100644
--- a/src/include/executor/execdesc.h
+++ b/src/include/executor/execdesc.h
@@ -77,22 +77,6 @@ typedef struct HostnameVolumeInfo
        int64 datavolume;
 } HostnameVolumeInfo;
 
-/*
- * structure for query resource parameters
- */
-typedef struct QueryResourceParameters
-{
-       NodeTag            type;
-
-       QueryResourceLife  life;
-       int32              slice_size;
-       int64_t            iobytes;
-       int                max_target_segment_num;
-       int                min_target_segment_num;
-       HostnameVolumeInfo *vol_info;
-       int                vol_info_size;
-} QueryResourceParameters;
-
 /* ----------------
  *             query descriptor:
  *

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/6dee3ccc/src/include/nodes/nodes.h
----------------------------------------------------------------------
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 2b97270..3c85f16 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -524,7 +524,6 @@ typedef enum NodeTag
 
        /* tags for describing the query resource should occupied in segment*/
        T_QueryResource = 1050,
-       T_QueryResourceParameters,
 
        /*
         * TAGS FOR CAQL PARSER

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/6dee3ccc/src/include/nodes/plannodes.h
----------------------------------------------------------------------
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 7c10cd5..1183e69 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -197,7 +197,6 @@ typedef struct PlannedStmt
                QueryContextInfo * contextdisp; /* query context for 
dispatching */
 
                struct QueryResource *resource;
-               struct QueryResourceParameters *resource_parameters;
                int     planner_segments;
 
     /* The overall memory consumption account (i.e., outside of an operator) */

Reply via email to